Skip to content

The tokens completed within the proc-macro are stuck together #19972

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

Open
A4-Tacks opened this issue Jun 11, 2025 · 0 comments
Open

The tokens completed within the proc-macro are stuck together #19972

A4-Tacks opened this issue Jun 11, 2025 · 0 comments
Labels
A-completion autocompletion A-macro macro expansion C-bug Category: bug

Comments

@A4-Tacks
Copy link
Contributor

rust-analyzer version: rust-analyzer 1.88.0-nightly (a15cce2 2025-04-17)

rustc version: rustc 1.88.0-nightly (a15cce269 2025-04-17)

editor or extension: VIM9.1 coc-rust-analyzer

code snippet to reproduce:

struct Foo;

#[proc_macro_impl::identity_walk]
impl<'a> AsRef<&'a i32> for Foo {
    |
}

| is cursor, input fn, complete fn as_ref(..)~:

struct Foo;

#[proc_macro_impl::identity_walk]
impl<'a> AsRef<&'a i32> for Foo {
    fn as_ref(&self) -> &&'ai32 {
        
    }
}

Expect &&'a i32:

struct Foo;

#[proc_macro_impl::identity_walk]
impl<'a> AsRef<&'a i32> for Foo {
    fn as_ref(&self) -> &&'a i32 {
        
    }
}

proc_macro implements:

use proc_macro::*;
#[proc_macro_attribute]
pub fn identity_walk(_attr: TokenStream, stream: TokenStream) -> TokenStream {
    stream.into_iter()
        .map(|tt| match tt {
            TokenTree::Group(g) => {
                let mut sub = Group::new(
                    g.delimiter(),
                    identity_walk(TokenStream::new(), g.stream()),
                );
                sub.set_span(g.span());
                sub.into()
            },
            _ => tt,
        })
        .collect()
}
@A4-Tacks A4-Tacks added the C-bug Category: bug label Jun 11, 2025
@Veykril Veykril added A-completion autocompletion A-macro macro expansion labels Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion A-macro macro expansion C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants