Avoid creating an empty identifer in Symbol::to_ident_string.
Because that causes an assertion failure in debug builds.
Fixes #140884.
(cherry picked from commit 1cc0e38fdc)
This commit is contained in:
parent
281a202470
commit
e5fe68da52
3 changed files with 20 additions and 1 deletions
|
|
@ -2583,7 +2583,8 @@ impl Symbol {
|
||||||
/// (`token_to_string`, `Ident::to_string`), except that symbols don't keep the rawness flag
|
/// (`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.
|
/// or edition, so we have to guess the rawness using the global edition.
|
||||||
pub fn to_ident_string(self) -> String {
|
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() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
3
tests/ui/extern/extern-empty-string-issue-140884.rs
vendored
Normal file
3
tests/ui/extern/extern-empty-string-issue-140884.rs
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
extern "" {} //~ ERROR invalid ABI: found ``
|
||||||
|
|
||||||
|
fn main() {}
|
||||||
15
tests/ui/extern/extern-empty-string-issue-140884.stderr
vendored
Normal file
15
tests/ui/extern/extern-empty-string-issue-140884.stderr
vendored
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
error[E0703]: invalid ABI: found ``
|
||||||
|
--> $DIR/extern-empty-string-issue-140884.rs:1:8
|
||||||
|
|
|
||||||
|
LL | extern "" {}
|
||||||
|
| ^^ invalid ABI
|
||||||
|
|
|
||||||
|
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
|
||||||
|
help: there's a similarly named valid ABI `C`
|
||||||
|
|
|
||||||
|
LL | extern "C" {}
|
||||||
|
| +
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0703`.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue