mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-03 01:25:15 +00:00
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