1
Fork 0

When finding item gated behind a cfg flat, point at it

Previously we would only mention that the item was gated out, and opportunisitically mention the feature flag name when possible. We now point to the place where the item was gated, which can be behind layers of macro indirection, or in different modules.

```
error[E0433]: failed to resolve: could not find `doesnt_exist` in `inner`
  --> $DIR/diagnostics-cross-crate.rs:18:23
   |
LL |     cfged_out::inner::doesnt_exist::hello();
   |                       ^^^^^^^^^^^^ could not find `doesnt_exist` in `inner`
   |
note: found an item that was configured out
  --> $DIR/auxiliary/cfged_out.rs:6:13
   |
LL |     pub mod doesnt_exist {
   |             ^^^^^^^^^^^^
note: the item is gated here
  --> $DIR/auxiliary/cfged_out.rs:5:5
   |
LL |     #[cfg(FALSE)]
   |     ^^^^^^^^^^^^^
```
This commit is contained in:
Esteban Küber 2024-07-12 18:52:52 +00:00
parent 5d76a13bbe
commit cf09cba20c
11 changed files with 122 additions and 25 deletions

View file

@ -1228,6 +1228,15 @@ pub(crate) struct FoundItemConfigureOut {
#[note(resolve_item_was_behind_feature)]
pub(crate) struct ItemWasBehindFeature {
pub(crate) feature: Symbol,
#[primary_span]
pub(crate) span: Span,
}
#[derive(Subdiagnostic)]
#[note(resolve_item_was_cfg_out)]
pub(crate) struct ItemWasCfgOut {
#[primary_span]
pub(crate) span: Span,
}
#[derive(Diagnostic)]