1 use expect_test::expect;
3 use super::{check_infer, check_infer_with_mismatches, check_types};
9 //- /main.rs crate:main deps:core
12 impl Future for IntFuture {
22 //- /core.rs crate:core
23 #[prelude_import] use future::*;
25 #[lang = "future_trait"]
38 //- /main.rs crate:main deps:core
39 async fn foo() -> u64 {
49 //- /core.rs crate:core
50 #[prelude_import] use future::*;
52 #[lang = "future_trait"]
62 fn infer_desugar_async() {
65 //- /main.rs crate:main deps:core
66 async fn foo() -> u64 {
73 } //^ impl Future<Output = u64>
75 //- /core.rs crate:core
76 #[prelude_import] use future::*;
88 fn infer_async_block() {
91 //- /main.rs crate:main deps:core
95 // ^ impl Future<Output = i32>
99 let b = async {}.await;
103 let y = Option::None;
107 let _: Option<u64> = c.await;
109 // ^ impl Future<Output = Option<u64>>
112 enum Option<T> { None, Some(T) }
114 //- /core.rs crate:core
115 #[prelude_import] use future::*;
117 #[lang = "future_trait"]
131 //- /main.rs crate:main deps:core
133 let r: Result<i32, u64> = Result::Ok(1);
138 //- /core.rs crate:core
139 #[prelude_import] use ops::*;
147 #[prelude_import] use result::*;
154 impl<O, E> crate::ops::Try for Result<O, E> {
164 fn infer_for_loop() {
167 //- /main.rs crate:main deps:core,alloc
168 use alloc::collections::Vec;
178 //- /core.rs crate:core
179 #[prelude_import] use iter::*;
186 //- /alloc.rs crate:alloc deps:core
190 fn new() -> Self { Vec {} }
191 fn push(&mut self, t: T) { }
194 impl<T> IntoIterator for Vec<T> {
206 //- /main.rs crate:main deps:std
210 impl std::ops::Neg for Bar {
220 //- /std.rs crate:std
221 #[prelude_import] use ops::*;
236 //- /main.rs crate:main deps:std
240 impl std::ops::Not for Bar {
250 //- /std.rs crate:std
251 #[prelude_import] use ops::*;
263 fn infer_from_bound_1() {
268 impl<U> Trait<U> for S<U> {}
269 fn foo<T: Trait<u32>>(t: T) {}
278 104..143 '{ ...(s); }': ()
280 118..119 'S': S<u32>(u32) -> S<u32>
281 118..128 'S(unknown)': S<u32>
282 120..127 'unknown': u32
283 134..137 'foo': fn foo<S<u32>>(S<u32>)
284 134..140 'foo(s)': ()
291 fn infer_from_bound_2() {
296 impl<U> Trait<U> for S<U> {}
297 fn foo<U, T: Trait<U>>(t: T) -> U {}
306 110..162 '{ ...(s); }': ()
308 124..125 'S': S<u32>(u32) -> S<u32>
309 124..134 'S(unknown)': S<u32>
310 126..133 'unknown': u32
312 153..156 'foo': fn foo<u32, S<u32>>(S<u32>) -> u32
313 153..159 'foo(s)': u32
320 fn trait_default_method_self_bound_implements_trait() {
321 cov_mark::check!(trait_self_implements_self);
325 fn foo(&self) -> i64;
337 79..89 'self.foo()': i64
343 fn trait_default_method_self_bound_implements_super_trait() {
347 fn foo(&self) -> i64;
349 trait Trait: SuperTrait {
358 94..129 '{ ... }': ()
360 112..116 'self': &Self
361 112..122 'self.foo()': i64
367 fn infer_project_associated_type() {
374 impl Iterable for S { type Item = u32; }
375 fn test<T: Iterable>() {
376 let x: <S as Iterable>::Item = 1;
377 let y: <T as Iterable>::Item = no_matter;
378 let z: T::Item = no_matter;
379 let a: <T>::Item = no_matter;
383 108..261 '{ ...ter; }': ()
386 156..157 'y': Iterable::Item<T>
387 183..192 'no_matter': Iterable::Item<T>
388 202..203 'z': Iterable::Item<T>
389 215..224 'no_matter': Iterable::Item<T>
390 234..235 'a': Iterable::Item<T>
391 249..258 'no_matter': Iterable::Item<T>
397 fn infer_return_associated_type() {
404 impl Iterable for S { type Item = u32; }
405 fn foo1<T: Iterable>(t: T) -> T::Item {}
406 fn foo2<T: Iterable>(t: T) -> <T as Iterable>::Item {}
407 fn foo3<T: Iterable>(t: T) -> <T>::Item {}
421 234..300 '{ ...(S); }': ()
423 248..252 'foo1': fn foo1<S>(S) -> <S as Iterable>::Item
424 248..255 'foo1(S)': u32
427 269..273 'foo2': fn foo2<S>(S) -> <S as Iterable>::Item
428 269..276 'foo2(S)': u32
431 290..294 'foo3': fn foo3<S>(S) -> <S as Iterable>::Item
432 290..297 'foo3(S)': u32
439 fn infer_associated_type_bound() {
445 fn test<T: Iterable<Item=u32>>() {
446 let y: T::Item = unknown;
450 67..100 '{ ...own; }': ()
452 90..97 'unknown': u32
458 fn infer_const_body() {
461 const A: u32 = 1 + 1;
462 static B: u64 = { let x = 1; x };
468 38..54 '{ let ...1; x }': u64
477 fn tuple_struct_fields() {
488 37..86 '{ ... a.1 }': u64
490 51..52 'S': S(i32, u64) -> S
504 fn tuple_struct_with_fn() {
507 struct S(fn(u32) -> u64);
515 43..101 '{ ...0(2) }': u64
517 57..58 'S': S(fn(u32) -> u64) -> S
518 57..67 'S(|i| 2*i)': S
519 59..66 '|i| 2*i': |u32| -> u64
526 81..84 'a.0': fn(u32) -> u64
530 93..96 'a.0': fn(u32) -> u64
538 fn indexing_arrays() {
540 "fn main() { &mut [9][2]; }",
542 10..26 '{ &mut...[2]; }': ()
543 12..23 '&mut [9][2]': &mut {unknown}
544 17..20 '[9]': [i32; _]
545 17..23 '[9][2]': {unknown}
553 fn infer_ops_index() {
556 //- /main.rs crate:main deps:std
560 impl std::ops::Index<u32> for Bar {
570 //- /std.rs crate:std
571 #[prelude_import] use ops::*;
574 pub trait Index<Idx> {
583 fn infer_ops_index_int() {
586 //- /main.rs crate:main deps:std
590 impl std::ops::Index<u32> for Bar {
595 impl std::ops::Index<Range> for Bar {
606 //- /std.rs crate:std
607 #[prelude_import] use ops::*;
610 pub trait Index<Idx> {
619 fn infer_ops_index_autoderef() {
622 //- /main.rs crate:main deps:std
624 let a = &[1u32, 2, 3];
629 //- /std.rs crate:std
630 impl<T> ops::Index<u32> for [T] {
634 #[prelude_import] use ops::*;
637 pub trait Index<Idx> {
652 fn deref(&self) -> &Self::Target;
656 impl<T> Deref for Arc<T> {
662 fn foo(&self) -> u128 {}
673 fn deref_trait_with_inference_var() {
680 fn deref(&self) -> &Self::Target;
684 fn new_arc<T>() -> Arc<T> {}
685 impl<T> Deref for Arc<T> {
703 fn deref_trait_infinite_recursion() {
709 fn deref(&self) -> &Self::Target;
726 fn deref_trait_with_question_mark_size() {
732 fn deref(&self) -> &Self::Target;
736 impl<T> Deref for Arc<T> {
742 fn foo(&self) -> u128 {}
753 fn obligation_from_function_clause() {
759 impl Trait<u32> for S {}
761 fn foo<T: Trait<U>, U>(t: T) -> U {}
771 fn obligation_from_method_clause() {
778 impl Trait<isize> for S {}
782 fn foo<T: Trait<U>, U>(&self, t: T) -> U {}
793 fn obligation_from_self_method_clause() {
799 impl Trait<i64> for S {}
802 fn foo<U>(&self) -> U where Self: Trait<U> {}
813 fn obligation_from_impl_clause() {
819 impl Trait<&str> for S {}
822 impl<U, T: Trait<U>> O<T> {
823 fn foo(&self) -> U {}
834 fn generic_param_env_1() {
838 trait Trait { fn foo(self) -> u128; }
841 impl<T> Trait for T where T: Clone {}
842 fn test<T: Clone>(t: T) { t.foo(); }
849 fn generic_param_env_1_not_met() {
854 trait Trait { fn foo(self) -> u128; }
857 impl<T> Trait for T where T: Clone {}
858 fn test<T>(t: T) { t.foo(); }
865 fn generic_param_env_2() {
868 trait Trait { fn foo(self) -> u128; }
871 fn test<T: Trait>(t: T) { t.foo(); }
878 fn generic_param_env_2_not_met() {
881 trait Trait { fn foo(self) -> u128; }
884 fn test<T>(t: T) { t.foo(); }
891 fn generic_param_env_deref() {
899 impl<T> Deref for T where T: Trait {
902 fn test<T: Trait>(t: T) { (*t); }
909 fn associated_type_placeholder() {
910 // inside the generic function, the associated type gets normalized to a placeholder `ApplL::Out<T>` [https://rust-lang.github.io/rustc-guide/traits/associated-types.html#placeholder-associated-types].
917 pub struct RefMutL<T>;
919 impl<T> ApplyL for RefMutL<T> {
920 type Out = <T as ApplyL>::Out;
923 fn test<T: ApplyL>() {
924 let y: <RefMutL<T> as ApplyL>::Out = no_matter;
932 fn associated_type_placeholder_2() {
938 fn foo<T: ApplyL>(t: T) -> <T as ApplyL>::Out;
940 fn test<T: ApplyL>(t: T) {
949 fn argument_impl_trait() {
950 check_infer_with_mismatches(
954 fn foo2(&self) -> i64;
956 fn bar(x: impl Trait<u16>) {}
958 impl<T> Trait<T> for S<T> {}
960 fn test(x: impl Trait<u64>, y: &impl Trait<u32>) {
976 77..78 'x': impl Trait<u16>
978 154..155 'x': impl Trait<u64>
979 174..175 'y': &impl Trait<u32>
980 195..323 '{ ...2(); }': ()
981 201..202 'x': impl Trait<u64>
982 208..209 'y': &impl Trait<u32>
984 223..224 'S': S<u16>(u16) -> S<u16>
985 223..227 'S(1)': S<u16>
987 233..236 'bar': fn bar(S<u16>)
988 233..239 'bar(z)': ()
990 245..246 'x': impl Trait<u64>
991 245..252 'x.foo()': u64
992 258..259 'y': &impl Trait<u32>
993 258..265 'y.foo()': u32
995 271..278 'z.foo()': u16
996 284..285 'x': impl Trait<u64>
997 284..292 'x.foo2()': i64
998 298..299 'y': &impl Trait<u32>
999 298..306 'y.foo2()': i64
1000 312..313 'z': S<u16>
1001 312..320 'z.foo2()': i64
1007 fn argument_impl_trait_type_args_1() {
1008 check_infer_with_mismatches(
1012 // this function has an implicit Self param, an explicit type param,
1013 // and an implicit impl Trait param!
1014 fn bar<T>(x: impl Trait) -> T { loop {} }
1016 fn foo<T>(x: impl Trait) -> T { loop {} }
1027 <F as Foo>::bar::<u32>(S);
1031 foo::<u32, i32>(S); // we should ignore the extraneous i32
1035 155..156 'x': impl Trait
1036 175..186 '{ loop {} }': T
1037 177..184 'loop {}': !
1039 199..200 'x': impl Trait
1040 219..230 '{ loop {} }': T
1041 221..228 'loop {}': !
1043 300..509 '{ ... i32 }': ()
1044 306..314 'Foo::bar': fn bar<{unknown}, {unknown}>(S) -> {unknown}
1045 306..317 'Foo::bar(S)': {unknown}
1047 323..338 '<F as Foo>::bar': fn bar<F, {unknown}>(S) -> {unknown}
1048 323..341 '<F as ...bar(S)': {unknown}
1050 347..353 'F::bar': fn bar<F, {unknown}>(S) -> {unknown}
1051 347..356 'F::bar(S)': {unknown}
1053 362..377 'Foo::bar::<u32>': fn bar<{unknown}, u32>(S) -> u32
1054 362..380 'Foo::b...32>(S)': u32
1056 386..408 '<F as ...:<u32>': fn bar<F, u32>(S) -> u32
1057 386..411 '<F as ...32>(S)': u32
1059 418..421 'foo': fn foo<{unknown}>(S) -> {unknown}
1060 418..424 'foo(S)': {unknown}
1062 430..440 'foo::<u32>': fn foo<u32>(S) -> u32
1063 430..443 'foo::<u32>(S)': u32
1065 449..464 'foo::<u32, i32>': fn foo<u32>(S) -> u32
1066 449..467 'foo::<...32>(S)': u32
1073 fn argument_impl_trait_type_args_2() {
1074 check_infer_with_mismatches(
1081 fn foo<U>(self, x: impl Trait) -> (T, U) { loop {} }
1087 F::<u32>.foo::<i32>(S);
1088 F::<u32>.foo::<i32, u32>(S); // extraneous argument should be ignored
1093 93..94 'x': impl Trait
1094 118..129 '{ loop {} }': (T, U)
1095 120..127 'loop {}': !
1097 143..283 '{ ...ored }': ()
1098 149..150 'F': F<{unknown}>
1099 149..157 'F.foo(S)': ({unknown}, {unknown})
1101 163..171 'F::<u32>': F<u32>
1102 163..178 'F::<u32>.foo(S)': (u32, {unknown})
1104 184..192 'F::<u32>': F<u32>
1105 184..206 'F::<u3...32>(S)': (u32, i32)
1107 212..220 'F::<u32>': F<u32>
1108 212..239 'F::<u3...32>(S)': (u32, i32)
1115 fn argument_impl_trait_to_fn_pointer() {
1116 check_infer_with_mismatches(
1119 fn foo(x: impl Trait) { loop {} }
1124 let f: fn(S) -> () = foo;
1128 22..23 'x': impl Trait
1129 37..48 '{ loop {} }': ()
1132 90..123 '{ ...foo; }': ()
1134 117..120 'foo': fn foo(S)
1145 fn foo2(&self) -> i64;
1147 fn bar() -> impl Trait<u64> {}
1149 fn test(x: impl Trait<u64>, y: &impl Trait<u64>) {
1162 29..33 'self': &Self
1163 54..58 'self': &Self
1165 110..111 'x': impl Trait<u64>
1166 130..131 'y': &impl Trait<u64>
1167 151..268 '{ ...2(); }': ()
1168 157..158 'x': impl Trait<u64>
1169 164..165 'y': &impl Trait<u64>
1170 175..176 'z': impl Trait<u64>
1171 179..182 'bar': fn bar() -> impl Trait<u64>
1172 179..184 'bar()': impl Trait<u64>
1173 190..191 'x': impl Trait<u64>
1174 190..197 'x.foo()': u64
1175 203..204 'y': &impl Trait<u64>
1176 203..210 'y.foo()': u64
1177 216..217 'z': impl Trait<u64>
1178 216..223 'z.foo()': u64
1179 229..230 'x': impl Trait<u64>
1180 229..237 'x.foo2()': i64
1181 243..244 'y': &impl Trait<u64>
1182 243..251 'y.foo2()': i64
1183 257..258 'z': impl Trait<u64>
1184 257..265 'z.foo2()': i64
1190 fn simple_return_pos_impl_trait() {
1191 cov_mark::check!(lower_rpit);
1197 fn bar() -> impl Trait<u64> { loop {} }
1205 29..33 'self': &Self
1206 71..82 '{ loop {} }': !
1209 94..129 '{ ...o(); }': ()
1210 104..105 'a': impl Trait<u64>
1211 108..111 'bar': fn bar() -> impl Trait<u64>
1212 108..113 'bar()': impl Trait<u64>
1213 119..120 'a': impl Trait<u64>
1214 119..126 'a.foo()': u64
1220 fn more_return_pos_impl_trait() {
1225 fn next(&mut self) -> Self::Item;
1230 fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) { loop {} }
1231 fn baz<T>(t: T) -> (impl Iterator<Item = impl Trait<T>>, impl Trait<T>) { loop {} }
1237 let (c, d) = baz(1u128);
1243 49..53 'self': &mut Self
1244 101..105 'self': &Self
1245 184..195 '{ loop {} }': ({unknown}, {unknown})
1246 186..193 'loop {}': !
1249 268..279 '{ loop {} }': ({unknown}, {unknown})
1250 270..277 'loop {}': !
1252 291..413 '{ ...o(); }': ()
1253 301..307 '(a, b)': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1254 302..303 'a': impl Iterator<Item = impl Trait<u32>>
1255 305..306 'b': impl Trait<u64>
1256 310..313 'bar': fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1257 310..315 'bar()': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1258 321..322 'a': impl Iterator<Item = impl Trait<u32>>
1259 321..329 'a.next()': impl Trait<u32>
1260 321..335 'a.next().foo()': u32
1261 341..342 'b': impl Trait<u64>
1262 341..348 'b.foo()': u64
1263 358..364 '(c, d)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1264 359..360 'c': impl Iterator<Item = impl Trait<u128>>
1265 362..363 'd': impl Trait<u128>
1266 367..370 'baz': fn baz<u128>(u128) -> (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1267 367..377 'baz(1u128)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1268 371..376 '1u128': u128
1269 383..384 'c': impl Iterator<Item = impl Trait<u128>>
1270 383..391 'c.next()': impl Trait<u128>
1271 383..397 'c.next().foo()': u128
1272 403..404 'd': impl Trait<u128>
1273 403..410 'd.foo()': u128
1284 fn foo2(&self) -> i64;
1286 fn bar() -> dyn Trait<u64> {}
1288 fn test(x: dyn Trait<u64>, y: &dyn Trait<u64>) {
1301 29..33 'self': &Self
1302 54..58 'self': &Self
1304 109..110 'x': dyn Trait<u64>
1305 128..129 'y': &dyn Trait<u64>
1306 148..265 '{ ...2(); }': ()
1307 154..155 'x': dyn Trait<u64>
1308 161..162 'y': &dyn Trait<u64>
1309 172..173 'z': dyn Trait<u64>
1310 176..179 'bar': fn bar() -> dyn Trait<u64>
1311 176..181 'bar()': dyn Trait<u64>
1312 187..188 'x': dyn Trait<u64>
1313 187..194 'x.foo()': u64
1314 200..201 'y': &dyn Trait<u64>
1315 200..207 'y.foo()': u64
1316 213..214 'z': dyn Trait<u64>
1317 213..220 'z.foo()': u64
1318 226..227 'x': dyn Trait<u64>
1319 226..234 'x.foo2()': i64
1320 240..241 'y': &dyn Trait<u64>
1321 240..248 'y.foo2()': i64
1322 254..255 'z': dyn Trait<u64>
1323 254..262 'z.foo2()': i64
1329 fn dyn_trait_in_impl() {
1333 fn foo(&self) -> (T, U);
1336 impl<T, U> S<T, U> {
1337 fn bar(&self) -> &dyn Trait<T, U> { loop {} }
1339 trait Trait2<T, U> {
1340 fn baz(&self) -> (T, U);
1342 impl<T, U> Trait2<T, U> for dyn Trait<T, U> { }
1344 fn test(s: S<u32, i32>) {
1349 32..36 'self': &Self
1350 102..106 'self': &S<T, U>
1351 128..139 '{ loop {} }': &dyn Trait<T, U>
1352 130..137 'loop {}': !
1354 175..179 'self': &Self
1355 251..252 's': S<u32, i32>
1356 267..289 '{ ...z(); }': ()
1357 273..274 's': S<u32, i32>
1358 273..280 's.bar()': &dyn Trait<u32, i32>
1359 273..286 's.bar().baz()': (u32, i32)
1365 fn dyn_trait_bare() {
1369 fn foo(&self) -> u64;
1371 fn bar() -> Trait {}
1373 fn test(x: Trait, y: &Trait) -> u64 {
1383 26..30 'self': &Self
1385 72..73 'x': dyn Trait
1386 82..83 'y': &dyn Trait
1387 100..175 '{ ...o(); }': ()
1388 106..107 'x': dyn Trait
1389 113..114 'y': &dyn Trait
1390 124..125 'z': dyn Trait
1391 128..131 'bar': fn bar() -> dyn Trait
1392 128..133 'bar()': dyn Trait
1393 139..140 'x': dyn Trait
1394 139..146 'x.foo()': u64
1395 152..153 'y': &dyn Trait
1396 152..159 'y.foo()': u64
1397 165..166 'z': dyn Trait
1398 165..172 'z.foo()': u64
1408 fn test(a: impl Trait + 'lifetime, b: impl 'lifetime, c: impl (Trait), d: impl ('lifetime), e: impl ?Sized, f: impl Trait + ?Sized) {}
1411 23..24 'a': impl Trait
1413 69..70 'c': impl Trait
1415 107..108 'e': impl {error}
1416 123..124 'f': impl Trait + {error}
1424 fn error_bound_chalk() {
1428 fn foo(&self) -> u32 {}
1431 fn test(x: (impl Trait + UnknownTrait)) {
1439 fn assoc_type_bindings() {
1446 fn get<T: Trait>(t: T) -> <T as Trait>::Type {}
1447 fn get2<U, T: Trait<Type = U>>(t: T) -> U {}
1448 fn set<T: Trait<Type = u64>>(t: T) -> T {t}
1451 impl<T> Trait for S<T> { type Type = T; }
1453 fn test<T: Trait<Type = u32>>(x: T, y: impl Trait<Type = i64>) {
1472 262..263 'y': impl Trait<Type = i64>
1473 289..397 '{ ...r>); }': ()
1474 295..298 'get': fn get<T>(T) -> <T as Trait>::Type
1475 295..301 'get(x)': u32
1477 307..311 'get2': fn get2<u32, T>(T) -> u32
1478 307..314 'get2(x)': u32
1480 320..323 'get': fn get<impl Trait<Type = i64>>(impl Trait<Type = i64>) -> <impl Trait<Type = i64> as Trait>::Type
1481 320..326 'get(y)': i64
1482 324..325 'y': impl Trait<Type = i64>
1483 332..336 'get2': fn get2<i64, impl Trait<Type = i64>>(impl Trait<Type = i64>) -> i64
1484 332..339 'get2(y)': i64
1485 337..338 'y': impl Trait<Type = i64>
1486 345..348 'get': fn get<S<u64>>(S<u64>) -> <S<u64> as Trait>::Type
1487 345..356 'get(set(S))': u64
1488 349..352 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1489 349..355 'set(S)': S<u64>
1490 353..354 'S': S<u64>
1491 362..366 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64
1492 362..374 'get2(set(S))': u64
1493 367..370 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1494 367..373 'set(S)': S<u64>
1495 371..372 'S': S<u64>
1496 380..384 'get2': fn get2<str, S<str>>(S<str>) -> str
1497 380..394 'get2(S::<str>)': str
1498 385..393 'S::<str>': S<str>
1504 fn impl_trait_assoc_binding_projection_bug() {
1507 //- /main.rs crate:main deps:std
1508 pub trait Language {
1511 pub enum RustLanguage {}
1512 impl Language for RustLanguage {
1513 type Kind = SyntaxKind;
1515 struct SyntaxNode<L> {}
1516 fn foo() -> impl Iterator<Item = SyntaxNode<RustLanguage>> {}
1519 fn clone(&self) -> Self;
1522 fn api_walkthrough() {
1528 //- /std.rs crate:std
1529 #[prelude_import] use iter::*;
1531 trait IntoIterator {
1537 impl<T: Iterator> IntoIterator for T {
1538 type Item = <T as Iterator>::Item;
1546 fn projection_eq_within_chalk() {
1555 impl<T, U> Trait2<T> for U where U: Trait1<Type = T> {}
1557 fn test<T: Trait1<Type = u32>>(x: T) {
1564 169..185 '{ ...o(); }': ()
1566 175..182 'x.foo()': u32
1572 fn where_clause_trait_in_scope_for_method_resolution() {
1577 fn foo(&self) -> u32 {}
1581 fn test<T: foo::Trait>(x: T) {
1589 fn super_trait_method_resolution() {
1594 fn foo(&self) -> u32 {}
1597 trait Trait1: foo::SuperTrait {}
1598 trait Trait2 where Self: foo::SuperTrait {}
1600 fn test<T: Trait1, U: Trait2>(x: T, y: U) {
1606 49..53 'self': &Self
1610 193..222 '{ ...o(); }': ()
1612 199..206 'x.foo()': u32
1614 212..219 'y.foo()': u32
1620 fn super_trait_impl_trait_method_resolution() {
1625 fn foo(&self) -> u32 {}
1628 trait Trait1: foo::SuperTrait {}
1630 fn test(x: &impl Trait1) {
1635 49..53 'self': &Self
1637 115..116 'x': &impl Trait1
1638 132..148 '{ ...o(); }': ()
1639 138..139 'x': &impl Trait1
1640 138..145 'x.foo()': u32
1646 fn super_trait_cycle() {
1647 // This just needs to not crash
1653 fn test<T: A>(x: T) {
1659 49..65 '{ ...o(); }': ()
1661 55..62 'x.foo()': {unknown}
1667 fn super_trait_assoc_type_bounds() {
1670 trait SuperTrait { type Type; }
1671 trait Trait where Self: SuperTrait {}
1673 fn get2<U, T: Trait<Type = U>>(t: T) -> U {}
1674 fn set<T: Trait<Type = u64>>(t: T) -> T {t}
1677 impl<T> SuperTrait for S<T> { type Type = T; }
1678 impl<T> Trait for S<T> {}
1690 258..279 '{ ...S)); }': ()
1691 264..268 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64
1692 264..276 'get2(set(S))': u64
1693 269..272 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1694 269..275 'set(S)': S<u64>
1695 273..274 'S': S<u64>
1704 trait FnOnce<Args> {
1707 fn call_once(self, args: Args) -> <Self as FnOnce<Args>>::Output;
1710 fn test<F: FnOnce(u32, u64) -> u128>(f: F) {
1711 f.call_once((1, 2));
1718 155..183 '{ ...2)); }': ()
1720 161..180 'f.call...1, 2))': u128
1721 173..179 '(1, 2)': (u32, u64)
1729 fn fn_ptr_and_item() {
1733 trait FnOnce<Args> {
1736 fn call_once(self, args: Args) -> Self::Output;
1745 impl<A1, R, F: FnOnce(A1) -> R> Foo<(A1, R)> for Bar<F> {
1746 fn foo(&self) -> (A1, R) {}
1749 enum Opt<T> { None, Some(T) }
1751 fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Opt<U> {}
1755 let bar: Bar<fn(u8) -> u32>;
1759 let f: fn(u8) -> u32;
1766 139..143 'self': &Self
1767 243..247 'self': &Bar<F>
1769 346..350 'self': Opt<T>
1772 384..500 '{ ...(f); }': ()
1773 394..397 'bar': Bar<fn(u8) -> u32>
1774 423..426 'bar': Bar<fn(u8) -> u32>
1775 423..432 'bar.foo()': (u8, u32)
1776 443..446 'opt': Opt<u8>
1777 465..466 'f': fn(u8) -> u32
1778 487..490 'opt': Opt<u8>
1779 487..497 'opt.map(f)': Opt<u32>
1780 495..496 'f': fn(u8) -> u32
1786 fn fn_trait_deref_with_ty_default() {
1793 fn deref(&self) -> &Self::Target;
1797 trait FnOnce<Args> {
1800 fn call_once(self, args: Args) -> Self::Output;
1806 fn foo(&self) -> usize {}
1809 struct Lazy<T, F = fn() -> T>(F);
1811 impl<T, F> Lazy<T, F> {
1812 pub fn new(f: F) -> Lazy<T, F> {}
1815 impl<T, F: FnOnce() -> T> Deref for Lazy<T, F> {
1820 let lazy1: Lazy<Foo, _> = Lazy::new(|| Foo);
1821 let r1 = lazy1.foo();
1823 fn make_foo_fn() -> Foo {}
1824 let make_foo_fn_ptr: fn() -> Foo = make_foo_fn;
1825 let lazy2: Lazy<Foo, _> = Lazy::new(make_foo_fn_ptr);
1826 let r2 = lazy2.foo();
1830 64..68 'self': &Self
1831 165..169 'self': Self
1832 171..175 'args': Args
1833 239..243 'self': &Foo
1837 443..689 '{ ...o(); }': ()
1838 453..458 'lazy1': Lazy<Foo, || -> Foo>
1839 475..484 'Lazy::new': fn new<Foo, || -> Foo>(|| -> Foo) -> Lazy<Foo, || -> Foo>
1840 475..492 'Lazy::...| Foo)': Lazy<Foo, || -> Foo>
1841 485..491 '|| Foo': || -> Foo
1843 502..504 'r1': usize
1844 507..512 'lazy1': Lazy<Foo, || -> Foo>
1845 507..518 'lazy1.foo()': usize
1846 560..575 'make_foo_fn_ptr': fn() -> Foo
1847 591..602 'make_foo_fn': fn make_foo_fn() -> Foo
1848 612..617 'lazy2': Lazy<Foo, fn() -> Foo>
1849 634..643 'Lazy::new': fn new<Foo, fn() -> Foo>(fn() -> Foo) -> Lazy<Foo, fn() -> Foo>
1850 634..660 'Lazy::...n_ptr)': Lazy<Foo, fn() -> Foo>
1851 644..659 'make_foo_fn_ptr': fn() -> Foo
1852 670..672 'r2': usize
1853 675..680 'lazy2': Lazy<Foo, fn() -> Foo>
1854 675..686 'lazy2.foo()': usize
1865 trait FnOnce<Args> {
1869 enum Option<T> { Some(T), None }
1871 fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {}
1875 let x = Option::Some(1u32);
1878 let y: Option<i64> = x.map(|_v| 1);
1882 147..151 'self': Option<T>
1885 188..307 '{ ... 1); }': ()
1886 198..199 'x': Option<u32>
1887 202..214 'Option::Some': Some<u32>(u32) -> Option<u32>
1888 202..220 'Option...(1u32)': Option<u32>
1889 215..219 '1u32': u32
1890 226..227 'x': Option<u32>
1891 226..242 'x.map(...v + 1)': Option<u32>
1892 232..241 '|v| v + 1': |u32| -> u32
1895 236..241 'v + 1': u32
1897 248..249 'x': Option<u32>
1898 248..264 'x.map(... 1u64)': Option<u64>
1899 254..263 '|_v| 1u64': |u32| -> u64
1901 259..263 '1u64': u64
1902 274..275 'y': Option<i64>
1903 291..292 'x': Option<u32>
1904 291..304 'x.map(|_v| 1)': Option<i64>
1905 297..303 '|_v| 1': |u32| -> i64
1916 trait FnOnce<Args> {
1920 fn test<F: FnOnce(u32) -> u64>(f: F) {
1924 let h = |v| 1u128 + v;
1929 78..154 '{ ...+ v; }': ()
1931 84..88 'f(1)': {unknown}
1933 98..99 'g': |u64| -> i32
1934 102..111 '|v| v + 1': |u64| -> i32
1937 106..111 'v + 1': i32
1939 117..118 'g': |u64| -> i32
1940 117..124 'g(1u64)': i32
1941 119..123 '1u64': u64
1942 134..135 'h': |u128| -> u128
1943 138..151 '|v| 1u128 + v': |u128| -> u128
1945 142..147 '1u128': u128
1946 142..151 '1u128 + v': u128
1953 fn closure_as_argument_inference_order() {
1957 trait FnOnce<Args> {
1961 fn foo1<T, U, F: FnOnce(T) -> U>(x: T, f: F) -> U {}
1962 fn foo2<T, U, F: FnOnce(T) -> U>(f: F, x: T) -> U {}
1966 fn method(self) -> u64;
1968 fn foo1<T, U, F: FnOnce(T) -> U>(self, x: T, f: F) -> U {}
1969 fn foo2<T, U, F: FnOnce(T) -> U>(self, f: F, x: T) -> U {}
1973 let x1 = foo1(S, |s| s.method());
1974 let x2 = foo2(|s| s.method(), S);
1975 let x3 = S.foo1(S, |s| s.method());
1976 let x4 = S.foo2(|s| s.method(), S);
1995 355..514 '{ ... S); }': ()
1997 370..374 'foo1': fn foo1<S, u64, |S| -> u64>(S, |S| -> u64) -> u64
1998 370..393 'foo1(S...hod())': u64
2000 378..392 '|s| s.method()': |S| -> u64
2003 382..392 's.method()': u64
2005 408..412 'foo2': fn foo2<S, u64, |S| -> u64>(|S| -> u64, S) -> u64
2006 408..431 'foo2(|...(), S)': u64
2007 413..427 '|s| s.method()': |S| -> u64
2010 417..427 's.method()': u64
2014 446..471 'S.foo1...hod())': u64
2016 456..470 '|s| s.method()': |S| -> u64
2019 460..470 's.method()': u64
2022 486..511 'S.foo2...(), S)': u64
2023 493..507 '|s| s.method()': |S| -> u64
2026 497..507 's.method()': u64
2033 fn fn_item_fn_trait() {
2037 trait FnOnce<Args> {
2045 fn takes_closure<U, F: FnOnce() -> U>(f: F) -> U { f() }
2049 } //^^^^^^^^^^^^^^^^^^ S
2055 fn unselected_projection_in_trait_env_1() {
2064 fn foo(&self) -> u32;
2067 fn test<T: Trait>() where T::Item: Trait2 {
2068 let x: T::Item = no_matter;
2076 fn unselected_projection_in_trait_env_2() {
2084 fn foo(&self) -> u32;
2087 fn test<T, U>() where T::Item: Trait2, T: Trait<U::Item>, U: Trait<()> {
2088 let x: T::Item = no_matter;
2096 fn unselected_projection_on_impl_self() {
2103 fn f(&self, x: Self::Item);
2110 fn f(&self, x: Self::Item) { let y = x; }
2117 fn f(&self, x: <Self>::Item) { let y = x; }
2121 40..44 'self': &Self
2122 46..47 'x': Trait::Item<Self>
2125 147..161 '{ let y = x; }': ()
2128 228..232 'self': &S2
2130 251..265 '{ let y = x; }': ()
2138 fn unselected_projection_on_trait_self() {
2144 fn f(&self) -> Self::Item { loop {} }
2160 fn unselected_projection_chalk_fold() {
2164 trait Fold<I: Interner, TI = I> {
2168 struct Ty<I: Interner> {}
2169 impl<I: Interner, TI: Interner> Fold<I, TI> for Ty<I> {
2170 type Result = Ty<TI>;
2173 fn fold<I: Interner, T>(interner: &I, t: T) -> T::Result
2180 fn foo<I: Interner>(interner: &I, t: Ty<I>) {
2188 fn trait_impl_self_ty() {
2197 impl Trait<Self> for S {}
2207 fn trait_impl_self_ty_cycle() {
2216 impl Trait for S<Self> {}
2226 fn unselected_projection_in_trait_env_cycle_1() {
2227 // this is a legitimate cycle
2236 fn test<T: Trait>() where T: Trait2<T::Item> {
2237 let x: T::Item = no_matter;
2244 fn unselected_projection_in_trait_env_cycle_2() {
2245 // this is a legitimate cycle
2253 fn test<T, U>() where T: Trait<U::Item>, U: Trait<T::Item> {
2254 let x: T::Item = no_matter;
2261 fn inline_assoc_type_bounds_1() {
2267 trait OtherTrait<T> {
2271 // workaround for Chalk assoc type normalization problems
2273 impl<T: Iterator> Iterator for S<T> {
2274 type Item = <T as Iterator>::Item;
2277 fn test<I: Iterator<Item: OtherTrait<u32>>>() {
2278 let x: <S<I> as Iterator>::Item;
2286 fn inline_assoc_type_bounds_2() {
2293 fn test<I: Iterator<Item: Iterator<Item = u32>>>() {
2294 let x: <<I as Iterator>::Item as Iterator>::Item;
2302 fn proc_macro_server_types() {
2305 macro_rules! with_api {
2306 ($S:ident, $self:ident, $m:ident) => {
2309 fn new() -> $S::TokenStream;
2316 macro_rules! associated_item {
2317 (type TokenStream) =>
2318 (type TokenStream: 'static;);
2320 (type Group: 'static;);
2321 ($($item:tt)*) => ($($item)*;)
2323 macro_rules! declare_server_traits {
2325 $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)*
2328 $(associated_item!(type $name);)*
2331 $(pub trait $name: Types {
2332 $(associated_item!(fn $method($($arg: $arg_ty),*) $(-> $ret_ty)?);)*
2335 pub trait Server: Types $(+ $name)* {}
2336 impl<S: Types $(+ $name)*> Server for S {}
2340 with_api!(Self, self_, declare_server_traits);
2344 impl Types for Rustc {
2345 type TokenStream = T;
2349 fn make<T>() -> T { loop {} }
2350 impl TokenStream for Rustc {
2351 fn new() -> Self::TokenStream {
2352 let group: Self::Group = make();
2358 1061..1072 '{ loop {} }': T
2359 1063..1070 'loop {}': !
2361 1136..1199 '{ ... }': T
2362 1150..1155 'group': G
2363 1171..1175 'make': fn make<G>() -> G
2364 1171..1177 'make()': G
2365 1187..1191 'make': fn make<T>() -> T
2366 1187..1193 'make()': T
2372 fn unify_impl_trait() {
2373 check_infer_with_mismatches(
2377 fn foo(x: impl Trait<u32>) { loop {} }
2378 fn bar<T>(x: impl Trait<T>) -> T { loop {} }
2381 impl<T> Trait<T> for S<T> {}
2383 fn default<T>() -> T { loop {} }
2385 fn test() -> impl Trait<i32> {
2386 let s1 = S(default());
2388 let x: i32 = bar(S(default()));
2393 26..27 'x': impl Trait<u32>
2394 46..57 '{ loop {} }': ()
2397 68..69 'x': impl Trait<T>
2398 91..102 '{ loop {} }': T
2399 93..100 'loop {}': !
2401 171..182 '{ loop {} }': T
2402 173..180 'loop {}': !
2404 213..309 '{ ...t()) }': S<{unknown}>
2405 223..225 's1': S<u32>
2406 228..229 'S': S<u32>(u32) -> S<u32>
2407 228..240 'S(default())': S<u32>
2408 230..237 'default': fn default<u32>() -> u32
2409 230..239 'default()': u32
2410 246..249 'foo': fn foo(S<u32>)
2411 246..253 'foo(s1)': ()
2412 250..252 's1': S<u32>
2414 272..275 'bar': fn bar<i32>(S<i32>) -> i32
2415 272..289 'bar(S(...lt()))': i32
2416 276..277 'S': S<i32>(i32) -> S<i32>
2417 276..288 'S(default())': S<i32>
2418 278..285 'default': fn default<i32>() -> i32
2419 278..287 'default()': i32
2420 295..296 'S': S<{unknown}>({unknown}) -> S<{unknown}>
2421 295..307 'S(default())': S<{unknown}>
2422 297..304 'default': fn default<{unknown}>() -> {unknown}
2423 297..306 'default()': {unknown}
2429 fn assoc_types_from_bounds() {
2434 trait FnOnce<Args> {
2453 f::<(), _>(|z| { z; });
2459 193..224 '{ ... }); }': ()
2460 199..209 'f::<(), _>': fn f<(), |&()| -> ()>(|&()| -> ())
2461 199..221 'f::<()... z; })': ()
2462 210..220 '|z| { z; }': |&()| -> ()
2464 214..220 '{ z; }': ()
2471 fn associated_type_bound() {
2475 type Item: OtherTrait<u32>;
2477 pub trait OtherTrait<T> {
2481 // this is just a workaround for chalk#234
2483 impl<T: Trait> Trait for S<T> {
2484 type Item = <T as Trait>::Item;
2487 fn test<T: Trait>() {
2488 let y: <S<T> as Trait>::Item = no_matter;
2496 fn dyn_trait_through_chalk() {
2504 impl<T> Deref for Box<T> {
2511 fn test(x: Box<dyn Trait>) {
2519 fn string_to_owned() {
2525 fn to_owned(&self) -> Self::Owned;
2527 impl ToOwned for str {
2528 type Owned = String;
2538 fn iterator_chain() {
2543 trait FnOnce<Args> {
2547 trait FnMut<Args>: FnOnce<Args> { }
2549 enum Option<T> { Some(T), None }
2552 pub trait Iterator {
2555 fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
2557 F: FnMut(Self::Item) -> Option<B>,
2560 fn for_each<F>(self, f: F)
2562 F: FnMut(Self::Item),
2566 pub trait IntoIterator {
2568 type IntoIter: Iterator<Item = Self::Item>;
2569 fn into_iter(self) -> Self::IntoIter;
2572 pub struct FilterMap<I, F> { }
2573 impl<B, I: Iterator, F> Iterator for FilterMap<I, F>
2575 F: FnMut(I::Item) -> Option<B>,
2580 #[stable(feature = "rust1", since = "1.0.0")]
2581 impl<I: Iterator> IntoIterator for I {
2582 type Item = I::Item;
2585 fn into_iter(self) -> I {
2592 fn new() -> Self { loop {} }
2595 impl<T> IntoIterator for Vec<T> {
2597 type IntoIter = IntoIter<T>;
2600 pub struct IntoIter<T> { }
2601 impl<T> Iterator for IntoIter<T> {
2606 Vec::<i32>::new().into_iter()
2607 .filter_map(|x| if x > 0 { Some(x as u32) } else { None })
2608 .for_each(|y| { y; });
2612 226..230 'self': Self
2614 317..328 '{ loop {} }': FilterMap<Self, F>
2615 319..326 'loop {}': !
2617 349..353 'self': Self
2619 405..416 '{ loop {} }': ()
2620 407..414 'loop {}': !
2622 525..529 'self': Self
2624 865..885 '{ ... }': I
2626 944..955 '{ loop {} }': Vec<T>
2627 946..953 'loop {}': !
2629 1142..1269 '{ ... }); }': ()
2630 1148..1163 'Vec::<i32>::new': fn new<i32>() -> Vec<i32>
2631 1148..1165 'Vec::<...:new()': Vec<i32>
2632 1148..1177 'Vec::<...iter()': IntoIter<i32>
2633 1148..1240 'Vec::<...one })': FilterMap<IntoIter<i32>, |i32| -> Option<u32>>
2634 1148..1266 'Vec::<... y; })': ()
2635 1194..1239 '|x| if...None }': |i32| -> Option<u32>
2637 1198..1239 'if x >...None }': Option<u32>
2639 1201..1206 'x > 0': bool
2641 1207..1225 '{ Some...u32) }': Option<u32>
2642 1209..1213 'Some': Some<u32>(u32) -> Option<u32>
2643 1209..1223 'Some(x as u32)': Option<u32>
2645 1214..1222 'x as u32': u32
2646 1231..1239 '{ None }': Option<u32>
2647 1233..1237 'None': Option<u32>
2648 1255..1265 '|y| { y; }': |u32| -> ()
2650 1259..1265 '{ y; }': ()
2673 fn foo() -> Self::Output;
2677 type Output = T::OutputA;
2678 fn foo() -> Self::Output { loop {} }
2689 fn trait_object_no_coercion() {
2690 check_infer_with_mismatches(
2694 fn foo(x: &dyn Foo) {}
2696 fn test(x: &dyn Foo) {
2701 21..22 'x': &dyn Foo
2703 46..47 'x': &dyn Foo
2704 59..74 '{ foo(x); }': ()
2705 65..68 'foo': fn foo(&dyn Foo)
2707 69..70 'x': &dyn Foo
2714 check_infer_with_mismatches(
2720 impl Copy for IsCopy {}
2723 trait Test { fn test(&self) -> bool; }
2724 impl<T: Copy> Test for T {}
2729 (IsCopy, IsCopy).test();
2730 (IsCopy, NotCopy).test();
2734 110..114 'self': &Self
2735 166..267 '{ ...t(); }': ()
2736 172..178 'IsCopy': IsCopy
2737 172..185 'IsCopy.test()': bool
2738 191..198 'NotCopy': NotCopy
2739 191..205 'NotCopy.test()': {unknown}
2740 211..227 '(IsCop...sCopy)': (IsCopy, IsCopy)
2741 211..234 '(IsCop...test()': bool
2742 212..218 'IsCopy': IsCopy
2743 220..226 'IsCopy': IsCopy
2744 240..257 '(IsCop...tCopy)': (IsCopy, NotCopy)
2745 240..264 '(IsCop...test()': {unknown}
2746 241..247 'IsCopy': IsCopy
2747 249..256 'NotCopy': NotCopy
2753 fn builtin_fn_def_copy() {
2754 check_infer_with_mismatches(
2760 fn bar<T: Copy>(T) -> T {}
2761 struct Struct(usize);
2762 enum Enum { Variant(usize) }
2764 trait Test { fn test(&self) -> bool; }
2765 impl<T: Copy> Test for T {}
2771 Enum::Variant.test();
2776 60..61 'T': {unknown}
2778 68..70: expected T, got ()
2779 145..149 'self': &Self
2780 201..281 '{ ...t(); }': ()
2781 207..210 'foo': fn foo()
2782 207..217 'foo.test()': bool
2783 223..226 'bar': fn bar<{unknown}>({unknown}) -> {unknown}
2784 223..233 'bar.test()': bool
2785 239..245 'Struct': Struct(usize) -> Struct
2786 239..252 'Struct.test()': bool
2787 258..271 'Enum::Variant': Variant(usize) -> Enum
2788 258..278 'Enum::...test()': bool
2794 fn builtin_fn_ptr_copy() {
2795 check_infer_with_mismatches(
2800 trait Test { fn test(&self) -> bool; }
2801 impl<T: Copy> Test for T {}
2803 fn test(f1: fn(), f2: fn(usize) -> u8, f3: fn(u8, u8) -> &u8) {
2810 54..58 'self': &Self
2812 118..120 'f2': fn(usize) -> u8
2813 139..141 'f3': fn(u8, u8) -> &u8
2814 162..210 '{ ...t(); }': ()
2816 168..177 'f1.test()': bool
2817 183..185 'f2': fn(usize) -> u8
2818 183..192 'f2.test()': bool
2819 198..200 'f3': fn(u8, u8) -> &u8
2820 198..207 'f3.test()': bool
2826 fn builtin_sized() {
2827 check_infer_with_mismatches(
2832 trait Test { fn test(&self) -> bool; }
2833 impl<T: Sized> Test for T {}
2837 (*"foo").test(); // not Sized
2839 (1u8, *"foo").test(); // not Sized
2843 56..60 'self': &Self
2844 113..228 '{ ...ized }': ()
2846 119..129 '1u8.test()': bool
2847 135..150 '(*"foo").test()': {unknown}
2848 136..142 '*"foo"': str
2849 137..142 '"foo"': &str
2850 169..179 '(1u8, 1u8)': (u8, u8)
2851 169..186 '(1u8, ...test()': bool
2854 192..205 '(1u8, *"foo")': (u8, str)
2855 192..212 '(1u8, ...test()': {unknown}
2857 198..204 '*"foo"': str
2858 199..204 '"foo"': &str
2864 fn integer_range_iterate() {
2867 //- /main.rs crate:main deps:core
2869 for x in 0..100 { x; }
2872 //- /core.rs crate:core
2874 pub struct Range<Idx> {
2881 pub trait Iterator {
2885 pub trait IntoIterator {
2887 type IntoIter: Iterator<Item = Self::Item>;
2890 impl<T> IntoIterator for T where T: Iterator {
2891 type Item = <T as Iterator>::Item;
2892 type IntoIter = Self;
2897 impl Step for i32 {}
2898 impl Step for i64 {}
2900 impl<A: Step> iter::Iterator for ops::Range<A> {
2908 fn infer_closure_arg() {
2919 let s = Option::None;
2920 let f = |x: Option<i32>| {};
2925 52..126 '{ ...)(s) }': ()
2926 62..63 's': Option<i32>
2927 66..78 'Option::None': Option<i32>
2928 88..89 'f': |Option<i32>| -> ()
2929 92..111 '|x: Op...2>| {}': |Option<i32>| -> ()
2930 93..94 'x': Option<i32>
2932 117..124 '(&f)(s)': ()
2933 118..120 '&f': &|Option<i32>| -> ()
2934 119..120 'f': |Option<i32>| -> ()
2935 122..123 's': Option<i32>
2941 fn infer_fn_trait_arg() {
2944 //- /lib.rs deps:std
2947 pub trait FnOnce<Args> {
2950 extern "rust-call" fn call_once(&self, args: Args) -> Self::Output;
2954 pub trait Fn<Args>:FnOnce<Args> {
2955 extern "rust-call" fn call(&self, args: Args) -> Self::Output;
2963 fn foo<F, T>(f: F) -> T
2965 F: Fn(Option<i32>) -> T,
2972 101..105 'self': &Self
2973 107..111 'args': Args
2974 220..224 'self': &Self
2975 226..230 'args': Args
2977 359..389 '{ ...f(s) }': T
2978 369..370 's': Option<i32>
2979 373..377 'None': Option<i32>
2982 385..386 's': Option<i32>
2988 fn infer_box_fn_arg() {
2991 //- /lib.rs deps:std
2994 pub trait FnOnce<Args> {
2997 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
3002 type Target: ?Sized;
3004 fn deref(&self) -> &Self::Target;
3007 #[lang = "owned_box"]
3008 pub struct Box<T: ?Sized> {
3012 impl<T: ?Sized> Deref for Box<T> {
3015 fn deref(&self) -> &T {
3026 let s = Option::None;
3027 let f: Box<dyn FnOnce(&Option<i32>)> = box (|ps| {});
3032 100..104 'self': Self
3033 106..110 'args': Args
3034 214..218 'self': &Self
3035 384..388 'self': &Box<T>
3036 396..423 '{ ... }': &T
3037 406..417 '&self.inner': &*mut T
3038 407..411 'self': &Box<T>
3039 407..417 'self.inner': *mut T
3040 478..575 '{ ...(&s) }': FnOnce::Output<dyn FnOnce(&Option<i32>), (&Option<i32>,)>
3041 488..489 's': Option<i32>
3042 492..504 'Option::None': Option<i32>
3043 514..515 'f': Box<dyn FnOnce(&Option<i32>)>
3044 549..562 'box (|ps| {})': Box<|{unknown}| -> ()>
3045 554..561 '|ps| {}': |{unknown}| -> ()
3046 555..557 'ps': {unknown}
3048 568..569 'f': Box<dyn FnOnce(&Option<i32>)>
3049 568..573 'f(&s)': FnOnce::Output<dyn FnOnce(&Option<i32>), (&Option<i32>,)>
3050 570..572 '&s': &Option<i32>
3051 571..572 's': Option<i32>
3057 fn infer_dyn_fn_output() {
3061 pub trait FnOnce<Args> {
3063 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
3067 pub trait Fn<Args>: FnOnce<Args> {
3068 extern "rust-call" fn call(&self, args: Args) -> Self::Output;
3072 let f: &dyn Fn() -> i32;
3080 fn infer_dyn_fn_once_output() {
3084 pub trait FnOnce<Args> {
3086 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
3090 let f: dyn FnOnce() -> i32;
3098 fn variable_kinds_1() {
3101 trait Trait<T> { fn get(self, t: T) -> T; }
3103 impl Trait<u128> for S {}
3104 impl Trait<f32> for S {}
3116 fn variable_kinds_2() {
3119 trait Trait { fn get(self) -> Self; }
3120 impl Trait for u128 {}
3121 impl Trait for f32 {}
3133 fn underscore_import() {
3138 fn method(&self) -> u8 { 0 }
3143 impl crate::tr::Tr for Tr {}
3145 use crate::tr::Tr as _;
3160 fn method(&self) -> u8 { 0 }
3177 fn inner_use_in_block() {
3182 fn method(&self) -> u8 { 0 }
3198 //^^^^^^^^^^^ {unknown}
3202 //^^^^^^^^^^^ {unknown}