Files
rust/tests/ui/impl-trait/precise-capturing
albab-hasan 057e810a4e do not suggest precise capturing when the opaque span is inside a macro expansion
impl_trait_overcapture_suggestion anchored every suggestion on tcx.def_span(opaque_def_id) with no expansion check. for an opaque created inside an attribute macro expansion that span is the attribute, which is not a type position, so applying the machine-applicable suggestion breaks the file

the obvious patch of calling can_be_used_for_suggestions() on that span directly suppresses all suggestions including for ordinary code, because ast lowering stamps DesugaringKind::OpaqueTy onto the opaque span at compiler/rustc_ast_lowering/src/lib.rs:1825, making from_expansion() unconditionally true. the fix calls parent_callsite() to peel that single desugaring layer and asks can_be_used_for_suggestions() about the span underneath

the guard sits at function entry rather than beside the rpit_span push because the apit rename and the generics-list insertion are anchored on the same span, so one check covers all three

fixes https://github.com/rust-lang/rust/issues/139567
2026-10-01 12:19:05 +06:00
..
…
…