rustc_span: Add Symbol::to_ident_string for use in diagnostic messages

This commit is contained in:
Vadim Petrochenkov 2020-02-26 21:24:22 +03:00
parent 892cb143e5
commit 6ce5ab6a7e

View File

@ -1023,6 +1023,14 @@ impl Symbol {
pub fn as_u32(self) -> u32 {
self.0.as_u32()
}
/// This method is supposed to be used in error messages, so it's expected to be
/// identical to printing the original identifier token written in source code
/// (`token_to_string`, `Ident::to_string`), except that symbols don't keep the rawness flag
/// or edition, so we have to guess the rawness using the global edition.
pub fn to_ident_string(self) -> String {
Ident::with_dummy_span(self).to_string()
}
}
impl fmt::Debug for Symbol {