This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -679,6 +679,10 @@ pub(crate) fn make_test(
679679 // parse the source, but only has false positives, not false
680680 // negatives.
681681 if s. contains ( crate_name) {
682+ // rustdoc implicitly inserts an `extern crate` item for the own crate
683+ // which may be unused, so we need to allow the lint.
684+ prog. push_str ( & format ! ( "#[allow(unused_extern_crates)]\n " ) ) ;
685+
682686 prog. push_str ( & format ! ( "extern crate r#{crate_name};\n " ) ) ;
683687 line_offset += 1 ;
684688 }
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ fn make_test_crate_name() {
3838 let input = "use asdf::qwop;
3939assert_eq!(2+2, 4);" ;
4040 let expected = "#![allow(unused)]
41+ #[allow(unused_extern_crates)]
4142extern crate r#asdf;
4243fn main() {
4344use asdf::qwop;
@@ -128,6 +129,7 @@ fn make_test_opts_attrs() {
128129 let input = "use asdf::qwop;
129130assert_eq!(2+2, 4);" ;
130131 let expected = "#![feature(sick_rad)]
132+ #[allow(unused_extern_crates)]
131133extern crate r#asdf;
132134fn main() {
133135use asdf::qwop;
@@ -141,6 +143,7 @@ assert_eq!(2+2, 4);
141143 opts. attrs . push ( "feature(hella_dope)" . to_string ( ) ) ;
142144 let expected = "#![feature(sick_rad)]
143145#![feature(hella_dope)]
146+ #[allow(unused_extern_crates)]
144147extern crate r#asdf;
145148fn main() {
146149use asdf::qwop;
@@ -236,6 +239,7 @@ assert_eq!(asdf::foo, 4);";
236239
237240 let expected = "#![allow(unused)]
238241extern crate hella_qwop;
242+ #[allow(unused_extern_crates)]
239243extern crate r#asdf;
240244fn main() {
241245assert_eq!(asdf::foo, 4);
Original file line number Diff line number Diff line change 1010pub fn dummy ( ) { }
1111
1212// ensure that `extern crate foo;` was inserted into code snips automatically:
13- // @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0Aextern+crate+r%23foo;%0Afn+main()+%7B%0Ause+foo::dummy;%0Adummy();%0A%7D&edition=2015"]' "Run"
13+ // @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0A%23%5Ballow(unused_extern_crates)%5D% 0Aextern+crate+r%23foo;%0Afn+main()+%7B%0Ause+foo::dummy;%0Adummy();%0A%7D&edition=2015"]' "Run"
You can’t perform that action at this time.
0 commit comments