diff --git a/bindgen-cli/options.rs b/bindgen-cli/options.rs index cd5e9bb1270e9addce196eed53a60220dea50a1f..3c5417bcab6db116fe593626d773345cdc27105a 100644 --- a/bindgen-cli/options.rs +++ b/bindgen-cli/options.rs @@ -444,7 +444,6 @@ struct BindgenCommand { emit_diagnostics: bool, /// Generates completions for the specified SHELL, sends them to `stdout` and exits. #[arg(long, value_name = "SHELL")] - generate_shell_completions: Option, /// Enables experimental features. #[arg(long)] experimental: bool, @@ -579,22 +578,12 @@ where wrap_static_fns_suffix, default_visibility, emit_diagnostics, - generate_shell_completions, experimental: _, version, clang_args, } = command; - if let Some(shell) = generate_shell_completions { - clap_complete::generate( - shell, - &mut BindgenCommand::command(), - "bindgen", - &mut std::io::stdout(), - ); - exit(0); - } if version { println!( diff --git a/bindgen/callbacks.rs b/bindgen/callbacks.rs index 0f16c4c0bfd9d6624242b84fefbc597dc5f8d0d1..1d059e6553d4437141bddd6514aecb35eee9eaed 100644 --- a/bindgen/callbacks.rs +++ b/bindgen/callbacks.rs @@ -20,7 +20,6 @@ pub enum MacroParsingBehavior { /// A trait to allow configuring different kinds of types in different /// situations. pub trait ParseCallbacks: fmt::Debug { - #[cfg(feature = "__cli")] #[doc(hidden)] fn cli_args(&self) -> Vec { vec![] diff --git a/bindgen/codegen/mod.rs b/bindgen/codegen/mod.rs index 741a3fbe43efec1146bb3147f70b3e90293ede5c..03048506a1015117a470597a01101cca17e1cc43 100644 --- a/bindgen/codegen/mod.rs +++ b/bindgen/codegen/mod.rs @@ -128,7 +128,6 @@ fn root_import( } bitflags! { - #[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] struct DerivableTraits: u16 { const DEBUG = 1 << 0; const DEFAULT = 1 << 1; @@ -4340,15 +4339,6 @@ impl TryToRustTy for FunctionSig { syn::parse_quote! { unsafe extern #abi fn ( #( #arguments ),* ) #ret }, ), Err(err) => { - if matches!(err, error::Error::UnsupportedAbi(_)) { - unsupported_abi_diagnostic( - self.name(), - self.is_variadic(), - item.location(), - ctx, - &err, - ); - } Err(err) } @@ -4391,7 +4381,6 @@ impl CodeGenerator for Function { if signature.is_variadic() { // We cannot generate wrappers for variadic static functions so we avoid // generating any code for them. - variadic_fn_diagnostic(self.name(), item.location(), ctx); return None; } } @@ -4457,13 +4446,6 @@ impl CodeGenerator for Function { let abi = match signature.abi(ctx, Some(name)) { Err(err) => { if matches!(err, error::Error::UnsupportedAbi(_)) { - unsupported_abi_diagnostic( - name, - signature.is_variadic(), - item.location(), - ctx, - &err, - ); } return None; @@ -4592,103 +4574,6 @@ impl CodeGenerator for Function { } } -#[cfg_attr(not(feature = "experimental"), allow(unused_variables))] -fn unsupported_abi_diagnostic( - fn_name: &str, - variadic: bool, - location: Option<&crate::clang::SourceLocation>, - ctx: &BindgenContext, - error: &error::Error, -) { - warn!( - "Skipping {}function `{}` because the {}", - if variadic { "variadic " } else { "" }, - fn_name, - error - ); - - #[cfg(feature = "experimental")] - if ctx.options().emit_diagnostics { - use crate::diagnostics::{get_line, Diagnostic, Level, Slice}; - - let mut diag = Diagnostic::default(); - diag.with_title( - format!( - "Skipping {}function `{}` because the {}", - if variadic { "variadic " } else { "" }, - fn_name, - error - ), - Level::Warn, - ) - .add_annotation( - "No code will be generated for this function.", - Level::Warn, - ) - .add_annotation( - format!( - "The configured Rust version is {}.", - ctx.options().rust_target - ), - Level::Note, - ); - - if let Some(loc) = location { - let (file, line, col, _) = loc.location(); - - if let Some(filename) = file.name() { - if let Ok(Some(source)) = get_line(&filename, line) { - let mut slice = Slice::default(); - slice - .with_source(source) - .with_location(filename, line, col); - diag.add_slice(slice); - } - } - } - - diag.display() - } -} - -fn variadic_fn_diagnostic( - fn_name: &str, - _location: Option<&crate::clang::SourceLocation>, - _ctx: &BindgenContext, -) { - warn!( - "Cannot generate wrapper for the static variadic function `{}`.", - fn_name, - ); - - #[cfg(feature = "experimental")] - if _ctx.options().emit_diagnostics { - use crate::diagnostics::{get_line, Diagnostic, Level, Slice}; - - let mut diag = Diagnostic::default(); - - diag.with_title(format!("Cannot generate wrapper for the static function `{}`.", fn_name), Level::Warn) - .add_annotation("The `--wrap-static-fns` feature does not support variadic functions.", Level::Note) - .add_annotation("No code will be generated for this function.", Level::Note); - - if let Some(loc) = _location { - let (file, line, col, _) = loc.location(); - - if let Some(filename) = file.name() { - if let Ok(Some(source)) = get_line(&filename, line) { - let mut slice = Slice::default(); - slice - .with_source(source) - .with_location(filename, line, col); - diag.add_slice(slice); - } - } - } - - diag.display() - } -} - fn objc_method_codegen( ctx: &BindgenContext, method: &ObjCMethod, diff --git a/bindgen/features.rs b/bindgen/features.rs index 990e4513cbe28bfcbec0652295ea0cd4926614e1..2cb2aaacbea26ab650a1d8177e479475b9fe09df 100644 --- a/bindgen/features.rs +++ b/bindgen/features.rs @@ -56,7 +56,6 @@ macro_rules! define_rust_targets { } } - #[cfg(feature = "__cli")] /// Strings of allowed `RustTarget` values pub const RUST_TARGET_STRINGS: &[&str] = &[$(concat!("1.", stringify!($minor)),)*]; diff --git a/bindgen/ir/comp.rs b/bindgen/ir/comp.rs index 036e7e5c8f9f8159da79240a7f6cb2cd01806318..d08be80df474c43e307f6caba1de835445fb465a 100644 --- a/bindgen/ir/comp.rs +++ b/bindgen/ir/comp.rs @@ -1,6 +1,5 @@ //! Compound types (unions and structs) in our intermediate representation. -use itertools::Itertools; use super::analysis::Sizedness; use super::annotations::Annotations; @@ -496,7 +495,6 @@ where { let non_bitfields = raw_fields .by_ref() - .peeking_take_while(|f| f.bitfield_width().is_none()) .map(|f| Field::DataMember(f.0)); fields.extend(non_bitfields); } @@ -506,7 +504,6 @@ where // the Itanium C++ ABI. let mut bitfields = raw_fields .by_ref() - .peeking_take_while(|f| f.bitfield_width().is_some()) .peekable(); if bitfields.peek().is_none() { diff --git a/bindgen/ir/context.rs b/bindgen/ir/context.rs index a1536935b6e77e255ce192907c327fd3111584be..22bbe8a2dd3e1c9506f2cab28cebf6f9ed2a9dbb 100644 --- a/bindgen/ir/context.rs +++ b/bindgen/ir/context.rs @@ -3137,19 +3137,4 @@ impl TemplateParameters for PartialType { fn unused_regex_diagnostic(item: &str, name: &str, _ctx: &BindgenContext) { warn!("unused option: {} {}", name, item); - #[cfg(feature = "experimental")] - if _ctx.options().emit_diagnostics { - use crate::diagnostics::{Diagnostic, Level}; - - Diagnostic::default() - .with_title( - format!("Unused regular expression: `{}`.", item), - Level::Warn, - ) - .add_annotation( - format!("This regular expression was passed to `{}`.", name), - Level::Note, - ) - .display(); - } } diff --git a/bindgen/ir/var.rs b/bindgen/ir/var.rs index 40a061e16c4c2f95497def98a53d232418bb70f8..bde630f71cda9c6d0e1a29dff2d5eb17c187c65f 100644 --- a/bindgen/ir/var.rs +++ b/bindgen/ir/var.rs @@ -486,7 +486,6 @@ fn duplicated_macro_diagnostic( ) { warn!("Duplicated macro definition: {}", macro_name); - #[cfg(feature = "experimental")] // FIXME (pvdrz & amanjeev): This diagnostic message shows way too often to be actually // useful. We have to change the logic where this function is called to be able to emit this // message only when the duplication is an actual issue. @@ -499,28 +498,6 @@ fn duplicated_macro_diagnostic( // ``` // // Will trigger this message even though there's nothing wrong with it. - #[allow(clippy::overly_complex_bool_expr)] - if false && _ctx.options().emit_diagnostics { - use crate::diagnostics::{get_line, Diagnostic, Level, Slice}; - use std::borrow::Cow; - - let mut slice = Slice::default(); - let mut source = Cow::from(macro_name); - - let (file, line, col, _) = _location.location(); - if let Some(filename) = file.name() { - if let Ok(Some(code)) = get_line(&filename, line) { - source = code.into(); - } - slice.with_location(filename, line, col); - } - slice.with_source(source); - Diagnostic::default() - .with_title("Duplicated macro definition.", Level::Warn) - .add_slice(slice) - .add_annotation("This macro had a duplicate.", Level::Note) - .display(); - } } diff --git a/bindgen/lib.rs b/bindgen/lib.rs index 3bf0bc3c1df64cf4e9958cf83dece7d27ab40751..429ab7e732ac3707bae828fc3d69bcfcbc6a7eeb 100644 --- a/bindgen/lib.rs +++ b/bindgen/lib.rs @@ -41,7 +41,6 @@ pub mod callbacks; mod clang; #[cfg(feature = "experimental")] -mod diagnostics; mod features; mod ir; mod parse; @@ -50,7 +49,6 @@ mod regex_set; pub use codegen::{ AliasVariation, EnumVariation, MacroTypeVariation, NonCopyUnionStyle, }; -#[cfg(feature = "__cli")] pub use features::RUST_TARGET_STRINGS; pub use features::{RustTarget, LATEST_STABLE_RUST}; pub use ir::annotations::FieldVisibilityKind; @@ -110,7 +108,6 @@ fn args_are_cpp(clang_args: &[Box]) -> bool { bitflags! { /// A type used to indicate which kind of items we have to generate. - #[derive(Copy, Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct CodegenConfig: u32 { /// Whether to generate functions. const FUNCTIONS = 1 << 0; @@ -587,24 +584,8 @@ impl BindgenOptions { } fn deprecated_target_diagnostic(target: RustTarget, _options: &BindgenOptions) { - warn!("The {} Rust target is deprecated. If you have a need to use this target please report it at https://github.com/rust-lang/rust-bindgen/issues", target); - #[cfg(feature = "experimental")] - if _options.emit_diagnostics { - use crate::diagnostics::{Diagnostic, Level}; - let mut diagnostic = Diagnostic::default(); - diagnostic.with_title( - format!("The {} Rust target is deprecated.", target), - Level::Warn, - ); - diagnostic.add_annotation( - "This Rust target was passed to `--rust-target`", - Level::Info, - ); - diagnostic.add_annotation("If you have a good reason to use this target please report it at https://github.com/rust-lang/rust-bindgen/issues", Level::Help); - diagnostic.display(); - } } #[cfg(feature = "runtime")] @@ -1052,18 +1033,6 @@ impl Bindings { fn rustfmt_non_fatal_error_diagnostic(msg: &str, _options: &BindgenOptions) { warn!("{}", msg); - #[cfg(feature = "experimental")] - if _options.emit_diagnostics { - use crate::diagnostics::{Diagnostic, Level}; - - Diagnostic::default() - .with_title(msg, Level::Warn) - .add_annotation( - "The bindings will be generated but not formatted.", - Level::Note, - ) - .display(); - } } impl std::fmt::Display for Bindings { diff --git a/bindgen/regex_set.rs b/bindgen/regex_set.rs index b78424aae12e2df7e57da179ec670e78acb70db3..d90651b7b41a0c4498eda5b855d372003d687c5d 100644 --- a/bindgen/regex_set.rs +++ b/bindgen/regex_set.rs @@ -63,7 +63,6 @@ impl RegexSet { self.build_inner(record_matches, None) } - #[cfg(all(feature = "__cli", feature = "experimental"))] /// Construct a RegexSet from the set of entries we've accumulated and emit diagnostics if the /// name of the regex set is passed to it. /// @@ -78,20 +77,6 @@ impl RegexSet { self.build_inner(record_matches, name) } - #[cfg(all(not(feature = "__cli"), feature = "experimental"))] - /// Construct a RegexSet from the set of entries we've accumulated and emit diagnostics if the - /// name of the regex set is passed to it. - /// - /// Must be called before calling `matches()`, or it will always return - /// false. - #[inline] - pub(crate) fn build_with_diagnostics( - &mut self, - record_matches: bool, - name: Option<&'static str>, - ) { - self.build_inner(record_matches, name) - } fn build_inner( &mut self, @@ -146,59 +131,6 @@ fn invalid_regex_warning( err: regex::Error, name: &'static str, ) { - use crate::diagnostics::{Diagnostic, Level, Slice}; - - let mut diagnostic = Diagnostic::default(); - - match err { - regex::Error::Syntax(string) => { - if string.starts_with("regex parse error:\n") { - let mut source = String::new(); - - let mut parsing_source = true; - - for line in string.lines().skip(1) { - if parsing_source { - if line.starts_with(' ') { - source.push_str(line); - source.push('\n'); - continue; - } - parsing_source = false; - } - let error = "error: "; - if line.starts_with(error) { - let (_, msg) = line.split_at(error.len()); - diagnostic.add_annotation(msg.to_owned(), Level::Error); - } else { - diagnostic.add_annotation(line.to_owned(), Level::Info); - } - } - let mut slice = Slice::default(); - slice.with_source(source); - diagnostic.add_slice(slice); - - diagnostic.with_title( - "Error while parsing a regular expression.", - Level::Warn, - ); - } else { - diagnostic.with_title(string, Level::Warn); - } - } - err => { - let err = err.to_string(); - diagnostic.with_title(err, Level::Warn); - } - } - diagnostic.add_annotation( - format!("This regular expression was passed via `{}`.", name), - Level::Note, - ); - if set.items.iter().any(|item| item.as_ref() == "*") { - diagnostic.add_annotation("Wildcard patterns \"*\" are no longer considered valid. Use \".*\" instead.", Level::Help); - } - diagnostic.display(); }