1 use expect_test::expect;
3 use super::{check_infer, check_types};
14 10..37 '{ ... {}; }': ()
16 24..34 'if true {}': ()
24 fn no_panic_on_field_of_enum() {
35 25..46 '{ ...eld; }': ()
37 31..43 'x.some_field': {unknown}
55 10..88 '{ ... } }': ()
56 16..20 'X {}': {unknown}
57 26..86 'match ... }': ()
59 44..51 'A::B {}': {unknown}
61 67..73 'A::Y()': {unknown}
77 10..40 '{ ...+ y; }': ()
89 cov_mark::check!(type_var_cycles_resolve_completely);
90 cov_mark::check!(type_var_cycles_resolve_as_possible);
99 10..47 '{ ...&y]; }': ()
100 20..21 'y': &{unknown}
101 24..31 'unknown': &{unknown}
102 37..44 '[y, &y]': [&&{unknown}; _]
103 38..39 'y': &{unknown}
104 41..43 '&y': &&{unknown}
105 42..43 'y': &{unknown}
111 fn recursive_vars_2() {
121 10..79 '{ ...x)]; }': ()
122 20..21 'x': &&{unknown}
123 24..31 'unknown': &&{unknown}
124 41..42 'y': &&{unknown}
125 45..52 'unknown': &&{unknown}
126 58..76 '[(x, y..., &x)]': [(&&&{unknown}, &&&{unknown}); _]
127 59..65 '(x, y)': (&&&{unknown}, &&&{unknown})
128 60..61 'x': &&{unknown}
129 63..64 'y': &&{unknown}
130 67..75 '(&y, &x)': (&&&{unknown}, &&&{unknown})
131 68..70 '&y': &&&{unknown}
132 69..70 'y': &&{unknown}
133 72..74 '&x': &&&{unknown}
134 73..74 'x': &&{unknown}
140 fn infer_std_crash_1() {
141 // caused stack overflow, taken from std
150 match something_unknown {
151 Maybe::Real(ref mut something) => (),
156 53..138 '{ ... } }': ()
157 59..136 'match ... }': ()
158 65..82 'someth...nknown': Maybe<{unknown}>
159 93..123 'Maybe:...thing)': Maybe<{unknown}>
160 105..122 'ref mu...ething': &mut {unknown}
167 fn infer_std_crash_2() {
168 cov_mark::check!(type_var_resolves_to_int_var);
169 // caused "equating two type variables, ...", taken from std
172 fn test_line_buffer() {
173 &[0, b'\n', 1, b'\n'];
177 22..52 '{ ...n']; }': ()
178 28..49 '&[0, b...b'\n']': &[u8; _]
179 29..49 '[0, b'...b'\n']': [u8; _]
189 fn infer_std_crash_3() {
195 SizeSkeleton::Pointer { non_zero: true, tail } => {}
200 17..107 '{ ... } }': ()
201 23..105 'match ... }': ()
202 29..36 'nope!()': {unknown}
203 47..93 'SizeSk...tail }': {unknown}
206 87..91 'tail': {unknown}
213 fn infer_std_crash_4() {
217 pub fn primitive_type() {
219 BorrowedRef { type_: Primitive(p), ..} => {},
224 24..105 '{ ... } }': ()
225 30..103 'match ... }': ()
226 36..41 '*self': {unknown}
227 37..41 'self': {unknown}
228 52..90 'Borrow...), ..}': {unknown}
229 73..85 'Primitive(p)': {unknown}
230 83..84 'p': {unknown}
237 fn infer_std_crash_5() {
241 fn extra_compiler_flags() {
242 for content in doesnt_matter {
243 let name = if doesnt_matter {
249 let content = if ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.contains(&name) {
258 26..322 '{ ... } }': ()
259 32..320 'for co... }': ()
260 36..43 'content': &{unknown}
261 47..60 'doesnt_matter': {unknown}
262 61..320 '{ ... }': ()
263 75..79 'name': &&{unknown}
264 82..166 'if doe... }': &&{unknown}
265 85..98 'doesnt_matter': bool
266 99..128 '{ ... }': &&{unknown}
267 113..118 'first': &&{unknown}
268 134..166 '{ ... }': &&{unknown}
269 148..156 '&content': &&{unknown}
270 149..156 'content': &{unknown}
271 181..188 'content': &{unknown}
272 191..313 'if ICE... }': &{unknown}
273 194..231 'ICE_RE..._VALUE': {unknown}
274 194..247 'ICE_RE...&name)': bool
275 241..246 '&name': &&&{unknown}
276 242..246 'name': &&{unknown}
277 248..276 '{ ... }': &&{unknown}
278 262..266 'name': &&{unknown}
279 282..313 '{ ... }': &{unknown}
280 296..303 'content': &{unknown}
286 fn infer_nested_generics_crash() {
287 // another crash found typechecking rustc
290 struct Canonical<V> {
293 struct QueryResponse<V> {
296 fn test<R>(query_response: Canonical<QueryResponse<R>>) {
297 &query_response.value;
301 91..105 'query_response': Canonical<QueryResponse<R>>
302 136..166 '{ ...lue; }': ()
303 142..163 '&query....value': &QueryResponse<R>
304 143..157 'query_response': Canonical<QueryResponse<R>>
305 143..163 'query_....value': QueryResponse<R>
311 fn infer_paren_macro_call() {
314 macro_rules! bar { () => {0u32} }
321 44..69 '{ ...()); }': ()
328 fn infer_array_macro_call() {
331 macro_rules! bar { () => {0u32} }
338 44..69 '{ ...()]; }': ()
340 58..66 '[bar!()]': [u32; _]
349 struct HashSet<T, H>;
351 type FxHashSet<T> = HashSet<T, FxHasher>;
353 impl<T, H> HashSet<T, H> {
354 fn default() -> HashSet<T, H> {}
358 FxHashSet::default();
363 168..197 '{ ...t(); }': ()
364 174..192 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<{unknown}, FxHasher>
365 174..194 'FxHash...ault()': HashSet<{unknown}, FxHasher>
376 struct Response<T> {}
382 impl<T:A> D for Response<T> {
392 119..214 '{ ... }': ()
393 129..132 'end': fn end<{unknown}>()
395 163..208 '{ ... }': ()
397 190..197 'loop {}': !
413 25..52 '{ ...oo() }': ()
414 31..48 '<Trait...>::foo': {unknown}
415 31..50 '<Trait...:foo()': ()
421 fn issue_2683_chars_impl() {
424 //- /main.rs crate:main deps:std
426 let chars: std::str::Chars<'_>;
427 (chars.next(), chars.nth(1));
428 } //^ (Option<char>, Option<char>)
430 //- /std.rs crate:std
435 pub use crate::iter::Iterator;
436 pub use crate::option::Option;
440 pub use self::traits::Iterator;
442 pub use self::iterator::Iterator;
447 fn next(&mut self) -> Option<Self::Item>;
448 fn nth(&mut self, n: usize) -> Option<Self::Item> {}
455 pub enum Option<T> {}
459 pub struct Chars<'a> {}
460 impl<'a> Iterator for Chars<'a> {
462 fn next(&mut self) -> Option<char> {}
470 fn issue_3642_bad_macro_stackover() {
474 macro_rules! match_ast {
475 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) };
477 (match ($node:expr) {
478 $( ast::$ast:ident($it:ident) => $res:expr, )*
479 _ => $catch_all:expr $(,)?
481 $( if let Some($it) = ast::$ast::cast($node.clone()) { $res } else )*
487 let anchor = match_ast! {
499 fn issue_3999_slice() {
502 fn foo(params: &[usize]) {
509 7..13 'params': &[usize]
510 25..80 '{ ... } }': ()
511 31..78 'match ... }': ()
512 37..43 'params': &[usize]
513 54..66 '[ps @ .., _]': [usize]
514 55..62 'ps @ ..': &[usize]
523 fn issue_3999_struct() {
524 // rust-analyzer should not panic on seeing this malformed
539 43..95 '{ ... } }': ()
540 49..93 'match ... }': ()
542 67..80 'Bar { a: .. }': Bar
550 fn issue_4235_name_conflicts() {
554 static FOO:FOO = FOO {};
569 85..119 '{ ...o(); }': ()
574 109..116 'a.foo()': ()
580 fn issue_4465_dollar_crate_at_type() {
584 pub fn anything<T>() -> T {
589 let r: $crate::Foo = anything();
598 44..59 '{ loop {} }': T
601 !0..31 '{letr:...g();r}': Foo
603 !18..26 'anything': fn anything<Foo>() -> Foo
604 !18..28 'anything()': Foo
606 163..187 '{ ...!(); }': ()
616 macro_rules! profile_function {
631 103..131 '{ ...!(); }': ()
637 fn issue_4053_diesel_where_clauses() {
642 fn internal_into_boxed(self) -> Self::Output;
645 struct SelectStatement<From, Select, Distinct, Where, Order, LimitOffset, GroupBy, Locking> {
649 trait QueryFragment<DB: Backend> {}
651 trait Into<T> { fn into(self) -> T; }
653 impl<F, S, D, W, O, LOf, DB> BoxedDsl<DB>
654 for SelectStatement<F, S, D, W, O, LOf, G>
656 O: Into<dyn QueryFragment<DB>>,
660 fn internal_into_boxed(self) -> Self::Output {
667 267..271 'self': Self
668 466..470 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
669 488..522 '{ ... }': ()
670 498..502 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
671 498..508 'self.order': O
672 498..515 'self.o...into()': dyn QueryFragment<DB>
681 pub struct Foo(pub i64);
683 fn test() -> Self { Self(0i64) }
687 58..72 '{ Self(0i64) }': Foo
688 60..64 'Self': Foo(i64) -> Foo
689 60..70 'Self(0i64)': Foo
695 pub struct Foo<T>(pub T);
697 fn test() -> Self { Self(0i64) }
701 64..78 '{ Self(0i64) }': Foo<i64>
702 66..70 'Self': Foo<i64>(i64) -> Foo<i64>
703 66..76 'Self(0i64)': Foo<i64>
717 trait CheckedDiv: Div<()> {}
719 trait PrimInt: CheckedDiv<Output = ()> {
723 fn check<T: PrimInt>(i: T) {
728 117..121 'self': Self
730 154..170 '{ ...w(); }': ()
732 160..167 'i.pow()': ()
741 #[lang = "coerce_unsized"]
742 pub trait CoerceUnsized<T> {}
750 fn foo<R, K>(key: &K) -> impl Future<Output = K::Bar>
756 fn bar<R, K>(key: &K) -> impl Future<Output = K::Bar>
764 198..214 '{ ...key) }': impl Future<Output = <K as Foo<R>>::Bar>
765 204..207 'bar': fn bar<R, K>(&K) -> impl Future<Output = <K as Foo<R>>::Bar>
766 204..212 'bar(key)': impl Future<Output = <K as Foo<R>>::Bar>
782 type E1<T> = (T, T, T);
783 type E2<T> = E1<E1<E1<(T, T, T)>>>;
785 impl Debug for Foo<E2<()>> {}
793 pub struct PeerSet<D>;
795 impl<D> Service<Request> for PeerSet<D>
801 type Future = dyn Future<Output = Self::Error>;
803 fn call(&mut self) -> Self::Future {
812 pub trait Service<Request> {
814 type Future: Future<Output = Self::Error>;
815 fn call(&mut self) -> Self::Future;
819 379..383 'self': &mut PeerSet<D>
820 401..424 '{ ... }': dyn Future<Output = ()>
821 411..418 'loop {}': !
823 575..579 'self': &mut Self
832 pub trait IntoIterator {
836 struct Repeat<A> { element: A }
838 struct Map<F> { f: F }
847 impl<T> Deref for Vec<T> {
851 fn from_iter<A, T: IntoIterator<Item = A>>(iter: T) -> Vec<A> {}
854 let inner = Map { f: |_: &f64| 0.0 };
856 let repeat = Repeat { element: inner };
858 let vec = from_iter(repeat);
866 303..447 '{ ...r(); }': ()
867 313..318 'inner': Map<|&f64| -> f64>
868 321..345 'Map { ... 0.0 }': Map<|&f64| -> f64>
869 330..343 '|_: &f64| 0.0': |&f64| -> f64
872 356..362 'repeat': Repeat<Map<|&f64| -> f64>>
873 365..390 'Repeat...nner }': Repeat<Map<|&f64| -> f64>>
874 383..388 'inner': Map<|&f64| -> f64>
875 401..404 'vec': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
876 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>>>>
877 407..424 'from_i...epeat)': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
878 417..423 'repeat': Repeat<Map<|&f64| -> f64>>
879 431..434 'vec': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
880 431..444 'vec.foo_bar()': {unknown}
890 pub trait FnOnce<Args> {
896 fn f(&self, _t: T) {}
897 fn g<F: FnOnce(&T)>(&self, _f: F) {}
906 105..109 'self': &S<T>
909 146..150 'self': &S<T>
912 174..225 '{ ...10); }': ()
914 188..189 'S': S<i32>() -> S<i32>
915 188..191 'S()': S<i32>
917 197..209 's.g(|_x| {})': ()
918 201..208 '|_x| {}': |&i32| -> ()
922 215..222 's.f(10)': ()
940 struct MutexGuard<'a, T> {}
942 fn lock(&self) -> MutexGuard<'_, T> {}
944 impl<'a, T: 'a> Deref for MutexGuard<'a, T> {
948 let w: &Mutex<BufWriter>;
953 156..160 'self': &Mutex<T>
955 267..271 'self': &{unknown}
956 273..323 '{ ...()); }': ()
957 283..284 'w': &Mutex<BufWriter>
958 309..320 '*(w.lock())': BufWriter
959 311..312 'w': &Mutex<BufWriter>
960 311..319 'w.lock()': MutexGuard<BufWriter>
966 fn param_overrides_fn() {
969 fn example(example: i32) {