don't panic on extern with just multiple quotes in the name
This commit is contained in:
parent
8111a2d6da
commit
cb06d91cd0
4 changed files with 41 additions and 19 deletions
|
|
@ -2511,9 +2511,11 @@ impl Ident {
|
|||
}
|
||||
|
||||
/// Creates a new ident with the same span and name with leading quote removed, if any.
|
||||
/// If called on an empty ident, or with name just a single quote, returns an empty ident which is invalid.
|
||||
/// Calling it on a `'` ident will return an empty ident, which triggers debug assertions.
|
||||
pub fn without_first_quote(self) -> Ident {
|
||||
Ident::new(Symbol::intern(self.as_str().trim_start_matches('\'')), self.span)
|
||||
self.as_str()
|
||||
.strip_prefix('\'')
|
||||
.map_or(self, |name| Ident::new(Symbol::intern(name), self.span))
|
||||
}
|
||||
|
||||
/// "Normalize" ident for use in comparisons using "item hygiene".
|
||||
|
|
|
|||
|
|
@ -2,8 +2,12 @@
|
|||
|
||||
// https://github.com/rust-lang/rust/issues/147365
|
||||
// Ensures we don't trigger debug assert by creating an empty Ident when determining whether
|
||||
// the single quote is a raw lifetime.
|
||||
// the quotes are a raw lifetime.
|
||||
|
||||
extern "'" {} //~ ERROR invalid ABI: found `'`
|
||||
|
||||
extern "''" {} //~ ERROR invalid ABI: found `''`
|
||||
|
||||
extern "'''" {} //~ ERROR invalid ABI: found `'''`
|
||||
|
||||
fn main() {}
|
||||
32
tests/ui/extern/extern-only-quotes-issue-147365.stderr
vendored
Normal file
32
tests/ui/extern/extern-only-quotes-issue-147365.stderr
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
error[E0703]: invalid ABI: found `'`
|
||||
--> $DIR/extern-only-quotes-issue-147365.rs:7: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 "'" {}
|
||||
LL + extern "C" {}
|
||||
|
|
||||
|
||||
error[E0703]: invalid ABI: found `''`
|
||||
--> $DIR/extern-only-quotes-issue-147365.rs:9:8
|
||||
|
|
||||
LL | extern "''" {}
|
||||
| ^^^^ invalid ABI
|
||||
|
|
||||
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
|
||||
|
||||
error[E0703]: invalid ABI: found `'''`
|
||||
--> $DIR/extern-only-quotes-issue-147365.rs:11:8
|
||||
|
|
||||
LL | extern "'''" {}
|
||||
| ^^^^^ invalid ABI
|
||||
|
|
||||
= note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0703`.
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
error[E0703]: invalid ABI: found `'`
|
||||
--> $DIR/extern-single-quote-issue-147365.rs:7: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 "'" {}
|
||||
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