Macro error shows not showing at invocation site

I have a macro that loads config files from a known location. Whenever an incorrect file name is given to the macro, the VSCode error squiggle shows at the include_str call in the macro body rather than at the macro invocation site.

#[macro_export]
macro_rules! config_file {
    ($name:expr) => {{
        include_str!(concat!(
            concat!(env!("CARGO_MANIFEST_DIR"), "/../config/"),
            concat!($name, ".json")
        ))
    }};
}

It'd be good to have the visual indication at the actual macro invocation site, which is where the error really is. I appreciate this might not be possible to do, but it would be useful rather than having to rely on the error message itself.

Is it possible to get the error squiggle to show at the call site instead?

Nightly Rust supports that, so this is a work-in-progress.

You get this enabled by default on nightly.

Thanks - what feature is this so that I can look it up?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.