rust/tests/ui/traits/next-solver/object-unsafety.rs
Matthias Krüger 702225e290
Rollup merge of #120598 - compiler-errors:no-rigid-check, r=lcnr
No need to `validate_alias_bound_self_from_param_env` in `assemble_alias_bound_candidates`

We already fully normalize the self type before we reach `assemble_alias_bound_candidates`, so there's no reason to double check that a projection is truly rigid by checking param-env bounds.

I think this is also blocked on us making sure to always normalize opaques: #120549.

r? lcnr
2024-02-22 18:09:52 +01:00

27 lines
720 B
Rust

//@ compile-flags: -Znext-solver
trait Setup {
type From: Copy;
}
fn copy<U: Setup + ?Sized>(from: &U::From) -> U::From {
*from
}
pub fn copy_any<T>(t: &T) -> T {
copy::<dyn Setup<From=T>>(t)
//~^ ERROR the type `&<dyn Setup<From = T> as Setup>::From` is not well-formed
//~| ERROR the trait bound `dyn Setup<From = T>: Setup` is not satisfied
//~| ERROR mismatched types
//~| ERROR the type `<dyn Setup<From = T> as Setup>::From` is not well-formed
// FIXME(-Znext-solver): These error messages are horrible and some of them
// are even simple fallout from previous error.
}
fn main() {
let x = String::from("Hello, world");
let y = copy_any(&x);
println!("{y}");
}