Adjust documentation for compatibility with 2021

This also adjusts the lint docs generation to accept (and ignore) an allow
attribute, rather than expecting the documentation to be immediately followed by
the lint name.
This commit is contained in:
Mark Rousskov 2021-09-20 08:46:26 -04:00
parent f338900826
commit 3b89679671
7 changed files with 35 additions and 28 deletions

View file

@ -13,7 +13,7 @@ declare_lint! {
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust /// ```rust,edition2018
/// # #![allow(unused)] /// # #![allow(unused)]
/// [1, 2, 3].into_iter().for_each(|n| { *n; }); /// [1, 2, 3].into_iter().for_each(|n| { *n; });
/// ``` /// ```

View file

@ -1686,7 +1686,7 @@ declare_lint! {
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust /// ```rust,edition2018
/// let x = 123; /// let x = 123;
/// match x { /// match x {
/// 0...100 => {} /// 0...100 => {}

View file

@ -18,7 +18,7 @@ declare_lint! {
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust,no_run /// ```rust,no_run,edition2018
/// panic!("{}"); /// panic!("{}");
/// panic!(123); /// panic!(123);
/// ``` /// ```

View file

@ -1584,7 +1584,7 @@ declare_lint! {
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust /// ```rust,edition2018
/// trait Trait { } /// trait Trait { }
/// ///
/// fn takes_trait_object(_: Box<Trait>) { /// fn takes_trait_object(_: Box<Trait>) {
@ -3313,7 +3313,7 @@ declare_lint! {
/// ///
/// ### Example /// ### Example
/// ///
/// ```rust,compile_fail /// ```rust,edition2018,compile_fail
/// #![deny(rust_2021_prefixes_incompatible_syntax)] /// #![deny(rust_2021_prefixes_incompatible_syntax)]
/// ///
/// macro_rules! m { /// macro_rules! m {
@ -3333,6 +3333,8 @@ declare_lint! {
/// ///
/// This lint suggests to add whitespace between the `z` and `"hey"` tokens /// This lint suggests to add whitespace between the `z` and `"hey"` tokens
/// to keep them separated in Rust 2021. /// to keep them separated in Rust 2021.
// Allow this lint -- rustdoc doesn't yet support threading edition into this lint's parser.
#[allow(rustdoc::invalid_rust_codeblocks)]
pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX, pub RUST_2021_PREFIXES_INCOMPATIBLE_SYNTAX,
Allow, Allow,
"identifiers that will be parsed as a prefix in Rust 2021", "identifiers that will be parsed as a prefix in Rust 2021",

View file

@ -257,7 +257,8 @@ pub struct ScopeTree {
/// ``` /// ```
/// ///
/// With the HIR tree (calls numbered for expository purposes) /// With the HIR tree (calls numbered for expository purposes)
/// ``` ///
/// ```text
/// Call#0(foo, [Call#1(f), Yield(y), Call#2(bar, Call#3(g))]) /// Call#0(foo, [Call#1(f), Yield(y), Call#2(bar, Call#3(g))])
/// ``` /// ```
/// ///

View file

@ -149,6 +149,10 @@ impl<'a> LintExtractor<'a> {
} else if line.starts_with("// ") { } else if line.starts_with("// ") {
// Ignore comments. // Ignore comments.
continue; continue;
} else if line.starts_with("#[allow") {
// Ignore allow of lints (useful for
// invalid_rust_codeblocks).
continue;
} else { } else {
let name = lint_name(line).map_err(|e| { let name = lint_name(line).map_err(|e| {
format!( format!(