pass unused_extern_crates
in librustdoc::doctest::make_test
Signed-off-by: ozkanonur <work@onurozkan.dev>
This commit is contained in:
parent
3128fd8ddf
commit
f56b6d0b12
@ -679,6 +679,10 @@ pub(crate) fn make_test(
|
||||
// parse the source, but only has false positives, not false
|
||||
// negatives.
|
||||
if s.contains(crate_name) {
|
||||
// rustdoc implicitly inserts an `extern crate` item for the own crate
|
||||
// which may be unused, so we need to allow the lint.
|
||||
prog.push_str(&format!("#[allow(unused_extern_crates)]\n"));
|
||||
|
||||
prog.push_str(&format!("extern crate r#{crate_name};\n"));
|
||||
line_offset += 1;
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ fn make_test_crate_name() {
|
||||
let input = "use asdf::qwop;
|
||||
assert_eq!(2+2, 4);";
|
||||
let expected = "#![allow(unused)]
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate r#asdf;
|
||||
fn main() {
|
||||
use asdf::qwop;
|
||||
@ -128,6 +129,7 @@ fn make_test_opts_attrs() {
|
||||
let input = "use asdf::qwop;
|
||||
assert_eq!(2+2, 4);";
|
||||
let expected = "#![feature(sick_rad)]
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate r#asdf;
|
||||
fn main() {
|
||||
use asdf::qwop;
|
||||
@ -141,6 +143,7 @@ fn main() {
|
||||
opts.attrs.push("feature(hella_dope)".to_string());
|
||||
let expected = "#![feature(sick_rad)]
|
||||
#![feature(hella_dope)]
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate r#asdf;
|
||||
fn main() {
|
||||
use asdf::qwop;
|
||||
@ -236,6 +239,7 @@ fn main() {
|
||||
|
||||
let expected = "#![allow(unused)]
|
||||
extern crate hella_qwop;
|
||||
#[allow(unused_extern_crates)]
|
||||
extern crate r#asdf;
|
||||
fn main() {
|
||||
assert_eq!(asdf::foo, 4);
|
||||
|
@ -10,4 +10,4 @@
|
||||
pub fn dummy() {}
|
||||
|
||||
// ensure that `extern crate foo;` was inserted into code snips automatically:
|
||||
// @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"
|
||||
// @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"
|
||||
|
Loading…
Reference in New Issue
Block a user