Skip to content

Corrupt highlighting after f32 expressed with ending period character #12216

Closed
@rapodaca

Description

@rapodaca

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-highlighting(semantic) token highlightingA-macromacro expansionC-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions