Conversation
src/librustc_resolve/diagnostics.rs
Outdated
There was a problem hiding this comment.
"You tried to use something that is not a trait as a trait bound." is slightly easier to read for me.
src/librustc_resolve/diagnostics.rs
Outdated
There was a problem hiding this comment.
Is 909 the biggest error code so far? I could have sworn we're still <700!
There was a problem hiding this comment.
Oh, I'm off by two... The largest I found was 907:
rust/src/librustc_typeck/diagnostics.rs
Line 4829 in b1f8e6f
I wasn't really sure how to choose the error number, though...
There was a problem hiding this comment.
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.
Hmm... maybe if I run the full test suite? Let me try.
There was a problem hiding this comment.
Yep, it appears that tidy does not run for a full build...
There was a problem hiding this comment.
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: Details |
|
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
There was a problem hiding this comment.
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.
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.
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.
@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.
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.
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.
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