Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

move_format_string_arg issue if arguments contain parentheses/token trees #13261

Closed
la10736 opened this issue Sep 19, 2022 · 2 comments · Fixed by #13321
Closed

move_format_string_arg issue if arguments contain parentheses/token trees #13261

la10736 opened this issue Sep 19, 2022 · 2 comments · Fixed by #13321

Comments

@la10736
Copy link

la10736 commented Sep 19, 2022

rust-analyzer version: 0.3.1212-standalone

rustc version: rustc 1.63.0 (4b91a6ea7 2022-08-08)

relevant settings: nothing

I found a little glitch in the amazing move_format_string_arg:

    fn yeld(&self) {
        let x = 2;
        println!("My name is {} {x + x}", stringify!(Paperino))
    }

Apply assistant to {x + x} transform it in

println!("My name is {} {}", stringify!, x + x)
@lnicola
Copy link
Member

lnicola commented Sep 19, 2022

@Veykril would a newtype wrapper over the text ranges we want in an edit prevent these issues?

@Veykril
Copy link
Member

Veykril commented Sep 19, 2022

In this case the macro isnt the problem, the same happens if you remove the !, the problem are the parentheses.

would a newtype wrapper over the text ranges we want in an edit prevent these issues?

We already have such a thing technically, FileRange which contains a FileId (opposed to a HirFileId, so that range is always a non-macro range). Usually the file id is just redundant which is why its barely used in these cases.

@Veykril Veykril changed the title move_format_string_arg issue if arguments contains macro move_format_string_arg issue if arguments contain parentheses/token trees Sep 19, 2022
@bors bors closed this as completed in 5b7e400 Sep 30, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants