Skip to content

Commit 6ce5ab6

Browse files
committed
rustc_span: Add Symbol::to_ident_string for use in diagnostic messages
1 parent 892cb14 commit 6ce5ab6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/librustc_span/symbol.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,14 @@ impl Symbol {
10231023
pub fn as_u32(self) -> u32 {
10241024
self.0.as_u32()
10251025
}
1026+
1027+
/// This method is supposed to be used in error messages, so it's expected to be
1028+
/// identical to printing the original identifier token written in source code
1029+
/// (`token_to_string`, `Ident::to_string`), except that symbols don't keep the rawness flag
1030+
/// or edition, so we have to guess the rawness using the global edition.
1031+
pub fn to_ident_string(self) -> String {
1032+
Ident::with_dummy_span(self).to_string()
1033+
}
10261034
}
10271035

10281036
impl fmt::Debug for Symbol {

0 commit comments

Comments
 (0)