File: semicolon-in-expressions-from-macros.rs

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, 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 (51 lines) | stat: -rw-r--r-- 1,245 bytes parent folder | download | duplicates (6)
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
//@ check-pass
//@ edition:2018
#![feature(stmt_expr_attributes)]
#![warn(semicolon_in_expressions_from_macros)]

#[allow(dead_code)]
macro_rules! foo {
    ($val:ident) => {
        true; //~  WARN trailing semicolon in macro
              //~| WARN this was previously accepted
              //~| WARN trailing semicolon in macro
              //~| WARN this was previously accepted
              //~| WARN trailing semicolon in macro
              //~| WARN this was previously accepted
    }
}

#[allow(semicolon_in_expressions_from_macros)]
async fn bar() {
    foo!(first);
}

fn main() {
    #[allow(semicolon_in_expressions_from_macros)]
    let _ = {
        foo!(first)
    };

    #[allow(semicolon_in_expressions_from_macros)]
    let _ = foo!(second);

    #[allow(semicolon_in_expressions_from_macros)]
    fn inner() {
        let _ = foo!(third);
    }

    #[allow(semicolon_in_expressions_from_macros)]
    async {
        let _ = foo!(fourth);
    };

    let _ = {
        foo!(warn_in_block)
    };

    let _ = foo!(warn_in_expr);

    // This `#[allow]` does not work, since the attribute gets dropped
    // when we expand the macro
    let _ = #[allow(semicolon_in_expressions_from_macros)] foo!(allow_does_not_work);
}