Skip to content

Commit 7c3904d

Browse files
committed
Auto merge of #12501 - epage:rustdoc, r=weihanglo
fix(lints): Doctest extraction should respect `[lints]` Note the first commit shows the bug and the second commit fixes it Fixes #12497
2 parents fdd0d27 + 9984855 commit 7c3904d

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

src/cargo/ops/cargo_test.rs

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ fn run_doc_tests(
260260
p.arg("--test-args").arg("--quiet");
261261
}
262262

263+
p.args(unit.pkg.manifest().lint_rustflags());
264+
263265
p.args(args);
264266

265267
if *unstable_opts {

tests/testsuite/lints.rs

+55
Original file line numberDiff line numberDiff line change
@@ -637,3 +637,58 @@ error: unresolved link to `bar`
637637
)
638638
.run();
639639
}
640+
641+
#[cargo_test]
642+
fn doctest_respects_lints() {
643+
let foo = project()
644+
.file(
645+
"Cargo.toml",
646+
r#"
647+
[package]
648+
name = "foo"
649+
version = "0.0.1"
650+
authors = []
651+
652+
[lints.rust]
653+
confusable-idents = 'allow'
654+
"#,
655+
)
656+
.file(
657+
"src/lib.rs",
658+
r#"
659+
/// Test
660+
///
661+
/// [`Foo`]
662+
///
663+
/// ```
664+
/// let s = "rust";
665+
/// let s_s = "rust2";
666+
/// ```
667+
pub fn f() {}
668+
pub const Ě: i32 = 1;
669+
pub const Ĕ: i32 = 2;
670+
"#,
671+
)
672+
.build();
673+
674+
foo.cargo("check -Zlints")
675+
.masquerade_as_nightly_cargo(&["lints"])
676+
.with_stderr(
677+
"\
678+
[CHECKING] foo v0.0.1 ([CWD])
679+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
680+
",
681+
)
682+
.run();
683+
684+
foo.cargo("test --doc -Zlints")
685+
.masquerade_as_nightly_cargo(&["lints"])
686+
.with_stderr(
687+
"\
688+
[COMPILING] foo v0.0.1 ([CWD])
689+
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]s
690+
[DOCTEST] foo
691+
",
692+
)
693+
.run();
694+
}

0 commit comments

Comments
 (0)