-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Centralize and clean type error reporting #34907
Conversation
e09f9d0
to
fdf8335
Compare
Few more errors to modernize:
Will fix these tomorrow. |
All type errors now look like:
|
@@ -16,7 +16,9 @@ struct Baz; | |||
|
|||
impl Foo for Baz { | |||
fn bar(&mut self, other: &Foo) {} | |||
//~^ ERROR method `bar` has an incompatible type for trait: values differ in mutability [E0053] |
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's hard for me to tell from this diff: has the "values differ in mutability" part of the message been entirely removed?
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.
See the error message above ^. It is now a label in new-skool and a single note in old-skool.
So I'm 👍 on removing the hack around newlines and centralizing the error reporting infrastructure here to go through a more common set of methods. That said, it seems like the new messages may be less specific and quite possibly less helpful than the old ones. It might be though that if we combined this patch with something that gives intelligent diffs, that would be the best of both worlds. Basically I think we want to avoid presenting people with two types and having them find the difference: so if we used to point out that the problem has to do with mutability, but now we make you figure it out for yourself, that could be a regression in usability. I also think that we calling everything "mismatched types" might be confused for people, if we can give a more specific indicator of where the type problem is. Also, @arielb1, you mention this:
How does it look now? Can you give an example of what got uglier? |
a44b5bf
to
7966739
Compare
ready for review. I would like @nikomatsakis to look at the last commit (efe1a68). |
32fd204
to
5b2cf69
Compare
ad37be1
to
031bc32
Compare
Unfortunately, projection errors do not come with a nice set of mismatched types. This is because the type equality check occurs within a higher-ranked context. Therefore, only the type error is reported. This is ugly but was always the situation. I will introduce better errors for the lower-ranked case in another commit. Fixes the last known occurence of rust-lang#31173
Refactor constant evaluation to use a single error reporting function that reports a type-error-like message. Also, unify all error codes with the "constant evaluation error" message to just E0080, and similarly for a few other duplicate codes. The old situation was a total mess, and now that we have *something* we can further iterate on the UX.
The type equation in projection takes place under a binder and a snapshot, which we can't easily take types out of. Instead, when encountering a projection error, try to re-do the projection and find the type error then. This fails to produce a sane type error when the failure was a "leak_check" failure. I can't think of a sane way to show *these*, so I just left them use the old crappy representation, and added a test to make sure we don't break them.
031bc32
to
521ada1
Compare
@bors r=nikomatsakis |
📌 Commit 717e392 has been approved by |
@bors retry |
@bors r- |
@bors retry r=nikomatsakis |
📌 Commit 717e392 has been approved by |
⌛ Testing commit 717e392 with merge d398d9c... |
💔 Test failed - auto-linux-cross-opt |
@bors: retry weeps On Sun, Jul 24, 2016 at 10:08 PM, bors notifications@github.com wrote:
|
⌛ Testing commit 717e392 with merge eccf954... |
💔 Test failed - auto-win-gnu-32-opt-rustbuild |
@bors: retry On Sun, Jul 24, 2016 at 10:43 PM, bors notifications@github.com wrote:
|
@bors: retry |
⌛ Testing commit 717e392 with merge 084ebe7... |
💔 Test failed - auto-win-gnu-32-opt |
@bors: retry On Mon, Jul 25, 2016 at 2:55 PM, bors notifications@github.com wrote:
|
⌛ Testing commit 717e392 with merge 727c4dc... |
💔 Test failed - auto-win-msvc-64-opt |
@bors: retry On Tue, Jul 26, 2016 at 3:13 AM, bors notifications@github.com wrote:
|
⌛ Testing commit 717e392 with merge f2e59cc... |
Centralize and clean type error reporting Refactors the code that handles type errors to be cleaner and fixes various edge cases. This made the already-bad "type mismatch resolving" error message somewhat uglier. I want to fix that in another commit before this PR is merged. Fixes #31173 r? @jonathandturner, cc @nikomatsakis
Refactors the code that handles type errors to be cleaner and fixes various edge cases.
This made the already-bad "type mismatch resolving" error message somewhat uglier. I want to fix that in another commit before this PR is merged.
Fixes #31173
r? @jonathandturner, cc @nikomatsakis