File tree 3 files changed +9
-1
lines changed
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(
679
679
// parse the source, but only has false positives, not false
680
680
// negatives.
681
681
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
+
682
686
prog. push_str ( & format ! ( "extern crate r#{crate_name};\n " ) ) ;
683
687
line_offset += 1 ;
684
688
}
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ fn make_test_crate_name() {
38
38
let input = "use asdf::qwop;
39
39
assert_eq!(2+2, 4);" ;
40
40
let expected = "#![allow(unused)]
41
+ #[allow(unused_extern_crates)]
41
42
extern crate r#asdf;
42
43
fn main() {
43
44
use asdf::qwop;
@@ -128,6 +129,7 @@ fn make_test_opts_attrs() {
128
129
let input = "use asdf::qwop;
129
130
assert_eq!(2+2, 4);" ;
130
131
let expected = "#![feature(sick_rad)]
132
+ #[allow(unused_extern_crates)]
131
133
extern crate r#asdf;
132
134
fn main() {
133
135
use asdf::qwop;
@@ -141,6 +143,7 @@ assert_eq!(2+2, 4);
141
143
opts. attrs . push ( "feature(hella_dope)" . to_string ( ) ) ;
142
144
let expected = "#![feature(sick_rad)]
143
145
#![feature(hella_dope)]
146
+ #[allow(unused_extern_crates)]
144
147
extern crate r#asdf;
145
148
fn main() {
146
149
use asdf::qwop;
@@ -236,6 +239,7 @@ assert_eq!(asdf::foo, 4);";
236
239
237
240
let expected = "#![allow(unused)]
238
241
extern crate hella_qwop;
242
+ #[allow(unused_extern_crates)]
239
243
extern crate r#asdf;
240
244
fn main() {
241
245
assert_eq!(asdf::foo, 4);
Original file line number Diff line number Diff line change 10
10
pub fn dummy ( ) { }
11
11
12
12
// 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