Skip to content
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

Diagnostics calculated from included files report them for the wrong file #14968

Closed
Veykril opened this issue Jun 4, 2023 · 0 comments · Fixed by #16035
Closed

Diagnostics calculated from included files report them for the wrong file #14968

Veykril opened this issue Jun 4, 2023 · 0 comments · Fixed by #16035
Labels
A-diagnostics diagnostics / error reporting Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug I-panic

Comments

@Veykril
Copy link
Member

Veykril commented Jun 4, 2023

Our diagnostics infra was written with the idea in mind that dianostics reported from macro expansions will only end up in the calling file and as such we never verify that the upmapped ranges belong to the file we calculate the diagnostics for. This assumption is incorrect, include! calls in fact have two macro inputs from differing files, as such, any diagnostic calculated from an included file right now will either report the diagnostic in some random location in the calling file or worse crash the server.

An example crash test case for unresolved_macro_call diagnostic:

    #[test]
    fn include_does_not_break_diagnostics() {
        check_diagnostics(
            r#"
//- minicore: include
//- /lib.rs crate:lib
include!("include-me.rs");
//- /include-me.rs
/// long doc that pushes the diagnostic range beyond the first file's text length
#[err]
mod prim_never {}
"#,
        );
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics diagnostics / error reporting Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug I-panic
Projects
None yet
1 participant