Files
rust/tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs
David Wood 8d64937dc2 trait_sel: MetaSized always holds temporarily
As a temporary measure while a proper fix for
`tests/ui/sized-hierarchy/incomplete-inference-issue-143992.rs`
is implemented, make `MetaSized` obligations always hold. In effect,
temporarily reverting the `sized_hierarchy` feature. This is a small
change that can be backported.
2025-07-16 12:35:44 +00:00

30 lines
778 B
Rust

//@ compile-flags: --crate-type=lib
//@ revisions: current next
//@ ignore-compare-mode-next-solver (explicit revisions)
//@[current] check-pass
//@[next] compile-flags: -Znext-solver
//@[next] check-fail
// Test that we avoid incomplete inference when normalizing. Without this,
// `Trait`'s implicit `MetaSized` supertrait requires proving `T::Assoc<_>: MetaSized`
// before checking the `new` arguments, resulting in eagerly constraining the inference
// var to `u32`. This is undesirable and would breaking code.
pub trait Trait {
type Assoc<G>: OtherTrait<G>;
}
pub trait OtherTrait<R> {
fn new(r: R) -> R {
r
}
}
pub fn function<T: Trait>()
where
T::Assoc<[u32; 1]>: Clone,
{
let _x = T::Assoc::new(());
//[next]~^ ERROR mismatched types
}