-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Add more context to E0599 errors #69255
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
2a5452b
to
9f63be0
Compare
// ignore-i586-unknown-linux-gnu | ||
// ignore-i586-unknown-linux-musl | ||
// ignore-i686-unknown-linux-musl |
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.
This seems unfortunate.
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.
At least we're tracking the underlying issue now :o)
error[E0599]: no associated item named `ID` found for type `i32` in the current scope | ||
--> $DIR/associated-const-no-item.rs:5:23 | ||
| | ||
LL | trait Foo { | ||
| --------- `Foo` defines an item `ID` | ||
... | ||
LL | const X: i32 = <i32>::ID; | ||
| ^^ associated item not found in `i32` | ||
| | ||
= help: items from traits can only be used if the trait is implemented and in scope | ||
= note: the following trait defines an item `ID`, perhaps you need to implement it: | ||
candidate #1: `Foo` |
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.
TODO: we should determine whether the implementing trait is in scope. If it isn't, suggest importing it. If it is, check whether the found adt implements it directly but the bounds weren't fulfilled. If not, suggest implementing it.
This PR now accounts for arbitrary self types when reporting E0599, but it doesn't help when the trait definition is not crate local. The suggestion to constrain type parameters is not as good as I would wish (it should suggest constraining the |
f493699
to
c5c78d1
Compare
| --------- `Bar` defines an item `foo`, perhaps you need to implement it | ||
... | ||
LL | self.foo(); | ||
| ^^^ method not found in `&Foo<T>` |
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.
I think this should go before both the struct and trait above
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.
@tmandry What do you think of this?
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.
This looks really, really good!
My only critique is that the two note
s (one on the span, one outside) are redundant.
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.
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.
Great! And I forgot to say again that I think the order of the spans ought to be reversed :)
This comment has been minimized.
This comment has been minimized.
c5c78d1
to
529b891
Compare
= note: the method `foo` exists but the following trait bounds were not satisfied: | ||
`T: std::default::Default` | ||
which is required by `Fin<T>: Bar` | ||
help: consider restricting the type parameter to satisfy the obligation |
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.
consider rewording obligations
to requirements
(or a better alternative)? as obligation
isn't a common term outside the internal rustc.
ps. a google search result
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.
What about "consider restricting the type parameter to satisfy the trait bound"?
@@ -579,6 +579,20 @@ impl<'tcx, N> Vtable<'tcx, N> { | |||
} | |||
} | |||
|
|||
pub fn borrow_nested_obligations(&self) -> &[N] { | |||
match &self { | |||
VtableImpl(i) => &i.nested[..], |
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.
Huh, these are unpleasant variant names.
@bors r+ |
📌 Commit c02e56a has been approved by |
Add more context to E0599 errors Point at the intermediary unfulfilled trait bounds. Fix rust-lang#52523, fix rust-lang#61661, cc rust-lang#36513, fix rust-lang#68131, fix rust-lang#64417, fix rust-lang#61768, cc rust-lang#57457, cc rust-lang#9082, fix rust-lang#57994, cc rust-lang#64934, cc rust-lang#65149.
Rollup of 8 pull requests Successful merges: - #60826 (Implement new gdb/lldb pretty-printers) - #69255 (Add more context to E0599 errors) - #69379 (Fail on multiple declarations of `main`.) - #69430 (librustc_typeck: remove loop that never actually loops) - #69449 (Do not ping PR reviewers in toolstate breakage) - #69491 (rustc_span: Add `Symbol::to_ident_string` for use in diagnostic messages) - #69495 (don't take redundant references to operands) - #69496 (use find(x) instead of filter(x).next()) Failed merges: r? @ghost
Add more context to E0599 errors Point at the intermediary unfulfilled trait bounds. Fix rust-lang#52523, fix rust-lang#61661, cc rust-lang#36513, fix rust-lang#68131, fix rust-lang#64417, fix rust-lang#61768, cc rust-lang#57457, cc rust-lang#9082, fix rust-lang#57994, cc rust-lang#64934, cc rust-lang#65149.
Failed in #69543 (comment) |
c02e56a
to
2fb35ad
Compare
@bors r=varkor rollup=never |
📌 Commit 2fb35ad has been approved by |
@bors p=1 |
☀️ Test successful - checks-azure |
This appears to have caused a regression: |
Follow up to rust-lang#69255, fix rust-lang#69629.
Point at the intermediary unfulfilled trait bounds.
Fix #52523, fix #61661, cc #36513, fix #68131, fix #64417, fix #61768, cc #57457, cc #9082, fix #57994, cc #64934, cc #65149.