1 // build-pass (FIXME(62277): could be check-pass?)
3 // Under the 2015 edition with the keyword_idents lint, `dyn` is
4 // not entirely acceptable as an identifier.
6 // We currently do not attempt to detect or fix uses of `dyn` as an
7 // identifier under a macro, including under the declarative `macro`
8 // forms from macros 1.2 and macros 2.0.
10 #![feature(decl_macro)]
11 #![allow(non_camel_case_types)]
12 #![deny(keyword_idents)]
20 // Here we are illustrating that the current lint does not flag the
21 // occurrences of `dyn` in this macro definition; however, it
22 // certainly *could* (and it would be nice if it did), since these
23 // occurrences are not compatible with the 2018 edition's
24 // interpretation of `dyn` as a keyword.
25 macro defn_has_dyn_idents() { ::outer_mod::dyn::dyn }
28 trait Trait { fn hello(&self) { }}
31 macro tt_trait($arg:tt) { & $arg Trait }
32 macro id_trait($id:ident) { & $id Trait }
35 defn_has_dyn_idents!();
37 // Here we are illustrating that the current lint does not flag
38 // the occurrences of `dyn` in these macro invocations. It
39 // definitely should *not* flag the one in `tt_trait`, since that
40 // is expanding in a valid fashion to `&dyn Trait`.
42 // It is arguable whether it would be valid to flag the occurrence
43 // in `id_trait`, since that macro specifies that it takes an
44 // `ident` as its input.
45 fn f_tt(x: &X) -> tt_trait!(dyn) { x }
46 fn f_id(x: &X) -> id_trait!(dyn) { x }