Fix tests that relied on the default variance to be invariant

And now it changed to bivariant.
This commit is contained in:
Chayim Refael Friedman
2025-12-27 20:06:24 +02:00
parent a9da655c9b
commit fc1cb48d3b
3 changed files with 20 additions and 19 deletions
@@ -851,7 +851,7 @@ fn obligation_from_impl_clause() {
trait Trait<T> {}
impl Trait<&str> for S {}
struct O<T>;
struct O<T>(T);
impl<U, T: Trait<U>> O<T> {
fn foo(&self) -> U { loop {} }
}
@@ -1492,7 +1492,7 @@ fn dyn_trait_in_impl() {
trait Trait<T, U> {
fn foo(&self) -> (T, U);
}
struct S<T, U> {}
struct S<T, U>(T, U);
impl<T, U> S<T, U> {
fn bar(&self) -> &dyn Trait<T, U> { loop {} }
}
@@ -1506,16 +1506,16 @@ fn test(s: S<u32, i32>) {
}"#,
expect![[r#"
32..36 'self': &'? Self
102..106 'self': &'? S<T, U>
128..139 '{ loop {} }': &'? (dyn Trait<T, U> + 'static)
130..137 'loop {}': !
135..137 '{}': ()
175..179 'self': &'? Self
251..252 's': S<u32, i32>
267..289 '{ ...z(); }': ()
273..274 's': S<u32, i32>
273..280 's.bar()': &'? (dyn Trait<u32, i32> + 'static)
273..286 's.bar().baz()': (u32, i32)
106..110 'self': &'? S<T, U>
132..143 '{ loop {} }': &'? (dyn Trait<T, U> + 'static)
134..141 'loop {}': !
139..141 '{}': ()
179..183 'self': &'? Self
255..256 's': S<u32, i32>
271..293 '{ ...z(); }': ()
277..278 's': S<u32, i32>
277..284 's.bar()': &'? (dyn Trait<u32, i32> + 'static)
277..290 's.bar().baz()': (u32, i32)
"#]],
);
}
@@ -652,7 +652,7 @@ fn foo(u: U) { u.$0 }
fn test_method_completion_only_fitting_impls() {
check_no_kw(
r#"
struct A<T> {}
struct A<T>(T);
impl A<u32> {
fn the_method(&self) {}
}
@@ -662,6 +662,7 @@ fn the_other_method(&self) {}
fn foo(a: A<u32>) { a.$0 }
"#,
expect![[r#"
fd 0 u32
me the_method() fn(&self)
"#]],
)
@@ -339,14 +339,14 @@ pub fn quux<T: Foo>() -> T::Bar {
fn lt_hints() {
check_types(
r#"
struct S<'lt>;
struct S<'lt>(*mut &'lt ());
fn f<'a>() {
let x = S::<'static>;
let x = S::<'static>(loop {});
//^ S<'static>
let y = S::<'_>;
let y = S::<'_>(loop {});
//^ S<'_>
let z = S::<'a>;
let z = S::<'a>(loop {});
//^ S<'a>
}
@@ -632,10 +632,10 @@ fn main() {
fn multi_dyn_trait_bounds() {
check_types(
r#"
pub struct Vec<T> {}
pub struct Vec<T>(*mut T);
impl<T> Vec<T> {
pub fn new() -> Self { Vec {} }
pub fn new() -> Self { Vec(0 as *mut T) }
}
pub struct Box<T> {}