Unnamed repository; edit this file 'description' to name the repository.
Fix tests that relied on the default variance to be invariant
And now it changed to bivariant.
| -rw-r--r-- | crates/hir-ty/src/tests/traits.rs | 24 | ||||
| -rw-r--r-- | crates/ide-completion/src/completions/dot.rs | 3 | ||||
| -rw-r--r-- | crates/ide/src/inlay_hints/bind_pat.rs | 12 |
3 files changed, 20 insertions, 19 deletions
diff --git a/crates/hir-ty/src/tests/traits.rs b/crates/hir-ty/src/tests/traits.rs index a54c0a799d..38591f486e 100644 --- a/crates/hir-ty/src/tests/traits.rs +++ b/crates/hir-ty/src/tests/traits.rs @@ -851,7 +851,7 @@ struct S; 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) "#]], ); } diff --git a/crates/ide-completion/src/completions/dot.rs b/crates/ide-completion/src/completions/dot.rs index 18cfa53f8e..18c1992afa 100644 --- a/crates/ide-completion/src/completions/dot.rs +++ b/crates/ide-completion/src/completions/dot.rs @@ -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 @@ impl A<i32> { fn foo(a: A<u32>) { a.$0 } "#, expect![[r#" + fd 0 u32 me the_method() fn(&self) "#]], ) diff --git a/crates/ide/src/inlay_hints/bind_pat.rs b/crates/ide/src/inlay_hints/bind_pat.rs index de207c7821..547004687c 100644 --- a/crates/ide/src/inlay_hints/bind_pat.rs +++ b/crates/ide/src/inlay_hints/bind_pat.rs @@ -339,14 +339,14 @@ fn main(a: SliceIter<'_, Container>) { 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> {} |