Skip to content
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

convert_tuple_struct_to_named_struct produces invalid code #18766

Open
adaszko opened this issue Dec 27, 2024 · 1 comment
Open

convert_tuple_struct_to_named_struct produces invalid code #18766

adaszko opened this issue Dec 27, 2024 · 1 comment
Labels
A-assists A-macro macro expansion C-bug Category: bug

Comments

@adaszko
Copy link
Contributor

adaszko commented Dec 27, 2024

rust-analyzer version: 2024-12-23

rustc version: rustc 1.83.0 (90b35a623 2024-11-26)

editor or extension: Reproduced under both Neovim and VSCode

code snippet to reproduce:

// add your code here
use std::{borrow::Borrow, debug_assert, rc::Rc};

#[derive(Clone, PartialEq)]
pub enum Expr {
    NontailCommand(Ustr, usize, ChicSpan),
}

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

    #[test]
    fn parses_nontail_command() {
        assert!(matches!(e, NontailCommand(s, 0, ..) if s == "foo"));
    }
}

Reproduction:

  1. Position cursor at Expr::NontailCommand and select "convert to named struct" code action:
Image 2. Code action inserts unexpected text in the first line of the buffer:Image

Same thing under VSCode:
Image

@adaszko adaszko added the C-bug Category: bug label Dec 27, 2024
@adaszko adaszko changed the title convert_tuple_struct_to_named_struct clobbers Neovim buffer convert_tuple_struct_to_named_struct produces invalid code Dec 27, 2024
@adaszko adaszko changed the title convert_tuple_struct_to_named_struct produces invalid code convert_tuple_struct_to_named_struct produces invalid code Dec 27, 2024
@Veykril
Copy link
Member

Veykril commented Dec 27, 2024

Looks like the assist is not upmapping ranges out of macro expansions

@Veykril Veykril added A-macro macro expansion A-assists labels Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists A-macro macro expansion C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants