forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#89277 - jyn514:codeblock-edition, r=Guillaume…
…Gomez Use the correct edition for syntax highlighting doctests Previously it would unconditionally use edition 2015, which was incorrect. Helps with rust-lang#89135 in that you can now override the doctest to be 2018 edition instead of being forced to fix the error. This doesn't resolve any of the deeper problems that rustdoc disagrees with most rust users on what a code block is. cc `@Mark-Simulacrum`
- Loading branch information
Showing
4 changed files
with
60 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// edition:2021 | ||
|
||
#![deny(rustdoc::invalid_rust_codeblocks)] | ||
//~^ NOTE lint level is defined here | ||
|
||
// By default, rustdoc should use the edition of the crate. | ||
//! ``` | ||
//! foo'b' | ||
//! ``` | ||
//~^^^ ERROR could not parse | ||
//~| NOTE prefix `foo` is unknown | ||
|
||
// Rustdoc should respect `edition2018` when highlighting syntax. | ||
//! ```edition2018 | ||
//! foo'b' | ||
//! ``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error: could not parse code block as Rust code | ||
--> $DIR/doctest-edition.rs:7:5 | ||
| | ||
LL | //! ``` | ||
| _____^ | ||
LL | | //! foo'b' | ||
LL | | //! ``` | ||
| |_______^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/doctest-edition.rs:3:9 | ||
| | ||
LL | #![deny(rustdoc::invalid_rust_codeblocks)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
= note: error from rustc: prefix `foo` is unknown | ||
help: mark blocks that do not contain Rust code as text | ||
| | ||
LL | //! ```text | ||
| ++++ | ||
|
||
error: aborting due to previous error | ||
|