diff options
| author | Joshua Nelson <jyn514@gmail.com> | 2021-09-26 16:29:41 +0000 |
|---|---|---|
| committer | Joshua Nelson <jyn514@gmail.com> | 2021-09-26 16:36:33 +0000 |
| commit | 6f087aedb60ccbed0e1ee05256100e2f80e45f2f (patch) | |
| tree | 6e2d11a5021ad5fda11d7827293b0276d2fade22 /src/test/rustdoc-ui | |
| parent | f4aa3b544f19290a6d27697f78ba29771df22860 (diff) | |
| download | rust-6f087aedb60ccbed0e1ee05256100e2f80e45f2f.tar.gz rust-6f087aedb60ccbed0e1ee05256100e2f80e45f2f.zip | |
Use the correct edition when syntax highlighting doctests
Previously it would unconditionally use edition 2015, which was incorrect.
Diffstat (limited to 'src/test/rustdoc-ui')
| -rw-r--r-- | src/test/rustdoc-ui/doctest-edition.rs | 16 | ||||
| -rw-r--r-- | src/test/rustdoc-ui/doctest-edition.stderr | 22 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/test/rustdoc-ui/doctest-edition.rs b/src/test/rustdoc-ui/doctest-edition.rs new file mode 100644 index 00000000000..b0787be972f --- /dev/null +++ b/src/test/rustdoc-ui/doctest-edition.rs @@ -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' +//! ``` diff --git a/src/test/rustdoc-ui/doctest-edition.stderr b/src/test/rustdoc-ui/doctest-edition.stderr new file mode 100644 index 00000000000..1643d605375 --- /dev/null +++ b/src/test/rustdoc-ui/doctest-edition.stderr @@ -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 + |
