Skip to content

Commit

Permalink
Auto merge of #12501 - epage:rustdoc, r=weihanglo
Browse files Browse the repository at this point in the history
fix(lints): Doctest extraction should respect `[lints]`

Note the first commit shows the bug and the second commit fixes it

Fixes #12497
  • Loading branch information
bors committed Aug 14, 2023
2 parents fdd0d27 + 9984855 commit 7c3904d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ fn run_doc_tests(
p.arg("--test-args").arg("--quiet");
}

p.args(unit.pkg.manifest().lint_rustflags());

p.args(args);

if *unstable_opts {
Expand Down
55 changes: 55 additions & 0 deletions tests/testsuite/lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,3 +637,58 @@ error: unresolved link to `bar`
)
.run();
}

#[cargo_test]
fn doctest_respects_lints() {
let foo = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[lints.rust]
confusable-idents = 'allow'
"#,
)
.file(
"src/lib.rs",
r#"
/// Test
///
/// [`Foo`]
///
/// ```
/// let s = "rust";
/// let s_s = "rust2";
/// ```
pub fn f() {}
pub const Ě: i32 = 1;
pub const Ĕ: i32 = 2;
"#,
)
.build();

foo.cargo("check -Zlints")
.masquerade_as_nightly_cargo(&["lints"])
.with_stderr(
"\
[CHECKING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
)
.run();

foo.cargo("test --doc -Zlints")
.masquerade_as_nightly_cargo(&["lints"])
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]s
[DOCTEST] foo
",
)
.run();
}

0 comments on commit 7c3904d

Please sign in to comment.