1 use expect_test::expect;
4 use super::{check_infer, check_infer_with_mismatches, check_types};
10 //- /main.rs crate:main deps:core
13 impl Future for IntFuture {
23 //- /core.rs crate:core
24 #[prelude_import] use future::*;
26 #[lang = "future_trait"]
39 //- /main.rs crate:main deps:core
40 async fn foo() -> u64 {
50 //- /core.rs crate:core
51 #[prelude_import] use future::*;
53 #[lang = "future_trait"]
63 fn infer_desugar_async() {
66 //- /main.rs crate:main deps:core
67 async fn foo() -> u64 {
74 } //^ impl Future<Output = u64>
76 //- /core.rs crate:core
77 #[prelude_import] use future::*;
89 fn infer_async_block() {
92 //- /main.rs crate:main deps:core
96 // ^ impl Future<Output = i32>
100 let b = async {}.await;
104 let y = Option::None;
108 let _: Option<u64> = c.await;
110 // ^ impl Future<Output = Option<u64>>
113 enum Option<T> { None, Some(T) }
115 //- /core.rs crate:core
116 #[prelude_import] use future::*;
118 #[lang = "future_trait"]
132 //- /main.rs crate:main deps:core
134 let r: Result<i32, u64> = Result::Ok(1);
139 //- /core.rs crate:core
140 #[prelude_import] use ops::*;
148 #[prelude_import] use result::*;
155 impl<O, E> crate::ops::Try for Result<O, E> {
165 fn infer_for_loop() {
168 //- /main.rs crate:main deps:core,alloc
169 use alloc::collections::Vec;
179 //- /core.rs crate:core
180 #[prelude_import] use iter::*;
187 //- /alloc.rs crate:alloc deps:core
191 fn new() -> Self { Vec {} }
192 fn push(&mut self, t: T) { }
195 impl<T> IntoIterator for Vec<T> {
207 //- /main.rs crate:main deps:std
211 impl std::ops::Neg for Bar {
221 //- /std.rs crate:std
222 #[prelude_import] use ops::*;
237 //- /main.rs crate:main deps:std
241 impl std::ops::Not for Bar {
251 //- /std.rs crate:std
252 #[prelude_import] use ops::*;
264 fn infer_from_bound_1() {
269 impl<U> Trait<U> for S<U> {}
270 fn foo<T: Trait<u32>>(t: T) {}
279 104..143 '{ ...(s); }': ()
281 118..119 'S': S<u32>(u32) -> S<u32>
282 118..128 'S(unknown)': S<u32>
283 120..127 'unknown': u32
284 134..137 'foo': fn foo<S<u32>>(S<u32>)
285 134..140 'foo(s)': ()
292 fn infer_from_bound_2() {
297 impl<U> Trait<U> for S<U> {}
298 fn foo<U, T: Trait<U>>(t: T) -> U {}
307 110..162 '{ ...(s); }': ()
309 124..125 'S': S<u32>(u32) -> S<u32>
310 124..134 'S(unknown)': S<u32>
311 126..133 'unknown': u32
313 153..156 'foo': fn foo<u32, S<u32>>(S<u32>) -> u32
314 153..159 'foo(s)': u32
321 fn trait_default_method_self_bound_implements_trait() {
322 mark::check!(trait_self_implements_self);
326 fn foo(&self) -> i64;
338 79..89 'self.foo()': i64
344 fn trait_default_method_self_bound_implements_super_trait() {
348 fn foo(&self) -> i64;
350 trait Trait: SuperTrait {
359 94..129 '{ ... }': ()
361 112..116 'self': &Self
362 112..122 'self.foo()': i64
368 fn infer_project_associated_type() {
375 impl Iterable for S { type Item = u32; }
376 fn test<T: Iterable>() {
377 let x: <S as Iterable>::Item = 1;
378 let y: <T as Iterable>::Item = no_matter;
379 let z: T::Item = no_matter;
380 let a: <T>::Item = no_matter;
384 108..261 '{ ...ter; }': ()
387 156..157 'y': Iterable::Item<T>
388 183..192 'no_matter': Iterable::Item<T>
389 202..203 'z': Iterable::Item<T>
390 215..224 'no_matter': Iterable::Item<T>
391 234..235 'a': Iterable::Item<T>
392 249..258 'no_matter': Iterable::Item<T>
398 fn infer_return_associated_type() {
405 impl Iterable for S { type Item = u32; }
406 fn foo1<T: Iterable>(t: T) -> T::Item {}
407 fn foo2<T: Iterable>(t: T) -> <T as Iterable>::Item {}
408 fn foo3<T: Iterable>(t: T) -> <T>::Item {}
422 234..300 '{ ...(S); }': ()
424 248..252 'foo1': fn foo1<S>(S) -> <S as Iterable>::Item
425 248..255 'foo1(S)': u32
428 269..273 'foo2': fn foo2<S>(S) -> <S as Iterable>::Item
429 269..276 'foo2(S)': u32
432 290..294 'foo3': fn foo3<S>(S) -> <S as Iterable>::Item
433 290..297 'foo3(S)': u32
440 fn infer_associated_type_bound() {
446 fn test<T: Iterable<Item=u32>>() {
447 let y: T::Item = unknown;
451 67..100 '{ ...own; }': ()
453 90..97 'unknown': u32
459 fn infer_const_body() {
462 const A: u32 = 1 + 1;
463 static B: u64 = { let x = 1; x };
469 38..54 '{ let ...1; x }': u64
478 fn tuple_struct_fields() {
489 37..86 '{ ... a.1 }': u64
491 51..52 'S': S(i32, u64) -> S
505 fn tuple_struct_with_fn() {
508 struct S(fn(u32) -> u64);
516 43..101 '{ ...0(2) }': u64
518 57..58 'S': S(fn(u32) -> u64) -> S
519 57..67 'S(|i| 2*i)': S
520 59..66 '|i| 2*i': |u32| -> u64
527 81..84 'a.0': fn(u32) -> u64
531 93..96 'a.0': fn(u32) -> u64
539 fn indexing_arrays() {
541 "fn main() { &mut [9][2]; }",
543 10..26 '{ &mut...[2]; }': ()
544 12..23 '&mut [9][2]': &mut {unknown}
545 17..20 '[9]': [i32; _]
546 17..23 '[9][2]': {unknown}
554 fn infer_ops_index() {
557 //- /main.rs crate:main deps:std
561 impl std::ops::Index<u32> for Bar {
571 //- /std.rs crate:std
572 #[prelude_import] use ops::*;
575 pub trait Index<Idx> {
584 fn infer_ops_index_int() {
587 //- /main.rs crate:main deps:std
591 impl std::ops::Index<u32> for Bar {
596 impl std::ops::Index<Range> for Bar {
607 //- /std.rs crate:std
608 #[prelude_import] use ops::*;
611 pub trait Index<Idx> {
620 fn infer_ops_index_autoderef() {
623 //- /main.rs crate:main deps:std
625 let a = &[1u32, 2, 3];
630 //- /std.rs crate:std
631 impl<T> ops::Index<u32> for [T] {
635 #[prelude_import] use ops::*;
638 pub trait Index<Idx> {
653 fn deref(&self) -> &Self::Target;
657 impl<T> Deref for Arc<T> {
663 fn foo(&self) -> u128 {}
674 fn deref_trait_with_inference_var() {
681 fn deref(&self) -> &Self::Target;
685 fn new_arc<T>() -> Arc<T> {}
686 impl<T> Deref for Arc<T> {
704 fn deref_trait_infinite_recursion() {
710 fn deref(&self) -> &Self::Target;
727 fn deref_trait_with_question_mark_size() {
733 fn deref(&self) -> &Self::Target;
737 impl<T> Deref for Arc<T> {
743 fn foo(&self) -> u128 {}
754 fn obligation_from_function_clause() {
760 impl Trait<u32> for S {}
762 fn foo<T: Trait<U>, U>(t: T) -> U {}
772 fn obligation_from_method_clause() {
779 impl Trait<isize> for S {}
783 fn foo<T: Trait<U>, U>(&self, t: T) -> U {}
794 fn obligation_from_self_method_clause() {
800 impl Trait<i64> for S {}
803 fn foo<U>(&self) -> U where Self: Trait<U> {}
814 fn obligation_from_impl_clause() {
820 impl Trait<&str> for S {}
823 impl<U, T: Trait<U>> O<T> {
824 fn foo(&self) -> U {}
835 fn generic_param_env_1() {
839 trait Trait { fn foo(self) -> u128; }
842 impl<T> Trait for T where T: Clone {}
843 fn test<T: Clone>(t: T) { t.foo(); }
850 fn generic_param_env_1_not_met() {
855 trait Trait { fn foo(self) -> u128; }
858 impl<T> Trait for T where T: Clone {}
859 fn test<T>(t: T) { t.foo(); }
866 fn generic_param_env_2() {
869 trait Trait { fn foo(self) -> u128; }
872 fn test<T: Trait>(t: T) { t.foo(); }
879 fn generic_param_env_2_not_met() {
882 trait Trait { fn foo(self) -> u128; }
885 fn test<T>(t: T) { t.foo(); }
892 fn generic_param_env_deref() {
900 impl<T> Deref for T where T: Trait {
903 fn test<T: Trait>(t: T) { (*t); }
910 fn associated_type_placeholder() {
911 // 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].
918 pub struct RefMutL<T>;
920 impl<T> ApplyL for RefMutL<T> {
921 type Out = <T as ApplyL>::Out;
924 fn test<T: ApplyL>() {
925 let y: <RefMutL<T> as ApplyL>::Out = no_matter;
933 fn associated_type_placeholder_2() {
939 fn foo<T: ApplyL>(t: T) -> <T as ApplyL>::Out;
941 fn test<T: ApplyL>(t: T) {
950 fn argument_impl_trait() {
951 check_infer_with_mismatches(
955 fn foo2(&self) -> i64;
957 fn bar(x: impl Trait<u16>) {}
959 impl<T> Trait<T> for S<T> {}
961 fn test(x: impl Trait<u64>, y: &impl Trait<u32>) {
977 77..78 'x': impl Trait<u16>
979 154..155 'x': impl Trait<u64>
980 174..175 'y': &impl Trait<u32>
981 195..323 '{ ...2(); }': ()
982 201..202 'x': impl Trait<u64>
983 208..209 'y': &impl Trait<u32>
985 223..224 'S': S<u16>(u16) -> S<u16>
986 223..227 'S(1)': S<u16>
988 233..236 'bar': fn bar(S<u16>)
989 233..239 'bar(z)': ()
991 245..246 'x': impl Trait<u64>
992 245..252 'x.foo()': u64
993 258..259 'y': &impl Trait<u32>
994 258..265 'y.foo()': u32
996 271..278 'z.foo()': u16
997 284..285 'x': impl Trait<u64>
998 284..292 'x.foo2()': i64
999 298..299 'y': &impl Trait<u32>
1000 298..306 'y.foo2()': i64
1001 312..313 'z': S<u16>
1002 312..320 'z.foo2()': i64
1008 fn argument_impl_trait_type_args_1() {
1009 check_infer_with_mismatches(
1013 // this function has an implicit Self param, an explicit type param,
1014 // and an implicit impl Trait param!
1015 fn bar<T>(x: impl Trait) -> T { loop {} }
1017 fn foo<T>(x: impl Trait) -> T { loop {} }
1028 <F as Foo>::bar::<u32>(S);
1032 foo::<u32, i32>(S); // we should ignore the extraneous i32
1036 155..156 'x': impl Trait
1037 175..186 '{ loop {} }': T
1038 177..184 'loop {}': !
1040 199..200 'x': impl Trait
1041 219..230 '{ loop {} }': T
1042 221..228 'loop {}': !
1044 300..509 '{ ... i32 }': ()
1045 306..314 'Foo::bar': fn bar<{unknown}, {unknown}>(S) -> {unknown}
1046 306..317 'Foo::bar(S)': {unknown}
1048 323..338 '<F as Foo>::bar': fn bar<F, {unknown}>(S) -> {unknown}
1049 323..341 '<F as ...bar(S)': {unknown}
1051 347..353 'F::bar': fn bar<F, {unknown}>(S) -> {unknown}
1052 347..356 'F::bar(S)': {unknown}
1054 362..377 'Foo::bar::<u32>': fn bar<{unknown}, u32>(S) -> u32
1055 362..380 'Foo::b...32>(S)': u32
1057 386..408 '<F as ...:<u32>': fn bar<F, u32>(S) -> u32
1058 386..411 '<F as ...32>(S)': u32
1060 418..421 'foo': fn foo<{unknown}>(S) -> {unknown}
1061 418..424 'foo(S)': {unknown}
1063 430..440 'foo::<u32>': fn foo<u32>(S) -> u32
1064 430..443 'foo::<u32>(S)': u32
1066 449..464 'foo::<u32, i32>': fn foo<u32>(S) -> u32
1067 449..467 'foo::<...32>(S)': u32
1074 fn argument_impl_trait_type_args_2() {
1075 check_infer_with_mismatches(
1082 fn foo<U>(self, x: impl Trait) -> (T, U) { loop {} }
1088 F::<u32>.foo::<i32>(S);
1089 F::<u32>.foo::<i32, u32>(S); // extraneous argument should be ignored
1094 93..94 'x': impl Trait
1095 118..129 '{ loop {} }': (T, U)
1096 120..127 'loop {}': !
1098 143..283 '{ ...ored }': ()
1099 149..150 'F': F<{unknown}>
1100 149..157 'F.foo(S)': ({unknown}, {unknown})
1102 163..171 'F::<u32>': F<u32>
1103 163..178 'F::<u32>.foo(S)': (u32, {unknown})
1105 184..192 'F::<u32>': F<u32>
1106 184..206 'F::<u3...32>(S)': (u32, i32)
1108 212..220 'F::<u32>': F<u32>
1109 212..239 'F::<u3...32>(S)': (u32, i32)
1116 fn argument_impl_trait_to_fn_pointer() {
1117 check_infer_with_mismatches(
1120 fn foo(x: impl Trait) { loop {} }
1125 let f: fn(S) -> () = foo;
1129 22..23 'x': impl Trait
1130 37..48 '{ loop {} }': ()
1133 90..123 '{ ...foo; }': ()
1135 117..120 'foo': fn foo(S)
1146 fn foo2(&self) -> i64;
1148 fn bar() -> impl Trait<u64> {}
1150 fn test(x: impl Trait<u64>, y: &impl Trait<u64>) {
1163 29..33 'self': &Self
1164 54..58 'self': &Self
1166 110..111 'x': impl Trait<u64>
1167 130..131 'y': &impl Trait<u64>
1168 151..268 '{ ...2(); }': ()
1169 157..158 'x': impl Trait<u64>
1170 164..165 'y': &impl Trait<u64>
1171 175..176 'z': impl Trait<u64>
1172 179..182 'bar': fn bar() -> impl Trait<u64>
1173 179..184 'bar()': impl Trait<u64>
1174 190..191 'x': impl Trait<u64>
1175 190..197 'x.foo()': u64
1176 203..204 'y': &impl Trait<u64>
1177 203..210 'y.foo()': u64
1178 216..217 'z': impl Trait<u64>
1179 216..223 'z.foo()': u64
1180 229..230 'x': impl Trait<u64>
1181 229..237 'x.foo2()': i64
1182 243..244 'y': &impl Trait<u64>
1183 243..251 'y.foo2()': i64
1184 257..258 'z': impl Trait<u64>
1185 257..265 'z.foo2()': i64
1191 fn simple_return_pos_impl_trait() {
1192 mark::check!(lower_rpit);
1198 fn bar() -> impl Trait<u64> { loop {} }
1206 29..33 'self': &Self
1207 71..82 '{ loop {} }': !
1210 94..129 '{ ...o(); }': ()
1211 104..105 'a': impl Trait<u64>
1212 108..111 'bar': fn bar() -> impl Trait<u64>
1213 108..113 'bar()': impl Trait<u64>
1214 119..120 'a': impl Trait<u64>
1215 119..126 'a.foo()': u64
1221 fn more_return_pos_impl_trait() {
1226 fn next(&mut self) -> Self::Item;
1231 fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) { loop {} }
1232 fn baz<T>(t: T) -> (impl Iterator<Item = impl Trait<T>>, impl Trait<T>) { loop {} }
1238 let (c, d) = baz(1u128);
1244 49..53 'self': &mut Self
1245 101..105 'self': &Self
1246 184..195 '{ loop {} }': ({unknown}, {unknown})
1247 186..193 'loop {}': !
1250 268..279 '{ loop {} }': ({unknown}, {unknown})
1251 270..277 'loop {}': !
1253 291..413 '{ ...o(); }': ()
1254 301..307 '(a, b)': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1255 302..303 'a': impl Iterator<Item = impl Trait<u32>>
1256 305..306 'b': impl Trait<u64>
1257 310..313 'bar': fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1258 310..315 'bar()': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1259 321..322 'a': impl Iterator<Item = impl Trait<u32>>
1260 321..329 'a.next()': impl Trait<u32>
1261 321..335 'a.next().foo()': u32
1262 341..342 'b': impl Trait<u64>
1263 341..348 'b.foo()': u64
1264 358..364 '(c, d)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1265 359..360 'c': impl Iterator<Item = impl Trait<u128>>
1266 362..363 'd': impl Trait<u128>
1267 367..370 'baz': fn baz<u128>(u128) -> (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1268 367..377 'baz(1u128)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1269 371..376 '1u128': u128
1270 383..384 'c': impl Iterator<Item = impl Trait<u128>>
1271 383..391 'c.next()': impl Trait<u128>
1272 383..397 'c.next().foo()': u128
1273 403..404 'd': impl Trait<u128>
1274 403..410 'd.foo()': u128
1285 fn foo2(&self) -> i64;
1287 fn bar() -> dyn Trait<u64> {}
1289 fn test(x: dyn Trait<u64>, y: &dyn Trait<u64>) {
1302 29..33 'self': &Self
1303 54..58 'self': &Self
1305 109..110 'x': dyn Trait<u64>
1306 128..129 'y': &dyn Trait<u64>
1307 148..265 '{ ...2(); }': ()
1308 154..155 'x': dyn Trait<u64>
1309 161..162 'y': &dyn Trait<u64>
1310 172..173 'z': dyn Trait<u64>
1311 176..179 'bar': fn bar() -> dyn Trait<u64>
1312 176..181 'bar()': dyn Trait<u64>
1313 187..188 'x': dyn Trait<u64>
1314 187..194 'x.foo()': u64
1315 200..201 'y': &dyn Trait<u64>
1316 200..207 'y.foo()': u64
1317 213..214 'z': dyn Trait<u64>
1318 213..220 'z.foo()': u64
1319 226..227 'x': dyn Trait<u64>
1320 226..234 'x.foo2()': i64
1321 240..241 'y': &dyn Trait<u64>
1322 240..248 'y.foo2()': i64
1323 254..255 'z': dyn Trait<u64>
1324 254..262 'z.foo2()': i64
1330 fn dyn_trait_in_impl() {
1334 fn foo(&self) -> (T, U);
1337 impl<T, U> S<T, U> {
1338 fn bar(&self) -> &dyn Trait<T, U> { loop {} }
1340 trait Trait2<T, U> {
1341 fn baz(&self) -> (T, U);
1343 impl<T, U> Trait2<T, U> for dyn Trait<T, U> { }
1345 fn test(s: S<u32, i32>) {
1350 32..36 'self': &Self
1351 102..106 'self': &S<T, U>
1352 128..139 '{ loop {} }': &dyn Trait<T, U>
1353 130..137 'loop {}': !
1355 175..179 'self': &Self
1356 251..252 's': S<u32, i32>
1357 267..289 '{ ...z(); }': ()
1358 273..274 's': S<u32, i32>
1359 273..280 's.bar()': &dyn Trait<u32, i32>
1360 273..286 's.bar().baz()': (u32, i32)
1366 fn dyn_trait_bare() {
1370 fn foo(&self) -> u64;
1372 fn bar() -> Trait {}
1374 fn test(x: Trait, y: &Trait) -> u64 {
1384 26..30 'self': &Self
1386 72..73 'x': dyn Trait
1387 82..83 'y': &dyn Trait
1388 100..175 '{ ...o(); }': ()
1389 106..107 'x': dyn Trait
1390 113..114 'y': &dyn Trait
1391 124..125 'z': dyn Trait
1392 128..131 'bar': fn bar() -> dyn Trait
1393 128..133 'bar()': dyn Trait
1394 139..140 'x': dyn Trait
1395 139..146 'x.foo()': u64
1396 152..153 'y': &dyn Trait
1397 152..159 'y.foo()': u64
1398 165..166 'z': dyn Trait
1399 165..172 'z.foo()': u64
1409 fn test(a: impl Trait + 'lifetime, b: impl 'lifetime, c: impl (Trait), d: impl ('lifetime), e: impl ?Sized, f: impl Trait + ?Sized) {}
1412 23..24 'a': impl Trait
1414 69..70 'c': impl Trait
1416 107..108 'e': impl {error}
1417 123..124 'f': impl Trait + {error}
1425 fn error_bound_chalk() {
1429 fn foo(&self) -> u32 {}
1432 fn test(x: (impl Trait + UnknownTrait)) {
1440 fn assoc_type_bindings() {
1447 fn get<T: Trait>(t: T) -> <T as Trait>::Type {}
1448 fn get2<U, T: Trait<Type = U>>(t: T) -> U {}
1449 fn set<T: Trait<Type = u64>>(t: T) -> T {t}
1452 impl<T> Trait for S<T> { type Type = T; }
1454 fn test<T: Trait<Type = u32>>(x: T, y: impl Trait<Type = i64>) {
1473 262..263 'y': impl Trait<Type = i64>
1474 289..397 '{ ...r>); }': ()
1475 295..298 'get': fn get<T>(T) -> <T as Trait>::Type
1476 295..301 'get(x)': u32
1478 307..311 'get2': fn get2<u32, T>(T) -> u32
1479 307..314 'get2(x)': u32
1481 320..323 'get': fn get<impl Trait<Type = i64>>(impl Trait<Type = i64>) -> <impl Trait<Type = i64> as Trait>::Type
1482 320..326 'get(y)': i64
1483 324..325 'y': impl Trait<Type = i64>
1484 332..336 'get2': fn get2<i64, impl Trait<Type = i64>>(impl Trait<Type = i64>) -> i64
1485 332..339 'get2(y)': i64
1486 337..338 'y': impl Trait<Type = i64>
1487 345..348 'get': fn get<S<u64>>(S<u64>) -> <S<u64> as Trait>::Type
1488 345..356 'get(set(S))': u64
1489 349..352 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1490 349..355 'set(S)': S<u64>
1491 353..354 'S': S<u64>
1492 362..366 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64
1493 362..374 'get2(set(S))': u64
1494 367..370 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1495 367..373 'set(S)': S<u64>
1496 371..372 'S': S<u64>
1497 380..384 'get2': fn get2<str, S<str>>(S<str>) -> str
1498 380..394 'get2(S::<str>)': str
1499 385..393 'S::<str>': S<str>
1505 fn impl_trait_assoc_binding_projection_bug() {
1508 //- /main.rs crate:main deps:std
1509 pub trait Language {
1512 pub enum RustLanguage {}
1513 impl Language for RustLanguage {
1514 type Kind = SyntaxKind;
1516 struct SyntaxNode<L> {}
1517 fn foo() -> impl Iterator<Item = SyntaxNode<RustLanguage>> {}
1520 fn clone(&self) -> Self;
1523 fn api_walkthrough() {
1529 //- /std.rs crate:std
1530 #[prelude_import] use iter::*;
1532 trait IntoIterator {
1538 impl<T: Iterator> IntoIterator for T {
1539 type Item = <T as Iterator>::Item;
1547 fn projection_eq_within_chalk() {
1556 impl<T, U> Trait2<T> for U where U: Trait1<Type = T> {}
1558 fn test<T: Trait1<Type = u32>>(x: T) {
1565 169..185 '{ ...o(); }': ()
1567 175..182 'x.foo()': u32
1573 fn where_clause_trait_in_scope_for_method_resolution() {
1578 fn foo(&self) -> u32 {}
1582 fn test<T: foo::Trait>(x: T) {
1590 fn super_trait_method_resolution() {
1595 fn foo(&self) -> u32 {}
1598 trait Trait1: foo::SuperTrait {}
1599 trait Trait2 where Self: foo::SuperTrait {}
1601 fn test<T: Trait1, U: Trait2>(x: T, y: U) {
1607 49..53 'self': &Self
1611 193..222 '{ ...o(); }': ()
1613 199..206 'x.foo()': u32
1615 212..219 'y.foo()': u32
1621 fn super_trait_impl_trait_method_resolution() {
1626 fn foo(&self) -> u32 {}
1629 trait Trait1: foo::SuperTrait {}
1631 fn test(x: &impl Trait1) {
1636 49..53 'self': &Self
1638 115..116 'x': &impl Trait1
1639 132..148 '{ ...o(); }': ()
1640 138..139 'x': &impl Trait1
1641 138..145 'x.foo()': u32
1647 fn super_trait_cycle() {
1648 // This just needs to not crash
1654 fn test<T: A>(x: T) {
1660 49..65 '{ ...o(); }': ()
1662 55..62 'x.foo()': {unknown}
1668 fn super_trait_assoc_type_bounds() {
1671 trait SuperTrait { type Type; }
1672 trait Trait where Self: SuperTrait {}
1674 fn get2<U, T: Trait<Type = U>>(t: T) -> U {}
1675 fn set<T: Trait<Type = u64>>(t: T) -> T {t}
1678 impl<T> SuperTrait for S<T> { type Type = T; }
1679 impl<T> Trait for S<T> {}
1691 258..279 '{ ...S)); }': ()
1692 264..268 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64
1693 264..276 'get2(set(S))': u64
1694 269..272 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1695 269..275 'set(S)': S<u64>
1696 273..274 'S': S<u64>
1705 trait FnOnce<Args> {
1708 fn call_once(self, args: Args) -> <Self as FnOnce<Args>>::Output;
1711 fn test<F: FnOnce(u32, u64) -> u128>(f: F) {
1712 f.call_once((1, 2));
1719 155..183 '{ ...2)); }': ()
1721 161..180 'f.call...1, 2))': u128
1722 173..179 '(1, 2)': (u32, u64)
1730 fn fn_ptr_and_item() {
1734 trait FnOnce<Args> {
1737 fn call_once(self, args: Args) -> Self::Output;
1746 impl<A1, R, F: FnOnce(A1) -> R> Foo<(A1, R)> for Bar<F> {
1747 fn foo(&self) -> (A1, R) {}
1750 enum Opt<T> { None, Some(T) }
1752 fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Opt<U> {}
1756 let bar: Bar<fn(u8) -> u32>;
1760 let f: fn(u8) -> u32;
1767 139..143 'self': &Self
1768 243..247 'self': &Bar<F>
1770 346..350 'self': Opt<T>
1773 384..500 '{ ...(f); }': ()
1774 394..397 'bar': Bar<fn(u8) -> u32>
1775 423..426 'bar': Bar<fn(u8) -> u32>
1776 423..432 'bar.foo()': (u8, u32)
1777 443..446 'opt': Opt<u8>
1778 465..466 'f': fn(u8) -> u32
1779 487..490 'opt': Opt<u8>
1780 487..497 'opt.map(f)': Opt<u32>
1781 495..496 'f': fn(u8) -> u32
1787 fn fn_trait_deref_with_ty_default() {
1794 fn deref(&self) -> &Self::Target;
1798 trait FnOnce<Args> {
1801 fn call_once(self, args: Args) -> Self::Output;
1807 fn foo(&self) -> usize {}
1810 struct Lazy<T, F = fn() -> T>(F);
1812 impl<T, F> Lazy<T, F> {
1813 pub fn new(f: F) -> Lazy<T, F> {}
1816 impl<T, F: FnOnce() -> T> Deref for Lazy<T, F> {
1821 let lazy1: Lazy<Foo, _> = Lazy::new(|| Foo);
1822 let r1 = lazy1.foo();
1824 fn make_foo_fn() -> Foo {}
1825 let make_foo_fn_ptr: fn() -> Foo = make_foo_fn;
1826 let lazy2: Lazy<Foo, _> = Lazy::new(make_foo_fn_ptr);
1827 let r2 = lazy2.foo();
1831 64..68 'self': &Self
1832 165..169 'self': Self
1833 171..175 'args': Args
1834 239..243 'self': &Foo
1838 443..689 '{ ...o(); }': ()
1839 453..458 'lazy1': Lazy<Foo, || -> Foo>
1840 475..484 'Lazy::new': fn new<Foo, || -> Foo>(|| -> Foo) -> Lazy<Foo, || -> Foo>
1841 475..492 'Lazy::...| Foo)': Lazy<Foo, || -> Foo>
1842 485..491 '|| Foo': || -> Foo
1844 502..504 'r1': usize
1845 507..512 'lazy1': Lazy<Foo, || -> Foo>
1846 507..518 'lazy1.foo()': usize
1847 560..575 'make_foo_fn_ptr': fn() -> Foo
1848 591..602 'make_foo_fn': fn make_foo_fn() -> Foo
1849 612..617 'lazy2': Lazy<Foo, fn() -> Foo>
1850 634..643 'Lazy::new': fn new<Foo, fn() -> Foo>(fn() -> Foo) -> Lazy<Foo, fn() -> Foo>
1851 634..660 'Lazy::...n_ptr)': Lazy<Foo, fn() -> Foo>
1852 644..659 'make_foo_fn_ptr': fn() -> Foo
1853 670..672 'r2': usize
1854 675..680 'lazy2': Lazy<Foo, fn() -> Foo>
1855 675..686 'lazy2.foo()': usize
1866 trait FnOnce<Args> {
1870 enum Option<T> { Some(T), None }
1872 fn map<U, F: FnOnce(T) -> U>(self, f: F) -> Option<U> {}
1876 let x = Option::Some(1u32);
1879 let y: Option<i64> = x.map(|_v| 1);
1883 147..151 'self': Option<T>
1886 188..307 '{ ... 1); }': ()
1887 198..199 'x': Option<u32>
1888 202..214 'Option::Some': Some<u32>(u32) -> Option<u32>
1889 202..220 'Option...(1u32)': Option<u32>
1890 215..219 '1u32': u32
1891 226..227 'x': Option<u32>
1892 226..242 'x.map(...v + 1)': Option<u32>
1893 232..241 '|v| v + 1': |u32| -> u32
1896 236..241 'v + 1': u32
1898 248..249 'x': Option<u32>
1899 248..264 'x.map(... 1u64)': Option<u64>
1900 254..263 '|_v| 1u64': |u32| -> u64
1902 259..263 '1u64': u64
1903 274..275 'y': Option<i64>
1904 291..292 'x': Option<u32>
1905 291..304 'x.map(|_v| 1)': Option<i64>
1906 297..303 '|_v| 1': |u32| -> i64
1917 trait FnOnce<Args> {
1921 fn test<F: FnOnce(u32) -> u64>(f: F) {
1925 let h = |v| 1u128 + v;
1930 78..154 '{ ...+ v; }': ()
1932 84..88 'f(1)': {unknown}
1934 98..99 'g': |u64| -> i32
1935 102..111 '|v| v + 1': |u64| -> i32
1938 106..111 'v + 1': i32
1940 117..118 'g': |u64| -> i32
1941 117..124 'g(1u64)': i32
1942 119..123 '1u64': u64
1943 134..135 'h': |u128| -> u128
1944 138..151 '|v| 1u128 + v': |u128| -> u128
1946 142..147 '1u128': u128
1947 142..151 '1u128 + v': u128
1954 fn closure_as_argument_inference_order() {
1958 trait FnOnce<Args> {
1962 fn foo1<T, U, F: FnOnce(T) -> U>(x: T, f: F) -> U {}
1963 fn foo2<T, U, F: FnOnce(T) -> U>(f: F, x: T) -> U {}
1967 fn method(self) -> u64;
1969 fn foo1<T, U, F: FnOnce(T) -> U>(self, x: T, f: F) -> U {}
1970 fn foo2<T, U, F: FnOnce(T) -> U>(self, f: F, x: T) -> U {}
1974 let x1 = foo1(S, |s| s.method());
1975 let x2 = foo2(|s| s.method(), S);
1976 let x3 = S.foo1(S, |s| s.method());
1977 let x4 = S.foo2(|s| s.method(), S);
1996 355..514 '{ ... S); }': ()
1998 370..374 'foo1': fn foo1<S, u64, |S| -> u64>(S, |S| -> u64) -> u64
1999 370..393 'foo1(S...hod())': u64
2001 378..392 '|s| s.method()': |S| -> u64
2004 382..392 's.method()': u64
2006 408..412 'foo2': fn foo2<S, u64, |S| -> u64>(|S| -> u64, S) -> u64
2007 408..431 'foo2(|...(), S)': u64
2008 413..427 '|s| s.method()': |S| -> u64
2011 417..427 's.method()': u64
2015 446..471 'S.foo1...hod())': u64
2017 456..470 '|s| s.method()': |S| -> u64
2020 460..470 's.method()': u64
2023 486..511 'S.foo2...(), S)': u64
2024 493..507 '|s| s.method()': |S| -> u64
2027 497..507 's.method()': u64
2034 fn fn_item_fn_trait() {
2038 trait FnOnce<Args> {
2046 fn takes_closure<U, F: FnOnce() -> U>(f: F) -> U { f() }
2050 } //^^^^^^^^^^^^^^^^^^ S
2056 fn unselected_projection_in_trait_env_1() {
2065 fn foo(&self) -> u32;
2068 fn test<T: Trait>() where T::Item: Trait2 {
2069 let x: T::Item = no_matter;
2077 fn unselected_projection_in_trait_env_2() {
2085 fn foo(&self) -> u32;
2088 fn test<T, U>() where T::Item: Trait2, T: Trait<U::Item>, U: Trait<()> {
2089 let x: T::Item = no_matter;
2097 fn unselected_projection_on_impl_self() {
2104 fn f(&self, x: Self::Item);
2111 fn f(&self, x: Self::Item) { let y = x; }
2118 fn f(&self, x: <Self>::Item) { let y = x; }
2122 40..44 'self': &Self
2123 46..47 'x': Trait::Item<Self>
2126 147..161 '{ let y = x; }': ()
2129 228..232 'self': &S2
2131 251..265 '{ let y = x; }': ()
2139 fn unselected_projection_on_trait_self() {
2145 fn f(&self) -> Self::Item { loop {} }
2161 fn unselected_projection_chalk_fold() {
2165 trait Fold<I: Interner, TI = I> {
2169 struct Ty<I: Interner> {}
2170 impl<I: Interner, TI: Interner> Fold<I, TI> for Ty<I> {
2171 type Result = Ty<TI>;
2174 fn fold<I: Interner, T>(interner: &I, t: T) -> T::Result
2181 fn foo<I: Interner>(interner: &I, t: Ty<I>) {
2189 fn trait_impl_self_ty() {
2198 impl Trait<Self> for S {}
2208 fn trait_impl_self_ty_cycle() {
2217 impl Trait for S<Self> {}
2227 fn unselected_projection_in_trait_env_cycle_1() {
2228 // this is a legitimate cycle
2237 fn test<T: Trait>() where T: Trait2<T::Item> {
2238 let x: T::Item = no_matter;
2245 fn unselected_projection_in_trait_env_cycle_2() {
2246 // this is a legitimate cycle
2254 fn test<T, U>() where T: Trait<U::Item>, U: Trait<T::Item> {
2255 let x: T::Item = no_matter;
2262 fn inline_assoc_type_bounds_1() {
2268 trait OtherTrait<T> {
2272 // workaround for Chalk assoc type normalization problems
2274 impl<T: Iterator> Iterator for S<T> {
2275 type Item = <T as Iterator>::Item;
2278 fn test<I: Iterator<Item: OtherTrait<u32>>>() {
2279 let x: <S<I> as Iterator>::Item;
2287 fn inline_assoc_type_bounds_2() {
2294 fn test<I: Iterator<Item: Iterator<Item = u32>>>() {
2295 let x: <<I as Iterator>::Item as Iterator>::Item;
2303 fn proc_macro_server_types() {
2306 macro_rules! with_api {
2307 ($S:ident, $self:ident, $m:ident) => {
2310 fn new() -> $S::TokenStream;
2317 macro_rules! associated_item {
2318 (type TokenStream) =>
2319 (type TokenStream: 'static;);
2321 (type Group: 'static;);
2322 ($($item:tt)*) => ($($item)*;)
2324 macro_rules! declare_server_traits {
2326 $(fn $method:ident($($arg:ident: $arg_ty:ty),* $(,)?) $(-> $ret_ty:ty)?;)*
2329 $(associated_item!(type $name);)*
2332 $(pub trait $name: Types {
2333 $(associated_item!(fn $method($($arg: $arg_ty),*) $(-> $ret_ty)?);)*
2336 pub trait Server: Types $(+ $name)* {}
2337 impl<S: Types $(+ $name)*> Server for S {}
2341 with_api!(Self, self_, declare_server_traits);
2345 impl Types for Rustc {
2346 type TokenStream = T;
2350 fn make<T>() -> T { loop {} }
2351 impl TokenStream for Rustc {
2352 fn new() -> Self::TokenStream {
2353 let group: Self::Group = make();
2359 1061..1072 '{ loop {} }': T
2360 1063..1070 'loop {}': !
2362 1136..1199 '{ ... }': T
2363 1150..1155 'group': G
2364 1171..1175 'make': fn make<G>() -> G
2365 1171..1177 'make()': G
2366 1187..1191 'make': fn make<T>() -> T
2367 1187..1193 'make()': T
2373 fn unify_impl_trait() {
2374 check_infer_with_mismatches(
2378 fn foo(x: impl Trait<u32>) { loop {} }
2379 fn bar<T>(x: impl Trait<T>) -> T { loop {} }
2382 impl<T> Trait<T> for S<T> {}
2384 fn default<T>() -> T { loop {} }
2386 fn test() -> impl Trait<i32> {
2387 let s1 = S(default());
2389 let x: i32 = bar(S(default()));
2394 26..27 'x': impl Trait<u32>
2395 46..57 '{ loop {} }': ()
2398 68..69 'x': impl Trait<T>
2399 91..102 '{ loop {} }': T
2400 93..100 'loop {}': !
2402 171..182 '{ loop {} }': T
2403 173..180 'loop {}': !
2405 213..309 '{ ...t()) }': S<{unknown}>
2406 223..225 's1': S<u32>
2407 228..229 'S': S<u32>(u32) -> S<u32>
2408 228..240 'S(default())': S<u32>
2409 230..237 'default': fn default<u32>() -> u32
2410 230..239 'default()': u32
2411 246..249 'foo': fn foo(S<u32>)
2412 246..253 'foo(s1)': ()
2413 250..252 's1': S<u32>
2415 272..275 'bar': fn bar<i32>(S<i32>) -> i32
2416 272..289 'bar(S(...lt()))': i32
2417 276..277 'S': S<i32>(i32) -> S<i32>
2418 276..288 'S(default())': S<i32>
2419 278..285 'default': fn default<i32>() -> i32
2420 278..287 'default()': i32
2421 295..296 'S': S<{unknown}>({unknown}) -> S<{unknown}>
2422 295..307 'S(default())': S<{unknown}>
2423 297..304 'default': fn default<{unknown}>() -> {unknown}
2424 297..306 'default()': {unknown}
2430 fn assoc_types_from_bounds() {
2435 trait FnOnce<Args> {
2454 f::<(), _>(|z| { z; });
2460 193..224 '{ ... }); }': ()
2461 199..209 'f::<(), _>': fn f<(), |&()| -> ()>(|&()| -> ())
2462 199..221 'f::<()... z; })': ()
2463 210..220 '|z| { z; }': |&()| -> ()
2465 214..220 '{ z; }': ()
2472 fn associated_type_bound() {
2476 type Item: OtherTrait<u32>;
2478 pub trait OtherTrait<T> {
2482 // this is just a workaround for chalk#234
2484 impl<T: Trait> Trait for S<T> {
2485 type Item = <T as Trait>::Item;
2488 fn test<T: Trait>() {
2489 let y: <S<T> as Trait>::Item = no_matter;
2497 fn dyn_trait_through_chalk() {
2505 impl<T> Deref for Box<T> {
2512 fn test(x: Box<dyn Trait>) {
2520 fn string_to_owned() {
2526 fn to_owned(&self) -> Self::Owned;
2528 impl ToOwned for str {
2529 type Owned = String;
2539 fn iterator_chain() {
2544 trait FnOnce<Args> {
2548 trait FnMut<Args>: FnOnce<Args> { }
2550 enum Option<T> { Some(T), None }
2553 pub trait Iterator {
2556 fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
2558 F: FnMut(Self::Item) -> Option<B>,
2561 fn for_each<F>(self, f: F)
2563 F: FnMut(Self::Item),
2567 pub trait IntoIterator {
2569 type IntoIter: Iterator<Item = Self::Item>;
2570 fn into_iter(self) -> Self::IntoIter;
2573 pub struct FilterMap<I, F> { }
2574 impl<B, I: Iterator, F> Iterator for FilterMap<I, F>
2576 F: FnMut(I::Item) -> Option<B>,
2581 #[stable(feature = "rust1", since = "1.0.0")]
2582 impl<I: Iterator> IntoIterator for I {
2583 type Item = I::Item;
2586 fn into_iter(self) -> I {
2593 fn new() -> Self { loop {} }
2596 impl<T> IntoIterator for Vec<T> {
2598 type IntoIter = IntoIter<T>;
2601 pub struct IntoIter<T> { }
2602 impl<T> Iterator for IntoIter<T> {
2607 Vec::<i32>::new().into_iter()
2608 .filter_map(|x| if x > 0 { Some(x as u32) } else { None })
2609 .for_each(|y| { y; });
2613 226..230 'self': Self
2615 317..328 '{ loop {} }': FilterMap<Self, F>
2616 319..326 'loop {}': !
2618 349..353 'self': Self
2620 405..416 '{ loop {} }': ()
2621 407..414 'loop {}': !
2623 525..529 'self': Self
2625 865..885 '{ ... }': I
2627 944..955 '{ loop {} }': Vec<T>
2628 946..953 'loop {}': !
2630 1142..1269 '{ ... }); }': ()
2631 1148..1163 'Vec::<i32>::new': fn new<i32>() -> Vec<i32>
2632 1148..1165 'Vec::<...:new()': Vec<i32>
2633 1148..1177 'Vec::<...iter()': IntoIter<i32>
2634 1148..1240 'Vec::<...one })': FilterMap<IntoIter<i32>, |i32| -> Option<u32>>
2635 1148..1266 'Vec::<... y; })': ()
2636 1194..1239 '|x| if...None }': |i32| -> Option<u32>
2638 1198..1239 'if x >...None }': Option<u32>
2640 1201..1206 'x > 0': bool
2642 1207..1225 '{ Some...u32) }': Option<u32>
2643 1209..1213 'Some': Some<u32>(u32) -> Option<u32>
2644 1209..1223 'Some(x as u32)': Option<u32>
2646 1214..1222 'x as u32': u32
2647 1231..1239 '{ None }': Option<u32>
2648 1233..1237 'None': Option<u32>
2649 1255..1265 '|y| { y; }': |u32| -> ()
2651 1259..1265 '{ y; }': ()
2674 fn foo() -> Self::Output;
2678 type Output = T::OutputA;
2679 fn foo() -> Self::Output { loop {} }
2690 fn trait_object_no_coercion() {
2691 check_infer_with_mismatches(
2695 fn foo(x: &dyn Foo) {}
2697 fn test(x: &dyn Foo) {
2702 21..22 'x': &dyn Foo
2704 46..47 'x': &dyn Foo
2705 59..74 '{ foo(x); }': ()
2706 65..68 'foo': fn foo(&dyn Foo)
2708 69..70 'x': &dyn Foo
2715 check_infer_with_mismatches(
2721 impl Copy for IsCopy {}
2724 trait Test { fn test(&self) -> bool; }
2725 impl<T: Copy> Test for T {}
2730 (IsCopy, IsCopy).test();
2731 (IsCopy, NotCopy).test();
2735 110..114 'self': &Self
2736 166..267 '{ ...t(); }': ()
2737 172..178 'IsCopy': IsCopy
2738 172..185 'IsCopy.test()': bool
2739 191..198 'NotCopy': NotCopy
2740 191..205 'NotCopy.test()': {unknown}
2741 211..227 '(IsCop...sCopy)': (IsCopy, IsCopy)
2742 211..234 '(IsCop...test()': bool
2743 212..218 'IsCopy': IsCopy
2744 220..226 'IsCopy': IsCopy
2745 240..257 '(IsCop...tCopy)': (IsCopy, NotCopy)
2746 240..264 '(IsCop...test()': {unknown}
2747 241..247 'IsCopy': IsCopy
2748 249..256 'NotCopy': NotCopy
2754 fn builtin_fn_def_copy() {
2755 check_infer_with_mismatches(
2761 fn bar<T: Copy>(T) -> T {}
2762 struct Struct(usize);
2763 enum Enum { Variant(usize) }
2765 trait Test { fn test(&self) -> bool; }
2766 impl<T: Copy> Test for T {}
2772 Enum::Variant.test();
2777 60..61 'T': {unknown}
2779 68..70: expected T, got ()
2780 145..149 'self': &Self
2781 201..281 '{ ...t(); }': ()
2782 207..210 'foo': fn foo()
2783 207..217 'foo.test()': bool
2784 223..226 'bar': fn bar<{unknown}>({unknown}) -> {unknown}
2785 223..233 'bar.test()': bool
2786 239..245 'Struct': Struct(usize) -> Struct
2787 239..252 'Struct.test()': bool
2788 258..271 'Enum::Variant': Variant(usize) -> Enum
2789 258..278 'Enum::...test()': bool
2795 fn builtin_fn_ptr_copy() {
2796 check_infer_with_mismatches(
2801 trait Test { fn test(&self) -> bool; }
2802 impl<T: Copy> Test for T {}
2804 fn test(f1: fn(), f2: fn(usize) -> u8, f3: fn(u8, u8) -> &u8) {
2811 54..58 'self': &Self
2813 118..120 'f2': fn(usize) -> u8
2814 139..141 'f3': fn(u8, u8) -> &u8
2815 162..210 '{ ...t(); }': ()
2817 168..177 'f1.test()': bool
2818 183..185 'f2': fn(usize) -> u8
2819 183..192 'f2.test()': bool
2820 198..200 'f3': fn(u8, u8) -> &u8
2821 198..207 'f3.test()': bool
2827 fn builtin_sized() {
2828 check_infer_with_mismatches(
2833 trait Test { fn test(&self) -> bool; }
2834 impl<T: Sized> Test for T {}
2838 (*"foo").test(); // not Sized
2840 (1u8, *"foo").test(); // not Sized
2844 56..60 'self': &Self
2845 113..228 '{ ...ized }': ()
2847 119..129 '1u8.test()': bool
2848 135..150 '(*"foo").test()': {unknown}
2849 136..142 '*"foo"': str
2850 137..142 '"foo"': &str
2851 169..179 '(1u8, 1u8)': (u8, u8)
2852 169..186 '(1u8, ...test()': bool
2855 192..205 '(1u8, *"foo")': (u8, str)
2856 192..212 '(1u8, ...test()': {unknown}
2858 198..204 '*"foo"': str
2859 199..204 '"foo"': &str
2865 fn integer_range_iterate() {
2868 //- /main.rs crate:main deps:core
2870 for x in 0..100 { x; }
2873 //- /core.rs crate:core
2875 pub struct Range<Idx> {
2882 pub trait Iterator {
2886 pub trait IntoIterator {
2888 type IntoIter: Iterator<Item = Self::Item>;
2891 impl<T> IntoIterator for T where T: Iterator {
2892 type Item = <T as Iterator>::Item;
2893 type IntoIter = Self;
2898 impl Step for i32 {}
2899 impl Step for i64 {}
2901 impl<A: Step> iter::Iterator for ops::Range<A> {
2909 fn infer_closure_arg() {
2920 let s = Option::None;
2921 let f = |x: Option<i32>| {};
2926 52..126 '{ ...)(s) }': ()
2927 62..63 's': Option<i32>
2928 66..78 'Option::None': Option<i32>
2929 88..89 'f': |Option<i32>| -> ()
2930 92..111 '|x: Op...2>| {}': |Option<i32>| -> ()
2931 93..94 'x': Option<i32>
2933 117..124 '(&f)(s)': ()
2934 118..120 '&f': &|Option<i32>| -> ()
2935 119..120 'f': |Option<i32>| -> ()
2936 122..123 's': Option<i32>
2942 fn infer_fn_trait_arg() {
2945 //- /lib.rs deps:std
2948 pub trait FnOnce<Args> {
2951 extern "rust-call" fn call_once(&self, args: Args) -> Self::Output;
2955 pub trait Fn<Args>:FnOnce<Args> {
2956 extern "rust-call" fn call(&self, args: Args) -> Self::Output;
2964 fn foo<F, T>(f: F) -> T
2966 F: Fn(Option<i32>) -> T,
2973 101..105 'self': &Self
2974 107..111 'args': Args
2975 220..224 'self': &Self
2976 226..230 'args': Args
2978 359..389 '{ ...f(s) }': T
2979 369..370 's': Option<i32>
2980 373..377 'None': Option<i32>
2983 385..386 's': Option<i32>
2989 fn infer_box_fn_arg() {
2992 //- /lib.rs deps:std
2995 pub trait FnOnce<Args> {
2998 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
3003 type Target: ?Sized;
3005 fn deref(&self) -> &Self::Target;
3008 #[lang = "owned_box"]
3009 pub struct Box<T: ?Sized> {
3013 impl<T: ?Sized> Deref for Box<T> {
3016 fn deref(&self) -> &T {
3027 let s = Option::None;
3028 let f: Box<dyn FnOnce(&Option<i32>)> = box (|ps| {});
3033 100..104 'self': Self
3034 106..110 'args': Args
3035 214..218 'self': &Self
3036 384..388 'self': &Box<T>
3037 396..423 '{ ... }': &T
3038 406..417 '&self.inner': &*mut T
3039 407..411 'self': &Box<T>
3040 407..417 'self.inner': *mut T
3041 478..575 '{ ...(&s) }': FnOnce::Output<dyn FnOnce(&Option<i32>), (&Option<i32>,)>
3042 488..489 's': Option<i32>
3043 492..504 'Option::None': Option<i32>
3044 514..515 'f': Box<dyn FnOnce(&Option<i32>)>
3045 549..562 'box (|ps| {})': Box<|{unknown}| -> ()>
3046 554..561 '|ps| {}': |{unknown}| -> ()
3047 555..557 'ps': {unknown}
3049 568..569 'f': Box<dyn FnOnce(&Option<i32>)>
3050 568..573 'f(&s)': FnOnce::Output<dyn FnOnce(&Option<i32>), (&Option<i32>,)>
3051 570..572 '&s': &Option<i32>
3052 571..572 's': Option<i32>
3058 fn infer_dyn_fn_output() {
3062 pub trait FnOnce<Args> {
3064 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
3068 pub trait Fn<Args>: FnOnce<Args> {
3069 extern "rust-call" fn call(&self, args: Args) -> Self::Output;
3073 let f: &dyn Fn() -> i32;
3081 fn infer_dyn_fn_once_output() {
3085 pub trait FnOnce<Args> {
3087 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
3091 let f: dyn FnOnce() -> i32;
3099 fn variable_kinds_1() {
3102 trait Trait<T> { fn get(self, t: T) -> T; }
3104 impl Trait<u128> for S {}
3105 impl Trait<f32> for S {}
3117 fn variable_kinds_2() {
3120 trait Trait { fn get(self) -> Self; }
3121 impl Trait for u128 {}
3122 impl Trait for f32 {}
3134 fn underscore_import() {
3139 fn method(&self) -> u8 { 0 }
3144 impl crate::tr::Tr for Tr {}
3146 use crate::tr::Tr as _;
3161 fn method(&self) -> u8 { 0 }
3178 fn inner_use_in_block() {
3183 fn method(&self) -> u8 { 0 }
3199 //^^^^^^^^^^^ {unknown}
3203 //^^^^^^^^^^^ {unknown}