You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code (also on playground) compiles fine on Stable and Beta rustc, but has started no longer compiling on latest nightly (2020-02-28, 2020-02-29 both have this issue).
I would expect this code snippet to compile with no errors as it currently does in stable and beta Rust.
Instead, on recent nightlies (02-28 and 02-29 were tested), an error is produced:
--> src/lib.rs:10:14
|
3 | impl<T, V> core::ops::Mul<T> for Container<V>
| - - expected type parameter
| |
| found type parameter
...
10 | Self(scalar * self.0.into())
| ^^^^^^^^^^^^^^^^^^^^^^ expected type parameter `V`, found type parameter `T`
|
= note: expected type parameter `V`
found type parameter `T`
= note: a type parameter was expected, but a different one was found; you might be missing a type parameter or trait bound
= note: for more information, visit https://doc.rust-lang.org/book/ch10-02-traits.html#traits-as-parameters
I believe this is because rustc is erroneously picking Self to be Container<V> (the type for which the impl is being specified) instead of using Container and inferring the (formerly correct) output type of Container<T>.
Yeah, this was caused by a bug fix to type checking of Self paths, which would previously wrongly introduce inference variables for type parameters in the impl. Using Self should always refer to the Self type, just as using Self {...} would. In other words, your code should never have compiled.
See rust-lang/rust#69611.
This is necessary because
> Using `Self` should always refer to the `Self` type, just as using
> `Self {...}` would. In other words, your code should never have
> compiled.
This'll fix the recurring build failure on nightly Rusts.
Signed-off-by: Kristofer Rye <[email protected]>
The following code (also on playground) compiles fine on Stable and Beta
rustc
, but has started no longer compiling on latest nightly (2020-02-28
,2020-02-29
both have this issue).I would expect this code snippet to compile with no errors as it currently does in stable and beta Rust.
Instead, on recent nightlies (02-28 and 02-29 were tested), an error is produced:
For what it's worth, the substitution
resolves the error.
I believe this is because
rustc
is erroneously pickingSelf
to beContainer<V>
(the type for which theimpl
is being specified) instead of usingContainer
and inferring the (formerly correct) output type ofContainer<T>
.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: