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

Renaming input identifier used in paste macro doesn't rename identifiers resulting from pasting #17204

Open
edgimar opened this issue May 8, 2024 · 0 comments
Labels
C-bug Category: bug

Comments

@edgimar
Copy link

edgimar commented May 8, 2024

rust-analyzer version: 0.3.1940-standalone (f216be4 2024-04-27)

rustc version: 1.76.0

editor or extension: VSCode - extension v0.3.1940

code snippet to reproduce:

macro_rules! bugdemo {
    ($newtype_name:ident, $elem_name:ident) => {
        #[derive(Debug, Clone, Copy)]
        struct $newtype_name(bool);

        paste::paste! {
        impl $newtype_name {
            fn $elem_name(&self) -> bool {
                self.0
            }

            fn [<$elem_name _mut>](&mut self) -> &mut bool {
                &mut self.0
            }
        }}
    };
}

bugdemo!(MyType, myelem);

fn foo2()
{
    let mut x = MyType(false);
    *x.myelem_mut() = true;
    assert!(x.myelem());
}

To reproduce: try to rename myelem in the bugdemo invocation to myelem2. It fails to rename myelem_mut to myelem2_mut.

@edgimar edgimar added the C-bug Category: bug label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

1 participant