Skip to content

Wrong unexpected token diagnostic when passing negative numbers to concat! #19417

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

Closed
vdrn opened this issue Mar 22, 2025 · 2 comments · Fixed by #19434
Closed

Wrong unexpected token diagnostic when passing negative numbers to concat! #19417

vdrn opened this issue Mar 22, 2025 · 2 comments · Fixed by #19434
Assignees
Labels
A-macro macro expansion C-bug Category: bug

Comments

@vdrn
Copy link

vdrn commented Mar 22, 2025

This code compiles fine with rustc, but rust analyzer reports error: unexpected token

 pub const T: &str = concat!(-42.0); 

rust-analyzer version: 1.87.0-nightly (be73c1f 2025-03-21)

rustc version: rustc 1.87.0-nightly (be73c1f46 2025-03-21)

@vishruth-thimmaiah
Copy link
Contributor

@rustbot claim

@ShoyuVanilla ShoyuVanilla added the A-macro macro expansion label Mar 22, 2025
yarrow added a commit to yarrow/rcal that referenced this issue Apr 12, 2025
Title: Wrong unexpected token diagnostic when passing negative numbers to concat!
Link: rust-lang/rust-analyzer#19417
@pedrocarlo
Copy link

Having this same issue where the rustc can correctly expand the macro with negative integers and floats, but RA cannot. I use extensively this macro, so I am getting red squiggles everywhere

macro:

sqlite_values!(-1)

RA

// Recursive expansion of sqlite_values! macro
// ============================================

<[_]>::into_vec(
    #[rustc_box]
    alloc::boxed::Box::new([(<[_]>::into_vec(
        #[rustc_box]
        alloc::boxed::Box::new([(::rusqlite::types::Value::Integer())]),
    ))]),
)

rustc

<[_]>::into_vec(
            #[rustc_box]
            ::alloc::boxed::Box::new([
                <[_]>::into_vec(
                    #[rustc_box]
                    ::alloc::boxed::Box::new([::rusqlite::types::Value::Integer(-1i64)]),
                ),
            ]),
        ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-macro macro expansion C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants