fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![deny(clippy::internal)] 2#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)] 3#![feature(rustc_private)] 4 5extern crate rustc_span; 6 7use rustc_span::symbol::Symbol; 8 9macro_rules! sym { 10 ($tt:tt) => { 11 rustc_span::symbol::Symbol::intern(stringify!($tt)) 12 }; 13} 14 15fn main() { 16 // Direct use of Symbol::intern 17 let _ = rustc_span::sym::f32; 18 19 // Using a sym macro 20 let _ = rustc_span::sym::f32; 21 22 // Correct suggestion when symbol isn't stringified constant name 23 let _ = rustc_span::sym::proc_dash_macro; 24 25 // interning a keyword 26 let _ = rustc_span::symbol::kw::SelfLower; 27 28 // Interning a symbol that is not defined 29 let _ = Symbol::intern("xyz123"); 30 let _ = sym!(xyz123); 31 32 // Using a different `intern` function 33 let _ = intern("f32"); 34} 35 36fn intern(_: &str) {}