Fix tests.

This commit is contained in:
Dawer 2021-06-16 03:23:04 +05:00
parent 5f2486e9a8
commit 0f6621fbfa
6 changed files with 355 additions and 336 deletions

View file

@ -45,7 +45,7 @@ fn render_raw_ptr_impl_ty() {
// FIXME: remove parens, they apper because there is an implicit Sized bound // FIXME: remove parens, they apper because there is an implicit Sized bound
check_types_source_code( check_types_source_code(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Unpin {} trait Unpin {}
fn foo() -> *const impl Unpin { loop {} } fn foo() -> *const impl Unpin { loop {} }
fn main() { fn main() {
@ -73,8 +73,7 @@ fn foo(foo: &dyn for<'a> Foo<'a>) {}
fn sized_bounds_apit() { fn sized_bounds_apit() {
check_types_source_code( check_types_source_code(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Foo {} trait Foo {}
trait Bar<T> {} trait Bar<T> {}
struct S<T>; struct S<T>;
@ -106,8 +105,7 @@ fn test(
fn sized_bounds_rpit() { fn sized_bounds_rpit() {
check_types_source_code( check_types_source_code(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Foo {} trait Foo {}
fn foo() -> impl Foo { loop {} } fn foo() -> impl Foo { loop {} }
fn test<T: Foo>() { fn test<T: Foo>() {
@ -122,8 +120,7 @@ fn test<T: Foo>() {
fn sized_bounds_impl_traits_in_fn_signature() { fn sized_bounds_impl_traits_in_fn_signature() {
check_types_source_code( check_types_source_code(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Foo {} trait Foo {}
fn test( fn test(
a: fn(impl Foo) -> impl Foo, a: fn(impl Foo) -> impl Foo,

View file

@ -922,7 +922,7 @@ fn test() { foo.call(); }
fn super_trait_impl_return_trait_method_resolution() { fn super_trait_impl_return_trait_method_resolution() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Base { trait Base {
fn foo(self) -> usize; fn foo(self) -> usize;
} }
@ -940,26 +940,26 @@ fn super_trait_impl_return_trait_method_resolution() {
} }
"#, "#,
expect![[r#" expect![[r#"
57..61 'self': Self 24..28 'self': Self
123..134 '{ loop {} }': ! 90..101 '{ loop {} }': !
125..132 'loop {}': ! 92..99 'loop {}': !
130..132 '{}': () 97..99 '{}': ()
161..172 '{ loop {} }': ! 128..139 '{ loop {} }': !
163..170 'loop {}': ! 130..137 'loop {}': !
168..170 '{}': () 135..137 '{}': ()
182..187 'base2': impl Base 149..154 'base2': impl Base
200..206 'super2': impl Super 167..173 'super2': impl Super
220..297 '{ ...o(); }': () 187..264 '{ ...o(); }': ()
226..231 'base1': fn base1() -> impl Base 193..198 'base1': fn base1() -> impl Base
226..233 'base1()': impl Base 193..200 'base1()': impl Base
226..239 'base1().foo()': usize 193..206 'base1().foo()': usize
245..251 'super1': fn super1() -> impl Super 212..218 'super1': fn super1() -> impl Super
245..253 'super1()': impl Super 212..220 'super1()': impl Super
245..259 'super1().foo()': usize 212..226 'super1().foo()': usize
265..270 'base2': impl Base 232..237 'base2': impl Base
265..276 'base2.foo()': usize 232..243 'base2.foo()': usize
282..288 'super2': impl Super 249..255 'super2': impl Super
282..294 'super2.foo()': usize 249..261 'super2.foo()': usize
"#]], "#]],
); );
} }
@ -1318,9 +1318,7 @@ impl<'a, T> IntoIterator for &'a [T] {
fn sized_blanket_impl() { fn sized_blanket_impl() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] //- minicore: sized
pub trait Sized {}
trait Foo { fn foo() -> u8; } trait Foo { fn foo() -> u8; }
impl<T: Sized> Foo for T {} impl<T: Sized> Foo for T {}
fn f<S: Sized, T, U: ?Sized>() { fn f<S: Sized, T, U: ?Sized>() {
@ -1332,12 +1330,12 @@ fn f<S: Sized, T, U: ?Sized>() {
} }
"#, "#,
expect![[r#" expect![[r#"
127..198 '{ ...foo; }': () 89..160 '{ ...foo; }': ()
133..141 'u32::foo': fn foo<u32>() -> u8 95..103 'u32::foo': fn foo<u32>() -> u8
147..153 'S::foo': fn foo<S>() -> u8 109..115 'S::foo': fn foo<S>() -> u8
159..165 'T::foo': fn foo<T>() -> u8 121..127 'T::foo': fn foo<T>() -> u8
171..177 'U::foo': {unknown} 133..139 'U::foo': {unknown}
183..195 '<[u32]>::foo': {unknown} 145..157 '<[u32]>::foo': {unknown}
"#]], "#]],
); );
} }

View file

@ -43,7 +43,7 @@ fn test() {
fn infer_desugar_async() { fn infer_desugar_async() {
check_types( check_types(
r#" r#"
//- minicore: future //- minicore: future, sized
async fn foo() -> u64 { 128 } async fn foo() -> u64 { 128 }
fn test() { fn test() {
@ -845,7 +845,7 @@ fn test<T: ApplyL>(t: T) {
fn argument_impl_trait() { fn argument_impl_trait() {
check_infer_with_mismatches( check_infer_with_mismatches(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait<T> { trait Trait<T> {
fn foo(&self) -> T; fn foo(&self) -> T;
fn foo2(&self) -> i64; fn foo2(&self) -> i64;
@ -867,34 +867,34 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u32>) {
z.foo2(); z.foo2();
}"#, }"#,
expect![[r#" expect![[r#"
62..66 'self': &Self 29..33 'self': &Self
87..91 'self': &Self 54..58 'self': &Self
110..111 'x': impl Trait<u16> 77..78 'x': impl Trait<u16>
130..132 '{}': () 97..99 '{}': ()
187..188 'x': impl Trait<u64> 154..155 'x': impl Trait<u64>
207..208 'y': &impl Trait<u32> 174..175 'y': &impl Trait<u32>
228..356 '{ ...2(); }': () 195..323 '{ ...2(); }': ()
234..235 'x': impl Trait<u64> 201..202 'x': impl Trait<u64>
241..242 'y': &impl Trait<u32> 208..209 'y': &impl Trait<u32>
252..253 'z': S<u16> 219..220 'z': S<u16>
256..257 'S': S<u16>(u16) -> S<u16> 223..224 'S': S<u16>(u16) -> S<u16>
256..260 'S(1)': S<u16> 223..227 'S(1)': S<u16>
258..259 '1': u16 225..226 '1': u16
266..269 'bar': fn bar(S<u16>) 233..236 'bar': fn bar(S<u16>)
266..272 'bar(z)': () 233..239 'bar(z)': ()
270..271 'z': S<u16> 237..238 'z': S<u16>
278..279 'x': impl Trait<u64> 245..246 'x': impl Trait<u64>
278..285 'x.foo()': u64 245..252 'x.foo()': u64
291..292 'y': &impl Trait<u32> 258..259 'y': &impl Trait<u32>
291..298 'y.foo()': u32 258..265 'y.foo()': u32
304..305 'z': S<u16> 271..272 'z': S<u16>
304..311 'z.foo()': u16 271..278 'z.foo()': u16
317..318 'x': impl Trait<u64> 284..285 'x': impl Trait<u64>
317..325 'x.foo2()': i64 284..292 'x.foo2()': i64
331..332 'y': &impl Trait<u32> 298..299 'y': &impl Trait<u32>
331..339 'y.foo2()': i64 298..306 'y.foo2()': i64
345..346 'z': S<u16> 312..313 'z': S<u16>
345..353 'z.foo2()': i64 312..320 'z.foo2()': i64
"#]], "#]],
); );
} }
@ -903,7 +903,7 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u32>) {
fn argument_impl_trait_type_args_1() { fn argument_impl_trait_type_args_1() {
check_infer_with_mismatches( check_infer_with_mismatches(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait {} trait Trait {}
trait Foo { trait Foo {
// this function has an implicit Self param, an explicit type param, // this function has an implicit Self param, an explicit type param,
@ -928,39 +928,39 @@ fn test() {
foo::<u32, i32>(S); // we should ignore the extraneous i32 foo::<u32, i32>(S); // we should ignore the extraneous i32
}"#, }"#,
expect![[r#" expect![[r#"
188..189 'x': impl Trait 155..156 'x': impl Trait
208..219 '{ loop {} }': T 175..186 '{ loop {} }': T
210..217 'loop {}': ! 177..184 'loop {}': !
215..217 '{}': () 182..184 '{}': ()
232..233 'x': impl Trait 199..200 'x': impl Trait
252..263 '{ loop {} }': T 219..230 '{ loop {} }': T
254..261 'loop {}': ! 221..228 'loop {}': !
259..261 '{}': () 226..228 '{}': ()
333..542 '{ ... i32 }': () 300..509 '{ ... i32 }': ()
339..347 'Foo::bar': fn bar<{unknown}, {unknown}>(S) -> {unknown} 306..314 'Foo::bar': fn bar<{unknown}, {unknown}>(S) -> {unknown}
339..350 'Foo::bar(S)': {unknown} 306..317 'Foo::bar(S)': {unknown}
348..349 'S': S 315..316 'S': S
356..371 '<F as Foo>::bar': fn bar<F, {unknown}>(S) -> {unknown} 323..338 '<F as Foo>::bar': fn bar<F, {unknown}>(S) -> {unknown}
356..374 '<F as ...bar(S)': {unknown} 323..341 '<F as ...bar(S)': {unknown}
372..373 'S': S 339..340 'S': S
380..386 'F::bar': fn bar<F, {unknown}>(S) -> {unknown} 347..353 'F::bar': fn bar<F, {unknown}>(S) -> {unknown}
380..389 'F::bar(S)': {unknown} 347..356 'F::bar(S)': {unknown}
387..388 'S': S 354..355 'S': S
395..410 'Foo::bar::<u32>': fn bar<{unknown}, u32>(S) -> u32 362..377 'Foo::bar::<u32>': fn bar<{unknown}, u32>(S) -> u32
395..413 'Foo::b...32>(S)': u32 362..380 'Foo::b...32>(S)': u32
411..412 'S': S 378..379 'S': S
419..441 '<F as ...:<u32>': fn bar<F, u32>(S) -> u32 386..408 '<F as ...:<u32>': fn bar<F, u32>(S) -> u32
419..444 '<F as ...32>(S)': u32 386..411 '<F as ...32>(S)': u32
442..443 'S': S 409..410 'S': S
451..454 'foo': fn foo<{unknown}>(S) -> {unknown} 418..421 'foo': fn foo<{unknown}>(S) -> {unknown}
451..457 'foo(S)': {unknown} 418..424 'foo(S)': {unknown}
455..456 'S': S 422..423 'S': S
463..473 'foo::<u32>': fn foo<u32>(S) -> u32 430..440 'foo::<u32>': fn foo<u32>(S) -> u32
463..476 'foo::<u32>(S)': u32 430..443 'foo::<u32>(S)': u32
474..475 'S': S 441..442 'S': S
482..497 'foo::<u32, i32>': fn foo<u32>(S) -> u32 449..464 'foo::<u32, i32>': fn foo<u32>(S) -> u32
482..500 'foo::<...32>(S)': u32 449..467 'foo::<...32>(S)': u32
498..499 'S': S 465..466 'S': S
"#]], "#]],
); );
} }
@ -969,7 +969,7 @@ fn test() {
fn argument_impl_trait_type_args_2() { fn argument_impl_trait_type_args_2() {
check_infer_with_mismatches( check_infer_with_mismatches(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait {} trait Trait {}
struct S; struct S;
impl Trait for S {} impl Trait for S {}
@ -985,24 +985,24 @@ fn test() {
F::<u32>.foo::<i32, u32>(S); // extraneous argument should be ignored F::<u32>.foo::<i32, u32>(S); // extraneous argument should be ignored
}"#, }"#,
expect![[r#" expect![[r#"
120..124 'self': F<T> 87..91 'self': F<T>
126..127 'x': impl Trait 93..94 'x': impl Trait
151..162 '{ loop {} }': (T, U) 118..129 '{ loop {} }': (T, U)
153..160 'loop {}': ! 120..127 'loop {}': !
158..160 '{}': () 125..127 '{}': ()
176..316 '{ ...ored }': () 143..283 '{ ...ored }': ()
182..183 'F': F<{unknown}> 149..150 'F': F<{unknown}>
182..190 'F.foo(S)': ({unknown}, {unknown}) 149..157 'F.foo(S)': ({unknown}, {unknown})
188..189 'S': S 155..156 'S': S
196..204 'F::<u32>': F<u32> 163..171 'F::<u32>': F<u32>
196..211 'F::<u32>.foo(S)': (u32, {unknown}) 163..178 'F::<u32>.foo(S)': (u32, {unknown})
209..210 'S': S 176..177 'S': S
217..225 'F::<u32>': F<u32> 184..192 'F::<u32>': F<u32>
217..239 'F::<u3...32>(S)': (u32, i32) 184..206 'F::<u3...32>(S)': (u32, i32)
204..205 'S': S
212..220 'F::<u32>': F<u32>
212..239 'F::<u3...32>(S)': (u32, i32)
237..238 'S': S 237..238 'S': S
245..253 'F::<u32>': F<u32>
245..272 'F::<u3...32>(S)': (u32, i32)
270..271 'S': S
"#]], "#]],
); );
} }
@ -1011,7 +1011,7 @@ fn test() {
fn argument_impl_trait_to_fn_pointer() { fn argument_impl_trait_to_fn_pointer() {
check_infer_with_mismatches( check_infer_with_mismatches(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait {} trait Trait {}
fn foo(x: impl Trait) { loop {} } fn foo(x: impl Trait) { loop {} }
struct S; struct S;
@ -1021,13 +1021,13 @@ fn test() {
let f: fn(S) -> () = foo; let f: fn(S) -> () = foo;
}"#, }"#,
expect![[r#" expect![[r#"
55..56 'x': impl Trait 22..23 'x': impl Trait
70..81 '{ loop {} }': () 37..48 '{ loop {} }': ()
72..79 'loop {}': ! 39..46 'loop {}': !
77..79 '{}': () 44..46 '{}': ()
123..156 '{ ...foo; }': () 90..123 '{ ...foo; }': ()
133..134 'f': fn(S) 100..101 'f': fn(S)
150..153 'foo': fn foo(S) 117..120 'foo': fn foo(S)
"#]], "#]],
); );
} }
@ -1036,7 +1036,7 @@ fn test() {
fn impl_trait() { fn impl_trait() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait<T> { trait Trait<T> {
fn foo(&self) -> T; fn foo(&self) -> T;
fn foo2(&self) -> i64; fn foo2(&self) -> i64;
@ -1055,29 +1055,29 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u64>) {
z.foo2(); z.foo2();
}"#, }"#,
expect![[r#" expect![[r#"
62..66 'self': &Self 29..33 'self': &Self
87..91 'self': &Self 54..58 'self': &Self
131..133 '{}': () 98..100 '{}': ()
143..144 'x': impl Trait<u64> 110..111 'x': impl Trait<u64>
163..164 'y': &impl Trait<u64> 130..131 'y': &impl Trait<u64>
184..301 '{ ...2(); }': () 151..268 '{ ...2(); }': ()
157..158 'x': impl Trait<u64>
164..165 'y': &impl Trait<u64>
175..176 'z': impl Trait<u64>
179..182 'bar': fn bar() -> impl Trait<u64>
179..184 'bar()': impl Trait<u64>
190..191 'x': impl Trait<u64> 190..191 'x': impl Trait<u64>
197..198 'y': &impl Trait<u64> 190..197 'x.foo()': u64
208..209 'z': impl Trait<u64> 203..204 'y': &impl Trait<u64>
212..215 'bar': fn bar() -> impl Trait<u64> 203..210 'y.foo()': u64
212..217 'bar()': impl Trait<u64> 216..217 'z': impl Trait<u64>
223..224 'x': impl Trait<u64> 216..223 'z.foo()': u64
223..230 'x.foo()': u64 229..230 'x': impl Trait<u64>
236..237 'y': &impl Trait<u64> 229..237 'x.foo2()': i64
236..243 'y.foo()': u64 243..244 'y': &impl Trait<u64>
249..250 'z': impl Trait<u64> 243..251 'y.foo2()': i64
249..256 'z.foo()': u64 257..258 'z': impl Trait<u64>
262..263 'x': impl Trait<u64> 257..265 'z.foo2()': i64
262..270 'x.foo2()': i64
276..277 'y': &impl Trait<u64>
276..284 'y.foo2()': i64
290..291 'z': impl Trait<u64>
290..298 'z.foo2()': i64
"#]], "#]],
); );
} }
@ -1087,7 +1087,7 @@ fn simple_return_pos_impl_trait() {
cov_mark::check!(lower_rpit); cov_mark::check!(lower_rpit);
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait<T> { trait Trait<T> {
fn foo(&self) -> T; fn foo(&self) -> T;
} }
@ -1098,16 +1098,16 @@ fn test() {
a.foo(); a.foo();
}"#, }"#,
expect![[r#" expect![[r#"
62..66 'self': &Self 29..33 'self': &Self
104..115 '{ loop {} }': ! 71..82 '{ loop {} }': !
106..113 'loop {}': ! 73..80 'loop {}': !
111..113 '{}': () 78..80 '{}': ()
127..162 '{ ...o(); }': () 94..129 '{ ...o(); }': ()
137..138 'a': impl Trait<u64> 104..105 'a': impl Trait<u64>
141..144 'bar': fn bar() -> impl Trait<u64> 108..111 'bar': fn bar() -> impl Trait<u64>
141..146 'bar()': impl Trait<u64> 108..113 'bar()': impl Trait<u64>
152..153 'a': impl Trait<u64> 119..120 'a': impl Trait<u64>
152..159 'a.foo()': u64 119..126 'a.foo()': u64
"#]], "#]],
); );
} }
@ -1116,7 +1116,7 @@ fn test() {
fn more_return_pos_impl_trait() { fn more_return_pos_impl_trait() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Iterator { trait Iterator {
type Item; type Item;
fn next(&mut self) -> Self::Item; fn next(&mut self) -> Self::Item;
@ -1136,37 +1136,37 @@ fn test() {
d.foo(); d.foo();
}"#, }"#,
expect![[r#" expect![[r#"
82..86 'self': &mut Self 49..53 'self': &mut Self
134..138 'self': &Self 101..105 'self': &Self
217..228 '{ loop {} }': ({unknown}, {unknown}) 184..195 '{ loop {} }': ({unknown}, {unknown})
219..226 'loop {}': ! 186..193 'loop {}': !
224..226 '{}': () 191..193 '{}': ()
239..240 't': T 206..207 't': T
301..312 '{ loop {} }': ({unknown}, {unknown}) 268..279 '{ loop {} }': ({unknown}, {unknown})
303..310 'loop {}': ! 270..277 'loop {}': !
308..310 '{}': () 275..277 '{}': ()
324..446 '{ ...o(); }': () 291..413 '{ ...o(); }': ()
334..340 '(a, b)': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) 301..307 '(a, b)': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
335..336 'a': impl Iterator<Item = impl Trait<u32>> 302..303 'a': impl Iterator<Item = impl Trait<u32>>
338..339 'b': impl Trait<u64> 305..306 'b': impl Trait<u64>
343..346 'bar': fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) 310..313 'bar': fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
343..348 'bar()': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) 310..315 'bar()': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
354..355 'a': impl Iterator<Item = impl Trait<u32>> 321..322 'a': impl Iterator<Item = impl Trait<u32>>
354..362 'a.next()': impl Trait<u32> 321..329 'a.next()': impl Trait<u32>
354..368 'a.next().foo()': u32 321..335 'a.next().foo()': u32
374..375 'b': impl Trait<u64> 341..342 'b': impl Trait<u64>
374..381 'b.foo()': u64 341..348 'b.foo()': u64
391..397 '(c, d)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 358..364 '(c, d)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
392..393 'c': impl Iterator<Item = impl Trait<u128>> 359..360 'c': impl Iterator<Item = impl Trait<u128>>
395..396 'd': impl Trait<u128> 362..363 'd': impl Trait<u128>
400..403 'baz': fn baz<u128>(u128) -> (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 367..370 'baz': fn baz<u128>(u128) -> (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
400..410 'baz(1u128)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 367..377 'baz(1u128)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
404..409 '1u128': u128 371..376 '1u128': u128
416..417 'c': impl Iterator<Item = impl Trait<u128>> 383..384 'c': impl Iterator<Item = impl Trait<u128>>
416..424 'c.next()': impl Trait<u128> 383..391 'c.next()': impl Trait<u128>
416..430 'c.next().foo()': u128 383..397 'c.next().foo()': u128
436..437 'd': impl Trait<u128> 403..404 'd': impl Trait<u128>
436..443 'd.foo()': u128 403..410 'd.foo()': u128
"#]], "#]],
); );
} }
@ -1175,7 +1175,7 @@ fn test() {
fn dyn_trait() { fn dyn_trait() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait<T> { trait Trait<T> {
fn foo(&self) -> T; fn foo(&self) -> T;
fn foo2(&self) -> i64; fn foo2(&self) -> i64;
@ -1194,29 +1194,29 @@ fn test(x: dyn Trait<u64>, y: &dyn Trait<u64>) {
z.foo2(); z.foo2();
}"#, }"#,
expect![[r#" expect![[r#"
62..66 'self': &Self 29..33 'self': &Self
87..91 'self': &Self 54..58 'self': &Self
130..132 '{}': () 97..99 '{}': ()
142..143 'x': dyn Trait<u64> 109..110 'x': dyn Trait<u64>
128..129 'y': &dyn Trait<u64>
148..265 '{ ...2(); }': ()
154..155 'x': dyn Trait<u64>
161..162 'y': &dyn Trait<u64> 161..162 'y': &dyn Trait<u64>
181..298 '{ ...2(); }': () 172..173 'z': dyn Trait<u64>
176..179 'bar': fn bar() -> dyn Trait<u64>
176..181 'bar()': dyn Trait<u64>
187..188 'x': dyn Trait<u64> 187..188 'x': dyn Trait<u64>
194..195 'y': &dyn Trait<u64> 187..194 'x.foo()': u64
205..206 'z': dyn Trait<u64> 200..201 'y': &dyn Trait<u64>
209..212 'bar': fn bar() -> dyn Trait<u64> 200..207 'y.foo()': u64
209..214 'bar()': dyn Trait<u64> 213..214 'z': dyn Trait<u64>
220..221 'x': dyn Trait<u64> 213..220 'z.foo()': u64
220..227 'x.foo()': u64 226..227 'x': dyn Trait<u64>
233..234 'y': &dyn Trait<u64> 226..234 'x.foo2()': i64
233..240 'y.foo()': u64 240..241 'y': &dyn Trait<u64>
246..247 'z': dyn Trait<u64> 240..248 'y.foo2()': i64
246..253 'z.foo()': u64 254..255 'z': dyn Trait<u64>
259..260 'x': dyn Trait<u64> 254..262 'z.foo2()': i64
259..267 'x.foo2()': i64
273..274 'y': &dyn Trait<u64>
273..281 'y.foo2()': i64
287..288 'z': dyn Trait<u64>
287..295 'z.foo2()': i64
"#]], "#]],
); );
} }
@ -1225,7 +1225,7 @@ fn test(x: dyn Trait<u64>, y: &dyn Trait<u64>) {
fn dyn_trait_in_impl() { fn dyn_trait_in_impl() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait<T, U> { trait Trait<T, U> {
fn foo(&self) -> (T, U); fn foo(&self) -> (T, U);
} }
@ -1242,17 +1242,17 @@ fn test(s: S<u32, i32>) {
s.bar().baz(); s.bar().baz();
}"#, }"#,
expect![[r#" expect![[r#"
65..69 'self': &Self 32..36 'self': &Self
135..139 'self': &S<T, U> 102..106 'self': &S<T, U>
161..172 '{ loop {} }': &dyn Trait<T, U> 128..139 '{ loop {} }': &dyn Trait<T, U>
163..170 'loop {}': ! 130..137 'loop {}': !
168..170 '{}': () 135..137 '{}': ()
208..212 'self': &Self 175..179 'self': &Self
284..285 's': S<u32, i32> 251..252 's': S<u32, i32>
300..322 '{ ...z(); }': () 267..289 '{ ...z(); }': ()
306..307 's': S<u32, i32> 273..274 's': S<u32, i32>
306..313 's.bar()': &dyn Trait<u32, i32> 273..280 's.bar()': &dyn Trait<u32, i32>
306..319 's.bar().baz()': (u32, i32) 273..286 's.bar().baz()': (u32, i32)
"#]], "#]],
); );
} }
@ -1261,7 +1261,7 @@ fn test(s: S<u32, i32>) {
fn dyn_trait_bare() { fn dyn_trait_bare() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait { trait Trait {
fn foo(&self) -> u64; fn foo(&self) -> u64;
} }
@ -1276,22 +1276,22 @@ fn test(x: Trait, y: &Trait) -> u64 {
z.foo(); z.foo();
}"#, }"#,
expect![[r#" expect![[r#"
59..63 'self': &Self 26..30 'self': &Self
93..95 '{}': () 60..62 '{}': ()
105..106 'x': dyn Trait 72..73 'x': dyn Trait
115..116 'y': &dyn Trait 82..83 'y': &dyn Trait
133..208 '{ ...o(); }': () 100..175 '{ ...o(); }': ()
106..107 'x': dyn Trait
113..114 'y': &dyn Trait
124..125 'z': dyn Trait
128..131 'bar': fn bar() -> dyn Trait
128..133 'bar()': dyn Trait
139..140 'x': dyn Trait 139..140 'x': dyn Trait
146..147 'y': &dyn Trait 139..146 'x.foo()': u64
157..158 'z': dyn Trait 152..153 'y': &dyn Trait
161..164 'bar': fn bar() -> dyn Trait 152..159 'y.foo()': u64
161..166 'bar()': dyn Trait 165..166 'z': dyn Trait
172..173 'x': dyn Trait 165..172 'z.foo()': u64
172..179 'x.foo()': u64
185..186 'y': &dyn Trait
185..192 'y.foo()': u64
198..199 'z': dyn Trait
198..205 'z.foo()': u64
"#]], "#]],
); );
} }
@ -1300,7 +1300,7 @@ fn test(x: Trait, y: &Trait) -> u64 {
fn weird_bounds() { fn weird_bounds() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait {} trait Trait {}
fn test( fn test(
a: impl Trait + 'lifetime, a: impl Trait + 'lifetime,
@ -1312,13 +1312,13 @@ fn test(
) {} ) {}
"#, "#,
expect![[r#" expect![[r#"
61..62 'a': impl Trait 28..29 'a': impl Trait
92..93 'b': impl Sized 59..60 'b': impl Sized
115..116 'c': impl Trait 82..83 'c': impl Trait
136..137 'd': impl Sized 103..104 'd': impl Sized
161..162 'e': impl ?Sized 128..129 'e': impl ?Sized
181..182 'f': impl Trait + ?Sized 148..149 'f': impl Trait + ?Sized
206..208 '{}': () 173..175 '{}': ()
"#]], "#]],
); );
} }
@ -1342,7 +1342,7 @@ fn test(x: (impl Trait + UnknownTrait)) {
fn assoc_type_bindings() { fn assoc_type_bindings() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait { trait Trait {
type Type; type Type;
} }
@ -1364,41 +1364,41 @@ fn test<T: Trait<Type = u32>>(x: T, y: impl Trait<Type = i64>) {
get2(S::<str>); get2(S::<str>);
}"#, }"#,
expect![[r#" expect![[r#"
82..83 't': T 49..50 't': T
110..112 '{}': () 77..79 '{}': ()
144..145 't': T 111..112 't': T
155..157 '{}': () 122..124 '{}': ()
187..188 't': T 154..155 't': T
198..201 '{t}': T 165..168 '{t}': T
199..200 't': T 166..167 't': T
289..290 'x': T 256..257 'x': T
295..296 'y': impl Trait<Type = i64> 262..263 'y': impl Trait<Type = i64>
322..430 '{ ...r>); }': () 289..397 '{ ...r>); }': ()
328..331 'get': fn get<T>(T) -> <T as Trait>::Type 295..298 'get': fn get<T>(T) -> <T as Trait>::Type
328..334 'get(x)': u32 295..301 'get(x)': u32
332..333 'x': T 299..300 'x': T
340..344 'get2': fn get2<u32, T>(T) -> u32 307..311 'get2': fn get2<u32, T>(T) -> u32
340..347 'get2(x)': u32 307..314 'get2(x)': u32
345..346 'x': T 312..313 'x': T
353..356 'get': fn get<impl Trait<Type = i64>>(impl Trait<Type = i64>) -> <impl Trait<Type = i64> as Trait>::Type 320..323 'get': fn get<impl Trait<Type = i64>>(impl Trait<Type = i64>) -> <impl Trait<Type = i64> as Trait>::Type
353..359 'get(y)': i64 320..326 'get(y)': i64
357..358 'y': impl Trait<Type = i64> 324..325 'y': impl Trait<Type = i64>
365..369 'get2': fn get2<i64, impl Trait<Type = i64>>(impl Trait<Type = i64>) -> i64 332..336 'get2': fn get2<i64, impl Trait<Type = i64>>(impl Trait<Type = i64>) -> i64
365..372 'get2(y)': i64 332..339 'get2(y)': i64
370..371 'y': impl Trait<Type = i64> 337..338 'y': impl Trait<Type = i64>
378..381 'get': fn get<S<u64>>(S<u64>) -> <S<u64> as Trait>::Type 345..348 'get': fn get<S<u64>>(S<u64>) -> <S<u64> as Trait>::Type
378..389 'get(set(S))': u64 345..356 'get(set(S))': u64
382..385 'set': fn set<S<u64>>(S<u64>) -> S<u64> 349..352 'set': fn set<S<u64>>(S<u64>) -> S<u64>
382..388 'set(S)': S<u64> 349..355 'set(S)': S<u64>
386..387 'S': S<u64> 353..354 'S': S<u64>
395..399 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64 362..366 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64
395..407 'get2(set(S))': u64 362..374 'get2(set(S))': u64
400..403 'set': fn set<S<u64>>(S<u64>) -> S<u64> 367..370 'set': fn set<S<u64>>(S<u64>) -> S<u64>
400..406 'set(S)': S<u64> 367..373 'set(S)': S<u64>
404..405 'S': S<u64> 371..372 'S': S<u64>
413..417 'get2': fn get2<str, S<str>>(S<str>) -> str 380..384 'get2': fn get2<str, S<str>>(S<str>) -> str
413..427 'get2(S::<str>)': str 380..394 'get2(S::<str>)': str
418..426 'S::<str>': S<str> 385..393 'S::<str>': S<str>
"#]], "#]],
); );
} }
@ -1507,7 +1507,7 @@ fn test<T: Trait1, U: Trait2>(x: T, y: U) {
fn super_trait_impl_trait_method_resolution() { fn super_trait_impl_trait_method_resolution() {
check_infer( check_infer(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
mod foo { mod foo {
trait SuperTrait { trait SuperTrait {
fn foo(&self) -> u32 {} fn foo(&self) -> u32 {}
@ -1519,12 +1519,12 @@ fn test(x: &impl Trait1) {
x.foo(); x.foo();
}"#, }"#,
expect![[r#" expect![[r#"
82..86 'self': &Self 49..53 'self': &Self
95..97 '{}': () 62..64 '{}': ()
148..149 'x': &impl Trait1 115..116 'x': &impl Trait1
165..181 '{ ...o(); }': () 132..148 '{ ...o(); }': ()
171..172 'x': &impl Trait1 138..139 'x': &impl Trait1
171..178 'x.foo()': u32 138..145 'x.foo()': u32
"#]], "#]],
); );
} }
@ -2312,7 +2312,7 @@ impl TokenStream for Rustc {
fn unify_impl_trait() { fn unify_impl_trait() {
check_infer_with_mismatches( check_infer_with_mismatches(
r#" r#"
#[lang = "sized"] trait Sized {} //- minicore: sized
trait Trait<T> {} trait Trait<T> {}
fn foo(x: impl Trait<u32>) { loop {} } fn foo(x: impl Trait<u32>) { loop {} }
@ -2330,37 +2330,37 @@ fn test() -> impl Trait<i32> {
S(default()) S(default())
}"#, }"#,
expect![[r#" expect![[r#"
59..60 'x': impl Trait<u32> 26..27 'x': impl Trait<u32>
79..90 '{ loop {} }': () 46..57 '{ loop {} }': ()
81..88 'loop {}': ! 48..55 'loop {}': !
86..88 '{}': () 53..55 '{}': ()
101..102 'x': impl Trait<T> 68..69 'x': impl Trait<T>
124..135 '{ loop {} }': T 91..102 '{ loop {} }': T
126..133 'loop {}': ! 93..100 'loop {}': !
131..133 '{}': () 98..100 '{}': ()
204..215 '{ loop {} }': T 171..182 '{ loop {} }': T
206..213 'loop {}': ! 173..180 'loop {}': !
211..213 '{}': () 178..180 '{}': ()
246..342 '{ ...t()) }': S<{unknown}> 213..309 '{ ...t()) }': S<{unknown}>
256..258 's1': S<u32> 223..225 's1': S<u32>
261..262 'S': S<u32>(u32) -> S<u32> 228..229 'S': S<u32>(u32) -> S<u32>
261..273 'S(default())': S<u32> 228..240 'S(default())': S<u32>
263..270 'default': fn default<u32>() -> u32 230..237 'default': fn default<u32>() -> u32
263..272 'default()': u32 230..239 'default()': u32
279..282 'foo': fn foo(S<u32>) 246..249 'foo': fn foo(S<u32>)
279..286 'foo(s1)': () 246..253 'foo(s1)': ()
283..285 's1': S<u32> 250..252 's1': S<u32>
296..297 'x': i32 263..264 'x': i32
305..308 'bar': fn bar<i32>(S<i32>) -> i32 272..275 'bar': fn bar<i32>(S<i32>) -> i32
305..322 'bar(S(...lt()))': i32 272..289 'bar(S(...lt()))': i32
309..310 'S': S<i32>(i32) -> S<i32> 276..277 'S': S<i32>(i32) -> S<i32>
309..321 'S(default())': S<i32> 276..288 'S(default())': S<i32>
311..318 'default': fn default<i32>() -> i32 278..285 'default': fn default<i32>() -> i32
311..320 'default()': i32 278..287 'default()': i32
328..329 'S': S<{unknown}>({unknown}) -> S<{unknown}> 295..296 'S': S<{unknown}>({unknown}) -> S<{unknown}>
328..340 'S(default())': S<{unknown}> 295..307 'S(default())': S<{unknown}>
330..337 'default': fn default<{unknown}>() -> {unknown} 297..304 'default': fn default<{unknown}>() -> {unknown}
330..339 'default()': {unknown} 297..306 'default()': {unknown}
"#]], "#]],
); );
} }

View file

@ -1189,7 +1189,9 @@ fn main() {
#[test] #[test]
fn hover_for_param_with_multiple_traits() { fn hover_for_param_with_multiple_traits() {
check( check(
r#"trait Deref { r#"
//- minicore: sized
trait Deref {
type Target: ?Sized; type Target: ?Sized;
} }
trait DerefMut { trait DerefMut {
@ -3380,17 +3382,17 @@ fn foo() {
fn hover_type_param() { fn hover_type_param() {
check( check(
r#" r#"
//- minicore: sized
struct Foo<T>(T); struct Foo<T>(T);
trait Copy {} trait Copy {}
trait Clone {} trait Clone {}
trait Sized {}
impl<T: Copy + Clone> Foo<T$0> where T: Sized {} impl<T: Copy + Clone> Foo<T$0> where T: Sized {}
"#, "#,
expect![[r#" expect![[r#"
*T* *T*
```rust ```rust
T: Copy + Clone + Sized T: Copy + Clone
``` ```
"#]], "#]],
); );
@ -3423,6 +3425,26 @@ impl<T: 'static> Foo<T$0> {}
); );
} }
#[test]
fn hover_type_param_not_sized() {
check(
r#"
//- minicore: sized
struct Foo<T>(T);
trait Copy {}
trait Clone {}
impl<T: Copy + Clone> Foo<T$0> where T: ?Sized {}
"#,
expect![[r#"
*T*
```rust
T: Copy + Clone + ?Sized
```
"#]],
);
}
#[test] #[test]
fn hover_const_param() { fn hover_const_param() {
check( check(

View file

@ -746,7 +746,8 @@ fn bar(worble: ()) ${0:-> ()} {
fn add_function_with_impl_trait_arg() { fn add_function_with_impl_trait_arg() {
check_assist( check_assist(
generate_function, generate_function,
r" r#"
#[lang = "sized"] trait Sized {}
trait Foo {} trait Foo {}
fn foo() -> impl Foo { fn foo() -> impl Foo {
todo!() todo!()
@ -754,8 +755,9 @@ fn foo() -> impl Foo {
fn baz() { fn baz() {
$0bar(foo()) $0bar(foo())
} }
", "#,
r" r#"
#[lang = "sized"] trait Sized {}
trait Foo {} trait Foo {}
fn foo() -> impl Foo { fn foo() -> impl Foo {
todo!() todo!()
@ -767,7 +769,7 @@ fn baz() {
fn bar(foo: impl Foo) ${0:-> ()} { fn bar(foo: impl Foo) ${0:-> ()} {
todo!() todo!()
} }
", "#,
) )
} }