-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error codes checkup and rustdoc test fix #67850
Conversation
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
I will review once #67837 has been merged and this is rebased atop of it (also, looks like there's a CI failure). |
0dce9d2
to
157a3d1
Compare
Forgot to run rustfmt on the new checker... Let's wait for #67837 now. :) |
157a3d1
to
9d84816
Compare
@Mark-Simulacrum #67837 has been merged. :) |
src/bootstrap/test.rs
Outdated
@@ -704,6 +704,39 @@ impl Step for RustdocUi { | |||
} | |||
} | |||
|
|||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] | |||
pub struct ErrorCodesCheck { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is already a step to run rustdoc tests on the error index:
Line 1393 in 1756313
pub struct ErrorIndex { |
Does it not work properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not for the same purpose. ErrorIndex
generates it, but it doesn't test that the code examples inside the explanations are compiling (or not) as expected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it does. It uses error_index_generator
to concatenate all of the error code docs into a single error-index.md
file and then runs rustdoc --test
on that:
Lines 1411 to 1436 in 1756313
/// Runs the error index generator tool to execute the tests located in the error | |
/// index. | |
/// | |
/// The `error_index_generator` tool lives in `src/tools` and is used to | |
/// generate a markdown file from the error indexes of the code base which is | |
/// then passed to `rustdoc --test`. | |
fn run(self, builder: &Builder<'_>) { | |
let compiler = self.compiler; | |
builder.ensure(compile::Std { compiler, target: compiler.host }); | |
let dir = testdir(builder, compiler.host); | |
t!(fs::create_dir_all(&dir)); | |
let output = dir.join("error-index.md"); | |
let mut tool = tool::ErrorIndex::command( | |
builder, | |
builder.compiler(compiler.stage, builder.config.build), | |
); | |
tool.arg("markdown").arg(&output).env("CFG_BUILD", &builder.config.build); | |
builder.info(&format!("Testing error-index stage{}", compiler.stage)); | |
let _time = util::timeit(&builder); | |
builder.run_quiet(&mut tool); | |
markdown_test(builder, compiler, &output); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And I can tell that it doesn't work since a lot of error codes I fixed in this PR weren't detected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why doesn't it work? If we have existing code that overlaps this one, ideally we'd fix the pre-existing code, rather than replace it wholesale (or at least, we should make sure that we're replacing it, rather than just also adding atop it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good question. Let me check again.
src/bootstrap/test.rs
Outdated
fn run(self, builder: &Builder<'_>) { | ||
builder.ensure(compile::Std { compiler: self.compiler, target: self.compiler.host }); | ||
|
||
let mut cmd = builder.tool_cmd(Tool::ErrorCodesCheck); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really need to be done using a new tool? Rustbuild can already run rustdoc --test
on all .md
files in a directory using the DocTest
step.
Either way this will be slower than the current ErrorIndex
step because it will have to call rustdoc --test
once for each error code rather than just once for all of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to write a tool in any case to import the markdown files. So instead of having everything at once, at least we get a very precise error output. Also, the run is a bit longer, but nothing much bigger.
Ping @Mark-Simulacrum |
I think @ollie27's comments around error-index-generator need to get resolved and then I can take another look (or not, if it turns out we're already doing everything necessary here). |
2e8db67
to
5b7d64e
Compare
@ollie27 was absolutely right: adding this new check was useless. I discovered this issue, believing that the change of the error explanations format somehow messed with the run of I think this is ready now. |
Please update the PR description (some of it seems a bit outdated). After that, r=me. |
@bors: r=Mark-Simulacrum |
📌 Commit 5b7d64e has been approved by |
…acrum Error codes checkup and rustdoc test fix This PR does a few things: * fix how rustdoc checks that an error code has been thrown (it only checked for "E0XXX" so if it appeared in the output because the file has it in its name or wherever, it passed the test, which was incorrect) * fix the failing code examples that weren't throwing the expected error code
☀️ Test successful - checks-azure |
This PR does a few things: