mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Don't remap float tokens to INT_NUMBER
This commit is contained in:
parent
f8c0062d4e
commit
cb5e8da88a
@ -92,3 +92,40 @@ fn foo() {
|
||||
}"##]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn float_parsing_panic() {
|
||||
// Regression test for https://github.com/rust-lang/rust-analyzer/issues/12211
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: identity
|
||||
macro_rules! id {
|
||||
($($t:tt)*) => {
|
||||
$($t)*
|
||||
};
|
||||
}
|
||||
|
||||
id! {
|
||||
#[proc_macros::identity]
|
||||
impl Foo for WrapBj {
|
||||
async fn foo(&self) {
|
||||
self.0. id().await;
|
||||
}
|
||||
}
|
||||
}
|
||||
"#,
|
||||
expect![[r##"
|
||||
macro_rules! id {
|
||||
($($t:tt)*) => {
|
||||
$($t)*
|
||||
};
|
||||
}
|
||||
|
||||
#[proc_macros::identity] impl Foo for WrapBj {
|
||||
async fn foo(&self ) {
|
||||
self .0.id().await ;
|
||||
}
|
||||
}
|
||||
"##]],
|
||||
);
|
||||
}
|
||||
|
@ -243,6 +243,8 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
|
||||
let char = match token.to_char(conv) {
|
||||
Some(c) => c,
|
||||
None => {
|
||||
// FIXME: this isn't really correct, `to_char` yields the *first* char of the token,
|
||||
// and this is relevant when eg. creating 2 `tt::Punct` from a single `::` token
|
||||
panic!("Token from lexer must be single char: token = {:#?}", token);
|
||||
}
|
||||
};
|
||||
|
@ -324,7 +324,9 @@ fn name_ref_or_index(p: &mut Parser) {
|
||||
);
|
||||
let m = p.start();
|
||||
if p.at(FLOAT_NUMBER_PART) || p.at_ts(FLOAT_LITERAL_FIRST) {
|
||||
p.bump_remap(INT_NUMBER);
|
||||
// Ideally we'd remap this to `INT_NUMBER` instead, but that causes the MBE conversion to
|
||||
// lose track of what's a float and what isn't, causing panics.
|
||||
p.bump_remap(FLOAT_NUMBER_PART);
|
||||
} else {
|
||||
p.bump_any();
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ SOURCE_FILE
|
||||
IDENT "x"
|
||||
DOT "."
|
||||
NAME_REF
|
||||
INT_NUMBER "0"
|
||||
FLOAT_NUMBER_PART "0"
|
||||
DOT "."
|
||||
WHITESPACE " "
|
||||
NAME_REF
|
||||
@ -67,10 +67,10 @@ SOURCE_FILE
|
||||
IDENT "x"
|
||||
DOT "."
|
||||
NAME_REF
|
||||
INT_NUMBER "0"
|
||||
FLOAT_NUMBER_PART "0"
|
||||
DOT "."
|
||||
NAME_REF
|
||||
INT_NUMBER "1"
|
||||
FLOAT_NUMBER_PART "1"
|
||||
SEMICOLON ";"
|
||||
WHITESPACE "\n "
|
||||
EXPR_STMT
|
||||
|
Loading…
Reference in New Issue
Block a user