-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.
Description
In #79770 I tried to create a new rustdoc-ui
testcase that runs doctests. However having the mod
substring in a doctest comment injected an invalid extern crate mod;
into the code generated for the doctest.
Turns out this here is a bit too aggressive:
rust/src/librustdoc/doctest.rs
Lines 533 to 534 in 0f6f2d6
if s.contains(cratename) { | |
prog.push_str(&format!("extern crate {};\n", cratename)); |
It looks like compiletest actually gave the crate the name mod
, perhaps because it was defined in a issue-XXX/mod.rs
file, and having a doctest such as this triggers the this auto-injection, resulting in a failed doctest run:
/// ```
/// // ^ mod.rs line 10
/// assert_eq!(1, 1);
/// ```
Metadata
Metadata
Assignees
Labels
A-doctestsArea: Documentation tests, run by rustdocArea: Documentation tests, run by rustdocC-bugCategory: This is a bug.Category: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.Relevant to the rustdoc team, which will review and decide on the PR/issue.