rust/tests/ui/cfg/diagnostics-reexport.rs
Esteban Küber cf09cba20c 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)]
   |     ^^^^^^^^^^^^^
```
2024-07-12 18:52:52 +00:00

41 lines
930 B
Rust

pub mod inner {
#[cfg(FALSE)]
mod gone {
pub fn uwu() {}
}
#[cfg(FALSE)] //~ NOTE the item is gated here
pub use super::uwu;
//~^ NOTE found an item that was configured out
}
pub use a::x;
//~^ ERROR unresolved import `a::x`
//~| NOTE no `x` in `a`
mod a {
#[cfg(FALSE)] //~ NOTE the item is gated here
pub fn x() {}
//~^ NOTE found an item that was configured out
}
pub use b::{x, y};
//~^ ERROR unresolved imports `b::x`, `b::y`
//~| NOTE no `x` in `b`
//~| NOTE no `y` in `b`
mod b {
#[cfg(FALSE)] //~ NOTE the item is gated here
pub fn x() {}
//~^ NOTE found an item that was configured out
#[cfg(FALSE)] //~ NOTE the item is gated here
pub fn y() {}
//~^ NOTE found an item that was configured out
}
fn main() {
// There is no uwu at this path - no diagnostic.
inner::uwu(); //~ ERROR cannot find function
//~^ NOTE not found in `inner`
}