Include span label in rust lints (#601)
* Include span label in rust lints This turns relatively unhelpful error messages like mismatched types into more expressive messages along the lines of mismatched types: expected bool, found integral variable Fixes #597. * Exclude rust lint span label if empty * Use single-quoted strings in vimscript * Add test for detailed rust errors * Prune Cargo JSON * Use matching error file name * Byte offsets not char offsets
This commit is contained in:
parent
42efd51723
commit
88948e0ee3
@ -55,7 +55,7 @@ function! ale#handlers#rust#HandleRustErrorsForFile(buffer, full_filename, lines
|
|||||||
\ 'end_lnum': l:span.line_end,
|
\ 'end_lnum': l:span.line_end,
|
||||||
\ 'col': l:span.byte_start,
|
\ 'col': l:span.byte_start,
|
||||||
\ 'end_col': l:span.byte_end,
|
\ 'end_col': l:span.byte_end,
|
||||||
\ 'text': l:error.message,
|
\ 'text': empty(l:span.label) ? l:error.message : printf('%s: %s', l:error.message, l:span.label),
|
||||||
\ 'type': toupper(l:error.level[0]),
|
\ 'type': toupper(l:error.level[0]),
|
||||||
\})
|
\})
|
||||||
else
|
else
|
||||||
|
@ -55,6 +55,25 @@ Execute(The Rust handler should handle cargo output):
|
|||||||
\ '{"message":{"children":[],"code":null,"level":"error","message":"aborting due to previous error","rendered":null,"spans":[]},"package_id":"update 0.0.1 (path+file:///home/w0rp/Downloads/rust-by-example)","reason":"compiler-message","target":{"kind":["bin"],"name":"update","src_path":"/home/w0rp/Downloads/rust-by-example/src/main.rs"}}',
|
\ '{"message":{"children":[],"code":null,"level":"error","message":"aborting due to previous error","rendered":null,"spans":[]},"package_id":"update 0.0.1 (path+file:///home/w0rp/Downloads/rust-by-example)","reason":"compiler-message","target":{"kind":["bin"],"name":"update","src_path":"/home/w0rp/Downloads/rust-by-example/src/main.rs"}}',
|
||||||
\ ])
|
\ ])
|
||||||
|
|
||||||
|
Execute(The Rust handler should show detailed errors):
|
||||||
|
AssertEqual
|
||||||
|
\ [
|
||||||
|
\ {
|
||||||
|
\ 'lnum': 4,
|
||||||
|
\ 'end_lnum': 4,
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'col': 52,
|
||||||
|
\ 'end_col': 54,
|
||||||
|
\ 'text': 'mismatched types: expected bool, found integral variable',
|
||||||
|
\ },
|
||||||
|
\ ],
|
||||||
|
\ ale#handlers#rust#HandleRustErrorsForFile(347, 'src/playpen.rs', [
|
||||||
|
\ '',
|
||||||
|
\ 'ignore this',
|
||||||
|
\ '{"message":{"children":[],"code":null,"level":"error","message":"mismatched types","rendered":null,"spans":[{"byte_end":54,"byte_start":52,"column_end":23,"column_start":21,"expansion":null,"file_name":"src/playpen.rs","is_primary":true,"label":"expected bool, found integral variable","line_end":4,"line_start":4,"suggested_replacement":null,"text":[{"highlight_end":23,"highlight_start":21,"text":" let foo: bool = 42;"}]}]},"package_id":"ale-rust-details 0.1.1 (path+file:///home/jon/tmp/ale-rust-details)","reason":"compiler-message","target":{"crate_types":["bin"],"kind":["bin"],"name":"ale-rust-details","src_path":"/home/jon/tmp/ale-rust-details/src/main.rs"}}',
|
||||||
|
\ '{"message":{"children":[],"code":null,"level":"error","message":"aborting due to previous error(s)","rendered":null,"spans":[]},"package_id":"ale-rust-details 0.1.1 (path+file:///home/jon/tmp/ale-rust-details)","reason":"compiler-message","target":{"crate_types":["bin"],"kind":["bin"],"name":"ale-rust-details","src_path":"/home/jon/tmp/ale-rust-details/src/main.rs"}}',
|
||||||
|
\ ])
|
||||||
|
|
||||||
Execute(The Rust handler should find correct files):
|
Execute(The Rust handler should find correct files):
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ [],
|
\ [],
|
||||||
|
Loading…
Reference in New Issue
Block a user