-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Nearly all compiler/ doctests are broken #95994
Comments
The scary thing to me is how long these have been broken - I guess we never run library tests in CI? I think it might be worth considering adding them. |
We "should" be running them, but it's relatively easy today for us to accidentally stop running tests. I have a long-term project in mind to track all executed tests (and target info) to give us positive presence (tests passing) indication rather than just negative (tests failing) as we have today. But that's a somewhat involved endeavor that I haven't had the time to invest in yet - probably a few weeks work. |
Mentoring instructions: For each test, decide whether it's meant to be a test or just a code comment. Then, add For example, this test is just a comment, because it's not meant to be valid syntax: /// Desugar `ExprKind::Try` from: `<expr>?` into:
/// ```
/// match Try::branch(<expr>) {
/// ControlFlow::Continue(val) => #[allow(unreachable_code)] val,,
/// ControlFlow::Break(residual) =>
/// #[allow(unreachable_code)]
/// // If there is an enclosing `try {...}`:
/// break 'catch_target Try::from_residual(residual),
/// // Otherwise:
/// return Try::from_residual(residual),
/// }
/// ```
fn lower_expr_try(&mut self, span: Span, sub_expr: &Expr) -> hir::ExprKind<'hir> { but this one can easily be a doctest: #[derive(Clone, Copy, PartialEq)]
enum IndentStyle {
/// Vertically aligned under whatever column this block begins at.
///
/// fn demo(arg1: usize,
/// arg2: usize);
Visual,
} @rustbot label +E-help-wanted +E-mentor |
Hi I could try to do this. |
@rustbot claim |
@Elliot-Roberts it already is a doctest. Rustdoc treats any 4-space indented block as a code block. The problem with it is that the test fails - the fix is simple in this case, just change |
Oh I see, thanks for the explanation. Just noticed it in the list of failing tests haha. |
@Elliot-Roberts btw you don't need to fix all of them at once, if you get halfway through and it gets tedious that's still super useful :) |
Ok cool. Here's a summary of the different types of failing doctest I've found so far:
Please let me know if my described approach to each of those sounds reasonable to you. |
That all sounds great! No need to hide the attributes on type 2 tests, I think it's illustrative to show what features they exercise. For type 5 tests, anything that uses rustc_xxx crates can be ignored, it will be too much of a headache to get bootstrap to give them the proper sysroot with rustc_private available. Happy to help you get the fancy type issues working :) |
…iler-errors Begin fixing all the broken doctests in `compiler/` Begins to fix rust-lang#95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
…iler-errors Begin fixing all the broken doctests in `compiler/` Begins to fix rust-lang#95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
test-output.log
I haven't tried
--stage 2
but I don't expect it to matter; most of these aren't build errors, they're just because the tests aren't valid syntax.Found while investigating #95515.
@rustbot label +T-compiler +A-testsuite +C-bug
The text was updated successfully, but these errors were encountered: