1 use expect_test::expect;
4 use super::{check_infer, check_types};
15 10..37 '{ ... {}; }': ()
17 24..34 'if true {}': ()
25 fn no_panic_on_field_of_enum() {
36 25..46 '{ ...eld; }': ()
38 31..43 'x.some_field': {unknown}
56 10..88 '{ ... } }': ()
57 16..20 'X {}': {unknown}
58 26..86 'match ... }': ()
60 44..51 'A::B {}': {unknown}
62 67..73 'A::Y()': {unknown}
78 10..40 '{ ...+ y; }': ()
90 mark::check!(type_var_cycles_resolve_completely);
91 mark::check!(type_var_cycles_resolve_as_possible);
100 10..47 '{ ...&y]; }': ()
101 20..21 'y': &{unknown}
102 24..31 'unknown': &{unknown}
103 37..44 '[y, &y]': [&&{unknown}; _]
104 38..39 'y': &{unknown}
105 41..43 '&y': &&{unknown}
106 42..43 'y': &{unknown}
112 fn recursive_vars_2() {
122 10..79 '{ ...x)]; }': ()
123 20..21 'x': &&{unknown}
124 24..31 'unknown': &&{unknown}
125 41..42 'y': &&{unknown}
126 45..52 'unknown': &&{unknown}
127 58..76 '[(x, y..., &x)]': [(&&&{unknown}, &&&{unknown}); _]
128 59..65 '(x, y)': (&&&{unknown}, &&&{unknown})
129 60..61 'x': &&{unknown}
130 63..64 'y': &&{unknown}
131 67..75 '(&y, &x)': (&&&{unknown}, &&&{unknown})
132 68..70 '&y': &&&{unknown}
133 69..70 'y': &&{unknown}
134 72..74 '&x': &&&{unknown}
135 73..74 'x': &&{unknown}
141 fn infer_std_crash_1() {
142 // caused stack overflow, taken from std
151 match something_unknown {
152 Maybe::Real(ref mut something) => (),
157 53..138 '{ ... } }': ()
158 59..136 'match ... }': ()
159 65..82 'someth...nknown': Maybe<{unknown}>
160 93..123 'Maybe:...thing)': Maybe<{unknown}>
161 105..122 'ref mu...ething': &mut {unknown}
168 fn infer_std_crash_2() {
169 mark::check!(type_var_resolves_to_int_var);
170 // caused "equating two type variables, ...", taken from std
173 fn test_line_buffer() {
174 &[0, b'\n', 1, b'\n'];
178 22..52 '{ ...n']; }': ()
179 28..49 '&[0, b...b'\n']': &[u8; _]
180 29..49 '[0, b'...b'\n']': [u8; _]
190 fn infer_std_crash_3() {
196 SizeSkeleton::Pointer { non_zero: true, tail } => {}
201 17..107 '{ ... } }': ()
202 23..105 'match ... }': ()
203 29..36 'nope!()': {unknown}
204 47..93 'SizeSk...tail }': {unknown}
207 87..91 'tail': {unknown}
214 fn infer_std_crash_4() {
218 pub fn primitive_type() {
220 BorrowedRef { type_: Primitive(p), ..} => {},
225 24..105 '{ ... } }': ()
226 30..103 'match ... }': ()
227 36..41 '*self': {unknown}
228 37..41 'self': {unknown}
229 52..90 'Borrow...), ..}': {unknown}
230 73..85 'Primitive(p)': {unknown}
231 83..84 'p': {unknown}
238 fn infer_std_crash_5() {
242 fn extra_compiler_flags() {
243 for content in doesnt_matter {
244 let name = if doesnt_matter {
250 let content = if ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.contains(&name) {
259 26..322 '{ ... } }': ()
260 32..320 'for co... }': ()
261 36..43 'content': &{unknown}
262 47..60 'doesnt_matter': {unknown}
263 61..320 '{ ... }': ()
264 75..79 'name': &&{unknown}
265 82..166 'if doe... }': &&{unknown}
266 85..98 'doesnt_matter': bool
267 99..128 '{ ... }': &&{unknown}
268 113..118 'first': &&{unknown}
269 134..166 '{ ... }': &&{unknown}
270 148..156 '&content': &&{unknown}
271 149..156 'content': &{unknown}
272 181..188 'content': &{unknown}
273 191..313 'if ICE... }': &{unknown}
274 194..231 'ICE_RE..._VALUE': {unknown}
275 194..247 'ICE_RE...&name)': bool
276 241..246 '&name': &&&{unknown}
277 242..246 'name': &&{unknown}
278 248..276 '{ ... }': &&{unknown}
279 262..266 'name': &&{unknown}
280 282..313 '{ ... }': &{unknown}
281 296..303 'content': &{unknown}
287 fn infer_nested_generics_crash() {
288 // another crash found typechecking rustc
291 struct Canonical<V> {
294 struct QueryResponse<V> {
297 fn test<R>(query_response: Canonical<QueryResponse<R>>) {
298 &query_response.value;
302 91..105 'query_response': Canonical<QueryResponse<R>>
303 136..166 '{ ...lue; }': ()
304 142..163 '&query....value': &QueryResponse<R>
305 143..157 'query_response': Canonical<QueryResponse<R>>
306 143..163 'query_....value': QueryResponse<R>
312 fn infer_paren_macro_call() {
315 macro_rules! bar { () => {0u32} }
322 44..69 '{ ...()); }': ()
329 fn infer_array_macro_call() {
332 macro_rules! bar { () => {0u32} }
339 44..69 '{ ...()]; }': ()
341 58..66 '[bar!()]': [u32; _]
350 struct HashSet<T, H>;
352 type FxHashSet<T> = HashSet<T, FxHasher>;
354 impl<T, H> HashSet<T, H> {
355 fn default() -> HashSet<T, H> {}
359 FxHashSet::default();
364 168..197 '{ ...t(); }': ()
365 174..192 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<{unknown}, FxHasher>
366 174..194 'FxHash...ault()': HashSet<{unknown}, FxHasher>
377 struct Response<T> {}
383 impl<T:A> D for Response<T> {
393 119..214 '{ ... }': ()
394 129..132 'end': fn end<{unknown}>()
396 163..208 '{ ... }': ()
398 190..197 'loop {}': !
414 25..52 '{ ...oo() }': ()
415 31..48 '<Trait...>::foo': {unknown}
416 31..50 '<Trait...:foo()': ()
422 fn issue_2683_chars_impl() {
425 //- /main.rs crate:main deps:std
427 let chars: std::str::Chars<'_>;
428 (chars.next(), chars.nth(1));
429 } //^ (Option<char>, Option<char>)
431 //- /std.rs crate:std
436 pub use crate::iter::Iterator;
437 pub use crate::option::Option;
441 pub use self::traits::Iterator;
443 pub use self::iterator::Iterator;
448 fn next(&mut self) -> Option<Self::Item>;
449 fn nth(&mut self, n: usize) -> Option<Self::Item> {}
456 pub enum Option<T> {}
460 pub struct Chars<'a> {}
461 impl<'a> Iterator for Chars<'a> {
463 fn next(&mut self) -> Option<char> {}
471 fn issue_3642_bad_macro_stackover() {
475 macro_rules! match_ast {
476 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) };
478 (match ($node:expr) {
479 $( ast::$ast:ident($it:ident) => $res:expr, )*
480 _ => $catch_all:expr $(,)?
482 $( if let Some($it) = ast::$ast::cast($node.clone()) { $res } else )*
488 let anchor = match_ast! {
500 fn issue_3999_slice() {
503 fn foo(params: &[usize]) {
510 7..13 'params': &[usize]
511 25..80 '{ ... } }': ()
512 31..78 'match ... }': ()
513 37..43 'params': &[usize]
514 54..66 '[ps @ .., _]': [usize]
515 55..62 'ps @ ..': &[usize]
524 fn issue_3999_struct() {
525 // rust-analyzer should not panic on seeing this malformed
540 43..95 '{ ... } }': ()
541 49..93 'match ... }': ()
543 67..80 'Bar { a: .. }': Bar
551 fn issue_4235_name_conflicts() {
555 static FOO:FOO = FOO {};
570 85..119 '{ ...o(); }': ()
575 109..116 'a.foo()': ()
581 fn issue_4465_dollar_crate_at_type() {
585 pub fn anything<T>() -> T {
590 let r: $crate::Foo = anything();
599 44..59 '{ loop {} }': T
602 !0..31 '{letr:...g();r}': Foo
604 !18..26 'anything': fn anything<Foo>() -> Foo
605 !18..28 'anything()': Foo
607 163..187 '{ ...!(); }': ()
617 macro_rules! profile_function {
632 103..131 '{ ...!(); }': ()
638 fn issue_4053_diesel_where_clauses() {
643 fn internal_into_boxed(self) -> Self::Output;
646 struct SelectStatement<From, Select, Distinct, Where, Order, LimitOffset, GroupBy, Locking> {
650 trait QueryFragment<DB: Backend> {}
652 trait Into<T> { fn into(self) -> T; }
654 impl<F, S, D, W, O, LOf, DB> BoxedDsl<DB>
655 for SelectStatement<F, S, D, W, O, LOf, G>
657 O: Into<dyn QueryFragment<DB>>,
661 fn internal_into_boxed(self) -> Self::Output {
668 267..271 'self': Self
669 466..470 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
670 488..522 '{ ... }': ()
671 498..502 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
672 498..508 'self.order': O
673 498..515 'self.o...into()': dyn QueryFragment<DB>
682 pub struct Foo(pub i64);
684 fn test() -> Self { Self(0i64) }
688 58..72 '{ Self(0i64) }': Foo
689 60..64 'Self': Foo(i64) -> Foo
690 60..70 'Self(0i64)': Foo
696 pub struct Foo<T>(pub T);
698 fn test() -> Self { Self(0i64) }
702 64..78 '{ Self(0i64) }': Foo<i64>
703 66..70 'Self': Foo<i64>(i64) -> Foo<i64>
704 66..76 'Self(0i64)': Foo<i64>
718 trait CheckedDiv: Div<()> {}
720 trait PrimInt: CheckedDiv<Output = ()> {
724 fn check<T: PrimInt>(i: T) {
729 117..121 'self': Self
731 154..170 '{ ...w(); }': ()
733 160..167 'i.pow()': ()
742 #[lang = "coerce_unsized"]
743 pub trait CoerceUnsized<T> {}
751 fn foo<R, K>(key: &K) -> impl Future<Output = K::Bar>
757 fn bar<R, K>(key: &K) -> impl Future<Output = K::Bar>
765 198..214 '{ ...key) }': impl Future<Output = <K as Foo<R>>::Bar>
766 204..207 'bar': fn bar<R, K>(&K) -> impl Future<Output = <K as Foo<R>>::Bar>
767 204..212 'bar(key)': impl Future<Output = <K as Foo<R>>::Bar>
783 type E1<T> = (T, T, T);
784 type E2<T> = E1<E1<E1<(T, T, T)>>>;
786 impl Debug for Foo<E2<()>> {}
794 pub struct PeerSet<D>;
796 impl<D> Service<Request> for PeerSet<D>
802 type Future = dyn Future<Output = Self::Error>;
804 fn call(&mut self) -> Self::Future {
813 pub trait Service<Request> {
815 type Future: Future<Output = Self::Error>;
816 fn call(&mut self) -> Self::Future;
820 379..383 'self': &mut PeerSet<D>
821 401..424 '{ ... }': dyn Future<Output = ()>
822 411..418 'loop {}': !
824 575..579 'self': &mut Self
833 pub trait IntoIterator {
837 struct Repeat<A> { element: A }
839 struct Map<F> { f: F }
848 impl<T> Deref for Vec<T> {
852 fn from_iter<A, T: IntoIterator<Item = A>>(iter: T) -> Vec<A> {}
855 let inner = Map { f: |_: &f64| 0.0 };
857 let repeat = Repeat { element: inner };
859 let vec = from_iter(repeat);
867 303..447 '{ ...r(); }': ()
868 313..318 'inner': Map<|&f64| -> f64>
869 321..345 'Map { ... 0.0 }': Map<|&f64| -> f64>
870 330..343 '|_: &f64| 0.0': |&f64| -> f64
873 356..362 'repeat': Repeat<Map<|&f64| -> f64>>
874 365..390 'Repeat...nner }': Repeat<Map<|&f64| -> f64>>
875 383..388 'inner': Map<|&f64| -> f64>
876 401..404 'vec': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
877 407..416 'from_iter': fn from_iter<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>, Repeat<Map<|&f64| -> f64>>>(Repeat<Map<|&f64| -> f64>>) -> Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
878 407..424 'from_i...epeat)': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
879 417..423 'repeat': Repeat<Map<|&f64| -> f64>>
880 431..434 'vec': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
881 431..444 'vec.foo_bar()': {unknown}
891 pub trait FnOnce<Args> {
897 fn f(&self, _t: T) {}
898 fn g<F: FnOnce(&T)>(&self, _f: F) {}
907 105..109 'self': &S<T>
910 146..150 'self': &S<T>
913 174..225 '{ ...10); }': ()
915 188..189 'S': S<i32>() -> S<i32>
916 188..191 'S()': S<i32>
918 197..209 's.g(|_x| {})': ()
919 201..208 '|_x| {}': |&i32| -> ()
923 215..222 's.f(10)': ()
941 struct MutexGuard<'a, T> {}
943 fn lock(&self) -> MutexGuard<'_, T> {}
945 impl<'a, T: 'a> Deref for MutexGuard<'a, T> {
949 let w: &Mutex<BufWriter>;
954 156..160 'self': &Mutex<T>
956 267..271 'self': &{unknown}
957 273..323 '{ ...()); }': ()
958 283..284 'w': &Mutex<BufWriter>
959 309..320 '*(w.lock())': BufWriter
960 311..312 'w': &Mutex<BufWriter>
961 311..319 'w.lock()': MutexGuard<BufWriter>