Skip to content
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

Print error lines and highlight error span #660

Closed
wants to merge 3 commits into from

Conversation

jdm
Copy link
Contributor

@jdm jdm commented Jul 11, 2011

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.

@jdm
Copy link
Contributor Author

jdm commented Jul 11, 2011

Well, that turned out ugly. http://pastebin.mozilla.org/1269518 shows the output in full indented glory.

@jdm jdm closed this Jul 11, 2011
@marijnh
Copy link
Contributor

marijnh commented Jul 11, 2011

The lexer already reads in the files in their entirety. You could extend the codemap to save these somewhere.

@jdm jdm reopened this Jul 11, 2011
@brson
Copy link
Contributor

brson commented Jul 12, 2011

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?).

@brson
Copy link
Contributor

brson commented Jul 12, 2011

OK. This is really cool. Integrated.

@brson brson closed this Jul 12, 2011
bors pushed a commit to rust-lang-ci/rust that referenced this pull request Oct 26, 2020
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants