-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Remove E0245; improve E0404 #48446
Remove E0245; improve E0404 #48446
Conversation
src/librustc_resolve/diagnostics.rs
Outdated
@@ -1674,6 +1674,29 @@ fn main() { | |||
``` | |||
"##, | |||
|
|||
E0910: r##" | |||
You tried to use something as a trait bound that is not a trait. |
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.
"You tried to use something that is not a trait as a trait bound." is slightly easier to read for me.
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.
Fixed
src/librustc_resolve/diagnostics.rs
Outdated
@@ -1674,6 +1674,29 @@ fn main() { | |||
``` | |||
"##, | |||
|
|||
E0910: r##" |
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.
Is 909 the biggest error code so far? I could have sworn we're still <700!
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, I'm off by two... The largest I found was 907:
rust/src/librustc_typeck/diagnostics.rs
Line 4829 in b1f8e6f
E0907, // type inside generator must be known in this context |
I wasn't really sure how to choose the error number, though...
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.
Tidy is supposed to tell you:
[00:05:36] * 534 error codes
[00:05:36] * highest error code: E0908
[00:05:36] * 175 features
I think that somebody sneaked a high error code skipping a bunch somewhere 👀
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.
Hmm... maybe if I run the full test suite? Let me try.
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.
Yep, it appears that tidy does not run for a full build...
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.
Ok, I changed it to E0909
r=me once travis passes |
@estebank There are ui tests failing for me locally... These are the test failures I am currently getting that I cannot understand:
|
They seem completely unrelated, which I find confusing... |
@mark-i-m oh, those. I believe that with a fresh clone of the repo those error go away... I've just been ignoring them :-/ If those are the only ones failing, travis will probably succeed. |
That's good to know... maybe it's because I'm running tests against the stage1 compiler locally? |
src/librustc_resolve/lib.rs
Outdated
#[derive(Copy, Clone, PartialEq, Eq, Debug)] | ||
enum PathSource<'a> { | ||
// Type paths `Path`. | ||
Type, | ||
// Trait paths in bounds or impls. | ||
Trait(AliasPossibility), | ||
Trait(AliasPossibility, ImplOrBound), |
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.
Wait.
AliasPossibility
is supposed to be exactly the same thing as ImplOrBound
- aliases can be used in bounds, but cannot be used in impl Trait for ...
.
Also, poly-trait-ref is always a bound, no need to change visitors.
What this PR tries to achieve?
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.
Thanks @petrochenkov ! That's really useful info. The goal was simply to emit a different error if something that is not a trait is used in a bound as opposed to an impl (i.e. impl Struct for Foo
vs foo<T: Struct>(...) {}
).
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.
So you are saying that if AliasPossibility::Maybe
it must be a bound. But is it also true that if AliasPossibility::No
it must be an impl
?
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.
@petrochenkov Is this correct:
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index bf8beb1..5492cd6 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -548,9 +541,9 @@ impl<'a> PathSource<'a> {
__diagnostic_used!(E0578);
__diagnostic_used!(E0909);
match (self, has_unexpected_resolution) {
- (PathSource::Trait(_, ImplOrBound::Impl), true) => "E0404",
- (PathSource::Trait(_, ImplOrBound::Bound), true) => "E0909",
- (PathSource::Trait(_, _), false) => "E0405",
+ (PathSource::Trait(AliasPossibility::No), true) => "E0404",
+ (PathSource::Trait(AliasPossibility::Maybe), true) => "E0909",
+ (PathSource::Trait(_), false) => "E0405",
(PathSource::Type, true) => "E0573",
(PathSource::Type, false) => "E0412",
(PathSource::Struct, true) => "E0574",
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.
No, the existing code is already correct, only E0245
need to be removed as dead code.
Also docs for E0404
should probably be tweaked to mention bounds in addition to impls.
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.
To clarify, #48446 (comment) is correct too, if you really want to make these error codes more fine grained, I'm just not sure this makes sense given that trait aliases are not even implemented yet.
If you do want to spend time on this, I'd suggest to split E0405
as well and document differences between bounds and impls and how trait aliases can be used in bounds but not in impls in the descriptions of E0404
/E0405
/E0909
/E0910
.
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.
if you really want to make these error codes more fine grained
I think that was the conclusion of #36337
If you do want to spend time on this, I'd suggest to split E0405 as well and document differences between bounds and impls and how trait aliases can be used in bounds but not in impls in the descriptions of E0404/E0405/E0909/E0910.
Sure, I can try to do that.
Made this WIP again... I will look into splitting E0405 too. In the meantime, I removed the |
Hmm... Reading this again, I'm not 100% sure we need to mention trait aliases at all. Can't we just mention say that structs are not allowed as bounds? |
That's what I suggested originally. If trait aliases are not mentioned, then there's no difference between impls and bounds, structs are not allowed "in trait position" generally (i.e. in both impls and bounds), and splitting error codes is not necessary, only error descriptions need to be updated. |
@petrochenkov @estebank Updated.
Let me know what you think. |
LGTM. |
Thanks! |
@bors delegate+ |
✌️ @mark-i-m can now approve this pull request |
@bors r+ 🎉 |
📌 Commit c03ef66 has been approved by |
@bors r- |
Oh, I should have read "after squashing commits and fixing the failing test"! |
Ok, I squashed and fixed the test. Will wait for travis, then r+ |
@bors r+ |
📌 Commit 2ec79f9 has been approved by |
🌲 The tree is currently closed for pull requests below priority 200, this pull request will be tested once the tree is reopened |
@bors rollup |
Remove E0245; improve E0404 Fix rust-lang#36337 Somehow this is currently breaking --explain, but I don't understand how. r? @estebank
Fix #36337
Somehow this is currently breaking --explain, but I don't understand how.
r? @estebank