Provide structured suggestion for #![feature(foo)]

```
error: `S2<'_>` is forbidden as the type of a const generic parameter
  --> $DIR/lifetime-in-const-param.rs:5:23
   |
LL | struct S<'a, const N: S2>(&'a ());
   |                       ^^
   |
   = note: the only supported types are integers, `bool` and `char`
help: add `#![feature(adt_const_params)]` to the crate attributes to enable more complex and user defined types
   |
LL + #![feature(adt_const_params)]
   |
```

Fix #55941.
This commit is contained in:
Esteban Küber 2024-03-07 22:09:00 +00:00
parent 22e241e32e
commit 6c31f6ce12
98 changed files with 755 additions and 253 deletions

View file

@ -291,12 +291,16 @@ fn default_body_is_unstable(
reason: reason_str,
});
let inject_span = item_did
.as_local()
.and_then(|id| tcx.crate_level_attribute_injection_span(tcx.local_def_id_to_hir_id(id)));
rustc_session::parse::add_feature_diagnostics_for_issue(
&mut err,
&tcx.sess,
feature,
rustc_feature::GateIssue::Library(issue),
false,
inject_span,
);
err.emit();