2019-03-27 11:13:51 -05:00
|
|
|
// Under the 2015 edition with the keyword_idents lint, `dyn` is not
|
|
|
|
// entirely acceptable as an identifier. We currently do not attempt
|
|
|
|
// to detect or fix uses of `dyn` under a macro. Since we are testing
|
|
|
|
// this file via `rustfix`, we want the rustfix output to be
|
|
|
|
// compilable; so the macros here carefully use `dyn` "correctly."
|
2021-06-22 00:03:50 -05:00
|
|
|
//
|
|
|
|
// edition:2015
|
2019-03-27 11:13:51 -05:00
|
|
|
// run-rustfix
|
|
|
|
|
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
#![deny(keyword_idents)]
|
|
|
|
|
|
|
|
mod outer_mod {
|
|
|
|
pub mod dyn {
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
pub struct dyn;
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
use outer_mod::dyn::dyn;
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
//~| ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
match dyn { dyn => {} }
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
//~| ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
macro_defn::dyn();
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
|
|
|
|
macro_defn::boxed();
|
|
|
|
}
|
|
|
|
|
|
|
|
mod macro_defn {
|
|
|
|
use super::Trait;
|
|
|
|
|
|
|
|
macro_rules! dyn {
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
|
|
|
|
// Note that we do not lint nor fix occurrences under macros
|
2019-03-28 06:49:50 -05:00
|
|
|
($dyn:tt) => { (Box<dyn Trait>, Box<$dyn Trait>) }
|
2019-03-27 11:13:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn dyn() -> ::outer_mod::dyn::dyn {
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
//~| ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
//~| ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
::outer_mod::dyn::dyn
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
//~| ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn boxed() -> dyn!(
|
|
|
|
//~^ ERROR `dyn` is a keyword
|
2021-06-16 07:27:44 -05:00
|
|
|
//~| WARN this is accepted in the current edition
|
2019-03-27 11:13:51 -05:00
|
|
|
|
|
|
|
// Note that we do not lint nor fix occurrences under macros
|
|
|
|
dyn
|
|
|
|
)
|
|
|
|
{
|
2019-03-28 06:49:50 -05:00
|
|
|
(Box::new(1), Box::new(2))
|
2019-03-27 11:13:51 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Trait { }
|
|
|
|
|
|
|
|
impl Trait for u32 { }
|