fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #67350 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum73528e339aa

1.40.0
2.0 KiB81 linesraw
1// Under the 2015 edition with the keyword_idents lint, `dyn` is not
2// entirely acceptable as an identifier. We currently do not attempt
3// to detect or fix uses of `dyn` under a macro. Since we are testing
4// this file via `rustfix`, we want the rustfix output to be
5// compilable; so the macros here carefully use `dyn` "correctly."
6
7// run-rustfix
8
9#![allow(non_camel_case_types)]
10#![deny(keyword_idents)]
11
12mod outer_mod {
13    pub mod r#dyn {
14//~^ ERROR `dyn` is a keyword
15//~| WARN was previously accepted
16        pub struct r#dyn;
17//~^ ERROR `dyn` is a keyword
18//~| WARN was previously accepted
19    }
20}
21use outer_mod::r#dyn::r#dyn;
22//~^ ERROR `dyn` is a keyword
23//~| WARN was previously accepted
24//~| ERROR `dyn` is a keyword
25//~| WARN was previously accepted
26
27fn main() {
28    match r#dyn { r#dyn => {} }
29//~^ ERROR `dyn` is a keyword
30//~| WARN was previously accepted
31//~| ERROR `dyn` is a keyword
32//~| WARN was previously accepted
33    macro_defn::r#dyn();
34//~^ ERROR `dyn` is a keyword
35//~| WARN was previously accepted
36
37    macro_defn::boxed();
38}
39
40mod macro_defn {
41    use super::Trait;
42
43    macro_rules! r#dyn {
44//~^ ERROR `dyn` is a keyword
45//~| WARN was previously accepted
46
47        // Note that we do not lint nor fix occurrences under macros
48        ($dyn:tt) => { (Box<dyn Trait>, Box<$dyn Trait>) }
49    }
50
51    pub fn r#dyn() -> ::outer_mod::r#dyn::r#dyn {
52//~^ ERROR `dyn` is a keyword
53//~| WARN was previously accepted
54//~| ERROR `dyn` is a keyword
55//~| WARN was previously accepted
56//~| ERROR `dyn` is a keyword
57//~| WARN was previously accepted
58        ::outer_mod::r#dyn::r#dyn
59//~^ ERROR `dyn` is a keyword
60//~| WARN was previously accepted
61//~| ERROR `dyn` is a keyword
62//~| WARN was previously accepted
63    }
64
65
66
67    pub fn boxed() -> r#dyn!(
68        //~^ ERROR `dyn` is a keyword
69        //~| WARN was previously accepted
70
71            // Note that we do not lint nor fix occurrences under macros
72            dyn
73    )
74    {
75        (Box::new(1), Box::new(2))
76    }
77}
78
79pub trait Trait { }
80
81impl Trait for u32 { }