#![feature(unsize)]
use std::marker::Unsize;
fn meta_offset_layout<T: Unsize<U>, U>(value: &T) -> U
{
meta_offset_layout(value)
}
fails with
error[E0277]: the trait bound `U: Unsize<U>` is not satisfied
--> src/main.rs:5:24
|
5 | meta_offset_layout(value)
| ------------------ ^^^^^ the nightly-only, unstable trait `Unsize<U>` is not implemented for `U`
| |
| required by a bound introduced by this call
|
= note: all implementations of `Unsize` are provided automatically by the compiler, see <https://doc.rust-lang.org/stable/std/marker/trait.Unsize.html> for more information
note: required by a bound in `meta_offset_layout`
--> src/main.rs:3:26
|
3 | fn meta_offset_layout<T: Unsize<U>, U>(value: &T) -> U
| ^^^^^^^^^ required by this bound in `meta_offset_layout`
help: consider restricting type parameter `U` with unstable trait `Unsize`
|
3 | fn meta_offset_layout<T: Unsize<U>, U: std::marker::Unsize<U>>(value: &T) -> U
| ++++++++++++++++++++++++
in the new solver.
THis happens as coerce_unsize considers T: Unsize<?recursive_t>. While we bail with ambiguity in fn consider_structural_builtin_unsize_candidates, we assemble the ParamEnv candidate regardless and prefer that over the impl, constraining ?recursive_t to the U due to the where-clause.
See https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/.60static-box.60.20unsize.20issue/with/569043447. We could weaken candidate preference in the new solver to avoid this behavior, but I don't think that's necessarily worth the complexity.
This can only be triggered using unstable code, as it needs explicit Unsize where-clauses. It breaks static-box
fails with
in the new solver.
THis happens as
coerce_unsizeconsidersT: Unsize<?recursive_t>. While we bail with ambiguity in fn consider_structural_builtin_unsize_candidates, we assemble theParamEnvcandidate regardless and prefer that over the impl, constraining?recursive_tto theUdue to the where-clause.See https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/.60static-box.60.20unsize.20issue/with/569043447. We could weaken candidate preference in the new solver to avoid this behavior, but I don't think that's necessarily worth the complexity.
This can only be triggered using unstable code, as it needs explicit
Unsizewhere-clauses. It breaksstatic-box