-
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
Suggestion when encountering assoc types from hrtb #69048
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
cc @nagisa |
@@ -3,6 +3,8 @@ error[E0212]: cannot extract an associated type from a higher-ranked trait bound | |||
| | |||
LL | field: I::A | |||
| ^^^^ | |||
| | |||
= note: this is not currently representable in Rust |
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, this says "not representable", but you can still do things like:
pub trait Foo<T> {
type A;
fn get(&self, t: T) -> Self::A;
}
struct SomeStruct<'a, I : for<'x> Foo<&'x isize>> {
field: <I as Foo<&'a isize>>::A
}
And it’ll work fine, likely doing exactly what you’d expect?
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'll have a follow up PR with only the logic for this suggestion, as it will be more involved.
Added a very hacky version of the appropriate suggestion that would require some extra logic to be always accurate, but as a first approach it LGTM.
Very cool overall! I think we should remove the "not representable" message for now (or implement an alternative suggestion) and r=me then. |
cc @eddyb |
When encountering E0212, detect whether this is a representable case or not, i.e. if it's happening on an `fn` or on an ADT. If the former, provide a structured suggestion, otherwise note that this can't be represented in Rust.
Could someone take this over? I have too many assigned PRs. |
@bors r+ |
📌 Commit bde9677 has been approved by |
Suggestion when encountering assoc types from hrtb When encountering E0212, detect whether this is a representable case or not, i.e. if it's happening on an `fn` or on an ADT. If the former, provide a structured suggestion, otherwise note that this can't be represented in Rust. Fix rust-lang#69000.
Rollup of 9 pull requests Successful merges: - #67642 (Relax bounds on HashMap/HashSet) - #68848 (Hasten macro parsing) - #69008 (Properly use parent generics for opaque types) - #69048 (Suggestion when encountering assoc types from hrtb) - #69049 (Optimize image sizes) - #69050 (Micro-optimize the heck out of LEB128 reading and writing.) - #69068 (Make the SGX arg cleanup implementation a NOP) - #69082 (When expecting `BoxFuture` and using `async {}`, suggest `Box::pin`) - #69104 (bootstrap: Configure cmake when building sanitizer runtimes) Failed merges: r? @ghost
…=ecstatic-morse Select an appropriate unused lifetime name in suggestion Follow up to rust-lang#69048.
…=ecstatic-morse Select an appropriate unused lifetime name in suggestion Follow up to rust-lang#69048.
When encountering E0212, detect whether this is a representable case or
not, i.e. if it's happening on an
fn
or on an ADT. If the former,provide a structured suggestion, otherwise note that this can't be
represented in Rust.
Fix #69000.