]> git.lizzy.rs Git - rust.git/blob - tests/ui/attributes/collapse-debuginfo-invalid.rs
Rollup merge of #106797 - FawazTirmizi:dev/issues/104284, r=bjorn3
[rust.git] / tests / ui / attributes / collapse-debuginfo-invalid.rs
1 #![feature(collapse_debuginfo)]
2 #![feature(stmt_expr_attributes)]
3 #![feature(type_alias_impl_trait)]
4 #![no_std]
5
6 // Test that the `#[collapse_debuginfo]` attribute can only be used on macro definitions.
7
8 #[collapse_debuginfo]
9 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
10 extern crate std;
11
12 #[collapse_debuginfo]
13 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
14 use std::collections::HashMap;
15
16 #[collapse_debuginfo]
17 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
18 static FOO: u32 = 3;
19
20 #[collapse_debuginfo]
21 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
22 const BAR: u32 = 3;
23
24 #[collapse_debuginfo]
25 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
26 fn foo() {
27     let _ = #[collapse_debuginfo] || { };
28 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
29     #[collapse_debuginfo]
30 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
31     let _ = 3;
32     let _ = #[collapse_debuginfo] 3;
33 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
34     match (3, 4) {
35         #[collapse_debuginfo]
36 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
37         _ => (),
38     }
39 }
40
41 #[collapse_debuginfo]
42 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
43 mod bar {
44 }
45
46 #[collapse_debuginfo]
47 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
48 type Map = HashMap<u32, u32>;
49
50 #[collapse_debuginfo]
51 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
52 enum Foo {
53     #[collapse_debuginfo]
54 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
55     Variant,
56 }
57
58 #[collapse_debuginfo]
59 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
60 struct Bar {
61     #[collapse_debuginfo]
62 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
63     field: u32,
64 }
65
66 #[collapse_debuginfo]
67 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
68 union Qux {
69     a: u32,
70     b: u16
71 }
72
73 #[collapse_debuginfo]
74 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
75 trait Foobar {
76     #[collapse_debuginfo]
77 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
78     type Bar;
79 }
80
81 #[collapse_debuginfo]
82 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
83 type AFoobar = impl Foobar;
84
85 impl Foobar for Bar {
86     type Bar = u32;
87 }
88
89 fn constraining() -> AFoobar {
90     Bar { field: 3 }
91 }
92
93 #[collapse_debuginfo]
94 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
95 impl Bar {
96     #[collapse_debuginfo]
97 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
98     const FOO: u32 = 3;
99
100     #[collapse_debuginfo]
101 //~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
102     fn bar(&self) {}
103 }
104
105 #[collapse_debuginfo]
106 macro_rules! finally {
107     ($e:expr) => { $e }
108 }
109
110 fn main() {}