about summary refs log tree commit diff
path: root/tests/ui/loop-match/invalid-attribute.rs
blob: a5d7daac58357dcbf75a681ee7094d913e08d2ad (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
// Test that the `#[loop_match]` and `#[const_continue]` attributes can only be
// placed on expressions.

#![allow(incomplete_features)]
#![feature(loop_match)]
#![loop_match] //~ ERROR attribute cannot be used on
#![const_continue] //~ ERROR attribute cannot be used on

extern "C" {
    #[loop_match] //~ ERROR attribute cannot be used on
    #[const_continue] //~ ERROR attribute cannot be used on
    fn f();
}

#[loop_match] //~ ERROR attribute cannot be used on
#[const_continue] //~ ERROR attribute cannot be used on
#[repr(C)]
struct S {
    a: u32,
    b: u32,
}

trait Invoke {
    #[loop_match] //~ ERROR attribute cannot be used on
    #[const_continue] //~ ERROR attribute cannot be used on
    extern "C" fn invoke(&self);
}

#[loop_match] //~ ERROR attribute cannot be used on
#[const_continue] //~ ERROR attribute cannot be used on
extern "C" fn ok() {}

fn main() {
    #[loop_match] //~ ERROR attribute cannot be used on
    #[const_continue] //~ ERROR attribute cannot be used on
    || {};

    {
        #[loop_match] //~ ERROR should be applied to a loop
        #[const_continue] //~ ERROR should be applied to a break expression
        5
    };
}