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; }': ()
97 10..47 '{ ...&y]; }': ()
99 24..31 'unknown': {unknown}
100 37..44 '[y, &y]': [{unknown}; 2]
101 38..39 'y': {unknown}
102 41..43 '&y': &{unknown}
103 42..43 'y': {unknown}
109 fn recursive_vars_2() {
119 10..79 '{ ...x)]; }': ()
120 20..21 'x': &{unknown}
121 24..31 'unknown': &{unknown}
122 41..42 'y': {unknown}
123 45..52 'unknown': {unknown}
124 58..76 '[(x, y..., &x)]': [(&{unknown}, {unknown}); 2]
125 59..65 '(x, y)': (&{unknown}, {unknown})
126 60..61 'x': &{unknown}
127 63..64 'y': {unknown}
128 67..75 '(&y, &x)': (&{unknown}, {unknown})
129 68..70 '&y': &{unknown}
130 69..70 'y': {unknown}
131 72..74 '&x': &&{unknown}
132 73..74 'x': &{unknown}
138 fn infer_std_crash_1() {
139 // caused stack overflow, taken from std
148 match something_unknown {
149 Maybe::Real(ref mut something) => (),
154 53..138 '{ ... } }': ()
155 59..136 'match ... }': ()
156 65..82 'someth...nknown': Maybe<{unknown}>
157 93..123 'Maybe:...thing)': Maybe<{unknown}>
158 105..122 'ref mu...ething': &mut {unknown}
165 fn infer_std_crash_2() {
166 // caused "equating two type variables, ...", taken from std
169 fn test_line_buffer() {
170 &[0, b'\n', 1, b'\n'];
174 22..52 '{ ...n']; }': ()
175 28..49 '&[0, b...b'\n']': &[u8; 4]
176 29..49 '[0, b'...b'\n']': [u8; 4]
186 fn infer_std_crash_3() {
192 SizeSkeleton::Pointer { non_zero: true, tail } => {}
197 17..107 '{ ... } }': ()
198 23..105 'match ... }': ()
199 29..36 'nope!()': {unknown}
200 47..93 'SizeSk...tail }': {unknown}
203 87..91 'tail': {unknown}
210 fn infer_std_crash_4() {
214 pub fn primitive_type() {
216 BorrowedRef { type_: Primitive(p), ..} => {},
221 24..105 '{ ... } }': ()
222 30..103 'match ... }': ()
223 36..41 '*self': {unknown}
224 37..41 'self': {unknown}
225 52..90 'Borrow...), ..}': {unknown}
226 73..85 'Primitive(p)': {unknown}
227 83..84 'p': {unknown}
234 fn infer_std_crash_5() {
238 fn extra_compiler_flags() {
239 for content in doesnt_matter {
240 let name = if doesnt_matter {
246 let content = if ICE_REPORT_COMPILER_FLAGS_STRIP_VALUE.contains(&name) {
255 26..322 '{ ... } }': ()
256 32..320 'for co... }': ()
257 36..43 'content': {unknown}
258 47..60 'doesnt_matter': {unknown}
259 61..320 '{ ... }': ()
260 75..79 'name': &{unknown}
261 82..166 'if doe... }': &{unknown}
262 85..98 'doesnt_matter': bool
263 99..128 '{ ... }': &{unknown}
264 113..118 'first': &{unknown}
265 134..166 '{ ... }': &{unknown}
266 148..156 '&content': &{unknown}
267 149..156 'content': {unknown}
268 181..188 'content': &{unknown}
269 191..313 'if ICE... }': &{unknown}
270 194..231 'ICE_RE..._VALUE': {unknown}
271 194..247 'ICE_RE...&name)': bool
272 241..246 '&name': &&{unknown}
273 242..246 'name': &{unknown}
274 248..276 '{ ... }': &{unknown}
275 262..266 'name': &{unknown}
276 282..313 '{ ... }': {unknown}
277 296..303 'content': {unknown}
283 fn infer_nested_generics_crash() {
284 // another crash found typechecking rustc
287 struct Canonical<V> {
290 struct QueryResponse<V> {
293 fn test<R>(query_response: Canonical<QueryResponse<R>>) {
294 &query_response.value;
298 91..105 'query_response': Canonical<QueryResponse<R>>
299 136..166 '{ ...lue; }': ()
300 142..163 '&query....value': &QueryResponse<R>
301 143..157 'query_response': Canonical<QueryResponse<R>>
302 143..163 'query_....value': QueryResponse<R>
308 fn infer_paren_macro_call() {
311 macro_rules! bar { () => {0u32} }
318 44..69 '{ ...()); }': ()
325 fn infer_array_macro_call() {
328 macro_rules! bar { () => {0u32} }
335 44..69 '{ ...()]; }': ()
337 58..66 '[bar!()]': [u32; 1]
346 struct HashSet<T, H>;
348 type FxHashSet<T> = HashSet<T, FxHasher>;
350 impl<T, H> HashSet<T, H> {
351 fn default() -> HashSet<T, H> {}
355 FxHashSet::default();
360 168..197 '{ ...t(); }': ()
361 174..192 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<{unknown}, FxHasher>
362 174..194 'FxHash...ault()': HashSet<{unknown}, FxHasher>
373 struct Response<T> {}
379 impl<T:A> D for Response<T> {
389 119..214 '{ ... }': ()
390 129..132 'end': fn end<{unknown}>()
392 163..208 '{ ... }': ()
394 190..197 'loop {}': !
410 25..52 '{ ...oo() }': ()
411 31..48 '<Trait...>::foo': {unknown}
412 31..50 '<Trait...:foo()': ()
418 fn issue_2683_chars_impl() {
421 //- /main.rs crate:main deps:std
423 let chars: std::str::Chars<'_>;
424 (chars.next(), chars.nth(1));
425 } //^ (Option<char>, Option<char>)
427 //- /std.rs crate:std
429 use self::prelude::rust_2018::*;
432 pub use crate::iter::Iterator;
433 pub use crate::option::Option;
438 pub use self::traits::Iterator;
440 pub use self::iterator::Iterator;
445 fn next(&mut self) -> Option<Self::Item>;
446 fn nth(&mut self, n: usize) -> Option<Self::Item> {}
453 pub enum Option<T> {}
457 pub struct Chars<'a> {}
458 impl<'a> Iterator for Chars<'a> {
460 fn next(&mut self) -> Option<char> {}
468 fn issue_3642_bad_macro_stackover() {
472 macro_rules! match_ast {
473 (match $node:ident { $($tt:tt)* }) => { match_ast!(match ($node) { $($tt)* }) };
475 (match ($node:expr) {
476 $( ast::$ast:ident($it:ident) => $res:expr, )*
477 _ => $catch_all:expr $(,)?
479 $( if let Some($it) = ast::$ast::cast($node.clone()) { $res } else )*
485 let anchor = match_ast! {
497 fn issue_3999_slice() {
500 fn foo(params: &[usize]) {
507 7..13 'params': &[usize]
508 25..80 '{ ... } }': ()
509 31..78 'match ... }': ()
510 37..43 'params': &[usize]
511 54..66 '[ps @ .., _]': [usize]
512 55..62 'ps @ ..': &[usize]
521 fn issue_3999_struct() {
522 // rust-analyzer should not panic on seeing this malformed
537 43..95 '{ ... } }': ()
538 49..93 'match ... }': ()
540 67..80 'Bar { a: .. }': Bar
548 fn issue_4235_name_conflicts() {
552 static FOO:FOO = FOO {};
567 85..119 '{ ...o(); }': ()
572 109..116 'a.foo()': ()
578 fn issue_4465_dollar_crate_at_type() {
582 pub fn anything<T>() -> T {
587 let r: $crate::Foo = anything();
596 44..59 '{ loop {} }': T
599 !0..31 '{letr:...g();r}': Foo
601 !18..26 'anything': fn anything<Foo>() -> Foo
602 !18..28 'anything()': Foo
604 163..187 '{ ...!(); }': ()
614 macro_rules! profile_function {
629 103..131 '{ ...!(); }': ()
635 fn issue_4053_diesel_where_clauses() {
640 fn internal_into_boxed(self) -> Self::Output;
643 struct SelectStatement<From, Select, Distinct, Where, Order, LimitOffset, GroupBy, Locking> {
647 trait QueryFragment<DB: Backend> {}
649 trait Into<T> { fn into(self) -> T; }
651 impl<F, S, D, W, O, LOf, DB> BoxedDsl<DB>
652 for SelectStatement<F, S, D, W, O, LOf, G>
654 O: Into<dyn QueryFragment<DB>>,
658 fn internal_into_boxed(self) -> Self::Output {
665 267..271 'self': Self
666 466..470 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
667 488..522 '{ ... }': ()
668 498..502 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
669 498..508 'self.order': O
670 498..515 'self.o...into()': dyn QueryFragment<DB>
679 pub struct Foo(pub i64);
681 fn test() -> Self { Self(0i64) }
685 58..72 '{ Self(0i64) }': Foo
686 60..64 'Self': Foo(i64) -> Foo
687 60..70 'Self(0i64)': Foo
693 pub struct Foo<T>(pub T);
695 fn test() -> Self { Self(0i64) }
699 64..78 '{ Self(0i64) }': Foo<i64>
700 66..70 'Self': Foo<i64>(i64) -> Foo<i64>
701 66..76 'Self(0i64)': Foo<i64>
715 trait CheckedDiv: Div<()> {}
717 trait PrimInt: CheckedDiv<Output = ()> {
721 fn check<T: PrimInt>(i: T) {
726 117..121 'self': Self
728 154..170 '{ ...w(); }': ()
730 160..167 'i.pow()': ()
739 #[lang = "coerce_unsized"]
740 pub trait CoerceUnsized<T> {}
748 fn foo<R, K>(key: &K) -> impl Future<Output = K::Bar>
754 fn bar<R, K>(key: &K) -> impl Future<Output = K::Bar>
762 198..214 '{ ...key) }': impl Future<Output = <K as Foo<R>>::Bar>
763 204..207 'bar': fn bar<R, K>(&K) -> impl Future<Output = <K as Foo<R>>::Bar>
764 204..212 'bar(key)': impl Future<Output = <K as Foo<R>>::Bar>
780 type E1<T> = (T, T, T);
781 type E2<T> = E1<E1<E1<(T, T, T)>>>;
783 impl Debug for Foo<E2<()>> {}
791 pub struct PeerSet<D>;
793 impl<D> Service<Request> for PeerSet<D>
799 type Future = dyn Future<Output = Self::Error>;
801 fn call(&mut self) -> Self::Future {
810 pub trait Service<Request> {
812 type Future: Future<Output = Self::Error>;
813 fn call(&mut self) -> Self::Future;
817 379..383 'self': &mut PeerSet<D>
818 401..424 '{ ... }': dyn Future<Output = ()>
819 411..418 'loop {}': !
821 575..579 'self': &mut Self
830 pub trait IntoIterator {
834 struct Repeat<A> { element: A }
836 struct Map<F> { f: F }
845 impl<T> Deref for Vec<T> {
849 fn from_iter<A, T: IntoIterator<Item = A>>(iter: T) -> Vec<A> {}
852 let inner = Map { f: |_: &f64| 0.0 };
854 let repeat = Repeat { element: inner };
856 let vec = from_iter(repeat);
864 303..447 '{ ...r(); }': ()
865 313..318 'inner': Map<|&f64| -> f64>
866 321..345 'Map { ... 0.0 }': Map<|&f64| -> f64>
867 330..343 '|_: &f64| 0.0': |&f64| -> f64
870 356..362 'repeat': Repeat<Map<|&f64| -> f64>>
871 365..390 'Repeat...nner }': Repeat<Map<|&f64| -> f64>>
872 383..388 'inner': Map<|&f64| -> f64>
873 401..404 'vec': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
874 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>>>>
875 407..424 'from_i...epeat)': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
876 417..423 'repeat': Repeat<Map<|&f64| -> f64>>
877 431..434 'vec': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
878 431..444 'vec.foo_bar()': {unknown}
890 fn f(&self, _t: T) {}
891 fn g<F: FnOnce(&T)>(&self, _f: F) {}
906 109..160 '{ ...10); }': ()
908 123..124 'S': S<i32>() -> S<i32>
909 123..126 'S()': S<i32>
911 132..144 's.g(|_x| {})': ()
912 136..143 '|_x| {}': |&i32| -> ()
916 150..157 's.f(10)': ()
927 use core::ops::Deref;
932 struct MutexGuard<'a, T> {}
934 fn lock(&self) -> MutexGuard<'_, T> {}
936 impl<'a, T: 'a> Deref for MutexGuard<'a, T> {
940 let w: &Mutex<BufWriter>;
945 123..127 'self': &Mutex<T>
947 234..238 'self': &{unknown}
948 240..290 '{ ...()); }': ()
949 250..251 'w': &Mutex<BufWriter>
950 276..287 '*(w.lock())': BufWriter
951 278..279 'w': &Mutex<BufWriter>
952 278..286 'w.lock()': MutexGuard<BufWriter>
958 fn param_overrides_fn() {
961 fn example(example: i32) {
971 fn lifetime_from_chalk_during_deref() {
975 struct Box<T: ?Sized> {}
976 impl<T> core::ops::Deref for Box<T> {
979 fn deref(&self) -> &Self::Target {
988 pub struct Iter<'a, T: 'a> {
989 inner: Box<dyn IterTrait<'a, T, Item = &'a T> + 'a>,
992 trait IterTrait<'a, T: 'a>: Iterator<Item = &'a T> {
996 fn clone_iter<T>(s: Iter<T>) {
998 //^^^^^^^^^^^^^^^^^^^ ()
1008 pub trait Try: FromResidual {
1012 pub trait FromResidual<R = <Self as Try>::Residual> {
1013 fn from_residual(residual: R) -> Self;
1016 struct ControlFlow<B, C>;
1017 impl<B, C> Try for ControlFlow<B, C> {
1019 type Residual = ControlFlow<B, !>;
1021 impl<B, C> FromResidual for ControlFlow<B, C> {
1022 fn from_residual(r: ControlFlow<B, !>) -> Self { ControlFlow }
1026 ControlFlow::from_residual(ControlFlow::<u32, !>);
1030 144..152 'residual': R
1031 365..366 'r': ControlFlow<B, !>
1032 395..410 '{ ControlFlow }': ControlFlow<B, C>
1033 397..408 'ControlFlow': ControlFlow<B, C>
1034 424..482 '{ ...!>); }': ()
1035 430..456 'Contro...sidual': fn from_residual<ControlFlow<u32, {unknown}>, ControlFlow<u32, !>>(ControlFlow<u32, !>) -> ControlFlow<u32, {unknown}>
1036 430..479 'Contro...2, !>)': ControlFlow<u32, {unknown}>
1037 457..478 'Contro...32, !>': ControlFlow<u32, !>
1044 // https://github.com/rust-analyzer/rust-analyzer/issues/8378
1055 #[cfg(never)] { 11 }
1059 fn no_normal_tail(){
1064 fn no_actual_tail(){
1071 14..53 '{ ...)] 9 }': &str
1072 20..31 '{ "first" }': &str
1073 22..29 '"first"': &str
1074 72..190 '{ ...] 13 }': &str
1075 78..88 '{ "fake" }': &str
1076 80..86 '"fake"': &str
1077 93..103 '{ "fake" }': &str
1078 95..101 '"fake"': &str
1079 108..120 '{ "second" }': &str
1080 110..118 '"second"': &str
1081 210..273 '{ ... 15; }': &str
1082 216..227 '{ "third" }': &str
1083 218..225 '"third"': &str
1084 293..357 '{ ...] 15 }': ()
1085 299..311 '{ "fourth" }': &str
1086 301..309 '"fourth"': &str