-
Notifications
You must be signed in to change notification settings - Fork 297
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
Handling of primary vs. secondary spans in checkers #174
Comments
The plugin should point at the first primary span, not at the first span, as sometimes diagnostics will have a secondary span before the main span. |
@dpc, is this still relevant with Rust 1.27? I vaguely remember seeing this myself (I work with ALE as a checker) but I wasn't able to create a small working demo. The linked playground from the rust-lang/rust issue shows a single error at the correct place (the call). |
It still happens here with
I don't quite understand why, since the right place is first. I have a |
Thanks - I managed to reproduce the issue - this problem also afflicts ALE. Thinking of it, it affects all checkers that sort by line number and don't really do anything with the Ignoring the secondary spans is one way to solve it. Unfortunately ALE sorts by line numbers too - if we don't want to ignore the secondary spans we will have teach it to sort by an additional key. @w0rp what do you think? |
I don't know what you mean about sorting by an additional key. ALE sorts items by buffer or filename, then by line, then by column. |
Why is there an error message showing where the function is defined at all? Who cares? There's no fault at the function if a function is called incorrectly. That's like blaming Ford if someone crashes a car because they were speeding. |
this function takes 1 parameter but 3 parameters were supplied: defined here
is killing me :)
@w0rp it's not about blame, it's about context. We show you the method definition so you have the signature front and center so you can fix your code without having to search for it. If we don't have the span (which we don't for external crates), we show only the compiler's knowledge of the signature (only method name and types) as a note. We also use secondary spans for many things that can be considered "irrelevant", but that are useful to try and keep head-scratching to a minimum. If you do not care at all about these, you can use the The compiler team is making a balancing act between avoiding overwhelming newcomers to the language, not being too obscure for them and not spamming experienced programmers. Because of this the long term plan is to support 3 levels of verbosity: |
This problem still exists, and it is still being a painful thorn in the Rust in Vim experience. ~~I think Rust should at very list a flag that or something that would make all the existing software work OK.~~~ (If that's the |
This would be great improvement to the current situation, where the first span is used, which is quite often not the right one. See rust-lang/rust.vim#174 Related to: neomake#2075
This would be great improvement to the current situation, where the first span is used, which is quite often not the right one. See rust-lang/rust.vim#174 Related to: neomake#2075
The trouble I have with the primary and second spans is that it's difficult to write code for associating secondary spans with primary spans. The Cargo format seems to be roughly like this. [
{"spans": [
{"is_primary": true},
{"is_primary": false},
{"is_primary": false},
{"is_primary": true}
]},
{"spans": [
{"is_primary": true},
{"is_primary": false},
{"is_primary": false},
{"is_primary": true}
]}
] There are multiple spans for each item, and the location information is in the spans. There can be multiple primary spans for each message. From that it's difficult to figure out which secondary spans might be related to particular primary spans. It's hard to parse "the function call failed here, and here is where the function is defined." Does the Cargo JSON API guarantee that secondary spans will always appear after primary spans in the Arrays? If it does, then you could figure out how to associate secondary spans with primary spans by remembering what the last primary span was. APIs like the Language Server Protocol API present diagnostics like so instead.
Each item in the outer array represents one problem in your file, and the objects in the optional |
Can there be more than one This is indeed much more complicated than a typical |
@dpc the change in #2076 should be a very good heuristic for now. Rustc can emit multiple primary spans for a single error, but in those cases using the first primary spans is a good approximation for the editor to use for annotating, as I'm pretty sure in most real cases all the primary spans are very close to each other, like in this case https://github.com/rust-lang/rust/blob/master/src/test/ui/async-fn-multiple-lifetimes.stderr I'm without my laptop until next week, but I can help with figuring out how we can improve the situation. We won't be emitting less detailed information, as we want to allow external tools to be have the full context to rebuild the cli output with the json output, but if we can make it easier to do so, there's no reason for us not to change it. |
This would be great improvement to the current situation, where the first span is used, which is quite often not the right one. See rust-lang/rust.vim#174 Related to: neomake#2075
This would be great improvement to the current situation, where the first span is used, which is quite often not the right one. See rust-lang/rust.vim#174 Related to: neomake#2075
This would be great improvement to the current situation, where the first span is used, which is quite often not the right one. See rust-lang/rust.vim#174 Related to: neomake#2075
rustc
output must have changed, and now every time I compile my code and call a method with a wrong number of arguments, Vim will jump to the definition of the function that is called incorrectly, and not the place where it is being called. There's no easy way jump to the actual code that I need to fix, which is slowing me down a lot: I have to manually inspect the compiler output in another terminal, and manually go to the right place.It seems to me that the output of the compiler is wrong in the first place: the main error
file:line
message should point to the broken code, not the definition of the function that is called (which is useful, but secondary). Ideally I'd likerust.vim
to be able to display both in the compilation error list.The text was updated successfully, but these errors were encountered: