-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Move fix suggestion to subdiagnostic #19464
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
4fa0bae
Move fix suggestion to subdiagnostic
ntBre 04c820d
add and use Severity::Help
ntBre 745b4ce
try using SmallVec for subdiagnostics
ntBre 7618525
Revert "try using SmallVec for subdiagnostics"
ntBre a4521ac
try converting to string earlier
ntBre a167803
avoid duplicate noqa code in primary message
ntBre 12226e3
Diagnostic::suggestion -> first_help_text, update docs
ntBre 90497de
add SubDiagnosticSeverity
ntBre 10676cb
delete leftover Help variant in ty_wasm
ntBre File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #[cfg(test)] | ||
| mod tests { | ||
| use crate::diagnostic::{ | ||
| DiagnosticFormat, | ||
| render::tests::{create_diagnostics, create_syntax_error_diagnostics}, | ||
| }; | ||
|
|
||
| #[test] | ||
| fn output() { | ||
| let (env, diagnostics) = create_diagnostics(DiagnosticFormat::Full); | ||
| insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @r#" | ||
| error[unused-import]: `os` imported but unused | ||
| --> fib.py:1:8 | ||
| | | ||
| 1 | import os | ||
| | ^^ | ||
| | | ||
| help: Remove unused import: `os` | ||
|
|
||
| error[unused-variable]: Local variable `x` is assigned to but never used | ||
| --> fib.py:6:5 | ||
| | | ||
| 4 | def fibonacci(n): | ||
| 5 | """Compute the nth number in the Fibonacci sequence.""" | ||
| 6 | x = 1 | ||
| | ^ | ||
| 7 | if n == 0: | ||
| 8 | return 0 | ||
| | | ||
| help: Remove assignment to unused variable `x` | ||
|
|
||
| error[undefined-name]: Undefined name `a` | ||
| --> undef.py:1:4 | ||
| | | ||
| 1 | if a == 1: pass | ||
| | ^ | ||
| | | ||
| "#); | ||
| } | ||
|
|
||
| #[test] | ||
| fn syntax_errors() { | ||
| let (env, diagnostics) = create_syntax_error_diagnostics(DiagnosticFormat::Full); | ||
| insta::assert_snapshot!(env.render_diagnostics(&diagnostics), @r" | ||
| error[invalid-syntax]: SyntaxError: Expected one or more symbol names after import | ||
| --> syntax_errors.py:1:15 | ||
| | | ||
| 1 | from os import | ||
| | ^ | ||
| 2 | | ||
| 3 | if call(foo | ||
| | | ||
|
|
||
| error[invalid-syntax]: SyntaxError: Expected ')', found newline | ||
| --> syntax_errors.py:3:12 | ||
| | | ||
| 1 | from os import | ||
| 2 | | ||
| 3 | if call(foo | ||
| | ^ | ||
| 4 | def bar(): | ||
| 5 | pass | ||
| | | ||
| "); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be helpful to add a comment here explaining that this type was added to represent the additional
Helpvariant that isn't present onSeverity. And that, in particular, if we wanted to addSeverity::Help, it would be fine to delete this type and move back to one type.I say this because it clarifies that
Helpis the only reason for this type's existence, and that there isn't some other need for it. So hopefully it's easier for someone down the line to remove it if we do addSeverity::Help.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh good idea. I'll sneak this into #19398 since I haven't merged it yet. Thanks for the reviews!
Let me know if you find anything else. I'll be working in the same area on
fulloutput next.