summaryrefslogtreecommitdiffstats
path: root/src/test/ui/attributes/collapse-debuginfo-invalid.rs
blob: 42d8982c118612535a4c0c3e1f24a1af1e4c76fb (plain)
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#![feature(collapse_debuginfo)]
#![feature(stmt_expr_attributes)]
#![feature(type_alias_impl_trait)]
#![no_std]

// Test that the `#[collapse_debuginfo]` attribute can only be used on macro definitions.

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
extern crate std;

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
use std::collections::HashMap;

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
static FOO: u32 = 3;

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
const BAR: u32 = 3;

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
fn foo() {
    let _ = #[collapse_debuginfo] || { };
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
    #[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
    let _ = 3;
    let _ = #[collapse_debuginfo] 3;
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
    match (3, 4) {
        #[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
        _ => (),
    }
}

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
mod bar {
}

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
type Map = HashMap<u32, u32>;

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
enum Foo {
    #[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
    Variant,
}

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
struct Bar {
    #[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
    field: u32,
}

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
union Qux {
    a: u32,
    b: u16
}

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
trait Foobar {
    #[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
    type Bar;
}

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
type AFoobar = impl Foobar;

impl Foobar for Bar {
    type Bar = u32;
}

fn constraining() -> AFoobar {
    Bar { field: 3 }
}

#[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
impl Bar {
    #[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
    const FOO: u32 = 3;

    #[collapse_debuginfo]
//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions
    fn bar(&self) {}
}

#[collapse_debuginfo]
macro_rules! finally {
    ($e:expr) => { $e }
}

fn main() {}