We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I tried this code:
trait Op<Arg> { fn op (_: Arg); } trait Trait<'lt>: 'lt + Sized + Op<Self> + Op<&'lt Self> {} trait WithAssoc<'lt> { type Assoc: Trait<'lt>; } fn test<'lt, T: WithAssoc<'lt>> (it: T::Assoc) { <T::Assoc as Op<_>>::op(it) }
I expected to see this happen: code compiles
Instead, this happened: code doesn't compile with the following error:
error[E0308]: mismatched types --> src/lib.rs:10:29 | 10 | <T::Assoc as Op<_>>::op(it) | ^^ expected reference, found associated type | = note: expected reference `&'lt <T as WithAssoc<'lt>>::Assoc` found associated type `<T as WithAssoc<'lt>>::Assoc` help: consider constraining the associated type `<T as WithAssoc<'lt>>::Assoc` to `&'lt <T as WithAssoc<'lt>>::Assoc` | 9 | fn test<'lt, T: WithAssoc<'lt, Assoc = &'lt <T as WithAssoc<'lt>>::Assoc>> (it: T::Assoc) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider borrowing here | 10 | <T::Assoc as Op<_>>::op(&it) | ^^^
T::Assoc
Op<T::Assoc>
T: WithAssoc<'lt, Assoc = &'lt <T as WithAssoc<'lt>>::Assoc>
+ Op<&'lt Self>
<T::Assoc as Op<T::Assoc>>::op(it)
= note:
expected reference ...
Playground: [link]
tested on 1.46.0 and 1.48.0-nightly (2020-09-23 8b40853)
1.46.0
1.48.0-nightly
The text was updated successfully, but these errors were encountered:
This "fixes" it:
trait Trait<'lt>: 'lt + Sized + Op<&'lt Self> + Op<Self> {}
so I think this is the same issue as #72582
Sorry, something went wrong.
This is fixed by #73905
No branches or pull requests
I tried this code:
I expected to see this happen: code compiles
Instead, this happened: code doesn't compile with the following error:
T::Assoc
should implementOp<T::Assoc>
so the error shouldn't happenT: WithAssoc<'lt, Assoc = &'lt <T as WithAssoc<'lt>>::Assoc>
which is reccursion+ Op<&'lt Self>
<T::Assoc as Op<T::Assoc>>::op(it)
= note:
andexpected reference ...
though this is unrelated to the problemPlayground: [link]
Meta
tested on
1.46.0
and1.48.0-nightly
(2020-09-23 8b40853)The text was updated successfully, but these errors were encountered: