Skip to content

Inlay hints not working in macro call #11323

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
blaumeise20 opened this issue Jan 20, 2022 · 3 comments
Open

Inlay hints not working in macro call #11323

blaumeise20 opened this issue Jan 20, 2022 · 3 comments
Labels
A-inlay-hints inlay/inline hints C-feature Category: feature request

Comments

@blaumeise20
Copy link

rust-analyzer version: 0add6e9 2021-12-20 stable

rustc version: rustc 1.60.0-nightly (ee5d8d37b 2022-01-17)

When creating macros that accept blocks, if you declare a let, it doesn't show you the type. Doesn't work with function call parameter names either.

Bildschirmfoto 2022-01-20 um 11 52 58

fn main() {
    macro_rules! foo {
        (bar $b:block) => {
            $b
        }
    }

    fn baz(val: i32) {
        println!("baz {}", val);
    }

    foo!(bar {
        let x = 123;
        baz(x);
        println!("Hello, world!");
    });

    let x = 123;
    baz(x);
    println!("Hello, world!");
}
@Veykril Veykril added the A-inlay-hints inlay/inline hints label Jan 20, 2022
@Veykril
Copy link
Member

Veykril commented Jan 20, 2022

We currently can't(without showing a lot of confusing hints) show inlay hints in macro inputs, this requires #11183 for a proper solution.

@Veykril Veykril added the C-feature Category: feature request label May 20, 2022
@ilyvion
Copy link

ilyvion commented Jul 17, 2023

Just out of curiosity, how is it that rust-analyzer is able to realize what things are within macros when it comes to its tooltips:
image
whereas presenting that (seemingly) same information in an inlay hint requires a whole new machinery?

Again, I'm just asking out of curiosity, not because I think I've discovered some kind of "gotcha" here, but I really don't understand what the difference comes down to.

@flodiebold
Copy link
Member

The hard part is deciding where to place inlay hints in the macro input. I'm not sure I agree that we need macro fragment captures for that, because I think we should also be able to do it for proc macros, but it does need some logic and heuristics specific to each kind of inlay hint to figure out what parts of the macro input should get hints, and no one has implemented that yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-inlay-hints inlay/inline hints C-feature Category: feature request
Projects
None yet
Development

No branches or pull requests

4 participants