fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
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 13mod 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} 22use 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 28fn 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 41mod 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 80pub trait Trait { } 81 82impl Trait for u32 { }