-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix: split float literal tokens at .
to fix parsing of tuple field accesses
#12149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: split float literal tokens at .
to fix parsing of tuple field accesses
#12149
Conversation
You most likely can't do that easily. So the best approach here would be to check when highlighting the |
Ah, it looks like the problem was that token trees don't use an |
Ah that is a problem indeed (as long as they aren't being downmapped that is), wrapping them inside of token trees might be better in that case. (Though that would unfortunately mean token trees no longer only contain other token tree syntax nodes which I think some code might be assuming right now) |
Hackier than I'd like, but it seems to work. Oh well, not like we can escape hacks for this. |
☔ The latest upstream changes (presumably #12157) made this pull request unmergeable. Please resolve the merge conflicts. |
Hm, ye some code actually does make the assumption about only rust-analyzer/crates/syntax/src/ast/node_ext.rs Lines 739 to 746 in e789d73
|
This is more difficult to fix than I thought. With this PR we fail to parse
Urgh |
New approach: The first token of a float literal is now one of I've removed the |
Sounds good to me (that is as good as a hack can sound). |
@bors r+ |
📌 Commit d974a0b has been approved by |
☀️ Test successful - checks-actions |
I think this broke macro-expansion (reduced snippet from macro_rules! constant {
($( $method:ident () -> $ret:expr ; )*)
=> {$(
#[inline]
fn $method() -> Self {
$ret
}
)*};
}
trait M {
fn neg_zero() -> Self;
}
impl M for f32 {
constant! {
neg_zero() -> -0.0;
}
} I am also getting this error with an unrelated project. (I can reproduce this with an empty crate with a single dependency: Output
|
fix: Remap float parts as integers when parsed as indices cc #12149
…s-schievink fix: revert float parsing "fix" to avoid macro-related panics Reverts #12149 and the follow-up fixes, while keeping their tests. #12149 has caused many unexpected panics related to macros, and the fixes for those are not straightforward and further complicate the MBE token conversion logic, which was already fairly hard to follow before these fixes.
This introduces an
ast::FloatLiteral
node, changes theFLOAT_LITERAL
token toFLOAT_LITERAL_PART
, and splits any float literal at the.
character, into aFLOAT_LITERAL_PART
, and optionalDOT
and trailingFLOAT_LITERAL_PART
token. The tokens are reassembled when passing them to a macro as att::Literal
.A slight regression is introduced in how float literals are highlighted: theThis is fixed.
is now highlighted as an operator. I've tried to fix this but couldn't figure out how to highlight the wholeast::FloatLiteral
node as a unit.Fixes #1109
Fixes #10492
Fixes #12107
Fixes #10560
Fixes #11487