Use the same span for attributes and Try expansion of ?

This is needed for Clippy to know that the `#[allow(unused)]` attributes
added by the expansion of `?` are part of the desugaring, and that they
do not come from the user code.

rust-lang/rust-clippy#13380 exhibits a manifestation of this problem.
This commit is contained in:
Samuel Tardieu 2024-09-11 20:43:50 +02:00
parent f7f8bdf2e0
commit 6ee87ae594

View File

@ -1837,7 +1837,7 @@ fn lower_expr_try(&mut self, span: Span, sub_expr: &Expr) -> hir::ExprKind<'hir>
Safety::Default,
sym::allow,
sym::unreachable_code,
self.lower_span(span),
try_span,
);
let attrs: AttrVec = thin_vec![attr];