rust/tests/ui/attributes/check-cfg_attr-ice.rs
Esteban Küber c73b3d20c6 Unify wording of resolve error
Remove "failed to resolve" and use the same format we use in other resolution errors "cannot find `name`".

```
error[E0433]: cannot find `nonexistent` in `existent`
  --> $DIR/custom_attr_multisegment_error.rs:5:13
   |
LL | #[existent::nonexistent]
   |             ^^^^^^^^^^^ could not find `nonexistent` in `existent`
```
2026-02-17 16:51:44 +00:00

68 lines
1.9 KiB
Rust

//! I missed a `cfg_attr` match in #128581, it should have had the same treatment as `cfg`. If
//! an invalid attribute starting with `cfg_attr` is passed, then it would trigger an ICE because
//! it was not considered "checked" (e.g. `#[cfg_attr::skip]` or `#[cfg_attr::no_such_thing]`).
//!
//! This test is not exhaustive, there's too many possible positions to check, instead it just does
//! a basic smoke test in a few select positions to make sure we don't ICE for e.g.
//! `#[cfg_attr::no_such_thing]`.
//!
//! issue: rust-lang/rust#128716
#![crate_type = "lib"]
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
mod we_are_no_strangers_to_love {}
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
struct YouKnowTheRules {
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
and_so_do_i: u8,
}
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
fn a_full_commitment() {
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
let is_what_i_am_thinking_of = ();
}
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
union AnyOtherGuy {
owo: ()
}
struct This;
#[cfg_attr(FALSE, doc = "you wouldn't get this")]
impl From<AnyOtherGuy> for This {
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
fn from(#[cfg_attr::no_such_thing] any_other_guy: AnyOtherGuy) -> This {
//~^ ERROR cannot find
#[cfg_attr::no_such_thing]
//~^ ERROR attributes on expressions are experimental
//~| ERROR cannot find
unreachable!()
}
}
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
enum NeverGonna {
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
GiveYouUp(#[cfg_attr::no_such_thing] u8),
//~^ ERROR cannot find
LetYouDown {
#![cfg_attr::no_such_thing]
//~^ ERROR an inner attribute is not permitted in this context
never_gonna: (),
round_around: (),
#[cfg_attr::no_such_thing]
//~^ ERROR cannot find
and_desert_you: (),
},
}