Print error lines and highlight error span#660
Closed
jdm wants to merge 3 commits intorust-lang:masterfrom
Closed
Conversation
Contributor
Author
|
Well, that turned out ugly. http://pastebin.mozilla.org/1269518 shows the output in full indented glory. |
Contributor
|
The lexer already reads in the files in their entirety. You could extend the codemap to save these somewhere. |
Contributor
|
This is cool. What happens when the span spans multiple lines? I don't know how big of a concern it is to reread the file. This isn't critical path stuff since it only happens on failure, and the os is going to have the file cached (why should we cache it if the os does it for us?). |
Contributor
|
OK. This is really cool. Integrated. |
bors
pushed a commit
to rust-lang-ci/rust
that referenced
this pull request
Oct 26, 2020
Libtest support
ZuseZ4
pushed a commit
to EnzymeAD/rust
that referenced
this pull request
Mar 7, 2023
celinval
pushed a commit
to celinval/rust-dev
that referenced
this pull request
Jun 4, 2024
* Enable `rmc-fixme` suite in `compiletest` * Add "rmc-fixme" suite to regular regression
GuillaumeGomez
pushed a commit
to GuillaumeGomez/rust
that referenced
this pull request
May 14, 2025
Stop ignoring the feature -sse
noscripter
pushed a commit
to noscripter/rust
that referenced
this pull request
Sep 8, 2025
--------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This isn't necessarily a request to pull, but more a request for feedback. This branch gives output like:
../src/test/compile-fail/forgot-ret.rs:8:19:12:1: note: In function f, not all control paths return a value ../src/test/compile-fail/forgot-ret.rs:8 fn f(int a) -> int { ../src/test/compile-fail/forgot-ret.rs:9 if (god_exists(a)) { ../src/test/compile-fail/forgot-ret.rs:10 ret 5; ...../src/test/compile-fail/for-loop-decl.rs:13:40:13:44: error: mismatched types: expected @tup(uint,tup(uint,uint)) but found @tup(uint,var_info) (types differ) ../src/test/compile-fail/for-loop-decl.rs:13 for each (@tup(uint, tup(uint, uint)) p in enclosing.vars.items()) { ^~~~The ^~~~ extends for the full width of the error span, so it's easier to see when spans are larger than they should be as well.
The downside here is that I took the easy route for obtaining the file contents and just read in the entire file on demand whenever we print an error. I fully acknowledge that that's an awful thing to do, but I was having trouble figuring out a better way to acquire the file contents from the lexer from all the different possible places we could be throwing errors.