Skip to content

Corrupt highlighting after f32 expressed with ending period character #12216

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

Closed
rapodaca opened this issue May 11, 2022 · 1 comment
Closed
Labels
A-highlighting (semantic) token highlighting A-macro macro expansion C-bug Category: bug

Comments

@rapodaca
Copy link

rust-analyzer version: v0.2.1048

rustc version: 1.60.0

relevant settings: none

The following code:

#[derive(Debug, PartialEq)]
struct Rectangle {
    left: f32,
    top: f32,
    right: f32,
    bottom: f32,
}

impl Rectangle {
    pub fn new(left: f32, top: f32, right: f32, bottom: f32) -> Self {
        Self { left: left, top: top, right: right, bottom: bottom }
    }
}

#[derive(Debug, PartialEq)]
struct Fragment {
    bounding_box: Option<Rectangle>,
    connection_order: Option<Vec<u32>>,
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let fragment = Fragment {
            bounding_box: Some(Rectangle::new(0., 0., 1., 1.)),
            connection_order: Some(vec![1,2]),
        };

        assert_eq!(
            fragment,
            Fragment {
                bounding_box: Some(Rectangle::new(0., 0., 1., 1.)),
                connection_order: Some(vec![1,2])
            }
        )
    }
}

Yields the following highlighting in VS Code:

screen

I expected the numbers inside the brackets on line 36 to be highlighted consistently, but they are not. The first is white and the second is red.

Changing line 35 to:

bounding_box: Some(Rectangle::new(0f32, 0f32, 1f32, 1f32)),

resolves the issue. The issue is also resolved by disabling Rust Analyzer.

@flodiebold flodiebold added A-macro macro expansion C-bug Category: bug A-highlighting (semantic) token highlighting labels May 12, 2022
bors added a commit that referenced this issue May 12, 2022
internal: Add token mapping test for float literals

cc #12216
@jonas-schievink
Copy link
Contributor

I've reverted the offending PR in #12241

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-highlighting (semantic) token highlighting A-macro macro expansion C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

3 participants