File: check-cfg_attr-ice.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (68 lines) | stat: -rw-r--r-- 2,053 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! 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 failed to resolve
mod we_are_no_strangers_to_love {}

#[cfg_attr::no_such_thing]
//~^ ERROR failed to resolve
struct YouKnowTheRules {
    #[cfg_attr::no_such_thing]
    //~^ ERROR failed to resolve
    and_so_do_i: u8,
}

#[cfg_attr::no_such_thing]
//~^ ERROR failed to resolve
fn a_full_commitment() {
    #[cfg_attr::no_such_thing]
    //~^ ERROR failed to resolve
    let is_what_i_am_thinking_of = ();
}

#[cfg_attr::no_such_thing]
//~^ ERROR failed to resolve
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 failed to resolve
    fn from(#[cfg_attr::no_such_thing] any_other_guy: AnyOtherGuy) -> This {
        //~^ ERROR failed to resolve
        #[cfg_attr::no_such_thing]
        //~^ ERROR attributes on expressions are experimental
        //~| ERROR failed to resolve
        unreachable!()
    }
}

#[cfg_attr::no_such_thing]
//~^ ERROR failed to resolve
enum NeverGonna {
    #[cfg_attr::no_such_thing]
    //~^ ERROR failed to resolve
    GiveYouUp(#[cfg_attr::no_such_thing] u8),
    //~^ ERROR failed to resolve
    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 failed to resolve
        and_desert_you: (),
    },
}