Repository: rust-lang/rust-bindgen
Pull request #2794 (2024-03-28 06:27:43)

needless declarations


Patch:
diff --git a/bindgen-integration/build.rs b/bindgen-integration/build.rs
index b5afeba9..6b06c91b 100644
--- a/bindgen-integration/build.rs
+++ b/bindgen-integration/build.rs
@@ -1,5 +1,4 @@
 extern crate bindgen;
-extern crate cc;
 
 use bindgen::callbacks::{
     DeriveInfo, IntKind, MacroParsingBehavior, ParseCallbacks,
diff --git a/bindgen-integration/src/lib.rs b/bindgen-integration/src/lib.rs
index e2344770..c37055ee 100755
--- a/bindgen-integration/src/lib.rs
+++ b/bindgen-integration/src/lib.rs
@@ -12,7 +12,6 @@ use std::ffi::CStr;
 use std::mem;
 use std::os::raw::c_int;
 
-#[allow(unused)]
 use bindings::testing::Bar; // This type is generated from module_raw_line.
 
 type MacroInteger = isize;
diff --git a/bindgen/codegen/dyngen.rs b/bindgen/codegen/dyngen.rs
index c067fada..b26c0b18 100644
--- a/bindgen/codegen/dyngen.rs
+++ b/bindgen/codegen/dyngen.rs
@@ -90,8 +90,6 @@ impl DynamicItems {
         };
 
         quote! {
-            extern crate libloading;
-
             pub struct #lib_ident {
                 __library: ::libloading::Library,
                 #(#struct_members)*
diff --git a/bindgen/features.rs b/bindgen/features.rs
index fa3f20d7..6ac1d6a1 100644
--- a/bindgen/features.rs
+++ b/bindgen/features.rs
@@ -231,7 +231,6 @@ impl Default for RustFeatures {
 
 #[cfg(test)]
 mod test {
-    #![allow(unused_imports)]
     use super::*;
 
     #[test]
diff --git a/book/src/non-system-libraries.md b/book/src/non-system-libraries.md
index d5d288d1..b080db80 100644
--- a/book/src/non-system-libraries.md
+++ b/book/src/non-system-libraries.md
@@ -17,8 +17,6 @@ Given that the library has not been compiled yet, we need to modify the
 library:
 
 ```rust,ignore
-extern crate bindgen;
-
 use std::env;
 use std::path::PathBuf;
 


Test patch:
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs
index 7682884b..a1fb1b0c 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_attributes.rs
@@ -1,5 +1,4 @@
 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-extern crate libloading;
 pub struct TestLib {
     __library: ::libloading::Library,
     pub foo: unsafe extern "C" fn(
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs
index 6fd97e4a..5c929ffc 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_required.rs
@@ -1,5 +1,4 @@
 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-extern crate libloading;
 pub struct TestLib {
     __library: ::libloading::Library,
     pub foo: unsafe extern "C" fn(
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs
index cdacf3ab..9a4cfaf5 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_simple.rs
@@ -1,5 +1,4 @@
 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-extern crate libloading;
 pub struct TestLib {
     __library: ::libloading::Library,
     pub foo: Result<
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs
index 65c36e48..65f079be 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_template.rs
@@ -1,5 +1,4 @@
 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-extern crate libloading;
 pub struct TestLib {
     __library: ::libloading::Library,
     pub foo: Result<
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs
index 06fffc3d..e65176b8 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_allowlist.rs
@@ -1,5 +1,4 @@
 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-extern crate libloading;
 pub struct TestLib {
     __library: ::libloading::Library,
     pub foo: Result<
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs
index 9273583a..49081598 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_blocklist.rs
@@ -37,7 +37,6 @@ impl X {
         __bindgen_tmp.assume_init()
     }
 }
-extern crate libloading;
 pub struct TestLib {
     __library: ::libloading::Library,
     pub foo: Result<
diff --git a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs
index dd0544b0..694d7e4a 100644
--- a/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs
+++ b/bindgen-tests/tests/expectations/tests/dynamic_loading_with_class.rs
@@ -37,7 +37,6 @@ impl A {
         __bindgen_tmp.assume_init()
     }
 }
-extern crate libloading;
 pub struct TestLib {
     __library: ::libloading::Library,
     pub foo: Result<
diff --git a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_dynamic_loading_simple.rs b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_dynamic_loading_simple.rs
index 968f10f6..2f5b4cc5 100644
--- a/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_dynamic_loading_simple.rs
+++ b/bindgen-tests/tests/expectations/tests/wrap_unsafe_ops_dynamic_loading_simple.rs
@@ -1,5 +1,4 @@
 #![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]
-extern crate libloading;
 pub struct TestLib {
     __library: ::libloading::Library,
     pub foo: Result<
diff --git a/bindgen-tests/tests/quickchecking/src/bin.rs b/bindgen-tests/tests/quickchecking/src/bin.rs
index 7f1307e1..fcd56652 100644
--- a/bindgen-tests/tests/quickchecking/src/bin.rs
+++ b/bindgen-tests/tests/quickchecking/src/bin.rs
@@ -14,8 +14,6 @@
 //! ```
 //!
 #![deny(missing_docs)]
-extern crate clap;
-extern crate quickchecking;
 
 use clap::{Arg, ArgAction, Command};
 use std::path::PathBuf;
diff --git a/bindgen-tests/tests/quickchecking/src/lib.rs b/bindgen-tests/tests/quickchecking/src/lib.rs
index 631c1c67..38da62f6 100644
--- a/bindgen-tests/tests/quickchecking/src/lib.rs
+++ b/bindgen-tests/tests/quickchecking/src/lib.rs
@@ -3,8 +3,6 @@
 //! ## Example
 //!
 //! ```rust
-//! extern crate quickcheck;
-//! extern crate quickchecking;
 //! use quickcheck::{Arbitrary, Gen};
 //! use quickchecking::fuzzers;
 //!
@@ -20,8 +18,6 @@
 #![deny(missing_docs)]
 #[macro_use]
 extern crate lazy_static;
-extern crate quickcheck;
-extern crate tempfile;
 
 use quickcheck::{Gen, QuickCheck, TestResult};
 use std::error::Error;
diff --git a/bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs b/bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs
index e394efe3..0735a70c 100644
--- a/bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs
+++ b/bindgen-tests/tests/quickchecking/tests/fuzzed-c-headers.rs
@@ -1,6 +1,3 @@
-extern crate quickcheck;
-extern crate quickchecking;
-
 use quickcheck::{Arbitrary, Gen};
 use quickchecking::fuzzers::{
     ArrayDimensionC, BaseTypeC, BasicTypeDeclarationC, DeclarationC,
diff --git a/bindgen-tests/tests/stylo_sanity.rs b/bindgen-tests/tests/stylo_sanity.rs
index e9ec69bc..7b94e298 100755
--- a/bindgen-tests/tests/stylo_sanity.rs
+++ b/bindgen-tests/tests/stylo_sanity.rs
@@ -1,7 +1,3 @@
-// Don't want to copy that nasty `cfg` below...
-#[allow(unused_extern_crates)]
-extern crate bindgen;
-
 /// A sanity test that we can generate bindings for Stylo.
 ///
 /// We don't assert on expected output because its just too big. The output will
diff --git a/bindgen-tests/tests/tests.rs b/bindgen-tests/tests/tests.rs
index c096b2e8..e6c038a0 100644
--- a/bindgen-tests/tests/tests.rs
+++ b/bindgen-tests/tests/tests.rs
@@ -1,9 +1,3 @@
-extern crate bindgen;
-extern crate clap;
-#[cfg(feature = "logging")]
-extern crate env_logger;
-extern crate shlex;
-
 use bindgen::{clang_version, Builder};
 use owo_colors::{OwoColorize, Style};
 use similar::{ChangeTag, TextDiff};