]> git.lizzy.rs Git - rust.git/blob - tests/ui/dyn-keyword/dyn-2015-edition-keyword-ident-lint.fixed
Rollup merge of #106707 - ehuss:remove-dupe-sha-1, r=Mark-Simulacrum
[rust.git] / tests / ui / dyn-keyword / dyn-2015-edition-keyword-ident-lint.fixed
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 // edition:2015
8 // run-rustfix
9
10 #![allow(non_camel_case_types)]
11 #![deny(keyword_idents)]
12
13 mod outer_mod {
14     pub mod r#dyn {
15 //~^ ERROR `dyn` is a keyword
16 //~| WARN this is accepted in the current edition
17         pub struct r#dyn;
18 //~^ ERROR `dyn` is a keyword
19 //~| WARN this is accepted in the current edition
20     }
21 }
22 use outer_mod::r#dyn::r#dyn;
23 //~^ ERROR `dyn` is a keyword
24 //~| WARN this is accepted in the current edition
25 //~| ERROR `dyn` is a keyword
26 //~| WARN this is accepted in the current edition
27
28 fn main() {
29     match r#dyn { r#dyn => {} }
30 //~^ ERROR `dyn` is a keyword
31 //~| WARN this is accepted in the current edition
32 //~| ERROR `dyn` is a keyword
33 //~| WARN this is accepted in the current edition
34     macro_defn::r#dyn();
35 //~^ ERROR `dyn` is a keyword
36 //~| WARN this is accepted in the current edition
37
38     macro_defn::boxed();
39 }
40
41 mod macro_defn {
42     use super::Trait;
43
44     macro_rules! r#dyn {
45 //~^ ERROR `dyn` is a keyword
46 //~| WARN this is accepted in the current edition
47
48         // Note that we do not lint nor fix occurrences under macros
49         ($dyn:tt) => { (Box<dyn Trait>, Box<$dyn Trait>) }
50     }
51
52     pub fn r#dyn() -> ::outer_mod::r#dyn::r#dyn {
53 //~^ ERROR `dyn` is a keyword
54 //~| WARN this is accepted in the current edition
55 //~| ERROR `dyn` is a keyword
56 //~| WARN this is accepted in the current edition
57 //~| ERROR `dyn` is a keyword
58 //~| WARN this is accepted in the current edition
59         ::outer_mod::r#dyn::r#dyn
60 //~^ ERROR `dyn` is a keyword
61 //~| WARN this is accepted in the current edition
62 //~| ERROR `dyn` is a keyword
63 //~| WARN this is accepted in the current edition
64     }
65
66
67
68     pub fn boxed() -> r#dyn!(
69         //~^ ERROR `dyn` is a keyword
70         //~| WARN this is accepted in the current edition
71
72             // Note that we do not lint nor fix occurrences under macros
73             dyn
74     )
75     {
76         (Box::new(1), Box::new(2))
77     }
78 }
79
80 pub trait Trait { }
81
82 impl Trait for u32 { }