Skip to content

Inline macro, expand to re-input macro token cannot joint #19886

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 May 29, 2025 · 0 comments
Open

Inline macro, expand to re-input macro token cannot joint #19886

A4-Tacks opened this issue May 29, 2025 · 0 comments
Labels
A-assists 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: VIM-9.1

code snippet to reproduce:

use proc_macro::{Delimiter, Group, Ident, Literal, Punct, Span, TokenStream, TokenTree, Spacing::*};

#[proc_macro]
pub fn foo(item: TokenStream) -> TokenStream {
    TokenStream::from_iter([
        TokenTree::from(Ident::new("dbg", Span::call_site())),
        TokenTree::from(Punct::new('!', Joint)),
        TokenTree::from(Group::new(
            Delimiter::Parenthesis,
            TokenStream::from_iter([
                TokenTree::from(Literal::character('a')),
                TokenTree::from(Punct::new('.', Joint)),
                TokenTree::from(Punct::new('.', Joint)),
                TokenTree::from(Punct::new('=', Joint)),
                TokenTree::from(Literal::character('b')),
            ]),
        )),
    ])
}
fn main() {
    proc_macro_impl::foo!();
}

Use ide-assist Inline macro to:

fn main() {
    dbg!('a'.. = 'b');
}

Expect:

fn main() {
    dbg!('a'..='b');
}
@A4-Tacks A4-Tacks added the C-bug Category: bug label May 29, 2025
@Veykril Veykril added the A-macro macro expansion label May 29, 2025
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

3 participants