about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCentri3 <114838443+Centri3@users.noreply.github.com>2023-06-07 18:22:17 -0500
committerCentri3 <114838443+Centri3@users.noreply.github.com>2023-06-07 18:34:34 -0500
commit5da34559ee6a1cf34ddfc889513f205c819bc112 (patch)
treef1508790a4977372b65abb577f115ee6cc558224
parent725399a178158be33f0754c423b95b5f7f8b53ac (diff)
downloadrust-5da34559ee6a1cf34ddfc889513f205c819bc112.tar.gz
rust-5da34559ee6a1cf34ddfc889513f205c819bc112.zip
Check if from proc macro and better tests
-rw-r--r--clippy_lints/src/excessive_nesting.rs17
-rw-r--r--tests/ui-toml/excessive_nesting/above/clippy.toml1
-rw-r--r--tests/ui-toml/excessive_nesting/auxiliary/macro_rules.rs7
-rw-r--r--tests/ui-toml/excessive_nesting/auxiliary/mod.rs16
-rw-r--r--tests/ui-toml/excessive_nesting/auxiliary/proc_macros.rs476
-rw-r--r--tests/ui-toml/excessive_nesting/default/clippy.toml1
-rw-r--r--tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr (renamed from tests/ui-toml/excessive_nesting/excessive_nesting.stderr)223
-rw-r--r--tests/ui-toml/excessive_nesting/excessive_nesting.default.stderr0
-rw-r--r--tests/ui-toml/excessive_nesting/excessive_nesting.rs13
-rw-r--r--tests/ui-toml/excessive_nesting/excessive_nesting.set.stderr100
-rw-r--r--tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr1
11 files changed, 622 insertions, 233 deletions
diff --git a/clippy_lints/src/excessive_nesting.rs b/clippy_lints/src/excessive_nesting.rs
index 1d68d7f9478..1c6cd27789d 100644
--- a/clippy_lints/src/excessive_nesting.rs
+++ b/clippy_lints/src/excessive_nesting.rs
@@ -1,4 +1,4 @@
-use clippy_utils::diagnostics::span_lint_and_help;
+use clippy_utils::{diagnostics::span_lint_and_help, source::snippet};
 use rustc_ast::{
     node_id::NodeSet,
     visit::{walk_block, walk_item, Visitor},
@@ -86,6 +86,10 @@ impl ExcessiveNesting {
 
 impl EarlyLintPass for ExcessiveNesting {
     fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &Crate) {
+        if self.excessive_nesting_threshold == 0 {
+            return;
+        }
+
         let mut visitor = NestingVisitor {
             conf: self,
             cx,
@@ -114,9 +118,7 @@ struct NestingVisitor<'conf, 'cx> {
 
 impl NestingVisitor<'_, '_> {
     fn check_indent(&mut self, span: Span, id: NodeId) -> bool {
-        let threshold = self.conf.excessive_nesting_threshold;
-
-        if threshold != 0 && self.nest_level > threshold && !in_external_macro(self.cx.sess(), span) {
+        if self.nest_level > self.conf.excessive_nesting_threshold && !in_external_macro(self.cx.sess(), span) {
             self.conf.nodes.insert(id);
 
             return true;
@@ -132,6 +134,13 @@ impl<'conf, 'cx> Visitor<'_> for NestingVisitor<'conf, 'cx> {
             return;
         }
 
+        // TODO: This should be rewritten using `LateLintPass` so we can use `is_from_proc_macro` instead,
+        // but for now, this is fine.
+        let snippet = snippet(self.cx, block.span, "{}").trim().to_owned();
+        if !snippet.starts_with('{') || !snippet.ends_with('}') {
+            return;
+        }
+
         self.nest_level += 1;
 
         if !self.check_indent(block.span, block.id) {
diff --git a/tests/ui-toml/excessive_nesting/above/clippy.toml b/tests/ui-toml/excessive_nesting/above/clippy.toml
new file mode 100644
index 00000000000..e60ac978cac
--- /dev/null
+++ b/tests/ui-toml/excessive_nesting/above/clippy.toml
@@ -0,0 +1 @@
+excessive-nesting-threshold = 4
diff --git a/tests/ui-toml/excessive_nesting/auxiliary/macro_rules.rs b/tests/ui-toml/excessive_nesting/auxiliary/macro_rules.rs
deleted file mode 100644
index 86663db68f2..00000000000
--- a/tests/ui-toml/excessive_nesting/auxiliary/macro_rules.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#[rustfmt::skip]
-#[macro_export]
-macro_rules! excessive_nesting {
-    () => {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{
-        println!("hi!!")
-    }}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}
-}
diff --git a/tests/ui-toml/excessive_nesting/auxiliary/mod.rs b/tests/ui-toml/excessive_nesting/auxiliary/mod.rs
deleted file mode 100644
index 967b3af3bca..00000000000
--- a/tests/ui-toml/excessive_nesting/auxiliary/mod.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-#![rustfmt::skip]
-
-mod a {
-    mod b {
-        mod c {
-            mod d {
-                mod e {}
-            }
-        }
-    }
-}
-
-fn main() {
-    // this should lint
-    {{{}}}
-}
diff --git a/tests/ui-toml/excessive_nesting/auxiliary/proc_macros.rs b/tests/ui-toml/excessive_nesting/auxiliary/proc_macros.rs
new file mode 100644
index 00000000000..87620fe91ba
--- /dev/null
+++ b/tests/ui-toml/excessive_nesting/auxiliary/proc_macros.rs
@@ -0,0 +1,476 @@
+//@compile-flags: --emit=link
+//@no-prefer-dynamic
+
+// NOTE: Copied from `ui/auxiliary/proc_macros.rs`, couldn't get `../` to work for some reason
+
+#![crate_type = "proc-macro"]
+#![feature(let_chains)]
+#![feature(proc_macro_span)]
+#![allow(dead_code)]
+
+extern crate proc_macro;
+
+use core::mem;
+use proc_macro::{
+    token_stream::IntoIter,
+    Delimiter::{self, Brace, Parenthesis},
+    Group, Ident, Literal, Punct,
+    Spacing::{self, Alone, Joint},
+    Span, TokenStream, TokenTree as TT,
+};
+
+type Result<T> = core::result::Result<T, TokenStream>;
+
+/// Make a `compile_error!` pointing to the given span.
+fn make_error(msg: &str, span: Span) -> TokenStream {
+    TokenStream::from_iter([
+        TT::Ident(Ident::new("compile_error", span)),
+        TT::Punct(punct_with_span('!', Alone, span)),
+        TT::Group({
+            let mut msg = Literal::string(msg);
+            msg.set_span(span);
+            group_with_span(Parenthesis, TokenStream::from_iter([TT::Literal(msg)]), span)
+        }),
+    ])
+}
+
+fn expect_tt<T>(tt: Option<TT>, f: impl FnOnce(TT) -> Option<T>, expected: &str, span: Span) -> Result<T> {
+    match tt {
+        None => Err(make_error(
+            &format!("unexpected end of input, expected {expected}"),
+            span,
+        )),
+        Some(tt) => {
+            let span = tt.span();
+            match f(tt) {
+                Some(x) => Ok(x),
+                None => Err(make_error(&format!("unexpected token, expected {expected}"), span)),
+            }
+        },
+    }
+}
+
+fn punct_with_span(c: char, spacing: Spacing, span: Span) -> Punct {
+    let mut p = Punct::new(c, spacing);
+    p.set_span(span);
+    p
+}
+
+fn group_with_span(delimiter: Delimiter, stream: TokenStream, span: Span) -> Group {
+    let mut g = Group::new(delimiter, stream);
+    g.set_span(span);
+    g
+}
+
+/// Token used to escape the following token from the macro's span rules.
+const ESCAPE_CHAR: char = '$';
+
+/// Takes a single token followed by a sequence of tokens. Returns the sequence of tokens with their
+/// span set to that of the first token. Tokens may be escaped with either `#ident` or `#(tokens)`.
+#[proc_macro]
+pub fn with_span(input: TokenStream) -> TokenStream {
+    let mut iter = input.into_iter();
+    let span = iter.next().unwrap().span();
+    let mut res = TokenStream::new();
+    if let Err(e) = write_with_span(span, iter, &mut res) {
+        e
+    } else {
+        res
+    }
+}
+
+/// Takes a sequence of tokens and return the tokens with the span set such that they appear to be
+/// from an external macro. Tokens may be escaped with either `#ident` or `#(tokens)`.
+#[proc_macro]
+pub fn external(input: TokenStream) -> TokenStream {
+    let mut res = TokenStream::new();
+    if let Err(e) = write_with_span(Span::mixed_site(), input.into_iter(), &mut res) {
+        e
+    } else {
+        res
+    }
+}
+
+/// Copies all the tokens, replacing all their spans with the given span. Tokens can be escaped
+/// either by `#ident` or `#(tokens)`.
+fn write_with_span(s: Span, mut input: IntoIter, out: &mut TokenStream) -> Result<()> {
+    while let Some(tt) = input.next() {
+        match tt {
+            TT::Punct(p) if p.as_char() == ESCAPE_CHAR => {
+                expect_tt(
+                    input.next(),
+                    |tt| match tt {
+                        tt @ (TT::Ident(_) | TT::Literal(_)) => {
+                            out.extend([tt]);
+                            Some(())
+                        },
+                        TT::Punct(mut p) if p.as_char() == ESCAPE_CHAR => {
+                            p.set_span(s);
+                            out.extend([TT::Punct(p)]);
+                            Some(())
+                        },
+                        TT::Group(g) if g.delimiter() == Parenthesis => {
+                            out.extend([TT::Group(group_with_span(Delimiter::None, g.stream(), g.span()))]);
+                            Some(())
+                        },
+                        _ => None,
+                    },
+                    "an ident, a literal, or parenthesized tokens",
+                    p.span(),
+                )?;
+            },
+            TT::Group(g) => {
+                let mut stream = TokenStream::new();
+                write_with_span(s, g.stream().into_iter(), &mut stream)?;
+                out.extend([TT::Group(group_with_span(g.delimiter(), stream, s))]);
+            },
+            mut tt => {
+                tt.set_span(s);
+                out.extend([tt]);
+            },
+        }
+    }
+    Ok(())
+}
+
+/// Within the item this attribute is attached to, an `inline!` macro is available which expands the
+/// contained tokens as though they came from a macro expansion.
+///
+/// Within the `inline!` macro, any token preceded by `$` is passed as though it were an argument
+/// with an automatically chosen fragment specifier. `$ident` will be passed as `ident`, `$1` or
+/// `$"literal"` will be passed as `literal`, `$'lt` will be passed as `lifetime`, and `$(...)` will
+/// pass the contained tokens as a `tt` sequence (the wrapping parenthesis are removed). If another
+/// specifier is required it can be specified within parenthesis like `$(@expr ...)`. This will
+/// expand the remaining tokens as a single argument.
+///
+/// Multiple `inline!` macros may be nested within each other. This will expand as nested macro
+/// calls. However, any arguments will be passed as though they came from the outermost context.
+#[proc_macro_attribute]
+pub fn inline_macros(args: TokenStream, input: TokenStream) -> TokenStream {
+    let mut args = args.into_iter();
+    let mac_name = match args.next() {
+        Some(TT::Ident(name)) => Some(name),
+        Some(tt) => {
+            return make_error(
+                "unexpected argument, expected either an ident or no arguments",
+                tt.span(),
+            );
+        },
+        None => None,
+    };
+    if let Some(tt) = args.next() {
+        return make_error(
+            "unexpected argument, expected either an ident or no arguments",
+            tt.span(),
+        );
+    };
+
+    let mac_name = if let Some(mac_name) = mac_name {
+        Ident::new(&format!("__inline_mac_{mac_name}"), Span::call_site())
+    } else {
+        let mut input = match LookaheadIter::new(input.clone().into_iter()) {
+            Some(x) => x,
+            None => return input,
+        };
+        loop {
+            match input.next() {
+                None => break Ident::new("__inline_mac", Span::call_site()),
+                Some(TT::Ident(kind)) => match &*kind.to_string() {
+                    "impl" => break Ident::new("__inline_mac_impl", Span::call_site()),
+                    kind @ ("struct" | "enum" | "union" | "fn" | "mod" | "trait" | "type" | "const" | "static") => {
+                        if let TT::Ident(name) = &input.tt {
+                            break Ident::new(&format!("__inline_mac_{kind}_{name}"), Span::call_site());
+                        } else {
+                            break Ident::new(&format!("__inline_mac_{kind}"), Span::call_site());
+                        }
+                    },
+                    _ => {},
+                },
+                _ => {},
+            }
+        }
+    };
+
+    let mut expander = Expander::default();
+    let mut mac = MacWriter::new(mac_name);
+    if let Err(e) = expander.expand(input.into_iter(), &mut mac) {
+        return e;
+    }
+    let mut out = TokenStream::new();
+    mac.finish(&mut out);
+    out.extend(expander.expn);
+    out
+}
+
+/// Wraps a `TokenStream` iterator with a single token lookahead.
+struct LookaheadIter {
+    tt: TT,
+    iter: IntoIter,
+}
+impl LookaheadIter {
+    fn new(mut iter: IntoIter) -> Option<Self> {
+        iter.next().map(|tt| Self { tt, iter })
+    }
+
+    /// Get's the lookahead token, replacing it with the next token in the stream.
+    /// Note: If there isn't a next token, this will not return the lookahead token.
+    fn next(&mut self) -> Option<TT> {
+        self.iter.next().map(|tt| mem::replace(&mut self.tt, tt))
+    }
+}
+
+/// Builds the macro used to implement all the `inline!` macro calls.
+struct MacWriter {
+    name: Ident,
+    macros: TokenStream,
+    next_idx: usize,
+}
+impl MacWriter {
+    fn new(name: Ident) -> Self {
+        Self {
+            name,
+            macros: TokenStream::new(),
+            next_idx: 0,
+        }
+    }
+
+    /// Inserts a new `inline!` call.
+    fn insert(&mut self, name_span: Span, bang_span: Span, body: Group, expander: &mut Expander) -> Result<()> {
+        let idx = self.next_idx;
+        self.next_idx += 1;
+
+        let mut inner = Expander::for_arm(idx);
+        inner.expand(body.stream().into_iter(), self)?;
+        let new_arm = inner.arm.unwrap();
+
+        self.macros.extend([
+            TT::Group(Group::new(Parenthesis, new_arm.args_def)),
+            TT::Punct(Punct::new('=', Joint)),
+            TT::Punct(Punct::new('>', Alone)),
+            TT::Group(Group::new(Parenthesis, inner.expn)),
+            TT::Punct(Punct::new(';', Alone)),
+        ]);
+
+        expander.expn.extend([
+            TT::Ident({
+                let mut name = self.name.clone();
+                name.set_span(name_span);
+                name
+            }),
+            TT::Punct(punct_with_span('!', Alone, bang_span)),
+        ]);
+        let mut call_body = TokenStream::from_iter([TT::Literal(Literal::usize_unsuffixed(idx))]);
+        if let Some(arm) = expander.arm.as_mut() {
+            if !new_arm.args.is_empty() {
+                arm.add_sub_args(new_arm.args, &mut call_body);
+            }
+        } else {
+            call_body.extend(new_arm.args);
+        }
+        let mut g = Group::new(body.delimiter(), call_body);
+        g.set_span(body.span());
+        expander.expn.extend([TT::Group(g)]);
+        Ok(())
+    }
+
+    /// Creates the macro definition.
+    fn finish(self, out: &mut TokenStream) {
+        if self.next_idx != 0 {
+            out.extend([
+                TT::Ident(Ident::new("macro_rules", Span::call_site())),
+                TT::Punct(Punct::new('!', Alone)),
+                TT::Ident(self.name),
+                TT::Group(Group::new(Brace, self.macros)),
+            ])
+        }
+    }
+}
+
+struct MacroArm {
+    args_def: TokenStream,
+    args: Vec<TT>,
+}
+impl MacroArm {
+    fn add_single_arg_def(&mut self, kind: &str, dollar_span: Span, arg_span: Span, out: &mut TokenStream) {
+        let mut name = Ident::new(&format!("_{}", self.args.len()), Span::call_site());
+        self.args_def.extend([
+            TT::Punct(Punct::new('$', Alone)),
+            TT::Ident(name.clone()),
+            TT::Punct(Punct::new(':', Alone)),
+            TT::Ident(Ident::new(kind, Span::call_site())),
+        ]);
+        name.set_span(arg_span);
+        out.extend([TT::Punct(punct_with_span('$', Alone, dollar_span)), TT::Ident(name)]);
+    }
+
+    fn add_parenthesized_arg_def(&mut self, kind: Ident, dollar_span: Span, arg_span: Span, out: &mut TokenStream) {
+        let mut name = Ident::new(&format!("_{}", self.args.len()), Span::call_site());
+        self.args_def.extend([TT::Group(Group::new(
+            Parenthesis,
+            TokenStream::from_iter([
+                TT::Punct(Punct::new('$', Alone)),
+                TT::Ident(name.clone()),
+                TT::Punct(Punct::new(':', Alone)),
+                TT::Ident(kind),
+            ]),
+        ))]);
+        name.set_span(arg_span);
+        out.extend([TT::Punct(punct_with_span('$', Alone, dollar_span)), TT::Ident(name)]);
+    }
+
+    fn add_multi_arg_def(&mut self, dollar_span: Span, arg_span: Span, out: &mut TokenStream) {
+        let mut name = Ident::new(&format!("_{}", self.args.len()), Span::call_site());
+        self.args_def.extend([TT::Group(Group::new(
+            Parenthesis,
+            TokenStream::from_iter([
+                TT::Punct(Punct::new('$', Alone)),
+                TT::Group(Group::new(
+                    Parenthesis,
+                    TokenStream::from_iter([
+                        TT::Punct(Punct::new('$', Alone)),
+                        TT::Ident(name.clone()),
+                        TT::Punct(Punct::new(':', Alone)),
+                        TT::Ident(Ident::new("tt", Span::call_site())),
+                    ]),
+                )),
+                TT::Punct(Punct::new('*', Alone)),
+            ]),
+        ))]);
+        name.set_span(arg_span);
+        out.extend([
+            TT::Punct(punct_with_span('$', Alone, dollar_span)),
+            TT::Group(group_with_span(
+                Parenthesis,
+                TokenStream::from_iter([TT::Punct(punct_with_span('$', Alone, dollar_span)), TT::Ident(name)]),
+                dollar_span,
+            )),
+            TT::Punct(punct_with_span('*', Alone, dollar_span)),
+        ]);
+    }
+
+    fn add_arg(&mut self, dollar_span: Span, tt: TT, input: &mut IntoIter, out: &mut TokenStream) -> Result<()> {
+        match tt {
+            TT::Punct(p) if p.as_char() == ESCAPE_CHAR => out.extend([TT::Punct(p)]),
+            TT::Punct(p) if p.as_char() == '\'' && p.spacing() == Joint => {
+                let lt_name = expect_tt(
+                    input.next(),
+                    |tt| match tt {
+                        TT::Ident(x) => Some(x),
+                        _ => None,
+                    },
+                    "lifetime name",
+                    p.span(),
+                )?;
+                let arg_span = p.span().join(lt_name.span()).unwrap_or(p.span());
+                self.add_single_arg_def("lifetime", dollar_span, arg_span, out);
+                self.args.extend([TT::Punct(p), TT::Ident(lt_name)]);
+            },
+            TT::Ident(x) => {
+                self.add_single_arg_def("ident", dollar_span, x.span(), out);
+                self.args.push(TT::Ident(x));
+            },
+            TT::Literal(x) => {
+                self.add_single_arg_def("literal", dollar_span, x.span(), out);
+                self.args.push(TT::Literal(x));
+            },
+            TT::Group(g) if g.delimiter() == Parenthesis => {
+                let mut inner = g.stream().into_iter();
+                if let Some(TT::Punct(p)) = inner.next()
+                    && p.as_char() == '@'
+                {
+                    let kind = expect_tt(
+                        inner.next(),
+                        |tt| match tt {
+                            TT::Ident(kind) => Some(kind),
+                            _ => None,
+                        },
+                        "a macro fragment specifier",
+                        p.span(),
+                    )?;
+                    self.add_parenthesized_arg_def(kind, dollar_span, g.span(), out);
+                    self.args.push(TT::Group(group_with_span(Parenthesis, inner.collect(), g.span())))
+                } else {
+                    self.add_multi_arg_def(dollar_span, g.span(), out);
+                    self.args.push(TT::Group(g));
+                }
+            },
+            tt => return Err(make_error("unsupported escape", tt.span())),
+        };
+        Ok(())
+    }
+
+    fn add_sub_args(&mut self, args: Vec<TT>, out: &mut TokenStream) {
+        self.add_multi_arg_def(Span::call_site(), Span::call_site(), out);
+        self.args
+            .extend([TT::Group(Group::new(Parenthesis, TokenStream::from_iter(args)))]);
+    }
+}
+
+#[derive(Default)]
+struct Expander {
+    arm: Option<MacroArm>,
+    expn: TokenStream,
+}
+impl Expander {
+    fn for_arm(idx: usize) -> Self {
+        Self {
+            arm: Some(MacroArm {
+                args_def: TokenStream::from_iter([TT::Literal(Literal::usize_unsuffixed(idx))]),
+                args: Vec::new(),
+            }),
+            expn: TokenStream::new(),
+        }
+    }
+
+    fn write_tt(&mut self, tt: TT, mac: &mut MacWriter) -> Result<()> {
+        match tt {
+            TT::Group(g) => {
+                let outer = mem::take(&mut self.expn);
+                self.expand(g.stream().into_iter(), mac)?;
+                let inner = mem::replace(&mut self.expn, outer);
+                self.expn
+                    .extend([TT::Group(group_with_span(g.delimiter(), inner, g.span()))]);
+            },
+            tt => self.expn.extend([tt]),
+        }
+        Ok(())
+    }
+
+    fn expand(&mut self, input: IntoIter, mac: &mut MacWriter) -> Result<()> {
+        let Some(mut input) = LookaheadIter::new(input) else {
+            return Ok(());
+        };
+        while let Some(tt) = input.next() {
+            if let TT::Punct(p) = &tt
+                && p.as_char() == ESCAPE_CHAR
+                && let Some(arm) = self.arm.as_mut()
+            {
+                arm.add_arg(p.span(), mem::replace(&mut input.tt, tt), &mut input.iter, &mut self.expn)?;
+                if input.next().is_none() {
+                    return Ok(());
+                }
+            } else if let TT::Punct(p) = &input.tt
+                && p.as_char() == '!'
+                && let TT::Ident(name) = &tt
+                && name.to_string() == "inline"
+            {
+                let g = expect_tt(
+                    input.iter.next(),
+                    |tt| match tt {
+                        TT::Group(g) => Some(g),
+                        _ => None,
+                    },
+                    "macro arguments",
+                    p.span(),
+                )?;
+                mac.insert(name.span(), p.span(), g, self)?;
+                if input.next().is_none() {
+                    return Ok(());
+                }
+            } else {
+                self.write_tt(tt, mac)?;
+            }
+        }
+        self.write_tt(input.tt, mac)
+    }
+}
diff --git a/tests/ui-toml/excessive_nesting/default/clippy.toml b/tests/ui-toml/excessive_nesting/default/clippy.toml
deleted file mode 100644
index e8b115a0f7c..00000000000
--- a/tests/ui-toml/excessive_nesting/default/clippy.toml
+++ /dev/null
@@ -1 +0,0 @@
-excessive-nesting-threshold = 0
diff --git a/tests/ui-toml/excessive_nesting/excessive_nesting.stderr b/tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr
index f1db396fe48..0ec41fbaa07 100644
--- a/tests/ui-toml/excessive_nesting/excessive_nesting.stderr
+++ b/tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr
@@ -1,369 +1,314 @@
 error: this block is too nested
-  --> $DIR/auxiliary/mod.rs:6:13
+  --> $DIR/excessive_nesting.rs:23:25
    |
-LL | /             mod d {
-LL | |                 mod e {}
-LL | |             }
-   | |_____________^
+LL |                 let w = { 3 };
+   |                         ^^^^^
    |
    = help: try refactoring your code to minimize nesting
    = note: `-D clippy::excessive-nesting` implied by `-D warnings`
 
 error: this block is too nested
-  --> $DIR/auxiliary/mod.rs:15:7
+  --> $DIR/excessive_nesting.rs:69:17
    |
-LL |     {{{}}}
-   |       ^^
-   |
-   = help: try refactoring your code to minimize nesting
-
-error: this block is too nested
-  --> $DIR/excessive_nesting.rs:21:21
-   |
-LL |               let z = {
-   |  _____________________^
-LL | |                 let w = { 3 };
-LL | |                 w
-LL | |             };
-   | |_____________^
-   |
-   = help: try refactoring your code to minimize nesting
-
-error: this block is too nested
-  --> $DIR/excessive_nesting.rs:65:24
-   |
-LL |               pub fn b() {
-   |  ________________________^
-LL | |                 struct C;
-LL | |
-LL | |                 impl C {
+LL | /                 impl C {
 LL | |                     pub fn c() {}
 LL | |                 }
-LL | |             }
-   | |_____________^
+   | |_________________^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:81:21
+  --> $DIR/excessive_nesting.rs:83:25
    |
-LL |               fn cc() {
-   |  _____________________^
-LL | |                 let x = { 1 }; // not a warning, but cc is
-LL | |             }
-   | |_____________^
+LL |                 let x = { 1 }; // not a warning, but cc is
+   |                         ^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:85:21
-   |
-LL |             let x = { 1 }; // warning
-   |                     ^^^^^
+  --> $DIR/excessive_nesting.rs:100:17
    |
-   = help: try refactoring your code to minimize nesting
-
-error: this block is too nested
-  --> $DIR/excessive_nesting.rs:98:13
-   |
-LL | /             pub mod d {
-LL | |                 pub mod e {
+LL | /                 pub mod e {
 LL | |                     pub mod f {}
 LL | |                 } // not here
-LL | |             } // only warning should be here
-   | |_____________^
+   | |_________________^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:112:17
+  --> $DIR/excessive_nesting.rs:113:18
    |
 LL |     a_but_not({{{{{{{{0}}}}}}}});
-   |                 ^^^^^^^^^^^^^
+   |                  ^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:113:11
+  --> $DIR/excessive_nesting.rs:114:12
    |
 LL |     a.a({{{{{{{{{0}}}}}}}}});
-   |           ^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:114:11
+  --> $DIR/excessive_nesting.rs:115:12
    |
 LL |     (0, {{{{{{{1}}}}}}});
-   |           ^^^^^^^^^^^
+   |            ^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:118:21
+  --> $DIR/excessive_nesting.rs:120:25
    |
-LL |               if true {
-   |  _____________________^
-LL | |                 if true {
+LL |                   if true {
+   |  _________________________^
 LL | |                     if true {
 LL | |
 LL | |                     }
 LL | |                 }
-LL | |             }
-   | |_____________^
+   | |_________________^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:130:25
+  --> $DIR/excessive_nesting.rs:132:29
    |
-LL |               let y = (|| {
-   |  _________________________^
-LL | |                 let z = (|| {
+LL |                   let z = (|| {
+   |  _____________________________^
 LL | |                     let w = { 3 };
 LL | |                     w
 LL | |                 })();
-LL | |                 z
-LL | |             })();
-   | |_____________^
-   |
-   = help: try refactoring your code to minimize nesting
-
-error: this block is too nested
-  --> $DIR/excessive_nesting.rs:145:36
-   |
-LL |     !{boo as u32 + !{boo as u32 + !{boo as u32}}};
-   |                                    ^^^^^^^^^^^^
+   | |_________________^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:149:12
+  --> $DIR/excessive_nesting.rs:151:13
    |
 LL |     y += {{{{{5}}}}};
-   |            ^^^^^^^
+   |             ^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:150:19
+  --> $DIR/excessive_nesting.rs:152:20
    |
 LL |     let z = y + {{{{{{{{{5}}}}}}}}};
-   |                   ^^^^^^^^^^^^^^^
+   |                    ^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:151:11
+  --> $DIR/excessive_nesting.rs:153:12
    |
 LL |     [0, {{{{{{{{{{0}}}}}}}}}}];
-   |           ^^^^^^^^^^^^^^^^^
+   |            ^^^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:152:24
+  --> $DIR/excessive_nesting.rs:154:25
    |
 LL |     let mut xx = [0; {{{{{{{{100}}}}}}}}];
-   |                        ^^^^^^^^^^^^^^^
+   |                         ^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:153:10
+  --> $DIR/excessive_nesting.rs:155:11
    |
 LL |     xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}];
-   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:154:12
+  --> $DIR/excessive_nesting.rs:156:13
    |
 LL |     &mut {{{{{{{{{{y}}}}}}}}}};
-   |            ^^^^^^^^^^^^^^^^^
+   |             ^^^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:156:16
+  --> $DIR/excessive_nesting.rs:158:17
    |
 LL |     for i in {{{{xx}}}} {{{{{{{{}}}}}}}}
-   |                ^^^^^^
+   |                 ^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:156:27
+  --> $DIR/excessive_nesting.rs:158:28
    |
 LL |     for i in {{{{xx}}}} {{{{{{{{}}}}}}}}
-   |                           ^^^^^^^^^^^^
+   |                            ^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:158:27
+  --> $DIR/excessive_nesting.rs:160:28
    |
 LL |     while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}}
-   |                           ^^^^^^^^^^^^^^^
+   |                            ^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:158:47
+  --> $DIR/excessive_nesting.rs:160:48
    |
 LL |     while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}}
-   |                                               ^^^^^^^^^^
+   |                                                ^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:160:13
+  --> $DIR/excessive_nesting.rs:162:14
    |
 LL |     while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}}
-   |             ^^^^^^^^^^^^^^^^
+   |              ^^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:160:34
+  --> $DIR/excessive_nesting.rs:162:35
    |
 LL |     while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}}
-   |                                  ^^^^^^^^^^^^^^
+   |                                   ^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:162:22
+  --> $DIR/excessive_nesting.rs:164:23
    |
 LL |     let d = D { d: {{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}} };
-   |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:164:7
+  --> $DIR/excessive_nesting.rs:166:8
    |
 LL |     {{{{1;}}}}..{{{{{{3}}}}}};
-   |       ^^^^^^
+   |        ^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:164:19
+  --> $DIR/excessive_nesting.rs:166:20
    |
 LL |     {{{{1;}}}}..{{{{{{3}}}}}};
-   |                   ^^^^^^^^^
+   |                    ^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:165:7
+  --> $DIR/excessive_nesting.rs:167:8
    |
 LL |     {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}};
-   |       ^^^^^^
+   |        ^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:165:20
+  --> $DIR/excessive_nesting.rs:167:21
    |
 LL |     {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}};
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:166:9
+  --> $DIR/excessive_nesting.rs:168:10
    |
 LL |     ..{{{{{{{5}}}}}}};
-   |         ^^^^^^^^^^^
+   |          ^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:167:10
+  --> $DIR/excessive_nesting.rs:169:11
    |
 LL |     ..={{{{{3}}}}};
-   |          ^^^^^^^
+   |           ^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:168:7
+  --> $DIR/excessive_nesting.rs:170:8
    |
 LL |     {{{{{1;}}}}}..;
-   |       ^^^^^^^^
+   |        ^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:170:19
+  --> $DIR/excessive_nesting.rs:172:20
    |
 LL |     loop { break {{{{1}}}} };
-   |                   ^^^^^^^
+   |                    ^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:171:12
+  --> $DIR/excessive_nesting.rs:173:13
    |
 LL |     loop {{{{{{}}}}}}
-   |            ^^^^^^^^
+   |             ^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:173:13
+  --> $DIR/excessive_nesting.rs:175:14
    |
 LL |     match {{{{{{true}}}}}} {
-   |             ^^^^^^^^^^^^
+   |              ^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:174:19
+  --> $DIR/excessive_nesting.rs:176:20
    |
 LL |         true => {{{{}}}},
-   |                   ^^^^
+   |                    ^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:175:20
+  --> $DIR/excessive_nesting.rs:177:21
    |
 LL |         false => {{{{}}}},
-   |                    ^^^^
+   |                     ^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:180:13
+  --> $DIR/excessive_nesting.rs:183:17
    |
-LL | /             {
-LL | |                 {
+LL | /                 {
 LL | |                     println!("warning! :)");
 LL | |                 }
-LL | |             }
-   | |_____________^
+   | |_________________^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:190:27
+  --> $DIR/excessive_nesting.rs:192:28
    |
 LL |     async fn c() -> u32 {{{{{{{0}}}}}}}
-   |                           ^^^^^^^^^^^
+   |                            ^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:196:7
+  --> $DIR/excessive_nesting.rs:198:8
    |
 LL |     {{{{b().await}}}};
-   |       ^^^^^^^^^^^^^
+   |        ^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
-error: aborting due to 41 previous errors
+error: aborting due to 37 previous errors
 
diff --git a/tests/ui-toml/excessive_nesting/excessive_nesting.default.stderr b/tests/ui-toml/excessive_nesting/excessive_nesting.default.stderr
deleted file mode 100644
index e69de29bb2d..00000000000
--- a/tests/ui-toml/excessive_nesting/excessive_nesting.default.stderr
+++ /dev/null
diff --git a/tests/ui-toml/excessive_nesting/excessive_nesting.rs b/tests/ui-toml/excessive_nesting/excessive_nesting.rs
index 5e436b97ee8..432c4132b57 100644
--- a/tests/ui-toml/excessive_nesting/excessive_nesting.rs
+++ b/tests/ui-toml/excessive_nesting/excessive_nesting.rs
@@ -1,7 +1,7 @@
-//@aux-build:macro_rules.rs
-//@revisions: set default
+//@aux-build:proc_macros.rs
+//@revisions: set above
 //@[set] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/excessive_nesting/set
-//@[default] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/excessive_nesting/default
+//@[above] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/excessive_nesting/above
 #![rustfmt::skip]
 #![feature(custom_inner_attributes)]
 #![allow(unused)]
@@ -13,10 +13,8 @@
 #![warn(clippy::excessive_nesting)]
 #![allow(clippy::collapsible_if)]
 
-mod auxiliary;
-
 #[macro_use]
-extern crate macro_rules;
+extern crate proc_macros;
 
 static X: u32 = {
     let x = {
@@ -142,7 +140,8 @@ fn main() {
         x
     })();
 
-    excessive_nesting!(); // ensure this isn't linted in external macros
+    external! { {{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}} }; // ensure this isn't linted in external macros
+    with_span! { span {{{{{{{{{{{{}}}}}}}}}}}} }; // don't lint for proc macros
     xx!(); // ensure this is never linted
     let boo = true;
     !{boo as u32 + !{boo as u32 + !{boo as u32}}};
diff --git a/tests/ui-toml/excessive_nesting/excessive_nesting.set.stderr b/tests/ui-toml/excessive_nesting/excessive_nesting.set.stderr
index 1f069437dfe..237cc6c4a90 100644
--- a/tests/ui-toml/excessive_nesting/excessive_nesting.set.stderr
+++ b/tests/ui-toml/excessive_nesting/excessive_nesting.set.stderr
@@ -1,24 +1,5 @@
 error: this block is too nested
-  --> $DIR/auxiliary/mod.rs:6:13
-   |
-LL | /             mod d {
-LL | |                 mod e {}
-LL | |             }
-   | |_____________^
-   |
-   = help: try refactoring your code to minimize nesting
-   = note: `-D clippy::excessive-nesting` implied by `-D warnings`
-
-error: this block is too nested
-  --> $DIR/auxiliary/mod.rs:15:7
-   |
-LL |     {{{}}}
-   |       ^^
-   |
-   = help: try refactoring your code to minimize nesting
-
-error: this block is too nested
-  --> $DIR/excessive_nesting.rs:24:21
+  --> $DIR/excessive_nesting.rs:22:21
    |
 LL |               let z = {
    |  _____________________^
@@ -28,9 +9,10 @@ LL | |             };
    | |_____________^
    |
    = help: try refactoring your code to minimize nesting
+   = note: `-D clippy::excessive-nesting` implied by `-D warnings`
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:68:24
+  --> $DIR/excessive_nesting.rs:66:24
    |
 LL |               pub fn b() {
    |  ________________________^
@@ -45,7 +27,7 @@ LL | |             }
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:84:21
+  --> $DIR/excessive_nesting.rs:82:21
    |
 LL |               fn cc() {
    |  _____________________^
@@ -56,7 +38,7 @@ LL | |             }
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:88:21
+  --> $DIR/excessive_nesting.rs:86:21
    |
 LL |             let x = { 1 }; // warning
    |                     ^^^^^
@@ -64,7 +46,7 @@ LL |             let x = { 1 }; // warning
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:101:13
+  --> $DIR/excessive_nesting.rs:99:13
    |
 LL | /             pub mod d {
 LL | |                 pub mod e {
@@ -76,7 +58,7 @@ LL | |             } // only warning should be here
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:115:17
+  --> $DIR/excessive_nesting.rs:113:17
    |
 LL |     a_but_not({{{{{{{{0}}}}}}}});
    |                 ^^^^^^^^^^^^^
@@ -84,7 +66,7 @@ LL |     a_but_not({{{{{{{{0}}}}}}}});
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:116:11
+  --> $DIR/excessive_nesting.rs:114:11
    |
 LL |     a.a({{{{{{{{{0}}}}}}}}});
    |           ^^^^^^^^^^^^^^^
@@ -92,7 +74,7 @@ LL |     a.a({{{{{{{{{0}}}}}}}}});
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:117:11
+  --> $DIR/excessive_nesting.rs:115:11
    |
 LL |     (0, {{{{{{{1}}}}}}});
    |           ^^^^^^^^^^^
@@ -100,7 +82,7 @@ LL |     (0, {{{{{{{1}}}}}}});
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:121:21
+  --> $DIR/excessive_nesting.rs:119:21
    |
 LL |               if true {
    |  _____________________^
@@ -115,7 +97,7 @@ LL | |             }
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:133:25
+  --> $DIR/excessive_nesting.rs:131:25
    |
 LL |               let y = (|| {
    |  _________________________^
@@ -130,7 +112,7 @@ LL | |             })();
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:148:36
+  --> $DIR/excessive_nesting.rs:147:36
    |
 LL |     !{boo as u32 + !{boo as u32 + !{boo as u32}}};
    |                                    ^^^^^^^^^^^^
@@ -138,7 +120,7 @@ LL |     !{boo as u32 + !{boo as u32 + !{boo as u32}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:152:12
+  --> $DIR/excessive_nesting.rs:151:12
    |
 LL |     y += {{{{{5}}}}};
    |            ^^^^^^^
@@ -146,7 +128,7 @@ LL |     y += {{{{{5}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:153:19
+  --> $DIR/excessive_nesting.rs:152:19
    |
 LL |     let z = y + {{{{{{{{{5}}}}}}}}};
    |                   ^^^^^^^^^^^^^^^
@@ -154,7 +136,7 @@ LL |     let z = y + {{{{{{{{{5}}}}}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:154:11
+  --> $DIR/excessive_nesting.rs:153:11
    |
 LL |     [0, {{{{{{{{{{0}}}}}}}}}}];
    |           ^^^^^^^^^^^^^^^^^
@@ -162,7 +144,7 @@ LL |     [0, {{{{{{{{{{0}}}}}}}}}}];
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:155:24
+  --> $DIR/excessive_nesting.rs:154:24
    |
 LL |     let mut xx = [0; {{{{{{{{100}}}}}}}}];
    |                        ^^^^^^^^^^^^^^^
@@ -170,7 +152,7 @@ LL |     let mut xx = [0; {{{{{{{{100}}}}}}}}];
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:156:10
+  --> $DIR/excessive_nesting.rs:155:10
    |
 LL |     xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}];
    |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -178,7 +160,7 @@ LL |     xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}];
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:157:12
+  --> $DIR/excessive_nesting.rs:156:12
    |
 LL |     &mut {{{{{{{{{{y}}}}}}}}}};
    |            ^^^^^^^^^^^^^^^^^
@@ -186,7 +168,7 @@ LL |     &mut {{{{{{{{{{y}}}}}}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:159:16
+  --> $DIR/excessive_nesting.rs:158:16
    |
 LL |     for i in {{{{xx}}}} {{{{{{{{}}}}}}}}
    |                ^^^^^^
@@ -194,7 +176,7 @@ LL |     for i in {{{{xx}}}} {{{{{{{{}}}}}}}}
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:159:27
+  --> $DIR/excessive_nesting.rs:158:27
    |
 LL |     for i in {{{{xx}}}} {{{{{{{{}}}}}}}}
    |                           ^^^^^^^^^^^^
@@ -202,7 +184,7 @@ LL |     for i in {{{{xx}}}} {{{{{{{{}}}}}}}}
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:161:27
+  --> $DIR/excessive_nesting.rs:160:27
    |
 LL |     while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}}
    |                           ^^^^^^^^^^^^^^^
@@ -210,7 +192,7 @@ LL |     while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}}
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:161:47
+  --> $DIR/excessive_nesting.rs:160:47
    |
 LL |     while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}}
    |                                               ^^^^^^^^^^
@@ -218,7 +200,7 @@ LL |     while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}}
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:163:13
+  --> $DIR/excessive_nesting.rs:162:13
    |
 LL |     while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}}
    |             ^^^^^^^^^^^^^^^^
@@ -226,7 +208,7 @@ LL |     while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}}
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:163:34
+  --> $DIR/excessive_nesting.rs:162:34
    |
 LL |     while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}}
    |                                  ^^^^^^^^^^^^^^
@@ -234,7 +216,7 @@ LL |     while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}}
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:165:22
+  --> $DIR/excessive_nesting.rs:164:22
    |
 LL |     let d = D { d: {{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}} };
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -242,7 +224,7 @@ LL |     let d = D { d: {{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}} };
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:167:7
+  --> $DIR/excessive_nesting.rs:166:7
    |
 LL |     {{{{1;}}}}..{{{{{{3}}}}}};
    |       ^^^^^^
@@ -250,7 +232,7 @@ LL |     {{{{1;}}}}..{{{{{{3}}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:167:19
+  --> $DIR/excessive_nesting.rs:166:19
    |
 LL |     {{{{1;}}}}..{{{{{{3}}}}}};
    |                   ^^^^^^^^^
@@ -258,7 +240,7 @@ LL |     {{{{1;}}}}..{{{{{{3}}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:168:7
+  --> $DIR/excessive_nesting.rs:167:7
    |
 LL |     {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}};
    |       ^^^^^^
@@ -266,7 +248,7 @@ LL |     {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:168:20
+  --> $DIR/excessive_nesting.rs:167:20
    |
 LL |     {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}};
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -274,7 +256,7 @@ LL |     {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:169:9
+  --> $DIR/excessive_nesting.rs:168:9
    |
 LL |     ..{{{{{{{5}}}}}}};
    |         ^^^^^^^^^^^
@@ -282,7 +264,7 @@ LL |     ..{{{{{{{5}}}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:170:10
+  --> $DIR/excessive_nesting.rs:169:10
    |
 LL |     ..={{{{{3}}}}};
    |          ^^^^^^^
@@ -290,7 +272,7 @@ LL |     ..={{{{{3}}}}};
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:171:7
+  --> $DIR/excessive_nesting.rs:170:7
    |
 LL |     {{{{{1;}}}}}..;
    |       ^^^^^^^^
@@ -298,7 +280,7 @@ LL |     {{{{{1;}}}}}..;
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:173:19
+  --> $DIR/excessive_nesting.rs:172:19
    |
 LL |     loop { break {{{{1}}}} };
    |                   ^^^^^^^
@@ -306,7 +288,7 @@ LL |     loop { break {{{{1}}}} };
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:174:12
+  --> $DIR/excessive_nesting.rs:173:12
    |
 LL |     loop {{{{{{}}}}}}
    |            ^^^^^^^^
@@ -314,7 +296,7 @@ LL |     loop {{{{{{}}}}}}
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:176:13
+  --> $DIR/excessive_nesting.rs:175:13
    |
 LL |     match {{{{{{true}}}}}} {
    |             ^^^^^^^^^^^^
@@ -322,7 +304,7 @@ LL |     match {{{{{{true}}}}}} {
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:177:19
+  --> $DIR/excessive_nesting.rs:176:19
    |
 LL |         true => {{{{}}}},
    |                   ^^^^
@@ -330,7 +312,7 @@ LL |         true => {{{{}}}},
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:178:20
+  --> $DIR/excessive_nesting.rs:177:20
    |
 LL |         false => {{{{}}}},
    |                    ^^^^
@@ -338,7 +320,7 @@ LL |         false => {{{{}}}},
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:183:13
+  --> $DIR/excessive_nesting.rs:182:13
    |
 LL | /             {
 LL | |                 {
@@ -350,7 +332,7 @@ LL | |             }
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:193:27
+  --> $DIR/excessive_nesting.rs:192:27
    |
 LL |     async fn c() -> u32 {{{{{{{0}}}}}}}
    |                           ^^^^^^^^^^^
@@ -358,12 +340,12 @@ LL |     async fn c() -> u32 {{{{{{{0}}}}}}}
    = help: try refactoring your code to minimize nesting
 
 error: this block is too nested
-  --> $DIR/excessive_nesting.rs:199:7
+  --> $DIR/excessive_nesting.rs:198:7
    |
 LL |     {{{{b().await}}}};
    |       ^^^^^^^^^^^^^
    |
    = help: try refactoring your code to minimize nesting
 
-error: aborting due to 41 previous errors
+error: aborting due to 39 previous errors
 
diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr
index 28b6e7aa824..5ec6f3decc3 100644
--- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr
+++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr
@@ -86,6 +86,7 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect
            enforced-import-renames
            enum-variant-name-threshold
            enum-variant-size-threshold
+           excessive-nesting-threshold
            future-size-threshold
            ignore-interior-mutability
            large-error-threshold