mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
fix: Fix float parser hack creating empty NameRef tokens
This commit is contained in:
parent
d9e9ca2981
commit
cba39f8553
4 changed files with 46 additions and 7 deletions
|
@ -46,12 +46,16 @@ impl LexedStr<'_> {
|
|||
// Tag the token as joint if it is float with a fractional part
|
||||
// we use this jointness to inform the parser about what token split
|
||||
// event to emit when we encounter a float literal in a field access
|
||||
if kind == SyntaxKind::FLOAT_NUMBER && !self.text(i).ends_with('.') {
|
||||
res.was_joint();
|
||||
if kind == SyntaxKind::FLOAT_NUMBER {
|
||||
if !self.text(i).ends_with('.') {
|
||||
res.was_joint();
|
||||
} else {
|
||||
was_joint = false;
|
||||
}
|
||||
} else {
|
||||
was_joint = true;
|
||||
}
|
||||
}
|
||||
|
||||
was_joint = true;
|
||||
}
|
||||
}
|
||||
res
|
||||
|
@ -204,6 +208,7 @@ impl Builder<'_, '_> {
|
|||
assert!(right.is_empty(), "{left}.{right}");
|
||||
self.state = State::Normal;
|
||||
} else {
|
||||
assert!(!right.is_empty(), "{left}.{right}");
|
||||
(self.sink)(StrStep::Enter { kind: SyntaxKind::NAME_REF });
|
||||
(self.sink)(StrStep::Token { kind: SyntaxKind::INT_NUMBER, text: right });
|
||||
(self.sink)(StrStep::Exit);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue