Files
rust/tests/ui/parser
Jonathan Brouwer 75b25343be Rollup merge of #160478 - Dnreikronos:diagnostics/closure_lifetime_binder_sugg, r=mejrs
diagnostics: Suggest fn binding type for unstable closure for<> binders

Fixes rust-lang/rust#160431

`for<'a> |x: &'a T| -> U { ... }` currently just says "consider removing for<...>", which idk is kinda useless when someone landed there while fighting HRTB errors. This rewrites the obvious case to `let cl: for<'a> fn(...) = |x| { ... }` instead.

Visitor emits the gate so we have AST context for the rewrite, and we still keep a pre-expansion fallback for `#[cfg(false)]` etc. MachineApplicable only when we're pretty sure: by-value bindings, lifetime-only unbounded binders, no `_` in the sig, no macro expansion. Capture checking is a conservative single-segment free-path heuristic since this runs pre-resolution/pre-typeck; when that looks uncertain we fall back to MaybeIncorrect (or just "consider removing"). imo that's the right tradeoff here: better a maybe-wrong help than rustfix auto-applying into E0308. fyi free-fn / `None` / `Some` cases also hit MaybeIncorrect for the same reason.

ltm if the heuristic feels too conservative and y'all want it tightened later.
2026-08-16 22:46:22 +02:00
..
…
…
2026-08-10 10:05:45 +02:00
2026-08-10 10:05:45 +02:00