2023-04-20 14:37:15 +00:00
|
|
|
//@run-rustfix
|
2020-12-13 04:32:41 +00:00
|
|
|
#![deny(clippy::internal)]
|
2022-03-17 23:53:28 +00:00
|
|
|
#![allow(clippy::missing_clippy_version_attribute, clippy::let_unit_value)]
|
2020-12-13 04:32:41 +00:00
|
|
|
#![feature(rustc_private)]
|
|
|
|
|
|
|
|
extern crate rustc_span;
|
|
|
|
|
|
|
|
use rustc_span::symbol::Symbol;
|
|
|
|
|
|
|
|
macro_rules! sym {
|
|
|
|
($tt:tt) => {
|
|
|
|
rustc_span::symbol::Symbol::intern(stringify!($tt))
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
// Direct use of Symbol::intern
|
|
|
|
let _ = Symbol::intern("f32");
|
|
|
|
|
|
|
|
// Using a sym macro
|
|
|
|
let _ = sym!(f32);
|
|
|
|
|
|
|
|
// Correct suggestion when symbol isn't stringified constant name
|
|
|
|
let _ = Symbol::intern("proc-macro");
|
|
|
|
|
2020-12-29 21:40:55 +00:00
|
|
|
// interning a keyword
|
|
|
|
let _ = Symbol::intern("self");
|
|
|
|
|
2020-12-13 04:32:41 +00:00
|
|
|
// Interning a symbol that is not defined
|
|
|
|
let _ = Symbol::intern("xyz123");
|
|
|
|
let _ = sym!(xyz123);
|
|
|
|
|
|
|
|
// Using a different `intern` function
|
|
|
|
let _ = intern("f32");
|
|
|
|
}
|
|
|
|
|
|
|
|
fn intern(_: &str) {}
|