diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-05-21 11:28:47 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-21 11:28:47 +0200 |
| commit | 5b150e312202cdceb6e0f6cb7ef58b3ac9780aea (patch) | |
| tree | 2b836335dfd46af2703cc0758f24c342ae22b1ad /compiler | |
| parent | aaa684fd1d8678132e0a409b674b5cc0d43b895f (diff) | |
| parent | 1cc0e38fdc4d2ec8c9c130d7ffc9c30d100885a2 (diff) | |
| download | rust-5b150e312202cdceb6e0f6cb7ef58b3ac9780aea.tar.gz rust-5b150e312202cdceb6e0f6cb7ef58b3ac9780aea.zip | |
Rollup merge of #141318 - nnethercote:fix-140884, r=compiler-errors
Avoid creating an empty identifer in `Symbol::to_ident_string`. Because that causes an assertion failure in debug builds. Fixes #140884. r? `@oli-obk`
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_span/src/symbol.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index efae6250b07..fbe3b4ca6f5 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -2592,7 +2592,8 @@ impl Symbol { /// (`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() + // Avoid creating an empty identifier, because that asserts in debug builds. + if self == kw::Empty { String::new() } else { Ident::with_dummy_span(self).to_string() } } } |
