-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
rustdoc: Properly detect syntactically invalid doctests (to fix a regression) #148101
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -203,11 +203,6 @@ pub trait Emitter { | |
| true | ||
| } | ||
|
|
||
| /// Checks if we can use colors in the current output stream. | ||
| fn supports_color(&self) -> bool { | ||
| false | ||
| } | ||
|
Comment on lines
-206
to
-209
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #148101 (comment). |
||
|
|
||
| fn source_map(&self) -> Option<&SourceMap>; | ||
|
|
||
| fn translator(&self) -> &Translator; | ||
|
|
||
Large diffs are not rendered by default.
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here the parser recovers from a missing semicolon and returns Now that we consider it syntactically invalid (rightfully so!), it no longer enjoys this privilege. Hence the warning. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,5 +14,12 @@ LL | Input: 123 | |
| LL ~ } } | ||
| | | ||
|
|
||
| error: aborting due to 1 previous error | ||
| error[E0601]: `main` function not found in crate `rust_out` | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I consider this an unfortunate regression. As mentioned in my other review comment, this doctest no longer gets preprocessed (like adding a If you like to see this addressed, I can of course change it to not bail out on However in general (not necessarily in this specific case), wrapping invalid doctests in a function is always a trade-off (it may lead to better errors in some cases but to worse ones in others; and it may leak internal names in diagnostics like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, due to the existence of error code checks like |
||
| --> $DIR/nocapture-fail.rs:10:2 | ||
| | | ||
| LL | } | ||
| | ^ consider adding a `main` function to `$DIR/nocapture-fail.rs` | ||
|
|
||
| error: aborting due to 2 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0601`. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| // issue: <https://github.com/rust-lang/rust/issues/147999> | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [add description] |
||
| //@ compile-flags: --test | ||
| //@ normalize-stdout: "tests/rustdoc-ui/doctest" -> "$$DIR" | ||
| //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" | ||
| //@ failure-status: 101 | ||
|
|
||
| //! ``` | ||
| //! #[derive(Clone)] | ||
| //! ``` | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
|
|
||
| running 1 test | ||
| test $DIR/recovered-syntax-error.rs - (line 7) ... FAILED | ||
|
|
||
| failures: | ||
|
|
||
| ---- $DIR/recovered-syntax-error.rs - (line 7) stdout ---- | ||
| error: expected item after attributes | ||
| --> $DIR/recovered-syntax-error.rs:8:1 | ||
| | | ||
| LL | #[derive(Clone)] | ||
| | ^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 1 previous error | ||
|
|
||
| Couldn't compile the test. | ||
|
|
||
| failures: | ||
| $DIR/recovered-syntax-error.rs - (line 7) | ||
|
|
||
| test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME | ||
|
|
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.
Prime example ^^