mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
Handle interpolated literal errors
This commit is contained in:
parent
6330daade9
commit
9ef580fa6f
@ -2023,17 +2023,14 @@ impl<'a> Parser<'a> {
|
||||
let recovered = self.recover_after_dot();
|
||||
let token = recovered.as_ref().unwrap_or(&self.token);
|
||||
match token::Lit::from_token(token) {
|
||||
Some(token_lit) => {
|
||||
match MetaItemLit::from_token_lit(token_lit, token.span) {
|
||||
Some(lit) => {
|
||||
match MetaItemLit::from_token_lit(lit, token.span) {
|
||||
Ok(lit) => {
|
||||
self.bump();
|
||||
Some(lit)
|
||||
}
|
||||
Err(err) => {
|
||||
let span = token.span;
|
||||
let token::Literal(lit) = token.kind else {
|
||||
unreachable!();
|
||||
};
|
||||
let span = token.uninterpolated_span();
|
||||
self.bump();
|
||||
report_lit_error(&self.sess, err, lit, span);
|
||||
// Pack possible quotes and prefixes from the original literal into
|
||||
|
10
tests/ui/parser/lit-err-in-macro.rs
Normal file
10
tests/ui/parser/lit-err-in-macro.rs
Normal file
@ -0,0 +1,10 @@
|
||||
macro_rules! f {
|
||||
($abi:literal) => {
|
||||
extern $abi fn f() {}
|
||||
}
|
||||
}
|
||||
|
||||
f!("Foo"__);
|
||||
//~^ ERROR suffixes on string literals are invalid
|
||||
|
||||
fn main() {}
|
8
tests/ui/parser/lit-err-in-macro.stderr
Normal file
8
tests/ui/parser/lit-err-in-macro.stderr
Normal file
@ -0,0 +1,8 @@
|
||||
error: suffixes on string literals are invalid
|
||||
--> $DIR/lit-err-in-macro.rs:7:4
|
||||
|
|
||||
LL | f!("Foo"__);
|
||||
| ^^^^^^^ invalid suffix `__`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
Loading…
Reference in New Issue
Block a user