about summary refs log tree commit diff
path: root/compiler/rustc_lint
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2025-06-22 08:49:05 +0200
committerGitHub <noreply@github.com>2025-06-22 08:49:05 +0200
commitbf63acfd3553fbd21e85e3eac3dd795d35fd0804 (patch)
treec752c7744aa84547803687c0deb9489bc641846e /compiler/rustc_lint
parentb5b106ab91ef614c0e6629df8e5f42a283746346 (diff)
parent6729b667ce4b013a5ec6f50b096bde3edabc28e3 (diff)
downloadrust-bf63acfd3553fbd21e85e3eac3dd795d35fd0804.tar.gz
rust-bf63acfd3553fbd21e85e3eac3dd795d35fd0804.zip
Rollup merge of #142776 - dtolnay:hirattrstyle2, r=jdonszelmann
All HIR attributes are outer

Fixes https://github.com/rust-lang/rust/issues/142649. Closes https://github.com/rust-lang/rust/pull/142759.

All HIR attributes, including parsed and not yet parsed, will now be rendered as outer attributes by `rustc_hir_pretty`. The original style of the corresponding AST attribute(s) is not relevant for pretty printing, only for diagnostics.

r? ````@jdonszelmann````
Diffstat (limited to 'compiler/rustc_lint')
-rw-r--r--compiler/rustc_lint/src/context.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs
index b6bf45dfbcf..414f2a1846b 100644
--- a/compiler/rustc_lint/src/context.rs
+++ b/compiler/rustc_lint/src/context.rs
@@ -855,14 +855,15 @@ impl<'tcx> LateContext<'tcx> {
     /// rendering diagnostic. This is not the same as the precedence that would
     /// be used for pretty-printing HIR by rustc_hir_pretty.
     pub fn precedence(&self, expr: &hir::Expr<'_>) -> ExprPrecedence {
-        let for_each_attr = |id: hir::HirId, callback: &mut dyn FnMut(&hir::Attribute)| {
+        let has_attr = |id: hir::HirId| -> bool {
             for attr in self.tcx.hir_attrs(id) {
                 if attr.span().desugaring_kind().is_none() {
-                    callback(attr);
+                    return true;
                 }
             }
+            false
         };
-        expr.precedence(&for_each_attr)
+        expr.precedence(&has_attr)
     }
 
     /// If the given expression is a local binding, find the initializer expression.