Skip to content

Fix issue #41652 - #41668

Merged
bors merged 1 commit into
rust-lang:masterfrom
kennytm:fix-issue-41652
May 7, 2017
Merged

Fix issue #41652#41668
bors merged 1 commit into
rust-lang:masterfrom
kennytm:fix-issue-41652

Conversation

@kennytm

Copy link
Copy Markdown
Member

Fix issue #41652. Don't print anything in render_source_line() if no source code is given.

(cc @jonathandturner#34789)

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @arielb1

(rust_highfive has picked a reviewer for you, use r? to override)

@kennytm

Copy link
Copy Markdown
MemberAuthor

The error happens because imported modules have no associated source code. As I mentioned in #41652, on stable this leads to a span pointing nowhere 👻

note: candidate #1 is defined in the trait `b::Tr`
--> b/src/lib.rs:11:5
|
11 | | _____^ starting here...
12 | |
| |__________________________^ ...ending here
= help: to disambiguate the method call, write `b::Tr::read(3)` instead

and causes ICE after #41245 because of source_string[0..ann.start_col] (where source_string == "").

In this PR, the error will be printed as

note: candidate #1 is defined in the trait `b::Tr`
--> /full/path/to/b/src/lib.rs:11:5
|
= help: to disambiguate the method call, write `b::Tr::read(3)` instead

Note the line number is still printed, but without any source code following it. While this is certainly better than the current situation, I don't know if it is good enough.

Alternatively we could ensure FileMap actually contains the source code when reporting error, but I don't see an easy way to do so without heavily modifying libsyntax ☺️.

@kennytm
kennytmforce-pushed the fix-issue-41652 branch 2 times, most recently from 5d326ab to 1edad2dCompareMay 1, 2017 09:37
@arielb1

Copy link
Copy Markdown
Contributor

Could you have a UI test for that?

r? @jonathandturner

@kennytm

Copy link
Copy Markdown
MemberAuthor

@arielb1 Added (ce92a54). In that case, should I just remove the compile-fail test?

@arielb1

arielb1 commented May 1, 2017

Copy link
Copy Markdown
Contributor

Yeah. There's no need for duplicate ui + cfail tests. Just a UI test so we can make sure the output is sane.

@carols10centscarols10cents added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 1, 2017
@arielb1

Copy link
Copy Markdown
Contributor

@jonathandturner can you review this change?

@sophiajt

Copy link
Copy Markdown
Contributor

This seems better than what we have, so we may want to approve just based on that. How difficult would it be to have this instead?

note: candidate #1 is defined in the trait `b::Tr`
help: to disambiguate the method call, write `b::Tr::read(3)` instead

Since starting to draw the span but not drawing anything doesn't seem to help the user much.

Don't print the source code in emit_message_default() and
render_source_line() if the source code is None.
@kennytm

Copy link
Copy Markdown
MemberAuthor

@jonathandturner Looks like skipping the whole iteration works. The output is now

error: no method named `f` found fortype `{integer}` in the current scope
--> $DIR/issue_41652.rs:19:11
|
19 | 3.f()
| ^
|
= note: found the following associated functions; to be usedasmethods, functions must have a `self` parameter
note:candidate #1 is defined in the trait `issue_41652_b::Tr`
= help: to disambiguate the method call, write `issue_41652_b::Tr::f(3)` instead
error:aborting due to previous error

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@jonathandturner Just checking in here, looks like this PR is ready for another review.

@sophiajt

Copy link
Copy Markdown
Contributor

Great!

@bors r+

@bors

bors commented May 7, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 81bfdc8 has been approved by jonathandturner

@bors

bors commented May 7, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 81bfdc8 with merge 5b31bf8...

bors added a commit that referenced this pull request May 7, 2017
Fix issue #41652
Fix issue #41652. Don't print anything in `render_source_line()` if no source code is given.
(cc @jonathandturner#34789)
@bors

bors commented May 7, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: jonathandturner
Pushing 5b31bf8 to master...

@bors
bors merged commit 81bfdc8 into rust-lang:masterMay 7, 2017
@kennytm
kennytm deleted the fix-issue-41652 branch May 7, 2017 04:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@kennytm@rust-highfive@arielb1@sophiajt@Mark-Simulacrum@bors@carols10cents