Representation of chained error by LSP #33870
boozook
started this conversation in
Language Support
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Example from huge workspace.

This from one crate:
This from another crate:

(I'm sorry for ugly theme, it isn't complete yet.
As I know, rust-analyzer as well as cargo reporting these errors in chains.
For example, this is how represents that error by cargo:
for humans:
[Spoiler, click me] And in json (look at `children`)
{ "reason": "compiler-message", "package_id": "path+file:///absolute-path-to-front-crate#[email protected]", "manifest_path": "/absolute-path-to-front-crate/Cargo.toml", "target": { "kind": ["lib"], "crate_types": ["lib"], "name": "front-crate", "src_path": "/absolute-path-to-front-crate/src/lib.rs", "edition": "2021", "doc": true, "doctest": true, "test": true }, "message": { "rendered": "error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied\n --> front-crate/src/lib.rs:171:12\n |\n171 | gfx: gfx::Graphics<gfx::api::Cache>,\n | ^^^^^^^^----------------- help: remove the unnecessary generics\n | |\n | expected 0 generic arguments\n |\nnote: struct defined here, with 0 generic parameters\n --> /abs-path-to-back-crate/gfx/src/lib.rs:50:12\n |\n50 | pub struct Graphics(Api);\n | ^^^^^^^^\n\n", "$message_type": "diagnostic", "children": [ { "children": [], "code": null, "level": "note", "message": "struct defined here, with 0 generic parameters", "rendered": null, "spans": [ { "byte_end": 1017, "byte_start": 1009, "column_end": 20, "column_start": 12, "expansion": null, "file_name": "/abs-path-to-back-crate/gfx/src/lib.rs", "is_primary": true, "label": null, "line_end": 50, "line_start": 50, "suggested_replacement": null, "suggestion_applicability": null, "text": [{ "highlight_end": 20, "highlight_start": 12, "text": "pub struct Graphics(Api);" }] } ] }, { "children": [], "code": null, "level": "help", "message": "remove the unnecessary generics", "rendered": null, "spans": [ { "byte_end": 4244, "byte_start": 4227, "column_end": 37, "column_start": 20, "expansion": null, "file_name": "front-crate/src/lib.rs", "is_primary": true, "label": null, "line_end": 171, "line_start": 171, "suggested_replacement": "", "suggestion_applicability": "MaybeIncorrect", "text": [{ "highlight_end": 37, "highlight_start": 20, "text": "\tgfx: gfx::Graphics<gfx::api::Cache>," }] } ] } ], "code": { "code": "E0107", "explanation": "An incorrect number of generic arguments was provided.\n\nErroneous code example:\n\n```compile_fail,E0107\nstruct Foo<T> { x: T }\n\nstruct Bar { x: Foo } // error: wrong number of type arguments:\n // expected 1, found 0\nstruct Baz<S, T> { x: Foo<S, T> } // error: wrong number of type arguments:\n // expected 1, found 2\n\nfn foo<T, U>(x: T, y: U) {}\nfn f() {}\n\nfn main() {\n let x: bool = true;\n foo::<bool>(x); // error: wrong number of type arguments:\n // expected 2, found 1\n foo::<bool, i32, i32>(x, 2, 4); // error: wrong number of type arguments:\n // expected 2, found 3\n f::<'static>(); // error: wrong number of lifetime arguments\n // expected 0, found 1\n}\n```\n\nWhen using/declaring an item with generic arguments, you must provide the exact\nsame number:\n\n```\nstruct Foo<T> { x: T }\n\nstruct Bar<T> { x: Foo<T> } // ok!\nstruct Baz<S, T> { x: Foo<S>, y: Foo<T> } // ok!\n\nfn foo<T, U>(x: T, y: U) {}\nfn f() {}\n\nfn main() {\n let x: bool = true;\n foo::<bool, u32>(x, 12); // ok!\n f(); // ok!\n}\n```\n" }, "level": "error", "message": "struct takes 0 generic arguments but 1 generic argument was supplied", "spans": [ { "byte_end": 4227, "byte_start": 4219, "column_end": 20, "column_start": 12, "expansion": null, "file_name": "front-crate/src/lib.rs", "is_primary": true, "label": "expected 0 generic arguments", "line_end": 171, "line_start": 171, "suggested_replacement": null, "suggestion_applicability": null, "text": [{ "highlight_end": 20, "highlight_start": 12, "text": "\tgfx: gfx::Graphics<gfx::api::Cache>," }] } ] } }So, currently, each part of a chain of one error is represented in the UI as many independent errors, which is neither correct nor convenient.
Idea
My idea is to allow navigation through such chains of errors (or parts of one error).
Also make the command “show this entire error in diagnostics-multibuffer”.
How it's done now:
I can't find the other parts of the error by looking at one of them.
I'm forced to open the whole list of errors and warnings in the diagnostics-multibuffer ("Project Diagnostics") and search for matches by hand.
Beta Was this translation helpful? Give feedback.
All reactions