aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r--crates/ra_hir_ty/src/_match.rs77
-rw-r--r--crates/ra_hir_ty/src/db.rs15
-rw-r--r--crates/ra_hir_ty/src/diagnostics.rs12
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs81
-rw-r--r--crates/ra_hir_ty/src/infer/pat.rs33
-rw-r--r--crates/ra_hir_ty/src/infer/path.rs2
-rw-r--r--crates/ra_hir_ty/src/lib.rs63
-rw-r--r--crates/ra_hir_ty/src/lower.rs25
-rw-r--r--crates/ra_hir_ty/src/method_resolution.rs198
-rw-r--r--crates/ra_hir_ty/src/tests.rs16
-rw-r--r--crates/ra_hir_ty/src/tests/coercion.rs632
-rw-r--r--crates/ra_hir_ty/src/tests/macros.rs120
-rw-r--r--crates/ra_hir_ty/src/tests/method_resolution.rs380
-rw-r--r--crates/ra_hir_ty/src/tests/never_type.rs190
-rw-r--r--crates/ra_hir_ty/src/tests/patterns.rs627
-rw-r--r--crates/ra_hir_ty/src/tests/regression.rs447
-rw-r--r--crates/ra_hir_ty/src/tests/simple.rs1654
-rw-r--r--crates/ra_hir_ty/src/tests/traits.rs1597
-rw-r--r--crates/ra_hir_ty/src/traits.rs43
-rw-r--r--crates/ra_hir_ty/src/traits/builtin.rs20
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs28
-rw-r--r--crates/ra_hir_ty/src/utils.rs14
22 files changed, 3458 insertions, 2816 deletions
diff --git a/crates/ra_hir_ty/src/_match.rs b/crates/ra_hir_ty/src/_match.rs
index 02a7a61f1..5495ce284 100644
--- a/crates/ra_hir_ty/src/_match.rs
+++ b/crates/ra_hir_ty/src/_match.rs
@@ -312,20 +312,16 @@ impl PatStack {
312 Self(v) 312 Self(v)
313 } 313 }
314 314
315 fn is_empty(&self) -> bool {
316 self.0.is_empty()
317 }
318
319 fn head(&self) -> PatIdOrWild {
320 self.0[0]
321 }
322
323 fn get_head(&self) -> Option<PatIdOrWild> { 315 fn get_head(&self) -> Option<PatIdOrWild> {
324 self.0.first().copied() 316 self.0.first().copied()
325 } 317 }
326 318
319 fn tail(&self) -> &[PatIdOrWild] {
320 self.0.get(1..).unwrap_or(&[])
321 }
322
327 fn to_tail(&self) -> PatStack { 323 fn to_tail(&self) -> PatStack {
328 Self::from_slice(&self.0[1..]) 324 Self::from_slice(self.tail())
329 } 325 }
330 326
331 fn replace_head_with<I, T>(&self, pats: I) -> PatStack 327 fn replace_head_with<I, T>(&self, pats: I) -> PatStack
@@ -347,7 +343,7 @@ impl PatStack {
347 /// 343 ///
348 /// See the module docs and the associated documentation in rustc for details. 344 /// See the module docs and the associated documentation in rustc for details.
349 fn specialize_wildcard(&self, cx: &MatchCheckCtx) -> Option<PatStack> { 345 fn specialize_wildcard(&self, cx: &MatchCheckCtx) -> Option<PatStack> {
350 if matches!(self.head().as_pat(cx), Pat::Wild) { 346 if matches!(self.get_head()?.as_pat(cx), Pat::Wild) {
351 Some(self.to_tail()) 347 Some(self.to_tail())
352 } else { 348 } else {
353 None 349 None
@@ -362,11 +358,12 @@ impl PatStack {
362 cx: &MatchCheckCtx, 358 cx: &MatchCheckCtx,
363 constructor: &Constructor, 359 constructor: &Constructor,
364 ) -> MatchCheckResult<Option<PatStack>> { 360 ) -> MatchCheckResult<Option<PatStack>> {
365 if self.is_empty() { 361 let head = match self.get_head() {
366 return Ok(None); 362 Some(head) => head,
367 } 363 None => return Ok(None),
364 };
368 365
369 let head_pat = self.head().as_pat(cx); 366 let head_pat = head.as_pat(cx);
370 let result = match (head_pat, constructor) { 367 let result = match (head_pat, constructor) {
371 (Pat::Tuple { args: ref pat_ids, ellipsis }, Constructor::Tuple { arity: _ }) => { 368 (Pat::Tuple { args: ref pat_ids, ellipsis }, Constructor::Tuple { arity: _ }) => {
372 if ellipsis.is_some() { 369 if ellipsis.is_some() {
@@ -394,7 +391,7 @@ impl PatStack {
394 (Pat::Wild, constructor) => Some(self.expand_wildcard(cx, constructor)?), 391 (Pat::Wild, constructor) => Some(self.expand_wildcard(cx, constructor)?),
395 (Pat::Path(_), Constructor::Enum(constructor)) => { 392 (Pat::Path(_), Constructor::Enum(constructor)) => {
396 // unit enum variants become `Pat::Path` 393 // unit enum variants become `Pat::Path`
397 let pat_id = self.head().as_id().expect("we know this isn't a wild"); 394 let pat_id = head.as_id().expect("we know this isn't a wild");
398 if !enum_variant_matches(cx, pat_id, *constructor) { 395 if !enum_variant_matches(cx, pat_id, *constructor) {
399 None 396 None
400 } else { 397 } else {
@@ -405,7 +402,7 @@ impl PatStack {
405 Pat::TupleStruct { args: ref pat_ids, ellipsis, .. }, 402 Pat::TupleStruct { args: ref pat_ids, ellipsis, .. },
406 Constructor::Enum(enum_constructor), 403 Constructor::Enum(enum_constructor),
407 ) => { 404 ) => {
408 let pat_id = self.head().as_id().expect("we know this isn't a wild"); 405 let pat_id = head.as_id().expect("we know this isn't a wild");
409 if !enum_variant_matches(cx, pat_id, *enum_constructor) { 406 if !enum_variant_matches(cx, pat_id, *enum_constructor) {
410 None 407 None
411 } else { 408 } else {
@@ -445,7 +442,7 @@ impl PatStack {
445 } 442 }
446 } 443 }
447 (Pat::Record { args: ref arg_patterns, .. }, Constructor::Enum(e)) => { 444 (Pat::Record { args: ref arg_patterns, .. }, Constructor::Enum(e)) => {
448 let pat_id = self.head().as_id().expect("we know this isn't a wild"); 445 let pat_id = head.as_id().expect("we know this isn't a wild");
449 if !enum_variant_matches(cx, pat_id, *e) { 446 if !enum_variant_matches(cx, pat_id, *e) {
450 None 447 None
451 } else { 448 } else {
@@ -491,7 +488,7 @@ impl PatStack {
491 ) -> MatchCheckResult<PatStack> { 488 ) -> MatchCheckResult<PatStack> {
492 assert_eq!( 489 assert_eq!(
493 Pat::Wild, 490 Pat::Wild,
494 self.head().as_pat(cx), 491 self.get_head().expect("expand_wildcard called on empty PatStack").as_pat(cx),
495 "expand_wildcard must only be called on PatStack with wild at head", 492 "expand_wildcard must only be called on PatStack with wild at head",
496 ); 493 );
497 494
@@ -509,7 +506,6 @@ impl PatStack {
509 } 506 }
510} 507}
511 508
512#[derive(Debug)]
513/// A collection of PatStack. 509/// A collection of PatStack.
514/// 510///
515/// This type is modeled from the struct of the same name in `rustc`. 511/// This type is modeled from the struct of the same name in `rustc`.
@@ -623,13 +619,16 @@ pub(crate) fn is_useful(
623 _ => (), 619 _ => (),
624 } 620 }
625 621
626 if v.is_empty() { 622 let head = match v.get_head() {
627 let result = if matrix.is_empty() { Usefulness::Useful } else { Usefulness::NotUseful }; 623 Some(head) => head,
624 None => {
625 let result = if matrix.is_empty() { Usefulness::Useful } else { Usefulness::NotUseful };
628 626
629 return Ok(result); 627 return Ok(result);
630 } 628 }
629 };
631 630
632 if let Pat::Or(pat_ids) = v.head().as_pat(cx) { 631 if let Pat::Or(pat_ids) = head.as_pat(cx) {
633 let mut found_unimplemented = false; 632 let mut found_unimplemented = false;
634 let any_useful = pat_ids.iter().any(|&pat_id| { 633 let any_useful = pat_ids.iter().any(|&pat_id| {
635 let v = PatStack::from_pattern(pat_id); 634 let v = PatStack::from_pattern(pat_id);
@@ -653,7 +652,7 @@ pub(crate) fn is_useful(
653 }; 652 };
654 } 653 }
655 654
656 if let Some(constructor) = pat_constructor(cx, v.head())? { 655 if let Some(constructor) = pat_constructor(cx, head)? {
657 let matrix = matrix.specialize_constructor(&cx, &constructor)?; 656 let matrix = matrix.specialize_constructor(&cx, &constructor)?;
658 let v = v 657 let v = v
659 .specialize_constructor(&cx, &constructor)? 658 .specialize_constructor(&cx, &constructor)?
@@ -854,10 +853,10 @@ mod tests {
854 } 853 }
855 854
856 pub(super) fn check_no_diagnostic(ra_fixture: &str) { 855 pub(super) fn check_no_diagnostic(ra_fixture: &str) {
857 let diagnostic_count = 856 let (s, diagnostic_count) =
858 TestDB::with_single_file(ra_fixture).0.diagnostic::<MissingMatchArms>().1; 857 TestDB::with_single_file(ra_fixture).0.diagnostic::<MissingMatchArms>();
859 858
860 assert_eq!(0, diagnostic_count, "expected no diagnostic, found one"); 859 assert_eq!(0, diagnostic_count, "expected no diagnostic, found one: {}", s);
861 } 860 }
862 861
863 #[test] 862 #[test]
@@ -2014,6 +2013,28 @@ mod tests {
2014 ", 2013 ",
2015 ); 2014 );
2016 } 2015 }
2016
2017 #[test]
2018 fn or_pattern_panic_2() {
2019 // FIXME: This is a false positive, but the code used to cause a panic in the match checker,
2020 // so this acts as a regression test for that.
2021 check_diagnostic(
2022 r"
2023 pub enum Category {
2024 Infinity,
2025 Zero,
2026 }
2027
2028 fn panic(a: Category, b: Category) {
2029 match (a, b) {
2030 (Category::Infinity, Category::Infinity) | (Category::Zero, Category::Zero) => {}
2031
2032 (Category::Infinity | Category::Zero, _) => {}
2033 }
2034 }
2035 ",
2036 );
2037 }
2017} 2038}
2018 2039
2019#[cfg(test)] 2040#[cfg(test)]
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index bf71d38d6..7889b8d2c 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -3,15 +3,15 @@
3use std::sync::Arc; 3use std::sync::Arc;
4 4
5use hir_def::{ 5use hir_def::{
6 db::DefDatabase, DefWithBodyId, FunctionId, GenericDefId, ImplId, LocalFieldId, TraitId, 6 db::DefDatabase, DefWithBodyId, FunctionId, GenericDefId, ImplId, LocalFieldId, TypeParamId,
7 TypeParamId, VariantId, 7 VariantId,
8}; 8};
9use ra_arena::map::ArenaMap; 9use ra_arena::map::ArenaMap;
10use ra_db::{impl_intern_key, salsa, CrateId, Upcast}; 10use ra_db::{impl_intern_key, salsa, CrateId, Upcast};
11use ra_prof::profile; 11use ra_prof::profile;
12 12
13use crate::{ 13use crate::{
14 method_resolution::{CrateImplDefs, TyFingerprint}, 14 method_resolution::CrateImplDefs,
15 traits::{chalk, AssocTyValue, Impl}, 15 traits::{chalk, AssocTyValue, Impl},
16 Binders, CallableDef, GenericPredicate, InferenceResult, OpaqueTyId, PolyFnSig, 16 Binders, CallableDef, GenericPredicate, InferenceResult, OpaqueTyId, PolyFnSig,
17 ReturnTypeImplTraits, Substs, TraitRef, Ty, TyDefId, TypeCtor, ValueTyDefId, 17 ReturnTypeImplTraits, Substs, TraitRef, Ty, TyDefId, TypeCtor, ValueTyDefId,
@@ -70,13 +70,8 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
70 #[salsa::invoke(crate::method_resolution::CrateImplDefs::impls_in_crate_query)] 70 #[salsa::invoke(crate::method_resolution::CrateImplDefs::impls_in_crate_query)]
71 fn impls_in_crate(&self, krate: CrateId) -> Arc<CrateImplDefs>; 71 fn impls_in_crate(&self, krate: CrateId) -> Arc<CrateImplDefs>;
72 72
73 #[salsa::invoke(crate::traits::impls_for_trait_query)] 73 #[salsa::invoke(crate::method_resolution::CrateImplDefs::impls_from_deps_query)]
74 fn impls_for_trait( 74 fn impls_from_deps(&self, krate: CrateId) -> Arc<CrateImplDefs>;
75 &self,
76 krate: CrateId,
77 trait_: TraitId,
78 self_ty_fp: Option<TyFingerprint>,
79 ) -> Arc<[ImplId]>;
80 75
81 // Interned IDs for Chalk integration 76 // Interned IDs for Chalk integration
82 #[salsa::interned] 77 #[salsa::interned]
diff --git a/crates/ra_hir_ty/src/diagnostics.rs b/crates/ra_hir_ty/src/diagnostics.rs
index 2c7298714..ebd9cb08f 100644
--- a/crates/ra_hir_ty/src/diagnostics.rs
+++ b/crates/ra_hir_ty/src/diagnostics.rs
@@ -6,7 +6,7 @@ use hir_expand::{db::AstDatabase, name::Name, HirFileId, InFile};
6use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr}; 6use ra_syntax::{ast, AstNode, AstPtr, SyntaxNodePtr};
7use stdx::format_to; 7use stdx::format_to;
8 8
9pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm}; 9pub use hir_def::{diagnostics::UnresolvedModule, expr::MatchArm, path::Path};
10pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink}; 10pub use hir_expand::diagnostics::{AstDiagnostic, Diagnostic, DiagnosticSink};
11 11
12#[derive(Debug)] 12#[derive(Debug)]
@@ -29,6 +29,16 @@ impl Diagnostic for NoSuchField {
29 } 29 }
30} 30}
31 31
32impl AstDiagnostic for NoSuchField {
33 type AST = ast::RecordField;
34
35 fn ast(&self, db: &impl AstDatabase) -> Self::AST {
36 let root = db.parse_or_expand(self.source().file_id).unwrap();
37 let node = self.source().value.to_node(&root);
38 ast::RecordField::cast(node).unwrap()
39 }
40}
41
32#[derive(Debug)] 42#[derive(Debug)]
33pub struct MissingFields { 43pub struct MissingFields {
34 pub file: HirFileId, 44 pub file: HirFileId,
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index 9fd310f69..a9565a58d 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -10,12 +10,12 @@ use hir_def::{
10 resolver::resolver_for_expr, 10 resolver::resolver_for_expr,
11 AdtId, AssocContainerId, FieldId, Lookup, 11 AdtId, AssocContainerId, FieldId, Lookup,
12}; 12};
13use hir_expand::name::Name; 13use hir_expand::name::{name, Name};
14use ra_syntax::ast::RangeOp; 14use ra_syntax::ast::RangeOp;
15 15
16use crate::{ 16use crate::{
17 autoderef, method_resolution, op, 17 autoderef, method_resolution, op,
18 traits::InEnvironment, 18 traits::{FnTrait, InEnvironment},
19 utils::{generics, variant_data, Generics}, 19 utils::{generics, variant_data, Generics},
20 ApplicationTy, Binders, CallableDef, InferTy, IntTy, Mutability, Obligation, Rawness, Substs, 20 ApplicationTy, Binders, CallableDef, InferTy, IntTy, Mutability, Obligation, Rawness, Substs,
21 TraitRef, Ty, TypeCtor, 21 TraitRef, Ty, TypeCtor,
@@ -63,6 +63,58 @@ impl<'a> InferenceContext<'a> {
63 self.resolve_ty_as_possible(ty) 63 self.resolve_ty_as_possible(ty)
64 } 64 }
65 65
66 fn callable_sig_from_fn_trait(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<Ty>, Ty)> {
67 let krate = self.resolver.krate()?;
68 let fn_once_trait = FnTrait::FnOnce.get_id(self.db, krate)?;
69 let output_assoc_type =
70 self.db.trait_data(fn_once_trait).associated_type_by_name(&name![Output])?;
71 let generic_params = generics(self.db.upcast(), fn_once_trait.into());
72 if generic_params.len() != 2 {
73 return None;
74 }
75
76 let mut param_builder = Substs::builder(num_args);
77 let mut arg_tys = vec![];
78 for _ in 0..num_args {
79 let arg = self.table.new_type_var();
80 param_builder = param_builder.push(arg.clone());
81 arg_tys.push(arg);
82 }
83 let parameters = param_builder.build();
84 let arg_ty = Ty::Apply(ApplicationTy {
85 ctor: TypeCtor::Tuple { cardinality: num_args as u16 },
86 parameters,
87 });
88 let substs = Substs::build_for_generics(&generic_params)
89 .push(ty.clone())
90 .push(arg_ty.clone())
91 .build();
92
93 let trait_env = Arc::clone(&self.trait_env);
94 let implements_fn_trait =
95 Obligation::Trait(TraitRef { trait_: fn_once_trait, substs: substs.clone() });
96 let goal = self.canonicalizer().canonicalize_obligation(InEnvironment {
97 value: implements_fn_trait.clone(),
98 environment: trait_env,
99 });
100 if self.db.trait_solve(krate, goal.value).is_some() {
101 self.obligations.push(implements_fn_trait);
102 let output_proj_ty =
103 crate::ProjectionTy { associated_ty: output_assoc_type, parameters: substs };
104 let return_ty = self.normalize_projection_ty(output_proj_ty);
105 Some((arg_tys, return_ty))
106 } else {
107 None
108 }
109 }
110
111 pub fn callable_sig(&mut self, ty: &Ty, num_args: usize) -> Option<(Vec<Ty>, Ty)> {
112 match ty.callable_sig(self.db) {
113 Some(sig) => Some((sig.params().to_vec(), sig.ret().clone())),
114 None => self.callable_sig_from_fn_trait(ty, num_args),
115 }
116 }
117
66 fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty { 118 fn infer_expr_inner(&mut self, tgt_expr: ExprId, expected: &Expectation) -> Ty {
67 let body = Arc::clone(&self.body); // avoid borrow checker problem 119 let body = Arc::clone(&self.body); // avoid borrow checker problem
68 let ty = match &body[tgt_expr] { 120 let ty = match &body[tgt_expr] {
@@ -198,14 +250,23 @@ impl<'a> InferenceContext<'a> {
198 } 250 }
199 Expr::Call { callee, args } => { 251 Expr::Call { callee, args } => {
200 let callee_ty = self.infer_expr(*callee, &Expectation::none()); 252 let callee_ty = self.infer_expr(*callee, &Expectation::none());
201 let (param_tys, ret_ty) = match callee_ty.callable_sig(self.db) { 253 let canonicalized = self.canonicalizer().canonicalize_ty(callee_ty.clone());
202 Some(sig) => (sig.params().to_vec(), sig.ret().clone()), 254 let mut derefs = autoderef(
203 None => { 255 self.db,
204 // Not callable 256 self.resolver.krate(),
205 // FIXME: report an error 257 InEnvironment {
206 (Vec::new(), Ty::Unknown) 258 value: canonicalized.value.clone(),
207 } 259 environment: self.trait_env.clone(),
208 }; 260 },
261 );
262 let (param_tys, ret_ty): (Vec<Ty>, Ty) = derefs
263 .find_map(|callee_deref_ty| {
264 self.callable_sig(
265 &canonicalized.decanonicalize_ty(callee_deref_ty.value),
266 args.len(),
267 )
268 })
269 .unwrap_or((Vec::new(), Ty::Unknown));
209 self.register_obligations_for_call(&callee_ty); 270 self.register_obligations_for_call(&callee_ty);
210 self.check_call_arguments(args, &param_tys); 271 self.check_call_arguments(args, &param_tys);
211 self.normalize_associated_types_in(ret_ty) 272 self.normalize_associated_types_in(ret_ty)
diff --git a/crates/ra_hir_ty/src/infer/pat.rs b/crates/ra_hir_ty/src/infer/pat.rs
index 4006f595d..23de2bd6b 100644
--- a/crates/ra_hir_ty/src/infer/pat.rs
+++ b/crates/ra_hir_ty/src/infer/pat.rs
@@ -4,7 +4,7 @@ use std::iter::repeat;
4use std::sync::Arc; 4use std::sync::Arc;
5 5
6use hir_def::{ 6use hir_def::{
7 expr::{BindingAnnotation, Pat, PatId, RecordFieldPat}, 7 expr::{BindingAnnotation, Expr, Literal, Pat, PatId, RecordFieldPat},
8 path::Path, 8 path::Path,
9 type_ref::Mutability, 9 type_ref::Mutability,
10 FieldId, 10 FieldId,
@@ -90,18 +90,7 @@ impl<'a> InferenceContext<'a> {
90 ) -> Ty { 90 ) -> Ty {
91 let body = Arc::clone(&self.body); // avoid borrow checker problem 91 let body = Arc::clone(&self.body); // avoid borrow checker problem
92 92
93 let is_non_ref_pat = match &body[pat] { 93 if is_non_ref_pat(&body, pat) {
94 Pat::Tuple { .. }
95 | Pat::Or(..)
96 | Pat::TupleStruct { .. }
97 | Pat::Record { .. }
98 | Pat::Range { .. }
99 | Pat::Slice { .. } => true,
100 // FIXME: Path/Lit might actually evaluate to ref, but inference is unimplemented.
101 Pat::Path(..) | Pat::Lit(..) => true,
102 Pat::Wild | Pat::Bind { .. } | Pat::Ref { .. } | Pat::Missing => false,
103 };
104 if is_non_ref_pat {
105 while let Some((inner, mutability)) = expected.as_reference() { 94 while let Some((inner, mutability)) = expected.as_reference() {
106 expected = inner; 95 expected = inner;
107 default_bm = match default_bm { 96 default_bm = match default_bm {
@@ -227,3 +216,21 @@ impl<'a> InferenceContext<'a> {
227 ty 216 ty
228 } 217 }
229} 218}
219
220fn is_non_ref_pat(body: &hir_def::body::Body, pat: PatId) -> bool {
221 match &body[pat] {
222 Pat::Tuple { .. }
223 | Pat::TupleStruct { .. }
224 | Pat::Record { .. }
225 | Pat::Range { .. }
226 | Pat::Slice { .. } => true,
227 Pat::Or(pats) => pats.iter().all(|p| is_non_ref_pat(body, *p)),
228 // FIXME: Path/Lit might actually evaluate to ref, but inference is unimplemented.
229 Pat::Path(..) => true,
230 Pat::Lit(expr) => match body[*expr] {
231 Expr::Literal(Literal::String(..)) => false,
232 _ => true,
233 },
234 Pat::Wild | Pat::Bind { .. } | Pat::Ref { .. } | Pat::Missing => false,
235 }
236}
diff --git a/crates/ra_hir_ty/src/infer/path.rs b/crates/ra_hir_ty/src/infer/path.rs
index 1ad0d8397..80d7ed10e 100644
--- a/crates/ra_hir_ty/src/infer/path.rs
+++ b/crates/ra_hir_ty/src/infer/path.rs
@@ -81,7 +81,7 @@ impl<'a> InferenceContext<'a> {
81 let generics = crate::utils::generics(self.db.upcast(), impl_id.into()); 81 let generics = crate::utils::generics(self.db.upcast(), impl_id.into());
82 let substs = Substs::type_params_for_generics(&generics); 82 let substs = Substs::type_params_for_generics(&generics);
83 let ty = self.db.impl_self_ty(impl_id).subst(&substs); 83 let ty = self.db.impl_self_ty(impl_id).subst(&substs);
84 if let Some((AdtId::StructId(struct_id), _)) = ty.as_adt() { 84 if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() {
85 let ty = self.db.value_ty(struct_id.into()).subst(&substs); 85 let ty = self.db.value_ty(struct_id.into()).subst(&substs);
86 return Some(ty); 86 return Some(ty);
87 } else { 87 } else {
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 2b9372b4b..f22232324 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -73,6 +73,7 @@ pub use lower::{
73pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; 73pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
74 74
75pub use chalk_ir::{BoundVar, DebruijnIndex}; 75pub use chalk_ir::{BoundVar, DebruijnIndex};
76use itertools::Itertools;
76 77
77/// A type constructor or type name: this might be something like the primitive 78/// A type constructor or type name: this might be something like the primitive
78/// type `bool`, a struct like `Vec`, or things like function pointers or 79/// type `bool`, a struct like `Vec`, or things like function pointers or
@@ -815,6 +816,11 @@ impl Ty {
815 } 816 }
816 } 817 }
817 818
819 /// If this is a `dyn Trait`, returns that trait.
820 pub fn dyn_trait(&self) -> Option<TraitId> {
821 self.dyn_trait_ref().map(|it| it.trait_)
822 }
823
818 fn builtin_deref(&self) -> Option<Ty> { 824 fn builtin_deref(&self) -> Option<Ty> {
819 match self { 825 match self {
820 Ty::Apply(a_ty) => match a_ty.ctor { 826 Ty::Apply(a_ty) => match a_ty.ctor {
@@ -867,13 +873,56 @@ impl Ty {
867 } 873 }
868 } 874 }
869 875
870 /// If this is a `dyn Trait`, returns that trait. 876 pub fn impl_trait_bounds(&self, db: &dyn HirDatabase) -> Option<Vec<GenericPredicate>> {
871 pub fn dyn_trait(&self) -> Option<TraitId> {
872 match self { 877 match self {
873 Ty::Dyn(predicates) => predicates.iter().find_map(|pred| match pred { 878 Ty::Opaque(opaque_ty) => {
874 GenericPredicate::Implemented(tr) => Some(tr.trait_), 879 let predicates = match opaque_ty.opaque_ty_id {
875 _ => None, 880 OpaqueTyId::ReturnTypeImplTrait(func, idx) => {
876 }), 881 db.return_type_impl_traits(func).map(|it| {
882 let data = (*it)
883 .as_ref()
884 .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone());
885 data.clone().subst(&opaque_ty.parameters)
886 })
887 }
888 };
889
890 predicates.map(|it| it.value)
891 }
892 Ty::Placeholder(id) => {
893 let generic_params = db.generic_params(id.parent);
894 let param_data = &generic_params.types[id.local_id];
895 match param_data.provenance {
896 hir_def::generics::TypeParamProvenance::ArgumentImplTrait => {
897 let predicates = db
898 .generic_predicates_for_param(*id)
899 .into_iter()
900 .map(|pred| pred.value.clone())
901 .collect_vec();
902
903 Some(predicates)
904 }
905 _ => None,
906 }
907 }
908 _ => None,
909 }
910 }
911
912 pub fn associated_type_parent_trait(&self, db: &dyn HirDatabase) -> Option<TraitId> {
913 match self {
914 Ty::Apply(ApplicationTy { ctor: TypeCtor::AssociatedType(type_alias_id), .. }) => {
915 match type_alias_id.lookup(db.upcast()).container {
916 AssocContainerId::TraitId(trait_id) => Some(trait_id),
917 _ => None,
918 }
919 }
920 Ty::Projection(projection_ty) => {
921 match projection_ty.associated_ty.lookup(db.upcast()).container {
922 AssocContainerId::TraitId(trait_id) => Some(trait_id),
923 _ => None,
924 }
925 }
877 _ => None, 926 _ => None,
878 } 927 }
879 } 928 }
@@ -1057,5 +1106,5 @@ pub struct ReturnTypeImplTraits {
1057 1106
1058#[derive(Clone, PartialEq, Eq, Debug, Hash)] 1107#[derive(Clone, PartialEq, Eq, Debug, Hash)]
1059pub(crate) struct ReturnTypeImplTrait { 1108pub(crate) struct ReturnTypeImplTrait {
1060 pub(crate) bounds: Binders<Vec<GenericPredicate>>, 1109 pub bounds: Binders<Vec<GenericPredicate>>,
1061} 1110}
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index 42713928f..d5154f436 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -337,17 +337,17 @@ impl Ty {
337 TraitRef::from_resolved_path(ctx, trait_, resolved_segment, self_ty); 337 TraitRef::from_resolved_path(ctx, trait_, resolved_segment, self_ty);
338 let ty = if remaining_segments.len() == 1 { 338 let ty = if remaining_segments.len() == 1 {
339 let segment = remaining_segments.first().unwrap(); 339 let segment = remaining_segments.first().unwrap();
340 let associated_ty = associated_type_by_name_including_super_traits( 340 let found = associated_type_by_name_including_super_traits(
341 ctx.db.upcast(), 341 ctx.db,
342 trait_ref.trait_, 342 trait_ref.clone(),
343 &segment.name, 343 &segment.name,
344 ); 344 );
345 match associated_ty { 345 match found {
346 Some(associated_ty) => { 346 Some((super_trait_ref, associated_ty)) => {
347 // FIXME handle type parameters on the segment 347 // FIXME handle type parameters on the segment
348 Ty::Projection(ProjectionTy { 348 Ty::Projection(ProjectionTy {
349 associated_ty, 349 associated_ty,
350 parameters: trait_ref.substs, 350 parameters: super_trait_ref.substs,
351 }) 351 })
352 } 352 }
353 None => { 353 None => {
@@ -467,6 +467,9 @@ impl Ty {
467 } 467 }
468 TypeParamLoweringMode::Variable => t.substs.clone(), 468 TypeParamLoweringMode::Variable => t.substs.clone(),
469 }; 469 };
470 // We need to shift in the bound vars, since
471 // associated_type_shorthand_candidates does not do that
472 let substs = substs.shift_bound_vars(ctx.in_binders);
470 // FIXME handle type parameters on the segment 473 // FIXME handle type parameters on the segment
471 return Some(Ty::Projection(ProjectionTy { 474 return Some(Ty::Projection(ProjectionTy {
472 associated_ty, 475 associated_ty,
@@ -706,17 +709,17 @@ fn assoc_type_bindings_from_type_bound<'a>(
706 .flat_map(|segment| segment.args_and_bindings.into_iter()) 709 .flat_map(|segment| segment.args_and_bindings.into_iter())
707 .flat_map(|args_and_bindings| args_and_bindings.bindings.iter()) 710 .flat_map(|args_and_bindings| args_and_bindings.bindings.iter())
708 .flat_map(move |binding| { 711 .flat_map(move |binding| {
709 let associated_ty = associated_type_by_name_including_super_traits( 712 let found = associated_type_by_name_including_super_traits(
710 ctx.db.upcast(), 713 ctx.db,
711 trait_ref.trait_, 714 trait_ref.clone(),
712 &binding.name, 715 &binding.name,
713 ); 716 );
714 let associated_ty = match associated_ty { 717 let (super_trait_ref, associated_ty) = match found {
715 None => return SmallVec::<[GenericPredicate; 1]>::new(), 718 None => return SmallVec::<[GenericPredicate; 1]>::new(),
716 Some(t) => t, 719 Some(t) => t,
717 }; 720 };
718 let projection_ty = 721 let projection_ty =
719 ProjectionTy { associated_ty, parameters: trait_ref.substs.clone() }; 722 ProjectionTy { associated_ty, parameters: super_trait_ref.substs.clone() };
720 let mut preds = SmallVec::with_capacity( 723 let mut preds = SmallVec::with_capacity(
721 binding.type_ref.as_ref().map_or(0, |_| 1) + binding.bounds.len(), 724 binding.type_ref.as_ref().map_or(0, |_| 1) + binding.bounds.len(),
722 ); 725 );
diff --git a/crates/ra_hir_ty/src/method_resolution.rs b/crates/ra_hir_ty/src/method_resolution.rs
index e83b39456..8b59a8bd6 100644
--- a/crates/ra_hir_ty/src/method_resolution.rs
+++ b/crates/ra_hir_ty/src/method_resolution.rs
@@ -38,18 +38,53 @@ impl TyFingerprint {
38 } 38 }
39} 39}
40 40
41/// A queryable and mergeable collection of impls.
41#[derive(Debug, PartialEq, Eq)] 42#[derive(Debug, PartialEq, Eq)]
42pub struct CrateImplDefs { 43pub struct CrateImplDefs {
43 impls: FxHashMap<TyFingerprint, Vec<ImplId>>, 44 inherent_impls: FxHashMap<TyFingerprint, Vec<ImplId>>,
44 impls_by_trait: FxHashMap<TraitId, FxHashMap<Option<TyFingerprint>, Vec<ImplId>>>, 45 impls_by_trait: FxHashMap<TraitId, FxHashMap<Option<TyFingerprint>, Vec<ImplId>>>,
45} 46}
46 47
47impl CrateImplDefs { 48impl CrateImplDefs {
48 pub(crate) fn impls_in_crate_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<CrateImplDefs> { 49 pub(crate) fn impls_in_crate_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<CrateImplDefs> {
49 let _p = profile("impls_in_crate_query"); 50 let _p = profile("impls_in_crate_query");
50 let mut res = 51 let mut res = CrateImplDefs {
51 CrateImplDefs { impls: FxHashMap::default(), impls_by_trait: FxHashMap::default() }; 52 inherent_impls: FxHashMap::default(),
53 impls_by_trait: FxHashMap::default(),
54 };
55 res.fill(db, krate);
56
57 Arc::new(res)
58 }
59
60 /// Collects all impls from transitive dependencies of `krate` that may be used by `krate`.
61 ///
62 /// The full set of impls that can be used by `krate` is the returned map plus all the impls
63 /// from `krate` itself.
64 pub(crate) fn impls_from_deps_query(
65 db: &dyn HirDatabase,
66 krate: CrateId,
67 ) -> Arc<CrateImplDefs> {
68 let _p = profile("impls_from_deps_query");
69 let crate_graph = db.crate_graph();
70 let mut res = CrateImplDefs {
71 inherent_impls: FxHashMap::default(),
72 impls_by_trait: FxHashMap::default(),
73 };
74
75 // For each dependency, calculate `impls_from_deps` recursively, then add its own
76 // `impls_in_crate`.
77 // As we might visit crates multiple times, `merge` has to deduplicate impls to avoid
78 // wasting memory.
79 for dep in &crate_graph[krate].dependencies {
80 res.merge(&db.impls_from_deps(dep.crate_id));
81 res.merge(&db.impls_in_crate(dep.crate_id));
82 }
52 83
84 Arc::new(res)
85 }
86
87 fn fill(&mut self, db: &dyn HirDatabase, krate: CrateId) {
53 let crate_def_map = db.crate_def_map(krate); 88 let crate_def_map = db.crate_def_map(krate);
54 for (_module_id, module_data) in crate_def_map.modules.iter() { 89 for (_module_id, module_data) in crate_def_map.modules.iter() {
55 for impl_id in module_data.scope.impls() { 90 for impl_id in module_data.scope.impls() {
@@ -57,7 +92,7 @@ impl CrateImplDefs {
57 Some(tr) => { 92 Some(tr) => {
58 let self_ty = db.impl_self_ty(impl_id); 93 let self_ty = db.impl_self_ty(impl_id);
59 let self_ty_fp = TyFingerprint::for_impl(&self_ty.value); 94 let self_ty_fp = TyFingerprint::for_impl(&self_ty.value);
60 res.impls_by_trait 95 self.impls_by_trait
61 .entry(tr.value.trait_) 96 .entry(tr.value.trait_)
62 .or_default() 97 .or_default()
63 .entry(self_ty_fp) 98 .entry(self_ty_fp)
@@ -67,18 +102,36 @@ impl CrateImplDefs {
67 None => { 102 None => {
68 let self_ty = db.impl_self_ty(impl_id); 103 let self_ty = db.impl_self_ty(impl_id);
69 if let Some(self_ty_fp) = TyFingerprint::for_impl(&self_ty.value) { 104 if let Some(self_ty_fp) = TyFingerprint::for_impl(&self_ty.value) {
70 res.impls.entry(self_ty_fp).or_default().push(impl_id); 105 self.inherent_impls.entry(self_ty_fp).or_default().push(impl_id);
71 } 106 }
72 } 107 }
73 } 108 }
74 } 109 }
75 } 110 }
111 }
112
113 fn merge(&mut self, other: &Self) {
114 for (fp, impls) in &other.inherent_impls {
115 let vec = self.inherent_impls.entry(*fp).or_default();
116 vec.extend(impls);
117 vec.sort();
118 vec.dedup();
119 }
76 120
77 Arc::new(res) 121 for (trait_, other_map) in &other.impls_by_trait {
122 let map = self.impls_by_trait.entry(*trait_).or_default();
123 for (fp, impls) in other_map {
124 let vec = map.entry(*fp).or_default();
125 vec.extend(impls);
126 vec.sort();
127 vec.dedup();
128 }
129 }
78 } 130 }
131
79 pub fn lookup_impl_defs(&self, ty: &Ty) -> impl Iterator<Item = ImplId> + '_ { 132 pub fn lookup_impl_defs(&self, ty: &Ty) -> impl Iterator<Item = ImplId> + '_ {
80 let fingerprint = TyFingerprint::for_impl(ty); 133 let fingerprint = TyFingerprint::for_impl(ty);
81 fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flatten().copied() 134 fingerprint.and_then(|f| self.inherent_impls.get(&f)).into_iter().flatten().copied()
82 } 135 }
83 136
84 pub fn lookup_impl_defs_for_trait(&self, tr: TraitId) -> impl Iterator<Item = ImplId> + '_ { 137 pub fn lookup_impl_defs_for_trait(&self, tr: TraitId) -> impl Iterator<Item = ImplId> + '_ {
@@ -110,7 +163,7 @@ impl CrateImplDefs {
110 } 163 }
111 164
112 pub fn all_impls<'a>(&'a self) -> impl Iterator<Item = ImplId> + 'a { 165 pub fn all_impls<'a>(&'a self) -> impl Iterator<Item = ImplId> + 'a {
113 self.impls 166 self.inherent_impls
114 .values() 167 .values()
115 .chain(self.impls_by_trait.values().flat_map(|m| m.values())) 168 .chain(self.impls_by_trait.values().flat_map(|m| m.values()))
116 .flatten() 169 .flatten()
@@ -218,6 +271,33 @@ pub fn iterate_method_candidates<T>(
218 mode: LookupMode, 271 mode: LookupMode,
219 mut callback: impl FnMut(&Ty, AssocItemId) -> Option<T>, 272 mut callback: impl FnMut(&Ty, AssocItemId) -> Option<T>,
220) -> Option<T> { 273) -> Option<T> {
274 let mut slot = None;
275 iterate_method_candidates_impl(
276 ty,
277 db,
278 env,
279 krate,
280 traits_in_scope,
281 name,
282 mode,
283 &mut |ty, item| {
284 slot = callback(ty, item);
285 slot.is_some()
286 },
287 );
288 slot
289}
290
291pub fn iterate_method_candidates_impl(
292 ty: &Canonical<Ty>,
293 db: &dyn HirDatabase,
294 env: Arc<TraitEnvironment>,
295 krate: CrateId,
296 traits_in_scope: &FxHashSet<TraitId>,
297 name: Option<&Name>,
298 mode: LookupMode,
299 callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool,
300) -> bool {
221 match mode { 301 match mode {
222 LookupMode::MethodCall => { 302 LookupMode::MethodCall => {
223 // For method calls, rust first does any number of autoderef, and then one 303 // For method calls, rust first does any number of autoderef, and then one
@@ -245,19 +325,19 @@ pub fn iterate_method_candidates<T>(
245 325
246 let deref_chain = autoderef_method_receiver(db, krate, ty); 326 let deref_chain = autoderef_method_receiver(db, krate, ty);
247 for i in 0..deref_chain.len() { 327 for i in 0..deref_chain.len() {
248 if let Some(result) = iterate_method_candidates_with_autoref( 328 if iterate_method_candidates_with_autoref(
249 &deref_chain[i..], 329 &deref_chain[i..],
250 db, 330 db,
251 env.clone(), 331 env.clone(),
252 krate, 332 krate,
253 traits_in_scope, 333 traits_in_scope,
254 name, 334 name,
255 &mut callback, 335 callback,
256 ) { 336 ) {
257 return Some(result); 337 return true;
258 } 338 }
259 } 339 }
260 None 340 false
261 } 341 }
262 LookupMode::Path => { 342 LookupMode::Path => {
263 // No autoderef for path lookups 343 // No autoderef for path lookups
@@ -268,22 +348,22 @@ pub fn iterate_method_candidates<T>(
268 krate, 348 krate,
269 traits_in_scope, 349 traits_in_scope,
270 name, 350 name,
271 &mut callback, 351 callback,
272 ) 352 )
273 } 353 }
274 } 354 }
275} 355}
276 356
277fn iterate_method_candidates_with_autoref<T>( 357fn iterate_method_candidates_with_autoref(
278 deref_chain: &[Canonical<Ty>], 358 deref_chain: &[Canonical<Ty>],
279 db: &dyn HirDatabase, 359 db: &dyn HirDatabase,
280 env: Arc<TraitEnvironment>, 360 env: Arc<TraitEnvironment>,
281 krate: CrateId, 361 krate: CrateId,
282 traits_in_scope: &FxHashSet<TraitId>, 362 traits_in_scope: &FxHashSet<TraitId>,
283 name: Option<&Name>, 363 name: Option<&Name>,
284 mut callback: impl FnMut(&Ty, AssocItemId) -> Option<T>, 364 mut callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool,
285) -> Option<T> { 365) -> bool {
286 if let Some(result) = iterate_method_candidates_by_receiver( 366 if iterate_method_candidates_by_receiver(
287 &deref_chain[0], 367 &deref_chain[0],
288 &deref_chain[1..], 368 &deref_chain[1..],
289 db, 369 db,
@@ -293,13 +373,13 @@ fn iterate_method_candidates_with_autoref<T>(
293 name, 373 name,
294 &mut callback, 374 &mut callback,
295 ) { 375 ) {
296 return Some(result); 376 return true;
297 } 377 }
298 let refed = Canonical { 378 let refed = Canonical {
299 num_vars: deref_chain[0].num_vars, 379 num_vars: deref_chain[0].num_vars,
300 value: Ty::apply_one(TypeCtor::Ref(Mutability::Shared), deref_chain[0].value.clone()), 380 value: Ty::apply_one(TypeCtor::Ref(Mutability::Shared), deref_chain[0].value.clone()),
301 }; 381 };
302 if let Some(result) = iterate_method_candidates_by_receiver( 382 if iterate_method_candidates_by_receiver(
303 &refed, 383 &refed,
304 deref_chain, 384 deref_chain,
305 db, 385 db,
@@ -309,13 +389,13 @@ fn iterate_method_candidates_with_autoref<T>(
309 name, 389 name,
310 &mut callback, 390 &mut callback,
311 ) { 391 ) {
312 return Some(result); 392 return true;
313 } 393 }
314 let ref_muted = Canonical { 394 let ref_muted = Canonical {
315 num_vars: deref_chain[0].num_vars, 395 num_vars: deref_chain[0].num_vars,
316 value: Ty::apply_one(TypeCtor::Ref(Mutability::Mut), deref_chain[0].value.clone()), 396 value: Ty::apply_one(TypeCtor::Ref(Mutability::Mut), deref_chain[0].value.clone()),
317 }; 397 };
318 if let Some(result) = iterate_method_candidates_by_receiver( 398 if iterate_method_candidates_by_receiver(
319 &ref_muted, 399 &ref_muted,
320 deref_chain, 400 deref_chain,
321 db, 401 db,
@@ -325,12 +405,12 @@ fn iterate_method_candidates_with_autoref<T>(
325 name, 405 name,
326 &mut callback, 406 &mut callback,
327 ) { 407 ) {
328 return Some(result); 408 return true;
329 } 409 }
330 None 410 false
331} 411}
332 412
333fn iterate_method_candidates_by_receiver<T>( 413fn iterate_method_candidates_by_receiver(
334 receiver_ty: &Canonical<Ty>, 414 receiver_ty: &Canonical<Ty>,
335 rest_of_deref_chain: &[Canonical<Ty>], 415 rest_of_deref_chain: &[Canonical<Ty>],
336 db: &dyn HirDatabase, 416 db: &dyn HirDatabase,
@@ -338,20 +418,18 @@ fn iterate_method_candidates_by_receiver<T>(
338 krate: CrateId, 418 krate: CrateId,
339 traits_in_scope: &FxHashSet<TraitId>, 419 traits_in_scope: &FxHashSet<TraitId>,
340 name: Option<&Name>, 420 name: Option<&Name>,
341 mut callback: impl FnMut(&Ty, AssocItemId) -> Option<T>, 421 mut callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool,
342) -> Option<T> { 422) -> bool {
343 // We're looking for methods with *receiver* type receiver_ty. These could 423 // We're looking for methods with *receiver* type receiver_ty. These could
344 // be found in any of the derefs of receiver_ty, so we have to go through 424 // be found in any of the derefs of receiver_ty, so we have to go through
345 // that. 425 // that.
346 for self_ty in std::iter::once(receiver_ty).chain(rest_of_deref_chain) { 426 for self_ty in std::iter::once(receiver_ty).chain(rest_of_deref_chain) {
347 if let Some(result) = 427 if iterate_inherent_methods(self_ty, db, name, Some(receiver_ty), krate, &mut callback) {
348 iterate_inherent_methods(self_ty, db, name, Some(receiver_ty), krate, &mut callback) 428 return true;
349 {
350 return Some(result);
351 } 429 }
352 } 430 }
353 for self_ty in std::iter::once(receiver_ty).chain(rest_of_deref_chain) { 431 for self_ty in std::iter::once(receiver_ty).chain(rest_of_deref_chain) {
354 if let Some(result) = iterate_trait_method_candidates( 432 if iterate_trait_method_candidates(
355 self_ty, 433 self_ty,
356 db, 434 db,
357 env.clone(), 435 env.clone(),
@@ -361,40 +439,28 @@ fn iterate_method_candidates_by_receiver<T>(
361 Some(receiver_ty), 439 Some(receiver_ty),
362 &mut callback, 440 &mut callback,
363 ) { 441 ) {
364 return Some(result); 442 return true;
365 } 443 }
366 } 444 }
367 None 445 false
368} 446}
369 447
370fn iterate_method_candidates_for_self_ty<T>( 448fn iterate_method_candidates_for_self_ty(
371 self_ty: &Canonical<Ty>, 449 self_ty: &Canonical<Ty>,
372 db: &dyn HirDatabase, 450 db: &dyn HirDatabase,
373 env: Arc<TraitEnvironment>, 451 env: Arc<TraitEnvironment>,
374 krate: CrateId, 452 krate: CrateId,
375 traits_in_scope: &FxHashSet<TraitId>, 453 traits_in_scope: &FxHashSet<TraitId>,
376 name: Option<&Name>, 454 name: Option<&Name>,
377 mut callback: impl FnMut(&Ty, AssocItemId) -> Option<T>, 455 mut callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool,
378) -> Option<T> { 456) -> bool {
379 if let Some(result) = iterate_inherent_methods(self_ty, db, name, None, krate, &mut callback) { 457 if iterate_inherent_methods(self_ty, db, name, None, krate, &mut callback) {
380 return Some(result); 458 return true;
381 }
382 if let Some(result) = iterate_trait_method_candidates(
383 self_ty,
384 db,
385 env,
386 krate,
387 traits_in_scope,
388 name,
389 None,
390 &mut callback,
391 ) {
392 return Some(result);
393 } 459 }
394 None 460 iterate_trait_method_candidates(self_ty, db, env, krate, traits_in_scope, name, None, callback)
395} 461}
396 462
397fn iterate_trait_method_candidates<T>( 463fn iterate_trait_method_candidates(
398 self_ty: &Canonical<Ty>, 464 self_ty: &Canonical<Ty>,
399 db: &dyn HirDatabase, 465 db: &dyn HirDatabase,
400 env: Arc<TraitEnvironment>, 466 env: Arc<TraitEnvironment>,
@@ -402,8 +468,8 @@ fn iterate_trait_method_candidates<T>(
402 traits_in_scope: &FxHashSet<TraitId>, 468 traits_in_scope: &FxHashSet<TraitId>,
403 name: Option<&Name>, 469 name: Option<&Name>,
404 receiver_ty: Option<&Canonical<Ty>>, 470 receiver_ty: Option<&Canonical<Ty>>,
405 mut callback: impl FnMut(&Ty, AssocItemId) -> Option<T>, 471 callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool,
406) -> Option<T> { 472) -> bool {
407 // if ty is `dyn Trait`, the trait doesn't need to be in scope 473 // if ty is `dyn Trait`, the trait doesn't need to be in scope
408 let inherent_trait = 474 let inherent_trait =
409 self_ty.value.dyn_trait().into_iter().flat_map(|t| all_super_traits(db.upcast(), t)); 475 self_ty.value.dyn_trait().into_iter().flat_map(|t| all_super_traits(db.upcast(), t));
@@ -436,23 +502,27 @@ fn iterate_trait_method_candidates<T>(
436 } 502 }
437 } 503 }
438 known_implemented = true; 504 known_implemented = true;
439 if let Some(result) = callback(&self_ty.value, *item) { 505 if callback(&self_ty.value, *item) {
440 return Some(result); 506 return true;
441 } 507 }
442 } 508 }
443 } 509 }
444 None 510 false
445} 511}
446 512
447fn iterate_inherent_methods<T>( 513fn iterate_inherent_methods(
448 self_ty: &Canonical<Ty>, 514 self_ty: &Canonical<Ty>,
449 db: &dyn HirDatabase, 515 db: &dyn HirDatabase,
450 name: Option<&Name>, 516 name: Option<&Name>,
451 receiver_ty: Option<&Canonical<Ty>>, 517 receiver_ty: Option<&Canonical<Ty>>,
452 krate: CrateId, 518 krate: CrateId,
453 mut callback: impl FnMut(&Ty, AssocItemId) -> Option<T>, 519 callback: &mut dyn FnMut(&Ty, AssocItemId) -> bool,
454) -> Option<T> { 520) -> bool {
455 for krate in self_ty.value.def_crates(db, krate)? { 521 let def_crates = match self_ty.value.def_crates(db, krate) {
522 Some(k) => k,
523 None => return false,
524 };
525 for krate in def_crates {
456 let impls = db.impls_in_crate(krate); 526 let impls = db.impls_in_crate(krate);
457 527
458 for impl_def in impls.lookup_impl_defs(&self_ty.value) { 528 for impl_def in impls.lookup_impl_defs(&self_ty.value) {
@@ -468,13 +538,13 @@ fn iterate_inherent_methods<T>(
468 test_utils::mark::hit!(impl_self_type_match_without_receiver); 538 test_utils::mark::hit!(impl_self_type_match_without_receiver);
469 continue; 539 continue;
470 } 540 }
471 if let Some(result) = callback(&self_ty.value, item) { 541 if callback(&self_ty.value, item) {
472 return Some(result); 542 return true;
473 } 543 }
474 } 544 }
475 } 545 }
476 } 546 }
477 None 547 false
478} 548}
479 549
480/// Returns the self type for the index trait call. 550/// Returns the self type for the index trait call.
diff --git a/crates/ra_hir_ty/src/tests.rs b/crates/ra_hir_ty/src/tests.rs
index 1fe05c70c..85ff26a36 100644
--- a/crates/ra_hir_ty/src/tests.rs
+++ b/crates/ra_hir_ty/src/tests.rs
@@ -67,8 +67,8 @@ fn type_at_pos_displayed(
67 panic!("Can't find expression") 67 panic!("Can't find expression")
68} 68}
69 69
70fn type_at(content: &str) -> String { 70fn type_at(ra_fixture: &str) -> String {
71 let (db, file_pos) = TestDB::with_position(content); 71 let (db, file_pos) = TestDB::with_position(ra_fixture);
72 type_at_pos(&db, file_pos) 72 type_at_pos(&db, file_pos)
73} 73}
74 74
@@ -164,13 +164,19 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
164 visit_module(&db, &crate_def_map, module.local_id, &mut |it| defs.push(it)); 164 visit_module(&db, &crate_def_map, module.local_id, &mut |it| defs.push(it));
165 defs.sort_by_key(|def| match def { 165 defs.sort_by_key(|def| match def {
166 DefWithBodyId::FunctionId(it) => { 166 DefWithBodyId::FunctionId(it) => {
167 it.lookup(&db).ast_id.to_node(&db).syntax().text_range().start() 167 let loc = it.lookup(&db);
168 let tree = db.item_tree(loc.id.file_id);
169 tree.source(&db, loc.id).syntax().text_range().start()
168 } 170 }
169 DefWithBodyId::ConstId(it) => { 171 DefWithBodyId::ConstId(it) => {
170 it.lookup(&db).ast_id.to_node(&db).syntax().text_range().start() 172 let loc = it.lookup(&db);
173 let tree = db.item_tree(loc.id.file_id);
174 tree.source(&db, loc.id).syntax().text_range().start()
171 } 175 }
172 DefWithBodyId::StaticId(it) => { 176 DefWithBodyId::StaticId(it) => {
173 it.lookup(&db).ast_id.to_node(&db).syntax().text_range().start() 177 let loc = it.lookup(&db);
178 let tree = db.item_tree(loc.id.file_id);
179 tree.source(&db, loc.id).syntax().text_range().start()
174 } 180 }
175 }); 181 });
176 for def in defs { 182 for def in defs {
diff --git a/crates/ra_hir_ty/src/tests/coercion.rs b/crates/ra_hir_ty/src/tests/coercion.rs
index 6f777ed8c..a2601c68a 100644
--- a/crates/ra_hir_ty/src/tests/coercion.rs
+++ b/crates/ra_hir_ty/src/tests/coercion.rs
@@ -29,10 +29,10 @@ fn test() {
29} 29}
30"#), 30"#),
31 @r###" 31 @r###"
32 11..41 '{ ...4 }; }': () 32 10..40 '{ ...4 }; }': ()
33 21..22 'a': i32 33 20..21 'a': i32
34 30..38 '{ 1i64 }': i64 34 29..37 '{ 1i64 }': i64
35 32..36 '1i64': i64 35 31..35 '1i64': i64
36 "###); 36 "###);
37} 37}
38 38
@@ -63,50 +63,50 @@ fn test2() {
63} 63}
64"#), 64"#),
65 @r###" 65 @r###"
66 31..32 '_': &[T] 66 30..31 '_': &[T]
67 45..56 '{ loop {} }': T 67 44..55 '{ loop {} }': T
68 47..54 'loop {}': ! 68 46..53 'loop {}': !
69 52..54 '{}': () 69 51..53 '{}': ()
70 65..66 '_': S<&[T]> 70 64..65 '_': S<&[T]>
71 82..93 '{ loop {} }': T 71 81..92 '{ loop {} }': T
72 84..91 'loop {}': ! 72 83..90 'loop {}': !
73 89..91 '{}': () 73 88..90 '{}': ()
74 122..133 '{ loop {} }': *mut [T; _] 74 121..132 '{ loop {} }': *mut [T; _]
75 124..131 'loop {}': ! 75 123..130 'loop {}': !
76 129..131 '{}': () 76 128..130 '{}': ()
77 160..173 '{ gen() }': *mut [U] 77 159..172 '{ gen() }': *mut [U]
78 166..169 'gen': fn gen<U>() -> *mut [U; _] 78 165..168 'gen': fn gen<U>() -> *mut [U; _]
79 166..171 'gen()': *mut [U; _] 79 165..170 'gen()': *mut [U; _]
80 186..420 '{ ...rr); }': () 80 185..419 '{ ...rr); }': ()
81 196..199 'arr': &[u8; _] 81 195..198 'arr': &[u8; _]
82 212..216 '&[1]': &[u8; _] 82 211..215 '&[1]': &[u8; _]
83 213..216 '[1]': [u8; _] 83 212..215 '[1]': [u8; _]
84 214..215 '1': u8 84 213..214 '1': u8
85 227..228 'a': &[u8] 85 226..227 'a': &[u8]
86 237..240 'arr': &[u8; _] 86 236..239 'arr': &[u8; _]
87 250..251 'b': u8 87 249..250 'b': u8
88 254..255 'f': fn f<u8>(&[u8]) -> u8 88 253..254 'f': fn f<u8>(&[u8]) -> u8
89 254..260 'f(arr)': u8 89 253..259 'f(arr)': u8
90 256..259 'arr': &[u8; _] 90 255..258 'arr': &[u8; _]
91 270..271 'c': &[u8] 91 269..270 'c': &[u8]
92 280..287 '{ arr }': &[u8] 92 279..286 '{ arr }': &[u8]
93 282..285 'arr': &[u8; _] 93 281..284 'arr': &[u8; _]
94 297..298 'd': u8 94 296..297 'd': u8
95 301..302 'g': fn g<u8>(S<&[u8]>) -> u8 95 300..301 'g': fn g<u8>(S<&[u8]>) -> u8
96 301..316 'g(S { a: arr })': u8 96 300..315 'g(S { a: arr })': u8
97 303..315 'S { a: arr }': S<&[u8]> 97 302..314 'S { a: arr }': S<&[u8]>
98 310..313 'arr': &[u8; _] 98 309..312 'arr': &[u8; _]
99 326..327 'e': [&[u8]; _] 99 325..326 'e': [&[u8]; _]
100 341..346 '[arr]': [&[u8]; _] 100 340..345 '[arr]': [&[u8]; _]
101 342..345 'arr': &[u8; _] 101 341..344 'arr': &[u8; _]
102 356..357 'f': [&[u8]; _] 102 355..356 'f': [&[u8]; _]
103 371..379 '[arr; 2]': [&[u8]; _] 103 370..378 '[arr; 2]': [&[u8]; _]
104 372..375 'arr': &[u8; _] 104 371..374 'arr': &[u8; _]
105 377..378 '2': usize 105 376..377 '2': usize
106 389..390 'g': (&[u8], &[u8]) 106 388..389 'g': (&[u8], &[u8])
107 407..417 '(arr, arr)': (&[u8], &[u8]) 107 406..416 '(arr, arr)': (&[u8], &[u8])
108 408..411 'arr': &[u8; _] 108 407..410 'arr': &[u8; _]
109 413..416 'arr': &[u8; _] 109 412..415 'arr': &[u8; _]
110 "### 110 "###
111 ); 111 );
112} 112}
@@ -121,15 +121,15 @@ fn test() {
121} 121}
122"#), 122"#),
123 @r###" 123 @r###"
124 11..76 '{ ...[1]; }': () 124 10..75 '{ ...[1]; }': ()
125 21..22 'x': &[isize] 125 20..21 'x': &[isize]
126 35..39 '&[1]': &[isize; _] 126 34..38 '&[1]': &[isize; _]
127 36..39 '[1]': [isize; _] 127 35..38 '[1]': [isize; _]
128 37..38 '1': isize 128 36..37 '1': isize
129 49..50 'x': *const [isize] 129 48..49 'x': *const [isize]
130 69..73 '&[1]': &[isize; _] 130 68..72 '&[1]': &[isize; _]
131 70..73 '[1]': [isize; _] 131 69..72 '[1]': [isize; _]
132 71..72 '1': isize 132 70..71 '1': isize
133 "###); 133 "###);
134} 134}
135 135
@@ -155,31 +155,31 @@ fn test(a: A<[u8; 2]>, b: B<[u8; 2]>, c: C<[u8; 2]>) {
155} 155}
156"#), 156"#),
157 @r###" 157 @r###"
158 258..259 'x': A<[T]> 158 257..258 'x': A<[T]>
159 279..284 '{ x }': A<[T]> 159 278..283 '{ x }': A<[T]>
160 281..282 'x': A<[T]> 160 280..281 'x': A<[T]>
161 296..297 'x': B<[T]> 161 295..296 'x': B<[T]>
162 317..322 '{ x }': B<[T]> 162 316..321 '{ x }': B<[T]>
163 319..320 'x': B<[T]> 163 318..319 'x': B<[T]>
164 334..335 'x': C<[T]> 164 333..334 'x': C<[T]>
165 355..360 '{ x }': C<[T]> 165 354..359 '{ x }': C<[T]>
166 357..358 'x': C<[T]> 166 356..357 'x': C<[T]>
167 370..371 'a': A<[u8; _]> 167 369..370 'a': A<[u8; _]>
168 385..386 'b': B<[u8; _]> 168 384..385 'b': B<[u8; _]>
169 400..401 'c': C<[u8; _]> 169 399..400 'c': C<[u8; _]>
170 415..481 '{ ...(c); }': () 170 414..480 '{ ...(c); }': ()
171 425..426 'd': A<[{unknown}]> 171 424..425 'd': A<[{unknown}]>
172 429..433 'foo1': fn foo1<{unknown}>(A<[{unknown}]>) -> A<[{unknown}]> 172 428..432 'foo1': fn foo1<{unknown}>(A<[{unknown}]>) -> A<[{unknown}]>
173 429..436 'foo1(a)': A<[{unknown}]> 173 428..435 'foo1(a)': A<[{unknown}]>
174 434..435 'a': A<[u8; _]> 174 433..434 'a': A<[u8; _]>
175 446..447 'e': B<[u8]> 175 445..446 'e': B<[u8]>
176 450..454 'foo2': fn foo2<u8>(B<[u8]>) -> B<[u8]> 176 449..453 'foo2': fn foo2<u8>(B<[u8]>) -> B<[u8]>
177 450..457 'foo2(b)': B<[u8]> 177 449..456 'foo2(b)': B<[u8]>
178 455..456 'b': B<[u8; _]> 178 454..455 'b': B<[u8; _]>
179 467..468 'f': C<[u8]> 179 466..467 'f': C<[u8]>
180 471..475 'foo3': fn foo3<u8>(C<[u8]>) -> C<[u8]> 180 470..474 'foo3': fn foo3<u8>(C<[u8]>) -> C<[u8]>
181 471..478 'foo3(c)': C<[u8]> 181 470..477 'foo3(c)': C<[u8]>
182 476..477 'c': C<[u8; _]> 182 475..476 'c': C<[u8; _]>
183 "### 183 "###
184 ); 184 );
185} 185}
@@ -198,24 +198,24 @@ fn test() {
198} 198}
199"#), 199"#),
200 @r###" 200 @r###"
201 11..12 'x': &[T] 201 10..11 'x': &[T]
202 28..39 '{ loop {} }': &[T] 202 27..38 '{ loop {} }': &[T]
203 30..37 'loop {}': ! 203 29..36 'loop {}': !
204 35..37 '{}': () 204 34..36 '{}': ()
205 50..126 '{ ... }; }': () 205 49..125 '{ ... }; }': ()
206 60..61 'x': &[i32] 206 59..60 'x': &[i32]
207 64..123 'if tru... }': &[i32] 207 63..122 'if tru... }': &[i32]
208 67..71 'true': bool 208 66..70 'true': bool
209 72..97 '{ ... }': &[i32] 209 71..96 '{ ... }': &[i32]
210 82..85 'foo': fn foo<i32>(&[i32]) -> &[i32] 210 81..84 'foo': fn foo<i32>(&[i32]) -> &[i32]
211 82..91 'foo(&[1])': &[i32] 211 81..90 'foo(&[1])': &[i32]
212 86..90 '&[1]': &[i32; _] 212 85..89 '&[1]': &[i32; _]
213 87..90 '[1]': [i32; _] 213 86..89 '[1]': [i32; _]
214 88..89 '1': i32 214 87..88 '1': i32
215 103..123 '{ ... }': &[i32; _] 215 102..122 '{ ... }': &[i32; _]
216 113..117 '&[1]': &[i32; _] 216 112..116 '&[1]': &[i32; _]
217 114..117 '[1]': [i32; _] 217 113..116 '[1]': [i32; _]
218 115..116 '1': i32 218 114..115 '1': i32
219 "### 219 "###
220 ); 220 );
221} 221}
@@ -234,24 +234,24 @@ fn test() {
234} 234}
235"#), 235"#),
236 @r###" 236 @r###"
237 11..12 'x': &[T] 237 10..11 'x': &[T]
238 28..39 '{ loop {} }': &[T] 238 27..38 '{ loop {} }': &[T]
239 30..37 'loop {}': ! 239 29..36 'loop {}': !
240 35..37 '{}': () 240 34..36 '{}': ()
241 50..126 '{ ... }; }': () 241 49..125 '{ ... }; }': ()
242 60..61 'x': &[i32] 242 59..60 'x': &[i32]
243 64..123 'if tru... }': &[i32] 243 63..122 'if tru... }': &[i32]
244 67..71 'true': bool 244 66..70 'true': bool
245 72..92 '{ ... }': &[i32; _] 245 71..91 '{ ... }': &[i32; _]
246 82..86 '&[1]': &[i32; _] 246 81..85 '&[1]': &[i32; _]
247 83..86 '[1]': [i32; _] 247 82..85 '[1]': [i32; _]
248 84..85 '1': i32 248 83..84 '1': i32
249 98..123 '{ ... }': &[i32] 249 97..122 '{ ... }': &[i32]
250 108..111 'foo': fn foo<i32>(&[i32]) -> &[i32] 250 107..110 'foo': fn foo<i32>(&[i32]) -> &[i32]
251 108..117 'foo(&[1])': &[i32] 251 107..116 'foo(&[1])': &[i32]
252 112..116 '&[1]': &[i32; _] 252 111..115 '&[1]': &[i32; _]
253 113..116 '[1]': [i32; _] 253 112..115 '[1]': [i32; _]
254 114..115 '1': i32 254 113..114 '1': i32
255 "### 255 "###
256 ); 256 );
257} 257}
@@ -270,31 +270,31 @@ fn test(i: i32) {
270} 270}
271"#), 271"#),
272 @r###" 272 @r###"
273 11..12 'x': &[T] 273 10..11 'x': &[T]
274 28..39 '{ loop {} }': &[T] 274 27..38 '{ loop {} }': &[T]
275 30..37 'loop {}': ! 275 29..36 'loop {}': !
276 35..37 '{}': () 276 34..36 '{}': ()
277 48..49 'i': i32 277 47..48 'i': i32
278 56..150 '{ ... }; }': () 278 55..149 '{ ... }; }': ()
279 66..67 'x': &[i32] 279 65..66 'x': &[i32]
280 70..147 'match ... }': &[i32] 280 69..146 'match ... }': &[i32]
281 76..77 'i': i32 281 75..76 'i': i32
282 88..89 '2': i32 282 87..88 '2': i32
283 88..89 '2': i32 283 87..88 '2': i32
284 93..96 'foo': fn foo<i32>(&[i32]) -> &[i32] 284 92..95 'foo': fn foo<i32>(&[i32]) -> &[i32]
285 93..102 'foo(&[2])': &[i32] 285 92..101 'foo(&[2])': &[i32]
286 97..101 '&[2]': &[i32; _] 286 96..100 '&[2]': &[i32; _]
287 98..101 '[2]': [i32; _] 287 97..100 '[2]': [i32; _]
288 99..100 '2': i32 288 98..99 '2': i32
289 112..113 '1': i32 289 111..112 '1': i32
290 112..113 '1': i32 290 111..112 '1': i32
291 117..121 '&[1]': &[i32; _] 291 116..120 '&[1]': &[i32; _]
292 118..121 '[1]': [i32; _] 292 117..120 '[1]': [i32; _]
293 119..120 '1': i32 293 118..119 '1': i32
294 131..132 '_': i32 294 130..131 '_': i32
295 136..140 '&[3]': &[i32; _] 295 135..139 '&[3]': &[i32; _]
296 137..140 '[3]': [i32; _] 296 136..139 '[3]': [i32; _]
297 138..139 '3': i32 297 137..138 '3': i32
298 "### 298 "###
299 ); 299 );
300} 300}
@@ -313,31 +313,31 @@ fn test(i: i32) {
313} 313}
314"#), 314"#),
315 @r###" 315 @r###"
316 11..12 'x': &[T] 316 10..11 'x': &[T]
317 28..39 '{ loop {} }': &[T] 317 27..38 '{ loop {} }': &[T]
318 30..37 'loop {}': ! 318 29..36 'loop {}': !
319 35..37 '{}': () 319 34..36 '{}': ()
320 48..49 'i': i32 320 47..48 'i': i32
321 56..150 '{ ... }; }': () 321 55..149 '{ ... }; }': ()
322 66..67 'x': &[i32] 322 65..66 'x': &[i32]
323 70..147 'match ... }': &[i32] 323 69..146 'match ... }': &[i32]
324 76..77 'i': i32 324 75..76 'i': i32
325 88..89 '1': i32 325 87..88 '1': i32
326 88..89 '1': i32 326 87..88 '1': i32
327 93..97 '&[1]': &[i32; _] 327 92..96 '&[1]': &[i32; _]
328 94..97 '[1]': [i32; _] 328 93..96 '[1]': [i32; _]
329 95..96 '1': i32 329 94..95 '1': i32
330 107..108 '2': i32 330 106..107 '2': i32
331 107..108 '2': i32 331 106..107 '2': i32
332 112..115 'foo': fn foo<i32>(&[i32]) -> &[i32] 332 111..114 'foo': fn foo<i32>(&[i32]) -> &[i32]
333 112..121 'foo(&[2])': &[i32] 333 111..120 'foo(&[2])': &[i32]
334 116..120 '&[2]': &[i32; _] 334 115..119 '&[2]': &[i32; _]
335 117..120 '[2]': [i32; _] 335 116..119 '[2]': [i32; _]
336 118..119 '2': i32 336 117..118 '2': i32
337 131..132 '_': i32 337 130..131 '_': i32
338 136..140 '&[3]': &[i32; _] 338 135..139 '&[3]': &[i32; _]
339 137..140 '[3]': [i32; _] 339 136..139 '[3]': [i32; _]
340 138..139 '3': i32 340 137..138 '3': i32
341 "### 341 "###
342 ); 342 );
343} 343}
@@ -358,24 +358,24 @@ fn test() {
358} 358}
359"#), 359"#),
360 @r###" 360 @r###"
361 11..145 '{ ... }; }': () 361 10..144 '{ ... }; }': ()
362 21..22 't': &mut i32 362 20..21 't': &mut i32
363 25..31 '&mut 1': &mut i32 363 24..30 '&mut 1': &mut i32
364 30..31 '1': i32 364 29..30 '1': i32
365 41..42 'x': *const i32 365 40..41 'x': *const i32
366 45..142 'match ... }': *const i32 366 44..141 'match ... }': *const i32
367 51..52 '1': i32 367 50..51 '1': i32
368 63..64 '1': i32 368 62..63 '1': i32
369 63..64 '1': i32 369 62..63 '1': i32
370 68..69 't': &mut i32 370 67..68 't': &mut i32
371 68..81 't as *mut i32': *mut i32 371 67..80 't as *mut i32': *mut i32
372 91..92 '2': i32 372 90..91 '2': i32
373 91..92 '2': i32 373 90..91 '2': i32
374 96..97 't': &mut i32 374 95..96 't': &mut i32
375 96..105 't as &i32': &i32 375 95..104 't as &i32': &i32
376 115..116 '_': i32 376 114..115 '_': i32
377 120..121 't': &mut i32 377 119..120 't': &mut i32
378 120..135 't as *const i32': *const i32 378 119..134 't as *const i32': *const i32
379 "### 379 "###
380 ); 380 );
381} 381}
@@ -389,9 +389,9 @@ fn foo() -> u32 {
389} 389}
390"#, true), 390"#, true),
391 @r###" 391 @r###"
392 17..40 '{ ...own; }': u32 392 16..39 '{ ...own; }': u32
393 23..37 'return unknown': ! 393 22..36 'return unknown': !
394 30..37 'unknown': u32 394 29..36 'unknown': u32
395 "### 395 "###
396 ); 396 );
397} 397}
@@ -409,24 +409,24 @@ fn test() {
409} 409}
410"#, true), 410"#, true),
411 @r###" 411 @r###"
412 30..31 'x': &Foo 412 29..30 'x': &Foo
413 39..41 '{}': () 413 38..40 '{}': ()
414 52..133 '{ ...oo); }': () 414 51..132 '{ ...oo); }': ()
415 58..71 'takes_ref_foo': fn takes_ref_foo(&Foo) 415 57..70 'takes_ref_foo': fn takes_ref_foo(&Foo)
416 58..77 'takes_...(&Foo)': () 416 57..76 'takes_...(&Foo)': ()
417 72..76 '&Foo': &Foo 417 71..75 '&Foo': &Foo
418 73..76 'Foo': Foo 418 72..75 'Foo': Foo
419 83..96 'takes_ref_foo': fn takes_ref_foo(&Foo) 419 82..95 'takes_ref_foo': fn takes_ref_foo(&Foo)
420 83..103 'takes_...&&Foo)': () 420 82..102 'takes_...&&Foo)': ()
421 97..102 '&&Foo': &&Foo 421 96..101 '&&Foo': &&Foo
422 98..102 '&Foo': &Foo 422 97..101 '&Foo': &Foo
423 99..102 'Foo': Foo 423 98..101 'Foo': Foo
424 109..122 'takes_ref_foo': fn takes_ref_foo(&Foo) 424 108..121 'takes_ref_foo': fn takes_ref_foo(&Foo)
425 109..130 'takes_...&&Foo)': () 425 108..129 'takes_...&&Foo)': ()
426 123..129 '&&&Foo': &&&Foo 426 122..128 '&&&Foo': &&&Foo
427 124..129 '&&Foo': &&Foo 427 123..128 '&&Foo': &&Foo
428 125..129 '&Foo': &Foo 428 124..128 '&Foo': &Foo
429 126..129 'Foo': Foo 429 125..128 'Foo': Foo
430 "### 430 "###
431 ); 431 );
432} 432}
@@ -444,26 +444,26 @@ fn test() {
444} 444}
445"#, true), 445"#, true),
446 @r###" 446 @r###"
447 29..30 'x': &T 447 28..29 'x': &T
448 41..47 '{ *x }': T 448 40..46 '{ *x }': T
449 43..45 '*x': T 449 42..44 '*x': T
450 44..45 'x': &T 450 43..44 'x': &T
451 58..127 '{ ...oo); }': () 451 57..126 '{ ...oo); }': ()
452 64..73 'takes_ref': fn takes_ref<Foo>(&Foo) -> Foo 452 63..72 'takes_ref': fn takes_ref<Foo>(&Foo) -> Foo
453 64..79 'takes_ref(&Foo)': Foo 453 63..78 'takes_ref(&Foo)': Foo
454 74..78 '&Foo': &Foo 454 73..77 '&Foo': &Foo
455 75..78 'Foo': Foo 455 74..77 'Foo': Foo
456 85..94 'takes_ref': fn takes_ref<&Foo>(&&Foo) -> &Foo 456 84..93 'takes_ref': fn takes_ref<&Foo>(&&Foo) -> &Foo
457 85..101 'takes_...&&Foo)': &Foo 457 84..100 'takes_...&&Foo)': &Foo
458 95..100 '&&Foo': &&Foo 458 94..99 '&&Foo': &&Foo
459 96..100 '&Foo': &Foo 459 95..99 '&Foo': &Foo
460 97..100 'Foo': Foo 460 96..99 'Foo': Foo
461 107..116 'takes_ref': fn takes_ref<&&Foo>(&&&Foo) -> &&Foo 461 106..115 'takes_ref': fn takes_ref<&&Foo>(&&&Foo) -> &&Foo
462 107..124 'takes_...&&Foo)': &&Foo 462 106..123 'takes_...&&Foo)': &&Foo
463 117..123 '&&&Foo': &&&Foo 463 116..122 '&&&Foo': &&&Foo
464 118..123 '&&Foo': &&Foo 464 117..122 '&&Foo': &&Foo
465 119..123 '&Foo': &Foo 465 118..122 '&Foo': &Foo
466 120..123 'Foo': Foo 466 119..122 'Foo': Foo
467 "### 467 "###
468 ); 468 );
469} 469}
@@ -483,18 +483,18 @@ fn test() {
483} 483}
484"#, true), 484"#, true),
485 @r###" 485 @r###"
486 127..128 'x': &str 486 126..127 'x': &str
487 136..138 '{}': () 487 135..137 '{}': ()
488 169..180 '{ loop {} }': String 488 168..179 '{ loop {} }': String
489 171..178 'loop {}': ! 489 170..177 'loop {}': !
490 176..178 '{}': () 490 175..177 '{}': ()
491 191..236 '{ ... }); }': () 491 190..235 '{ ... }); }': ()
492 197..210 'takes_ref_str': fn takes_ref_str(&str) 492 196..209 'takes_ref_str': fn takes_ref_str(&str)
493 197..233 'takes_...g() })': () 493 196..232 'takes_...g() })': ()
494 211..232 '&{ ret...ng() }': &String 494 210..231 '&{ ret...ng() }': &String
495 212..232 '{ retu...ng() }': String 495 211..231 '{ retu...ng() }': String
496 214..228 'returns_string': fn returns_string() -> String 496 213..227 'returns_string': fn returns_string() -> String
497 214..230 'return...ring()': String 497 213..229 'return...ring()': String
498 "### 498 "###
499 ); 499 );
500} 500}
@@ -513,19 +513,19 @@ fn foo() {
513} 513}
514"#, true), 514"#, true),
515 @r###" 515 @r###"
516 10..106 '{ ... }; }': () 516 9..105 '{ ... }; }': ()
517 20..21 'x': || -> &u32 517 19..20 'x': || -> &u32
518 24..103 '|| { ... }': || -> &u32 518 23..102 '|| { ... }': || -> &u32
519 27..103 '{ ... }': &u32 519 26..102 '{ ... }': &u32
520 37..82 'if tru... }': () 520 36..81 'if tru... }': ()
521 40..44 'true': bool 521 39..43 'true': bool
522 45..82 '{ ... }': () 522 44..81 '{ ... }': ()
523 59..71 'return &1u32': ! 523 58..70 'return &1u32': !
524 66..71 '&1u32': &u32 524 65..70 '&1u32': &u32
525 67..71 '1u32': u32 525 66..70 '1u32': u32
526 91..97 '&&1u32': &&u32 526 90..96 '&&1u32': &&u32
527 92..97 '&1u32': &u32 527 91..96 '&1u32': &u32
528 93..97 '1u32': u32 528 92..96 '1u32': u32
529 "### 529 "###
530 ); 530 );
531} 531}
@@ -540,12 +540,12 @@ fn test() {
540} 540}
541"#, true), 541"#, true),
542 @r###" 542 @r###"
543 8..9 'x': u32 543 7..8 'x': u32
544 25..30 '{ 1 }': isize 544 24..29 '{ 1 }': isize
545 27..28 '1': isize 545 26..27 '1': isize
546 41..79 '{ ...foo; }': () 546 40..78 '{ ...foo; }': ()
547 51..52 'f': fn(u32) -> isize 547 50..51 'f': fn(u32) -> isize
548 73..76 'foo': fn foo(u32) -> isize 548 72..75 'foo': fn foo(u32) -> isize
549 "### 549 "###
550 ); 550 );
551} 551}
@@ -567,27 +567,27 @@ fn test() {
567} 567}
568"#, true), 568"#, true),
569 @r###" 569 @r###"
570 9..10 'x': u32 570 8..9 'x': u32
571 26..31 '{ 1 }': isize 571 25..30 '{ 1 }': isize
572 28..29 '1': isize 572 27..28 '1': isize
573 40..41 'x': u32 573 39..40 'x': u32
574 57..62 '{ 2 }': isize 574 56..61 '{ 2 }': isize
575 59..60 '2': isize 575 58..59 '2': isize
576 71..72 'x': u32 576 70..71 'x': u32
577 88..93 '{ 3 }': isize 577 87..92 '{ 3 }': isize
578 90..91 '3': isize 578 89..90 '3': isize
579 104..193 '{ ... }; }': () 579 103..192 '{ ... }; }': ()
580 114..115 'x': fn(u32) -> isize 580 113..114 'x': fn(u32) -> isize
581 118..190 'match ... }': fn(u32) -> isize 581 117..189 'match ... }': fn(u32) -> isize
582 124..125 '1': i32 582 123..124 '1': i32
583 136..137 '1': i32 583 135..136 '1': i32
584 136..137 '1': i32 584 135..136 '1': i32
585 141..145 'foo1': fn foo1(u32) -> isize 585 140..144 'foo1': fn foo1(u32) -> isize
586 155..156 '2': i32 586 154..155 '2': i32
587 155..156 '2': i32 587 154..155 '2': i32
588 160..164 'foo2': fn foo2(u32) -> isize 588 159..163 'foo2': fn foo2(u32) -> isize
589 174..175 '_': i32 589 173..174 '_': i32
590 179..183 'foo3': fn foo3(u32) -> isize 590 178..182 'foo3': fn foo3(u32) -> isize
591 "### 591 "###
592 ); 592 );
593} 593}
@@ -601,12 +601,12 @@ fn test() {
601} 601}
602"#, true), 602"#, true),
603 @r###" 603 @r###"
604 11..55 '{ ...1 }; }': () 604 10..54 '{ ...1 }; }': ()
605 21..22 'f': fn(u32) -> isize 605 20..21 'f': fn(u32) -> isize
606 43..52 '|x| { 1 }': |u32| -> isize 606 42..51 '|x| { 1 }': |u32| -> isize
607 44..45 'x': u32 607 43..44 'x': u32
608 47..52 '{ 1 }': isize 608 46..51 '{ 1 }': isize
609 49..50 '1': isize 609 48..49 '1': isize
610 "### 610 "###
611 ); 611 );
612} 612}
@@ -624,11 +624,11 @@ impl<TT> S<TT> {
624} 624}
625"#, true), 625"#, true),
626 @r###" 626 @r###"
627 51..55 'self': &S<TT> 627 50..54 'self': &S<TT>
628 64..87 '{ ... }': &TT 628 63..86 '{ ... }': &TT
629 74..81 '&self.t': &TT 629 73..80 '&self.t': &TT
630 75..79 'self': &S<TT> 630 74..78 'self': &S<TT>
631 75..81 'self.t': TT 631 74..80 'self.t': TT
632 "### 632 "###
633 ); 633 );
634} 634}
@@ -649,13 +649,13 @@ fn test() {
649} 649}
650"#, true), 650"#, true),
651 @r###" 651 @r###"
652 162..199 '{ ... 3]; }': () 652 161..198 '{ ... 3]; }': ()
653 172..173 'f': &[usize] 653 171..172 'f': &[usize]
654 186..196 '&[1, 2, 3]': &[usize; _] 654 185..195 '&[1, 2, 3]': &[usize; _]
655 187..196 '[1, 2, 3]': [usize; _] 655 186..195 '[1, 2, 3]': [usize; _]
656 188..189 '1': usize 656 187..188 '1': usize
657 191..192 '2': usize 657 190..191 '2': usize
658 194..195 '3': usize 658 193..194 '3': usize
659 "### 659 "###
660 ); 660 );
661} 661}
@@ -689,19 +689,19 @@ fn test() {
689} 689}
690"#, true), 690"#, true),
691 @r###" 691 @r###"
692 388..573 '{ ...bj2; }': () 692 387..572 '{ ...bj2; }': ()
693 398..401 'obj': &dyn Baz<i8, i16> 693 397..400 'obj': &dyn Baz<i8, i16>
694 423..425 '&S': &S<i8, i16> 694 422..424 '&S': &S<i8, i16>
695 424..425 'S': S<i8, i16> 695 423..424 'S': S<i8, i16>
696 435..438 'obj': &dyn Bar<usize, i8, i16> 696 434..437 'obj': &dyn Bar<usize, i8, i16>
697 460..463 'obj': &dyn Baz<i8, i16> 697 459..462 'obj': &dyn Baz<i8, i16>
698 473..476 'obj': &dyn Foo<i8, usize> 698 472..475 'obj': &dyn Foo<i8, usize>
699 495..498 'obj': &dyn Bar<usize, i8, i16> 699 494..497 'obj': &dyn Bar<usize, i8, i16>
700 508..512 'obj2': &dyn Baz<i8, i16> 700 507..511 'obj2': &dyn Baz<i8, i16>
701 534..536 '&S': &S<i8, i16> 701 533..535 '&S': &S<i8, i16>
702 535..536 'S': S<i8, i16> 702 534..535 'S': S<i8, i16>
703 546..547 '_': &dyn Foo<i8, usize> 703 545..546 '_': &dyn Foo<i8, usize>
704 566..570 'obj2': &dyn Baz<i8, i16> 704 565..569 'obj2': &dyn Baz<i8, i16>
705 "### 705 "###
706 ); 706 );
707} 707}
@@ -734,12 +734,12 @@ fn test() {
734} 734}
735"#, true), 735"#, true),
736 @r###" 736 @r###"
737 292..348 '{ ...obj; }': () 737 291..347 '{ ...obj; }': ()
738 302..305 'obj': &dyn D 738 301..304 'obj': &dyn D
739 316..318 '&S': &S 739 315..317 '&S': &S
740 317..318 'S': S 740 316..317 'S': S
741 328..331 'obj': &dyn A 741 327..330 'obj': &dyn A
742 342..345 'obj': &dyn D 742 341..344 'obj': &dyn D
743 "### 743 "###
744 ); 744 );
745} 745}
diff --git a/crates/ra_hir_ty/src/tests/macros.rs b/crates/ra_hir_ty/src/tests/macros.rs
index 4c6099aa2..be2b48dcc 100644
--- a/crates/ra_hir_ty/src/tests/macros.rs
+++ b/crates/ra_hir_ty/src/tests/macros.rs
@@ -71,8 +71,8 @@ fn main() {
71 !1..4 'Foo': Foo({unknown}) -> Foo 71 !1..4 'Foo': Foo({unknown}) -> Foo
72 !1..16 'Foo(vec![1,2,])': Foo 72 !1..16 'Foo(vec![1,2,])': Foo
73 !5..15 'vec![1,2,]': {unknown} 73 !5..15 'vec![1,2,]': {unknown}
74 156..182 '{ ...,2); }': () 74 155..181 '{ ...,2); }': ()
75 166..167 'x': Foo 75 165..166 'x': Foo
76 "### 76 "###
77 ); 77 );
78} 78}
@@ -104,10 +104,10 @@ fn main() {
104 !1..4 'Foo': Foo({unknown}) -> Foo 104 !1..4 'Foo': Foo({unknown}) -> Foo
105 !1..16 'Foo(vec![1,2,])': Foo 105 !1..16 'Foo(vec![1,2,])': Foo
106 !5..15 'vec![1,2,]': {unknown} 106 !5..15 'vec![1,2,]': {unknown}
107 195..251 '{ ...,2); }': () 107 194..250 '{ ...,2); }': ()
108 205..206 'x': Foo 108 204..205 'x': Foo
109 228..229 'y': {unknown} 109 227..228 'y': {unknown}
110 232..248 'crate:...!(1,2)': {unknown} 110 231..247 'crate:...!(1,2)': {unknown}
111 "### 111 "###
112 ); 112 );
113} 113}
@@ -133,9 +133,9 @@ fn main() {
133 @r###" 133 @r###"
134 !0..5 '42i32': i32 134 !0..5 '42i32': i32
135 !0..5 '42i32': i32 135 !0..5 '42i32': i32
136 111..164 '{ ...!(); }': () 136 110..163 '{ ...!(); }': ()
137 121..122 'x': i32 137 120..121 'x': i32
138 148..149 'y': i32 138 147..148 'y': i32
139 "### 139 "###
140 ); 140 );
141} 141}
@@ -197,26 +197,26 @@ fn spam() {
197 !0..6 '1isize': isize 197 !0..6 '1isize': isize
198 !0..6 '1isize': isize 198 !0..6 '1isize': isize
199 !0..6 '1isize': isize 199 !0..6 '1isize': isize
200 54..457 '{ ...!(); }': () 200 53..456 '{ ...!(); }': ()
201 88..109 'spam!(...am!())': {unknown} 201 87..108 'spam!(...am!())': {unknown}
202 115..134 'for _ ...!() {}': () 202 114..133 'for _ ...!() {}': ()
203 119..120 '_': {unknown} 203 118..119 '_': {unknown}
204 132..134 '{}': () 204 131..133 '{}': ()
205 139..149 '|| spam!()': || -> isize 205 138..148 '|| spam!()': || -> isize
206 155..171 'while ...!() {}': () 206 154..170 'while ...!() {}': ()
207 169..171 '{}': () 207 168..170 '{}': ()
208 176..189 'break spam!()': ! 208 175..188 'break spam!()': !
209 195..209 'return spam!()': ! 209 194..208 'return spam!()': !
210 215..269 'match ... }': isize 210 214..268 'match ... }': isize
211 239..240 '_': isize 211 238..239 '_': isize
212 274..290 'spam!(...am!())': {unknown} 212 273..289 'spam!(...am!())': {unknown}
213 296..318 'Spam {...m!() }': {unknown} 213 295..317 'Spam {...m!() }': {unknown}
214 324..340 'spam!(...am!()]': {unknown} 214 323..339 'spam!(...am!()]': {unknown}
215 365..381 'spam!(... usize': usize 215 364..380 'spam!(... usize': usize
216 387..395 '&spam!()': &isize 216 386..394 '&spam!()': &isize
217 401..409 '-spam!()': isize 217 400..408 '-spam!()': isize
218 415..431 'spam!(...pam!()': {unknown} 218 414..430 'spam!(...pam!()': {unknown}
219 437..454 'spam!(...pam!()': isize 219 436..453 'spam!(...pam!()': isize
220 "### 220 "###
221 ); 221 );
222} 222}
@@ -245,8 +245,8 @@ fn foo() {
245"#), 245"#),
246 @r###" 246 @r###"
247 !0..5 '42i32': i32 247 !0..5 '42i32': i32
248 171..206 '{ ...32); }': () 248 170..205 '{ ...32); }': ()
249 181..184 'foo': i32 249 180..183 'foo': i32
250 "### 250 "###
251 ); 251 );
252} 252}
@@ -397,12 +397,12 @@ fn main() {
397} 397}
398"#), 398"#),
399 @r###" 399 @r###"
400 159..164 '{ 0 }': u64 400 158..163 '{ 0 }': u64
401 161..162 '0': u64 401 160..161 '0': u64
402 175..197 '{ ...f(); }': () 402 174..196 '{ ...f(); }': ()
403 185..187 '_a': u64 403 184..186 '_a': u64
404 191..192 'f': fn f() -> u64 404 190..191 'f': fn f() -> u64
405 191..194 'f()': u64 405 190..193 'f()': u64
406 "### 406 "###
407 ); 407 );
408} 408}
@@ -419,10 +419,10 @@ fn main() {
419} 419}
420"#), 420"#),
421 @r###" 421 @r###"
422 !0..6 '1usize': usize 422 !0..6 '1usize': usize
423 11..90 '{ ...!(); }': () 423 10..89 '{ ...!(); }': ()
424 17..66 'macro_... }': {unknown} 424 16..65 'macro_... }': {unknown}
425 75..77 '_a': usize 425 74..76 '_a': usize
426 "### 426 "###
427 ); 427 );
428} 428}
@@ -466,8 +466,8 @@ fn main() {
466"#), 466"#),
467 @r###" 467 @r###"
468 !0..1 '0': i32 468 !0..1 '0': i32
469 64..88 '{ ...!(); }': () 469 63..87 '{ ...!(); }': ()
470 74..75 'x': i32 470 73..74 'x': i32
471 "### 471 "###
472 ); 472 );
473} 473}
@@ -485,8 +485,8 @@ fn main() {
485"#), 485"#),
486 @r###" 486 @r###"
487 !0..2 '""': &str 487 !0..2 '""': &str
488 64..88 '{ ...!(); }': () 488 63..87 '{ ...!(); }': ()
489 74..75 'x': &str 489 73..74 'x': &str
490 "### 490 "###
491 ); 491 );
492} 492}
@@ -504,8 +504,8 @@ fn main() {
504"#), 504"#),
505 @r###" 505 @r###"
506 !0..1 '0': i32 506 !0..1 '0': i32
507 66..92 '{ ...!(); }': () 507 65..91 '{ ...!(); }': ()
508 76..77 'x': i32 508 75..76 'x': i32
509 "### 509 "###
510 ); 510 );
511} 511}
@@ -523,8 +523,8 @@ fn main() {
523"#), 523"#),
524 @r###" 524 @r###"
525 !0..13 '"helloworld!"': &str 525 !0..13 '"helloworld!"': &str
526 66..122 '{ ...")); }': () 526 65..121 '{ ...")); }': ()
527 76..77 'x': &str 527 75..76 'x': &str
528 "### 528 "###
529 ); 529 );
530} 530}
@@ -658,8 +658,8 @@ fn main() {
658"#), 658"#),
659 @r###" 659 @r###"
660 !0..13 '"helloworld!"': &str 660 !0..13 '"helloworld!"': &str
661 104..161 '{ ...")); }': () 661 103..160 '{ ...")); }': ()
662 114..115 'x': &str 662 113..114 'x': &str
663 "### 663 "###
664 ); 664 );
665} 665}
@@ -677,9 +677,9 @@ fn main() {
677} 677}
678"#), 678"#),
679 @r###" 679 @r###"
680 !0..5 '"bar"': &str 680 !0..22 '"__RA_...TED__"': &str
681 88..116 '{ ...o"); }': () 681 62..90 '{ ...o"); }': ()
682 98..99 'x': &str 682 72..73 'x': &str
683 "### 683 "###
684 ); 684 );
685} 685}
@@ -794,12 +794,12 @@ fn main() {
794} 794}
795"#), 795"#),
796 @r###" 796 @r###"
797 52..111 '{ ... }; }': () 797 51..110 '{ ... }; }': ()
798 62..63 'x': u32 798 61..62 'x': u32
799 66..108 'match ... }': u32 799 65..107 'match ... }': u32
800 72..74 '()': () 800 71..73 '()': ()
801 85..92 'unit!()': () 801 84..91 'unit!()': ()
802 96..101 '92u32': u32 802 95..100 '92u32': u32
803 "### 803 "###
804 ); 804 );
805} 805}
diff --git a/crates/ra_hir_ty/src/tests/method_resolution.rs b/crates/ra_hir_ty/src/tests/method_resolution.rs
index 804297315..20329bae4 100644
--- a/crates/ra_hir_ty/src/tests/method_resolution.rs
+++ b/crates/ra_hir_ty/src/tests/method_resolution.rs
@@ -22,15 +22,15 @@ fn test(x: &[u8]) {
22} 22}
23"#), 23"#),
24 @r###" 24 @r###"
25 45..49 'self': &[T] 25 44..48 'self': &[T]
26 56..79 '{ ... }': T 26 55..78 '{ ... }': T
27 66..73 'loop {}': ! 27 65..72 'loop {}': !
28 71..73 '{}': () 28 70..72 '{}': ()
29 131..132 'x': &[u8] 29 130..131 'x': &[u8]
30 141..163 '{ ...(x); }': () 30 140..162 '{ ...(x); }': ()
31 147..157 '<[_]>::foo': fn foo<u8>(&[u8]) -> u8 31 146..156 '<[_]>::foo': fn foo<u8>(&[u8]) -> u8
32 147..160 '<[_]>::foo(x)': u8 32 146..159 '<[_]>::foo(x)': u8
33 158..159 'x': &[u8] 33 157..158 'x': &[u8]
34 "### 34 "###
35 ); 35 );
36} 36}
@@ -52,15 +52,15 @@ fn test() {
52} 52}
53"#), 53"#),
54 @r###" 54 @r###"
55 49..75 '{ ... }': A 55 48..74 '{ ... }': A
56 59..69 'A { x: 0 }': A 56 58..68 'A { x: 0 }': A
57 66..67 '0': u32 57 65..66 '0': u32
58 88..122 '{ ...a.x; }': () 58 87..121 '{ ...a.x; }': ()
59 98..99 'a': A 59 97..98 'a': A
60 102..108 'A::new': fn new() -> A 60 101..107 'A::new': fn new() -> A
61 102..110 'A::new()': A 61 101..109 'A::new()': A
62 116..117 'a': A 62 115..116 'a': A
63 116..119 'a.x': u32 63 115..118 'a.x': u32
64 "### 64 "###
65 ); 65 );
66} 66}
@@ -87,19 +87,19 @@ fn test() {
87} 87}
88"#), 88"#),
89 @r###" 89 @r###"
90 47..67 '{ ... }': A 90 46..66 '{ ... }': A
91 57..61 'A::B': A 91 56..60 'A::B': A
92 88..108 '{ ... }': A 92 87..107 '{ ... }': A
93 98..102 'A::C': A 93 97..101 'A::C': A
94 121..178 '{ ... c; }': () 94 120..177 '{ ... c; }': ()
95 131..132 'a': A 95 130..131 'a': A
96 135..139 'A::b': fn b() -> A 96 134..138 'A::b': fn b() -> A
97 135..141 'A::b()': A 97 134..140 'A::b()': A
98 147..148 'a': A 98 146..147 'a': A
99 158..159 'c': A 99 157..158 'c': A
100 162..166 'A::c': fn c() -> A 100 161..165 'A::c': fn c() -> A
101 162..168 'A::c()': A 101 161..167 'A::c()': A
102 174..175 'c': A 102 173..174 'c': A
103 "### 103 "###
104 ); 104 );
105} 105}
@@ -131,22 +131,22 @@ fn test() {
131} 131}
132"#), 132"#),
133 @r###" 133 @r###"
134 56..64 '{ A {} }': A 134 55..63 '{ A {} }': A
135 58..62 'A {}': A 135 57..61 'A {}': A
136 126..132 '{ 99 }': u32 136 125..131 '{ 99 }': u32
137 128..130 '99': u32 137 127..129 '99': u32
138 202..210 '{ C {} }': C 138 201..209 '{ C {} }': C
139 204..208 'C {}': C 139 203..207 'C {}': C
140 241..325 '{ ...g(); }': () 140 240..324 '{ ...g(); }': ()
141 251..252 'x': A 141 250..251 'x': A
142 255..266 'a::A::thing': fn thing() -> A 142 254..265 'a::A::thing': fn thing() -> A
143 255..268 'a::A::thing()': A 143 254..267 'a::A::thing()': A
144 278..279 'y': u32 144 277..278 'y': u32
145 282..293 'b::B::thing': fn thing() -> u32 145 281..292 'b::B::thing': fn thing() -> u32
146 282..295 'b::B::thing()': u32 146 281..294 'b::B::thing()': u32
147 305..306 'z': C 147 304..305 'z': C
148 309..320 'c::C::thing': fn thing() -> C 148 308..319 'c::C::thing': fn thing() -> C
149 309..322 'c::C::thing()': C 149 308..321 'c::C::thing()': C
150 "### 150 "###
151 ); 151 );
152} 152}
@@ -170,15 +170,15 @@ fn test() {
170} 170}
171"#), 171"#),
172 @r###" 172 @r###"
173 64..67 'val': T 173 63..66 'val': T
174 82..109 '{ ... }': Gen<T> 174 81..108 '{ ... }': Gen<T>
175 92..103 'Gen { val }': Gen<T> 175 91..102 'Gen { val }': Gen<T>
176 98..101 'val': T 176 97..100 'val': T
177 123..155 '{ ...32); }': () 177 122..154 '{ ...32); }': ()
178 133..134 'a': Gen<u32> 178 132..133 'a': Gen<u32>
179 137..146 'Gen::make': fn make<u32>(u32) -> Gen<u32> 179 136..145 'Gen::make': fn make<u32>(u32) -> Gen<u32>
180 137..152 'Gen::make(0u32)': Gen<u32> 180 136..151 'Gen::make(0u32)': Gen<u32>
181 147..151 '0u32': u32 181 146..150 '0u32': u32
182 "### 182 "###
183 ); 183 );
184} 184}
@@ -202,13 +202,13 @@ fn test() {
202} 202}
203"#), 203"#),
204 @r###" 204 @r###"
205 76..100 '{ ... }': Gen<T> 205 75..99 '{ ... }': Gen<T>
206 86..94 'loop { }': ! 206 85..93 'loop { }': !
207 91..94 '{ }': () 207 90..93 '{ }': ()
208 114..149 '{ ...e(); }': () 208 113..148 '{ ...e(); }': ()
209 124..125 'a': Gen<u32> 209 123..124 'a': Gen<u32>
210 128..144 'Gen::<...::make': fn make<u32>() -> Gen<u32> 210 127..143 'Gen::<...::make': fn make<u32>() -> Gen<u32>
211 128..146 'Gen::<...make()': Gen<u32> 211 127..145 'Gen::<...make()': Gen<u32>
212 "### 212 "###
213 ); 213 );
214} 214}
@@ -233,13 +233,13 @@ fn test() {
233} 233}
234"#), 234"#),
235 @r###" 235 @r###"
236 102..126 '{ ... }': Gen<u32, T> 236 101..125 '{ ... }': Gen<u32, T>
237 112..120 'loop { }': ! 237 111..119 'loop { }': !
238 117..120 '{ }': () 238 116..119 '{ }': ()
239 140..180 '{ ...e(); }': () 239 139..179 '{ ...e(); }': ()
240 150..151 'a': Gen<u32, u64> 240 149..150 'a': Gen<u32, u64>
241 154..175 'Gen::<...::make': fn make<u64>() -> Gen<u32, u64> 241 153..174 'Gen::<...::make': fn make<u64>() -> Gen<u32, u64>
242 154..177 'Gen::<...make()': Gen<u32, u64> 242 153..176 'Gen::<...make()': Gen<u32, u64>
243 "### 243 "###
244 ); 244 );
245} 245}
@@ -287,13 +287,13 @@ fn test() {
287} 287}
288"#), 288"#),
289 @r###" 289 @r###"
290 31..35 'self': &Self 290 30..34 'self': &Self
291 110..114 'self': &Self 291 109..113 'self': &Self
292 170..228 '{ ...i128 }': () 292 169..227 '{ ...i128 }': ()
293 176..178 'S1': S1 293 175..177 'S1': S1
294 176..187 'S1.method()': u32 294 175..186 'S1.method()': u32
295 203..205 'S2': S2 295 202..204 'S2': S2
296 203..214 'S2.method()': i128 296 202..213 'S2.method()': i128
297 "### 297 "###
298 ); 298 );
299} 299}
@@ -334,14 +334,14 @@ mod bar_test {
334} 334}
335"#), 335"#),
336 @r###" 336 @r###"
337 63..67 'self': &Self 337 62..66 'self': &Self
338 169..173 'self': &Self 338 168..172 'self': &Self
339 300..337 '{ ... }': () 339 299..336 '{ ... }': ()
340 310..311 'S': S 340 309..310 'S': S
341 310..320 'S.method()': u32 341 309..319 'S.method()': u32
342 416..454 '{ ... }': () 342 415..453 '{ ... }': ()
343 426..427 'S': S 343 425..426 'S': S
344 426..436 'S.method()': i128 344 425..435 'S.method()': i128
345 "### 345 "###
346 ); 346 );
347} 347}
@@ -361,10 +361,10 @@ fn test() {
361} 361}
362"#), 362"#),
363 @r###" 363 @r###"
364 33..37 'self': &Self 364 32..36 'self': &Self
365 92..111 '{ ...d(); }': () 365 91..110 '{ ...d(); }': ()
366 98..99 'S': S 366 97..98 'S': S
367 98..108 'S.method()': u32 367 97..107 'S.method()': u32
368 "### 368 "###
369 ); 369 );
370} 370}
@@ -390,17 +390,17 @@ fn test() {
390} 390}
391"#), 391"#),
392 @r###" 392 @r###"
393 43..47 'self': &Self 393 42..46 'self': &Self
394 82..86 'self': &Self 394 81..85 'self': &Self
395 210..361 '{ ..., i8 }': () 395 209..360 '{ ..., i8 }': ()
396 216..218 'S1': S1 396 215..217 'S1': S1
397 216..228 'S1.method1()': (u8, u16, u32) 397 215..227 'S1.method1()': (u8, u16, u32)
398 250..252 'S1': S1 398 249..251 'S1': S1
399 250..262 'S1.method2()': (u32, u16, u8) 399 249..261 'S1.method2()': (u32, u16, u8)
400 284..286 'S2': S2 400 283..285 'S2': S2
401 284..296 'S2.method1()': (i8, i16, {unknown}) 401 283..295 'S2.method1()': (i8, i16, {unknown})
402 324..326 'S2': S2 402 323..325 'S2': S2
403 324..336 'S2.method2()': ({unknown}, i16, i8) 403 323..335 'S2.method2()': ({unknown}, i16, i8)
404 "### 404 "###
405 ); 405 );
406} 406}
@@ -420,12 +420,12 @@ fn test() {
420} 420}
421"#), 421"#),
422 @r###" 422 @r###"
423 33..37 'self': &Self 423 32..36 'self': &Self
424 102..127 '{ ...d(); }': () 424 101..126 '{ ...d(); }': ()
425 108..109 'S': S<u32>(u32) -> S<u32> 425 107..108 'S': S<u32>(u32) -> S<u32>
426 108..115 'S(1u32)': S<u32> 426 107..114 'S(1u32)': S<u32>
427 108..124 'S(1u32...thod()': u32 427 107..123 'S(1u32...thod()': u32
428 110..114 '1u32': u32 428 109..113 '1u32': u32
429 "### 429 "###
430 ); 430 );
431} 431}
@@ -446,16 +446,16 @@ fn test() {
446} 446}
447"#), 447"#),
448 @r###" 448 @r###"
449 87..193 '{ ...t(); }': () 449 86..192 '{ ...t(); }': ()
450 97..99 's1': S 450 96..98 's1': S
451 105..121 'Defaul...efault': fn default<S>() -> S 451 104..120 'Defaul...efault': fn default<S>() -> S
452 105..123 'Defaul...ault()': S 452 104..122 'Defaul...ault()': S
453 133..135 's2': S 453 132..134 's2': S
454 138..148 'S::default': fn default<S>() -> S 454 137..147 'S::default': fn default<S>() -> S
455 138..150 'S::default()': S 455 137..149 'S::default()': S
456 160..162 's3': S 456 159..161 's3': S
457 165..188 '<S as ...efault': fn default<S>() -> S 457 164..187 '<S as ...efault': fn default<S>() -> S
458 165..190 '<S as ...ault()': S 458 164..189 '<S as ...ault()': S
459 "### 459 "###
460 ); 460 );
461} 461}
@@ -478,16 +478,16 @@ fn test() {
478} 478}
479"#), 479"#),
480 @r###" 480 @r###"
481 127..211 '{ ...e(); }': () 481 126..210 '{ ...e(); }': ()
482 137..138 'a': u32 482 136..137 'a': u32
483 141..148 'S::make': fn make<S, u32>() -> u32 483 140..147 'S::make': fn make<S, u32>() -> u32
484 141..150 'S::make()': u32 484 140..149 'S::make()': u32
485 160..161 'b': u64 485 159..160 'b': u64
486 164..178 'G::<u64>::make': fn make<G<u64>, u64>() -> u64 486 163..177 'G::<u64>::make': fn make<G<u64>, u64>() -> u64
487 164..180 'G::<u6...make()': u64 487 163..179 'G::<u6...make()': u64
488 190..191 'c': f64 488 189..190 'c': f64
489 199..206 'G::make': fn make<G<f64>, f64>() -> f64 489 198..205 'G::make': fn make<G<f64>, f64>() -> f64
490 199..208 'G::make()': f64 490 198..207 'G::make()': f64
491 "### 491 "###
492 ); 492 );
493} 493}
@@ -512,22 +512,22 @@ fn test() {
512} 512}
513"#), 513"#),
514 @r###" 514 @r###"
515 135..313 '{ ...e(); }': () 515 134..312 '{ ...e(); }': ()
516 145..146 'a': (u32, i64) 516 144..145 'a': (u32, i64)
517 149..163 'S::make::<i64>': fn make<S, u32, i64>() -> (u32, i64) 517 148..162 'S::make::<i64>': fn make<S, u32, i64>() -> (u32, i64)
518 149..165 'S::mak...i64>()': (u32, i64) 518 148..164 'S::mak...i64>()': (u32, i64)
519 175..176 'b': (u32, i64) 519 174..175 'b': (u32, i64)
520 189..196 'S::make': fn make<S, u32, i64>() -> (u32, i64) 520 188..195 'S::make': fn make<S, u32, i64>() -> (u32, i64)
521 189..198 'S::make()': (u32, i64) 521 188..197 'S::make()': (u32, i64)
522 208..209 'c': (u32, i64) 522 207..208 'c': (u32, i64)
523 212..233 'G::<u3...:<i64>': fn make<G<u32>, u32, i64>() -> (u32, i64) 523 211..232 'G::<u3...:<i64>': fn make<G<u32>, u32, i64>() -> (u32, i64)
524 212..235 'G::<u3...i64>()': (u32, i64) 524 211..234 'G::<u3...i64>()': (u32, i64)
525 245..246 'd': (u32, i64) 525 244..245 'd': (u32, i64)
526 259..273 'G::make::<i64>': fn make<G<u32>, u32, i64>() -> (u32, i64) 526 258..272 'G::make::<i64>': fn make<G<u32>, u32, i64>() -> (u32, i64)
527 259..275 'G::mak...i64>()': (u32, i64) 527 258..274 'G::mak...i64>()': (u32, i64)
528 285..286 'e': (u32, i64) 528 284..285 'e': (u32, i64)
529 301..308 'G::make': fn make<G<u32>, u32, i64>() -> (u32, i64) 529 300..307 'G::make': fn make<G<u32>, u32, i64>() -> (u32, i64)
530 301..310 'G::make()': (u32, i64) 530 300..309 'G::make()': (u32, i64)
531 "### 531 "###
532 ); 532 );
533} 533}
@@ -546,10 +546,10 @@ fn test() {
546} 546}
547"#), 547"#),
548 @r###" 548 @r###"
549 101..127 '{ ...e(); }': () 549 100..126 '{ ...e(); }': ()
550 111..112 'a': (S<i32>, i64) 550 110..111 'a': (S<i32>, i64)
551 115..122 'S::make': fn make<S<i32>, i64>() -> (S<i32>, i64) 551 114..121 'S::make': fn make<S<i32>, i64>() -> (S<i32>, i64)
552 115..124 'S::make()': (S<i32>, i64) 552 114..123 'S::make()': (S<i32>, i64)
553 "### 553 "###
554 ); 554 );
555} 555}
@@ -570,13 +570,13 @@ fn test() {
570} 570}
571"#), 571"#),
572 @r###" 572 @r###"
573 131..203 '{ ...e(); }': () 573 130..202 '{ ...e(); }': ()
574 141..142 'a': (S<u64>, i64) 574 140..141 'a': (S<u64>, i64)
575 158..165 'S::make': fn make<S<u64>, i64>() -> (S<u64>, i64) 575 157..164 'S::make': fn make<S<u64>, i64>() -> (S<u64>, i64)
576 158..167 'S::make()': (S<u64>, i64) 576 157..166 'S::make()': (S<u64>, i64)
577 177..178 'b': (S<u32>, i32) 577 176..177 'b': (S<u32>, i32)
578 191..198 'S::make': fn make<S<u32>, i32>() -> (S<u32>, i32) 578 190..197 'S::make': fn make<S<u32>, i32>() -> (S<u32>, i32)
579 191..200 'S::make()': (S<u32>, i32) 579 190..199 'S::make()': (S<u32>, i32)
580 "### 580 "###
581 ); 581 );
582} 582}
@@ -596,13 +596,13 @@ fn test() {
596} 596}
597"#), 597"#),
598 @r###" 598 @r###"
599 107..211 '{ ...>(); }': () 599 106..210 '{ ...>(); }': ()
600 117..118 'a': (S<u64>, i64, u8) 600 116..117 'a': (S<u64>, i64, u8)
601 121..150 '<S as ...::<u8>': fn make<S<u64>, i64, u8>() -> (S<u64>, i64, u8) 601 120..149 '<S as ...::<u8>': fn make<S<u64>, i64, u8>() -> (S<u64>, i64, u8)
602 121..152 '<S as ...<u8>()': (S<u64>, i64, u8) 602 120..151 '<S as ...<u8>()': (S<u64>, i64, u8)
603 162..163 'b': (S<u64>, i64, u8) 603 161..162 'b': (S<u64>, i64, u8)
604 182..206 'Trait:...::<u8>': fn make<S<u64>, i64, u8>() -> (S<u64>, i64, u8) 604 181..205 'Trait:...::<u8>': fn make<S<u64>, i64, u8>() -> (S<u64>, i64, u8)
605 182..208 'Trait:...<u8>()': (S<u64>, i64, u8) 605 181..207 'Trait:...<u8>()': (S<u64>, i64, u8)
606 "### 606 "###
607 ); 607 );
608} 608}
@@ -619,11 +619,11 @@ fn test<T: Trait>(t: T) {
619} 619}
620"#), 620"#),
621 @r###" 621 @r###"
622 30..34 'self': &Self 622 29..33 'self': &Self
623 64..65 't': T 623 63..64 't': T
624 70..89 '{ ...d(); }': () 624 69..88 '{ ...d(); }': ()
625 76..77 't': T 625 75..76 't': T
626 76..86 't.method()': u32 626 75..85 't.method()': u32
627 "### 627 "###
628 ); 628 );
629} 629}
@@ -640,11 +640,11 @@ fn test<U, T: Trait<U>>(t: T) {
640} 640}
641"#), 641"#),
642 @r###" 642 @r###"
643 33..37 'self': &Self 643 32..36 'self': &Self
644 71..72 't': T 644 70..71 't': T
645 77..96 '{ ...d(); }': () 645 76..95 '{ ...d(); }': ()
646 83..84 't': T 646 82..83 't': T
647 83..93 't.method()': U 647 82..92 't.method()': U
648 "### 648 "###
649 ); 649 );
650} 650}
@@ -666,18 +666,18 @@ fn test() {
666} 666}
667"#), 667"#),
668 @r###" 668 @r###"
669 29..33 'self': Self 669 28..32 'self': Self
670 111..202 '{ ...(S); }': () 670 110..201 '{ ...(S); }': ()
671 121..122 'x': u32 671 120..121 'x': u32
672 130..131 'S': S 672 129..130 'S': S
673 130..138 'S.into()': u32 673 129..137 'S.into()': u32
674 148..149 'y': u64 674 147..148 'y': u64
675 157..158 'S': S 675 156..157 'S': S
676 157..165 'S.into()': u64 676 156..164 'S.into()': u64
677 175..176 'z': u64 677 174..175 'z': u64
678 179..196 'Into::...::into': fn into<S, u64>(S) -> u64 678 178..195 'Into::...::into': fn into<S, u64>(S) -> u64
679 179..199 'Into::...nto(S)': u64 679 178..198 'Into::...nto(S)': u64
680 197..198 'S': S 680 196..197 'S': S
681 "### 681 "###
682 ); 682 );
683} 683}
@@ -933,7 +933,7 @@ fn method_resolution_overloaded_method() {
933 test_utils::mark::check!(impl_self_type_match_without_receiver); 933 test_utils::mark::check!(impl_self_type_match_without_receiver);
934 let t = type_at( 934 let t = type_at(
935 r#" 935 r#"
936//- main.rs 936//- /main.rs
937struct Wrapper<T>(T); 937struct Wrapper<T>(T);
938struct Foo<T>(T); 938struct Foo<T>(T);
939struct Bar<T>(T); 939struct Bar<T>(T);
@@ -1063,13 +1063,13 @@ fn test(d: &dyn Trait) {
1063} 1063}
1064"#), 1064"#),
1065 @r###" 1065 @r###"
1066 52..56 'self': &Self 1066 51..55 'self': &Self
1067 65..70 '{ 0 }': u32 1067 64..69 '{ 0 }': u32
1068 67..68 '0': u32 1068 66..67 '0': u32
1069 177..178 'd': &dyn Trait 1069 176..177 'd': &dyn Trait
1070 192..208 '{ ...o(); }': () 1070 191..207 '{ ...o(); }': ()
1071 198..199 'd': &dyn Trait 1071 197..198 'd': &dyn Trait
1072 198..205 'd.foo()': u32 1072 197..204 'd.foo()': u32
1073 "### 1073 "###
1074 ); 1074 );
1075} 1075}
diff --git a/crates/ra_hir_ty/src/tests/never_type.rs b/crates/ra_hir_ty/src/tests/never_type.rs
index 082c47208..ab9a990f5 100644
--- a/crates/ra_hir_ty/src/tests/never_type.rs
+++ b/crates/ra_hir_ty/src/tests/never_type.rs
@@ -291,40 +291,40 @@ fn test6() {
291 true, 291 true,
292 ); 292 );
293 assert_snapshot!(t, @r###" 293 assert_snapshot!(t, @r###"
294 25..53 '{ ...urn; }': () 294 11..39 '{ ...urn; }': ()
295 35..36 'x': u32 295 21..22 'x': u32
296 44..50 'return': ! 296 30..36 'return': !
297 65..98 '{ ...; }; }': () 297 51..84 '{ ...; }; }': ()
298 75..76 'x': u32 298 61..62 'x': u32
299 84..95 '{ return; }': u32 299 70..81 '{ return; }': u32
300 86..92 'return': ! 300 72..78 'return': !
301 110..139 '{ ... {}; }': () 301 96..125 '{ ... {}; }': ()
302 120..121 'x': u32 302 106..107 'x': u32
303 129..136 'loop {}': ! 303 115..122 'loop {}': !
304 134..136 '{}': () 304 120..122 '{}': ()
305 151..184 '{ ...} }; }': () 305 137..170 '{ ...} }; }': ()
306 161..162 'x': u32 306 147..148 'x': u32
307 170..181 '{ loop {} }': u32 307 156..167 '{ loop {} }': u32
308 172..179 'loop {}': ! 308 158..165 'loop {}': !
309 177..179 '{}': () 309 163..165 '{}': ()
310 196..260 '{ ...} }; }': () 310 182..246 '{ ...} }; }': ()
311 206..207 'x': u32 311 192..193 'x': u32
312 215..257 '{ if t...}; } }': u32 312 201..243 '{ if t...}; } }': u32
313 217..255 'if tru... {}; }': u32 313 203..241 'if tru... {}; }': u32
314 220..224 'true': bool 314 206..210 'true': bool
315 225..237 '{ loop {}; }': u32 315 211..223 '{ loop {}; }': u32
316 227..234 'loop {}': ! 316 213..220 'loop {}': !
317 232..234 '{}': () 317 218..220 '{}': ()
318 243..255 '{ loop {}; }': u32 318 229..241 '{ loop {}; }': u32
319 245..252 'loop {}': ! 319 231..238 'loop {}': !
320 250..252 '{}': () 320 236..238 '{}': ()
321 272..324 '{ ...; }; }': () 321 258..310 '{ ...; }; }': ()
322 282..283 'x': u32 322 268..269 'x': u32
323 291..321 '{ let ...; }; }': u32 323 277..307 '{ let ...; }; }': u32
324 297..298 'y': u32 324 283..284 'y': u32
325 306..318 '{ loop {}; }': u32 325 292..304 '{ loop {}; }': u32
326 308..315 'loop {}': ! 326 294..301 'loop {}': !
327 313..315 '{}': () 327 299..301 '{}': ()
328 "###); 328 "###);
329} 329}
330 330
@@ -341,14 +341,14 @@ fn test1() {
341 true, 341 true,
342 ); 342 );
343 assert_snapshot!(t, @r###" 343 assert_snapshot!(t, @r###"
344 25..98 '{ ..." }; }': () 344 11..84 '{ ..." }; }': ()
345 68..69 'x': u32 345 54..55 'x': u32
346 77..95 '{ loop...foo" }': &str 346 63..81 '{ loop...foo" }': &str
347 79..86 'loop {}': ! 347 65..72 'loop {}': !
348 84..86 '{}': () 348 70..72 '{}': ()
349 88..93 '"foo"': &str 349 74..79 '"foo"': &str
350 77..95: expected u32, got &str 350 63..81: expected u32, got &str
351 88..93: expected u32, got &str 351 74..79: expected u32, got &str
352 "###); 352 "###);
353} 353}
354 354
@@ -381,58 +381,58 @@ fn test3() {
381 true, 381 true,
382 ); 382 );
383 assert_snapshot!(t, @r###" 383 assert_snapshot!(t, @r###"
384 25..99 '{ ...} }; }': () 384 11..85 '{ ...} }; }': ()
385 68..69 'x': u32 385 54..55 'x': u32
386 77..96 '{ loop...k; } }': () 386 63..82 '{ loop...k; } }': ()
387 79..94 'loop { break; }': () 387 65..80 'loop { break; }': ()
388 84..94 '{ break; }': () 388 70..80 '{ break; }': ()
389 86..91 'break': ! 389 72..77 'break': !
390 77..96: expected u32, got () 390 63..82: expected u32, got ()
391 79..94: expected u32, got () 391 65..80: expected u32, got ()
392 111..357 '{ ...; }; }': () 392 97..343 '{ ...; }; }': ()
393 154..155 'x': u32 393 140..141 'x': u32
394 163..189 '{ for ...; }; }': () 394 149..175 '{ for ...; }; }': ()
395 165..186 'for a ...eak; }': () 395 151..172 'for a ...eak; }': ()
396 169..170 'a': {unknown} 396 155..156 'a': {unknown}
397 174..175 'b': {unknown} 397 160..161 'b': {unknown}
398 176..186 '{ break; }': () 398 162..172 '{ break; }': ()
399 178..183 'break': ! 399 164..169 'break': !
400 240..241 'x': u32 400 226..227 'x': u32
401 249..267 '{ for ... {}; }': () 401 235..253 '{ for ... {}; }': ()
402 251..264 'for a in b {}': () 402 237..250 'for a in b {}': ()
403 255..256 'a': {unknown} 403 241..242 'a': {unknown}
404 260..261 'b': {unknown} 404 246..247 'b': {unknown}
405 262..264 '{}': () 405 248..250 '{}': ()
406 318..319 'x': u32 406 304..305 'x': u32
407 327..354 '{ for ...; }; }': () 407 313..340 '{ for ...; }; }': ()
408 329..351 'for a ...urn; }': () 408 315..337 'for a ...urn; }': ()
409 333..334 'a': {unknown} 409 319..320 'a': {unknown}
410 338..339 'b': {unknown} 410 324..325 'b': {unknown}
411 340..351 '{ return; }': () 411 326..337 '{ return; }': ()
412 342..348 'return': ! 412 328..334 'return': !
413 163..189: expected u32, got () 413 149..175: expected u32, got ()
414 249..267: expected u32, got () 414 235..253: expected u32, got ()
415 327..354: expected u32, got () 415 313..340: expected u32, got ()
416 369..668 '{ ...; }; }': () 416 355..654 '{ ...; }; }': ()
417 412..413 'x': u32 417 398..399 'x': u32
418 421..447 '{ whil...; }; }': () 418 407..433 '{ whil...; }; }': ()
419 423..444 'while ...eak; }': () 419 409..430 'while ...eak; }': ()
420 429..433 'true': bool 420 415..419 'true': bool
421 434..444 '{ break; }': () 421 420..430 '{ break; }': ()
422 436..441 'break': ! 422 422..427 'break': !
423 551..552 'x': u32 423 537..538 'x': u32
424 560..578 '{ whil... {}; }': () 424 546..564 '{ whil... {}; }': ()
425 562..575 'while true {}': () 425 548..561 'while true {}': ()
426 568..572 'true': bool 426 554..558 'true': bool
427 573..575 '{}': () 427 559..561 '{}': ()
428 629..630 'x': u32 428 615..616 'x': u32
429 638..665 '{ whil...; }; }': () 429 624..651 '{ whil...; }; }': ()
430 640..662 'while ...urn; }': () 430 626..648 'while ...urn; }': ()
431 646..650 'true': bool 431 632..636 'true': bool
432 651..662 '{ return; }': () 432 637..648 '{ return; }': ()
433 653..659 'return': ! 433 639..645 'return': !
434 421..447: expected u32, got () 434 407..433: expected u32, got ()
435 560..578: expected u32, got () 435 546..564: expected u32, got ()
436 638..665: expected u32, got () 436 624..651: expected u32, got ()
437 "###); 437 "###);
438} 438}
diff --git a/crates/ra_hir_ty/src/tests/patterns.rs b/crates/ra_hir_ty/src/tests/patterns.rs
index fe62587c0..e5ef241ca 100644
--- a/crates/ra_hir_ty/src/tests/patterns.rs
+++ b/crates/ra_hir_ty/src/tests/patterns.rs
@@ -30,54 +30,54 @@ fn test(x: &i32) {
30} 30}
31"#), 31"#),
32 @r###" 32 @r###"
33 9..10 'x': &i32 33 8..9 'x': &i32
34 18..369 '{ ...o_x; }': () 34 17..368 '{ ...o_x; }': ()
35 28..29 'y': &i32 35 27..28 'y': &i32
36 32..33 'x': &i32 36 31..32 'x': &i32
37 43..45 '&z': &i32 37 42..44 '&z': &i32
38 44..45 'z': i32 38 43..44 'z': i32
39 48..49 'x': &i32 39 47..48 'x': &i32
40 59..60 'a': i32 40 58..59 'a': i32
41 63..64 'z': i32 41 62..63 'z': i32
42 74..80 '(c, d)': (i32, &str) 42 73..79 '(c, d)': (i32, &str)
43 75..76 'c': i32 43 74..75 'c': i32
44 78..79 'd': &str 44 77..78 'd': &str
45 83..95 '(1, "hello")': (i32, &str) 45 82..94 '(1, "hello")': (i32, &str)
46 84..85 '1': i32 46 83..84 '1': i32
47 87..94 '"hello"': &str 47 86..93 '"hello"': &str
48 102..152 'for (e... }': () 48 101..151 'for (e... }': ()
49 106..112 '(e, f)': ({unknown}, {unknown}) 49 105..111 '(e, f)': ({unknown}, {unknown})
50 107..108 'e': {unknown} 50 106..107 'e': {unknown}
51 110..111 'f': {unknown} 51 109..110 'f': {unknown}
52 116..125 'some_iter': {unknown} 52 115..124 'some_iter': {unknown}
53 126..152 '{ ... }': () 53 125..151 '{ ... }': ()
54 140..141 'g': {unknown} 54 139..140 'g': {unknown}
55 144..145 'e': {unknown} 55 143..144 'e': {unknown}
56 158..205 'if let... }': () 56 157..204 'if let... }': ()
57 165..170 '[val]': [{unknown}] 57 164..169 '[val]': [{unknown}]
58 166..169 'val': {unknown} 58 165..168 'val': {unknown}
59 173..176 'opt': [{unknown}] 59 172..175 'opt': [{unknown}]
60 177..205 '{ ... }': () 60 176..204 '{ ... }': ()
61 191..192 'h': {unknown} 61 190..191 'h': {unknown}
62 195..198 'val': {unknown} 62 194..197 'val': {unknown}
63 215..221 'lambda': |u64, u64, i32| -> i32 63 214..220 'lambda': |u64, u64, i32| -> i32
64 224..256 '|a: u6...b; c }': |u64, u64, i32| -> i32 64 223..255 '|a: u6...b; c }': |u64, u64, i32| -> i32
65 225..226 'a': u64 65 224..225 'a': u64
66 233..234 'b': u64 66 232..233 'b': u64
67 236..237 'c': i32 67 235..236 'c': i32
68 244..256 '{ a + b; c }': i32 68 243..255 '{ a + b; c }': i32
69 246..247 'a': u64 69 245..246 'a': u64
70 246..251 'a + b': u64 70 245..250 'a + b': u64
71 250..251 'b': u64 71 249..250 'b': u64
72 253..254 'c': i32 72 252..253 'c': i32
73 267..279 'ref ref_to_x': &&i32 73 266..278 'ref ref_to_x': &&i32
74 282..283 'x': &i32 74 281..282 'x': &i32
75 293..302 'mut mut_x': &i32 75 292..301 'mut mut_x': &i32
76 305..306 'x': &i32 76 304..305 'x': &i32
77 316..336 'ref mu...f_to_x': &mut &i32 77 315..335 'ref mu...f_to_x': &mut &i32
78 339..340 'x': &i32 78 338..339 'x': &i32
79 350..351 'k': &mut &i32 79 349..350 'k': &mut &i32
80 354..366 'mut_ref_to_x': &mut &i32 80 353..365 'mut_ref_to_x': &mut &i32
81 "### 81 "###
82 ); 82 );
83} 83}
@@ -97,47 +97,47 @@ fn test(x: &i32) {
97} 97}
98"#, true), 98"#, true),
99 @r###" 99 @r###"
100 18..29 '{ loop {} }': T 100 17..28 '{ loop {} }': T
101 20..27 'loop {}': ! 101 19..26 'loop {}': !
102 25..27 '{}': () 102 24..26 '{}': ()
103 38..39 'x': &i32 103 37..38 'x': &i32
104 47..209 '{ ...) {} }': () 104 46..208 '{ ...) {} }': ()
105 53..76 'if let...y() {}': () 105 52..75 'if let...y() {}': ()
106 60..65 '"foo"': &str 106 59..64 '"foo"': &str
107 60..65 '"foo"': &str 107 59..64 '"foo"': &str
108 68..71 'any': fn any<&str>() -> &str 108 67..70 'any': fn any<&str>() -> &str
109 68..73 'any()': &str 109 67..72 'any()': &str
110 74..76 '{}': () 110 73..75 '{}': ()
111 81..100 'if let...y() {}': () 111 80..99 'if let...y() {}': ()
112 88..89 '1': i32 112 87..88 '1': i32
113 88..89 '1': i32 113 87..88 '1': i32
114 92..95 'any': fn any<i32>() -> i32 114 91..94 'any': fn any<i32>() -> i32
115 92..97 'any()': i32 115 91..96 'any()': i32
116 98..100 '{}': () 116 97..99 '{}': ()
117 105..127 'if let...y() {}': () 117 104..126 'if let...y() {}': ()
118 112..116 '1u32': u32 118 111..115 '1u32': u32
119 112..116 '1u32': u32 119 111..115 '1u32': u32
120 119..122 'any': fn any<u32>() -> u32 120 118..121 'any': fn any<u32>() -> u32
121 119..124 'any()': u32 121 118..123 'any()': u32
122 125..127 '{}': () 122 124..126 '{}': ()
123 132..154 'if let...y() {}': () 123 131..153 'if let...y() {}': ()
124 139..143 '1f32': f32 124 138..142 '1f32': f32
125 139..143 '1f32': f32 125 138..142 '1f32': f32
126 146..149 'any': fn any<f32>() -> f32 126 145..148 'any': fn any<f32>() -> f32
127 146..151 'any()': f32 127 145..150 'any()': f32
128 152..154 '{}': () 128 151..153 '{}': ()
129 159..180 'if let...y() {}': () 129 158..179 'if let...y() {}': ()
130 166..169 '1.0': f64 130 165..168 '1.0': f64
131 166..169 '1.0': f64 131 165..168 '1.0': f64
132 172..175 'any': fn any<f64>() -> f64 132 171..174 'any': fn any<f64>() -> f64
133 172..177 'any()': f64 133 171..176 'any()': f64
134 178..180 '{}': () 134 177..179 '{}': ()
135 185..207 'if let...y() {}': () 135 184..206 'if let...y() {}': ()
136 192..196 'true': bool 136 191..195 'true': bool
137 192..196 'true': bool 137 191..195 'true': bool
138 199..202 'any': fn any<bool>() -> bool 138 198..201 'any': fn any<bool>() -> bool
139 199..204 'any()': bool 139 198..203 'any()': bool
140 205..207 '{}': () 140 204..206 '{}': ()
141 "### 141 "###
142 ); 142 );
143} 143}
@@ -152,16 +152,16 @@ fn test(x: &i32) {
152} 152}
153"#, true), 153"#, true),
154 @r###" 154 @r###"
155 9..10 'x': &i32 155 8..9 'x': &i32
156 18..76 '{ ...2 {} }': () 156 17..75 '{ ...2 {} }': ()
157 24..46 'if let...u32 {}': () 157 23..45 'if let...u32 {}': ()
158 31..36 '1..76': u32 158 30..35 '1..76': u32
159 39..43 '2u32': u32 159 38..42 '2u32': u32
160 44..46 '{}': () 160 43..45 '{}': ()
161 51..74 'if let...u32 {}': () 161 50..73 'if let...u32 {}': ()
162 58..64 '1..=76': u32 162 57..63 '1..=76': u32
163 67..71 '2u32': u32 163 66..70 '2u32': u32
164 72..74 '{}': () 164 71..73 '{}': ()
165 "### 165 "###
166 ); 166 );
167} 167}
@@ -178,19 +178,19 @@ fn test() {
178} 178}
179"#), 179"#),
180 @r###" 180 @r###"
181 28..79 '{ ...(1); }': () 181 27..78 '{ ...(1); }': ()
182 38..42 'A(n)': A<i32> 182 37..41 'A(n)': A<i32>
183 40..41 'n': &i32 183 39..40 'n': &i32
184 45..50 '&A(1)': &A<i32> 184 44..49 '&A(1)': &A<i32>
185 46..47 'A': A<i32>(i32) -> A<i32> 185 45..46 'A': A<i32>(i32) -> A<i32>
186 46..50 'A(1)': A<i32> 186 45..49 'A(1)': A<i32>
187 48..49 '1': i32 187 47..48 '1': i32
188 60..64 'A(n)': A<i32> 188 59..63 'A(n)': A<i32>
189 62..63 'n': &mut i32 189 61..62 'n': &mut i32
190 67..76 '&mut A(1)': &mut A<i32> 190 66..75 '&mut A(1)': &mut A<i32>
191 72..73 'A': A<i32>(i32) -> A<i32> 191 71..72 'A': A<i32>(i32) -> A<i32>
192 72..76 'A(1)': A<i32> 192 71..75 'A(1)': A<i32>
193 74..75 '1': i32 193 73..74 '1': i32
194 "### 194 "###
195 ); 195 );
196} 196}
@@ -206,18 +206,18 @@ fn test() {
206} 206}
207"#), 207"#),
208 @r###" 208 @r###"
209 11..57 '{ ...= v; }': () 209 10..56 '{ ...= v; }': ()
210 21..22 'v': &(i32, &i32) 210 20..21 'v': &(i32, &i32)
211 25..33 '&(1, &2)': &(i32, &i32) 211 24..32 '&(1, &2)': &(i32, &i32)
212 26..33 '(1, &2)': (i32, &i32) 212 25..32 '(1, &2)': (i32, &i32)
213 27..28 '1': i32 213 26..27 '1': i32
214 30..32 '&2': &i32 214 29..31 '&2': &i32
215 31..32 '2': i32 215 30..31 '2': i32
216 43..50 '(_, &w)': (i32, &i32) 216 42..49 '(_, &w)': (i32, &i32)
217 44..45 '_': i32 217 43..44 '_': i32
218 47..49 '&w': &i32 218 46..48 '&w': &i32
219 48..49 'w': i32 219 47..48 'w': i32
220 53..54 'v': &(i32, &i32) 220 52..53 'v': &(i32, &i32)
221 "### 221 "###
222 ); 222 );
223} 223}
@@ -242,30 +242,87 @@ fn test() {
242} 242}
243"#), 243"#),
244 @r###" 244 @r###"
245 11..210 '{ ... } }': () 245 10..209 '{ ... } }': ()
246 21..26 'slice': &[f64] 246 20..25 'slice': &[f64]
247 37..43 '&[0.0]': &[f64; _] 247 36..42 '&[0.0]': &[f64; _]
248 38..43 '[0.0]': [f64; _] 248 37..42 '[0.0]': [f64; _]
249 39..42 '0.0': f64 249 38..41 '0.0': f64
250 49..208 'match ... }': () 250 48..207 'match ... }': ()
251 55..60 'slice': &[f64] 251 54..59 'slice': &[f64]
252 71..74 '&[]': &[f64] 252 70..73 '&[]': &[f64]
253 72..74 '[]': [f64] 253 71..73 '[]': [f64]
254 78..80 '{}': () 254 77..79 '{}': ()
255 90..94 '&[a]': &[f64] 255 89..93 '&[a]': &[f64]
256 91..94 '[a]': [f64] 256 90..93 '[a]': [f64]
257 92..93 'a': f64 257 91..92 'a': f64
258 98..124 '{ ... }': () 258 97..123 '{ ... }': ()
259 112..113 'a': f64 259 111..112 'a': f64
260 134..141 '&[b, c]': &[f64] 260 133..140 '&[b, c]': &[f64]
261 135..141 '[b, c]': [f64] 261 134..140 '[b, c]': [f64]
262 136..137 'b': f64 262 135..136 'b': f64
263 139..140 'c': f64 263 138..139 'c': f64
264 145..186 '{ ... }': () 264 144..185 '{ ... }': ()
265 159..160 'b': f64 265 158..159 'b': f64
266 174..175 'c': f64 266 173..174 'c': f64
267 195..196 '_': &[f64] 267 194..195 '_': &[f64]
268 200..202 '{}': () 268 199..201 '{}': ()
269 "###
270 );
271}
272
273#[test]
274fn infer_pattern_match_string_literal() {
275 assert_snapshot!(
276 infer_with_mismatches(r#"
277fn test() {
278 let s: &str = "hello";
279 match s {
280 "hello" => {}
281 _ => {}
282 }
283}
284"#, true),
285 @r###"
286 10..98 '{ ... } }': ()
287 20..21 's': &str
288 30..37 '"hello"': &str
289 43..96 'match ... }': ()
290 49..50 's': &str
291 61..68 '"hello"': &str
292 61..68 '"hello"': &str
293 72..74 '{}': ()
294 83..84 '_': &str
295 88..90 '{}': ()
296 "###
297 );
298}
299
300#[test]
301fn infer_pattern_match_or() {
302 assert_snapshot!(
303 infer_with_mismatches(r#"
304fn test() {
305 let s: &str = "hello";
306 match s {
307 "hello" | "world" => {}
308 _ => {}
309 }
310}
311"#, true),
312 @r###"
313 10..108 '{ ... } }': ()
314 20..21 's': &str
315 30..37 '"hello"': &str
316 43..106 'match ... }': ()
317 49..50 's': &str
318 61..68 '"hello"': &str
319 61..68 '"hello"': &str
320 61..78 '"hello...world"': &str
321 71..78 '"world"': &str
322 71..78 '"world"': &str
323 82..84 '{}': ()
324 93..94 '_': &str
325 98..100 '{}': ()
269 "### 326 "###
270 ); 327 );
271} 328}
@@ -288,25 +345,25 @@ fn test() {
288} 345}
289"#), 346"#),
290 @r###" 347 @r###"
291 11..180 '{ ... } }': () 348 10..179 '{ ... } }': ()
292 21..24 'arr': [f64; _] 349 20..23 'arr': [f64; _]
293 37..47 '[0.0, 1.0]': [f64; _] 350 36..46 '[0.0, 1.0]': [f64; _]
294 38..41 '0.0': f64 351 37..40 '0.0': f64
295 43..46 '1.0': f64 352 42..45 '1.0': f64
296 53..178 'match ... }': () 353 52..177 'match ... }': ()
297 59..62 'arr': [f64; _] 354 58..61 'arr': [f64; _]
298 73..81 '[1.0, a]': [f64; _] 355 72..80 '[1.0, a]': [f64; _]
299 74..77 '1.0': f64 356 73..76 '1.0': f64
300 74..77 '1.0': f64 357 73..76 '1.0': f64
301 79..80 'a': f64 358 78..79 'a': f64
302 85..111 '{ ... }': () 359 84..110 '{ ... }': ()
303 99..100 'a': f64 360 98..99 'a': f64
304 121..127 '[b, c]': [f64; _] 361 120..126 '[b, c]': [f64; _]
305 122..123 'b': f64 362 121..122 'b': f64
306 125..126 'c': f64 363 124..125 'c': f64
307 131..172 '{ ... }': () 364 130..171 '{ ... }': ()
308 145..146 'b': f64 365 144..145 'b': f64
309 160..161 'c': f64 366 159..160 'c': f64
310 "### 367 "###
311 ); 368 );
312} 369}
@@ -339,31 +396,31 @@ fn test() {
339} 396}
340"#), 397"#),
341 @r###" 398 @r###"
342 68..289 '{ ... d; }': () 399 67..288 '{ ... d; }': ()
343 78..79 'e': E 400 77..78 'e': E
344 82..95 'E::A { x: 3 }': E 401 81..94 'E::A { x: 3 }': E
345 92..93 '3': usize 402 91..92 '3': usize
346 106..113 'S(y, z)': S 403 105..112 'S(y, z)': S
347 108..109 'y': u32 404 107..108 'y': u32
348 111..112 'z': E 405 110..111 'z': E
349 116..119 'foo': S 406 115..118 'foo': S
350 129..148 'E::A {..._var }': E 407 128..147 'E::A {..._var }': E
351 139..146 'new_var': usize 408 138..145 'new_var': usize
352 151..152 'e': E 409 150..151 'e': E
353 159..245 'match ... }': usize 410 158..244 'match ... }': usize
354 165..166 'e': E 411 164..165 'e': E
355 177..187 'E::A { x }': E 412 176..186 'E::A { x }': E
356 184..185 'x': usize 413 183..184 'x': usize
357 191..192 'x': usize 414 190..191 'x': usize
358 202..206 'E::B': E 415 201..205 'E::B': E
359 210..213 'foo': bool 416 209..212 'foo': bool
360 217..218 '1': usize 417 216..217 '1': usize
361 228..232 'E::B': E 418 227..231 'E::B': E
362 236..238 '10': usize 419 235..237 '10': usize
363 256..275 'ref d ...{ .. }': &E 420 255..274 'ref d ...{ .. }': &E
364 264..275 'E::A { .. }': E 421 263..274 'E::A { .. }': E
365 278..279 'e': E 422 277..278 'e': E
366 285..286 'd': &E 423 284..285 'd': &E
367 "### 424 "###
368 ); 425 );
369} 426}
@@ -389,20 +446,20 @@ impl E {
389} 446}
390"#), 447"#),
391 @r###" 448 @r###"
392 76..218 '{ ... }': () 449 75..217 '{ ... }': ()
393 86..211 'match ... }': () 450 85..210 'match ... }': ()
394 93..100 'loop {}': ! 451 92..99 'loop {}': !
395 98..100 '{}': () 452 97..99 '{}': ()
396 116..129 'Self::A { x }': E 453 115..128 'Self::A { x }': E
397 126..127 'x': usize 454 125..126 'x': usize
398 133..139 '{ x; }': () 455 132..138 '{ x; }': ()
399 135..136 'x': usize 456 134..135 'x': usize
400 153..163 'Self::B(x)': E 457 152..162 'Self::B(x)': E
401 161..162 'x': usize 458 160..161 'x': usize
402 167..173 '{ x; }': () 459 166..172 '{ x; }': ()
403 169..170 'x': usize 460 168..169 'x': usize
404 187..194 'Self::C': E 461 186..193 'Self::C': E
405 198..200 '{}': () 462 197..199 '{}': ()
406 "### 463 "###
407 ); 464 );
408} 465}
@@ -430,23 +487,23 @@ fn test(a1: A<u32>, o: Option<u64>) {
430} 487}
431"#), 488"#),
432 @r###" 489 @r###"
433 79..81 'a1': A<u32> 490 78..80 'a1': A<u32>
434 91..92 'o': Option<u64> 491 90..91 'o': Option<u64>
435 107..244 '{ ... }; }': () 492 106..243 '{ ... }; }': ()
436 117..128 'A { x: x2 }': A<u32> 493 116..127 'A { x: x2 }': A<u32>
437 124..126 'x2': u32 494 123..125 'x2': u32
438 131..133 'a1': A<u32> 495 130..132 'a1': A<u32>
439 143..161 'A::<i6...: x3 }': A<i64> 496 142..160 'A::<i6...: x3 }': A<i64>
440 157..159 'x3': i64 497 156..158 'x3': i64
441 164..174 'A { x: 1 }': A<i64> 498 163..173 'A { x: 1 }': A<i64>
442 171..172 '1': i64 499 170..171 '1': i64
443 180..241 'match ... }': u64 500 179..240 'match ... }': u64
444 186..187 'o': Option<u64> 501 185..186 'o': Option<u64>
445 198..213 'Option::Some(t)': Option<u64> 502 197..212 'Option::Some(t)': Option<u64>
446 211..212 't': u64 503 210..211 't': u64
447 217..218 't': u64 504 216..217 't': u64
448 228..229 '_': Option<u64> 505 227..228 '_': Option<u64>
449 233..234 '1': u64 506 232..233 '1': u64
450 "### 507 "###
451 ); 508 );
452} 509}
@@ -470,27 +527,27 @@ fn test() {
470} 527}
471"#, true), 528"#, true),
472 @r###" 529 @r###"
473 74..75 '1': usize 530 73..74 '1': usize
474 88..310 '{ ...atch }': () 531 87..309 '{ ...atch }': ()
475 98..99 'a': Option<u32> 532 97..98 'a': Option<u32>
476 115..119 'None': Option<u32> 533 114..118 'None': Option<u32>
477 129..130 'b': Option<i64> 534 128..129 'b': Option<i64>
478 146..183 'match ... }': Option<i64> 535 145..182 'match ... }': Option<i64>
479 152..153 'a': Option<u32> 536 151..152 'a': Option<u32>
480 164..168 'None': Option<u32> 537 163..167 'None': Option<u32>
481 172..176 'None': Option<i64> 538 171..175 'None': Option<i64>
482 193..194 '_': () 539 192..193 '_': ()
483 201..224 'match ... Foo }': Foo 540 200..223 'match ... Foo }': Foo
484 207..209 '()': () 541 206..208 '()': ()
485 212..215 'Foo': Foo 542 211..214 'Foo': Foo
486 219..222 'Foo': Foo 543 218..221 'Foo': Foo
487 255..256 '_': () 544 254..255 '_': ()
488 263..286 'match ... Bar }': usize 545 262..285 'match ... Bar }': usize
489 269..271 '()': () 546 268..270 '()': ()
490 274..277 'Bar': usize 547 273..276 'Bar': usize
491 281..284 'Bar': usize 548 280..283 'Bar': usize
492 201..224: expected (), got Foo 549 200..223: expected (), got Foo
493 263..286: expected (), got usize 550 262..285: expected (), got usize
494 "### 551 "###
495 ); 552 );
496} 553}
@@ -507,18 +564,18 @@ fn main() {
507 s if s.foo() => (), 564 s if s.foo() => (),
508 } 565 }
509} 566}
510 "#), @" 567 "#), @r###"
511 28..32 'self': &S 568 27..31 'self': &S
512 42..51 '{ false }': bool 569 41..50 '{ false }': bool
513 44..49 'false': bool 570 43..48 'false': bool
514 65..116 '{ ... } }': () 571 64..115 '{ ... } }': ()
515 71..114 'match ... }': () 572 70..113 'match ... }': ()
516 77..78 'S': S 573 76..77 'S': S
517 89..90 's': S 574 88..89 's': S
518 94..95 's': S 575 93..94 's': S
519 94..101 's.foo()': bool 576 93..100 's.foo()': bool
520 105..107 '()': () 577 104..106 '()': ()
521 ") 578 "###)
522} 579}
523 580
524#[test] 581#[test]
@@ -538,35 +595,35 @@ fn test() {
538} 595}
539"#), 596"#),
540 @r###" 597 @r###"
541 94..95 't': T 598 93..94 't': T
542 100..101 'f': F 599 99..100 'f': F
543 111..122 '{ loop {} }': U 600 110..121 '{ loop {} }': U
544 113..120 'loop {}': ! 601 112..119 'loop {}': !
545 118..120 '{}': () 602 117..119 '{}': ()
546 134..233 '{ ... x); }': () 603 133..232 '{ ... x); }': ()
547 140..143 'foo': fn foo<&(i32, &str), i32, |&(i32, &str)| -> i32>(&(i32, &str), |&(i32, &str)| -> i32) -> i32 604 139..142 'foo': fn foo<&(i32, &str), i32, |&(i32, &str)| -> i32>(&(i32, &str), |&(i32, &str)| -> i32) -> i32
548 140..167 'foo(&(...y)| x)': i32 605 139..166 'foo(&(...y)| x)': i32
549 144..153 '&(1, "a")': &(i32, &str) 606 143..152 '&(1, "a")': &(i32, &str)
550 145..153 '(1, "a")': (i32, &str) 607 144..152 '(1, "a")': (i32, &str)
551 146..147 '1': i32 608 145..146 '1': i32
552 149..152 '"a"': &str 609 148..151 '"a"': &str
553 155..166 '|&(x, y)| x': |&(i32, &str)| -> i32 610 154..165 '|&(x, y)| x': |&(i32, &str)| -> i32
554 156..163 '&(x, y)': &(i32, &str) 611 155..162 '&(x, y)': &(i32, &str)
555 157..163 '(x, y)': (i32, &str) 612 156..162 '(x, y)': (i32, &str)
556 158..159 'x': i32 613 157..158 'x': i32
557 161..162 'y': &str 614 160..161 'y': &str
558 165..166 'x': i32 615 164..165 'x': i32
559 204..207 'foo': fn foo<&(i32, &str), &i32, |&(i32, &str)| -> &i32>(&(i32, &str), |&(i32, &str)| -> &i32) -> &i32 616 203..206 'foo': fn foo<&(i32, &str), &i32, |&(i32, &str)| -> &i32>(&(i32, &str), |&(i32, &str)| -> &i32) -> &i32
560 204..230 'foo(&(...y)| x)': &i32 617 203..229 'foo(&(...y)| x)': &i32
561 208..217 '&(1, "a")': &(i32, &str) 618 207..216 '&(1, "a")': &(i32, &str)
562 209..217 '(1, "a")': (i32, &str) 619 208..216 '(1, "a")': (i32, &str)
563 210..211 '1': i32 620 209..210 '1': i32
564 213..216 '"a"': &str 621 212..215 '"a"': &str
565 219..229 '|(x, y)| x': |&(i32, &str)| -> &i32 622 218..228 '|(x, y)| x': |&(i32, &str)| -> &i32
566 220..226 '(x, y)': (i32, &str) 623 219..225 '(x, y)': (i32, &str)
567 221..222 'x': &i32 624 220..221 'x': &i32
568 224..225 'y': &&str 625 223..224 'y': &&str
569 228..229 'x': &i32 626 227..228 'x': &i32
570 "### 627 "###
571 ); 628 );
572} 629}
diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs
index 1f004bd63..eedaa27ba 100644
--- a/crates/ra_hir_ty/src/tests/regression.rs
+++ b/crates/ra_hir_ty/src/tests/regression.rs
@@ -15,11 +15,11 @@ fn test() {
15} 15}
16"#), 16"#),
17 @r###" 17 @r###"
18 11..37 '{ l... {}; }': () 18 10..36 '{ l... {}; }': ()
19 20..21 'x': () 19 19..20 'x': ()
20 24..34 'if true {}': () 20 23..33 'if true {}': ()
21 27..31 'true': bool 21 26..30 'true': bool
22 32..34 '{}': () 22 31..33 '{}': ()
23 "### 23 "###
24 ); 24 );
25} 25}
@@ -35,10 +35,10 @@ fn test(x: X) {
35} 35}
36"#), 36"#),
37 @r###" 37 @r###"
38 20..21 'x': X 38 19..20 'x': X
39 26..47 '{ ...eld; }': () 39 25..46 '{ ...eld; }': ()
40 32..33 'x': X 40 31..32 'x': X
41 32..44 'x.some_field': {unknown} 41 31..43 'x.some_field': {unknown}
42 "### 42 "###
43 ); 43 );
44} 44}
@@ -56,14 +56,14 @@ fn test() {
56} 56}
57"#), 57"#),
58 @r###" 58 @r###"
59 11..89 '{ ... } }': () 59 10..88 '{ ... } }': ()
60 17..21 'X {}': {unknown} 60 16..20 'X {}': {unknown}
61 27..87 'match ... }': () 61 26..86 'match ... }': ()
62 33..34 'x': {unknown} 62 32..33 'x': {unknown}
63 45..52 'A::B {}': {unknown} 63 44..51 'A::B {}': {unknown}
64 56..58 '()': () 64 55..57 '()': ()
65 68..74 'A::Y()': {unknown} 65 67..73 'A::Y()': {unknown}
66 78..80 '()': () 66 77..79 '()': ()
67 "### 67 "###
68 ); 68 );
69} 69}
@@ -78,12 +78,12 @@ fn quux() {
78} 78}
79"#), 79"#),
80 @r###" 80 @r###"
81 11..41 '{ ...+ y; }': () 81 10..40 '{ ...+ y; }': ()
82 21..22 'y': i32 82 20..21 'y': i32
83 25..27 '92': i32 83 24..26 '92': i32
84 33..34 '1': i32 84 32..33 '1': i32
85 33..38 '1 + y': i32 85 32..37 '1 + y': i32
86 37..38 'y': i32 86 36..37 'y': i32
87 "### 87 "###
88 ); 88 );
89} 89}
@@ -100,13 +100,13 @@ fn test() {
100} 100}
101"#), 101"#),
102 @r###" 102 @r###"
103 11..48 '{ ...&y]; }': () 103 10..47 '{ ...&y]; }': ()
104 21..22 'y': &{unknown} 104 20..21 'y': &{unknown}
105 25..32 'unknown': &{unknown} 105 24..31 'unknown': &{unknown}
106 38..45 '[y, &y]': [&&{unknown}; _] 106 37..44 '[y, &y]': [&&{unknown}; _]
107 39..40 'y': &{unknown} 107 38..39 'y': &{unknown}
108 42..44 '&y': &&{unknown} 108 41..43 '&y': &&{unknown}
109 43..44 'y': &{unknown} 109 42..43 'y': &{unknown}
110 "### 110 "###
111 ); 111 );
112} 112}
@@ -122,20 +122,20 @@ fn test() {
122} 122}
123"#), 123"#),
124 @r###" 124 @r###"
125 11..80 '{ ...x)]; }': () 125 10..79 '{ ...x)]; }': ()
126 21..22 'x': &&{unknown} 126 20..21 'x': &&{unknown}
127 25..32 'unknown': &&{unknown} 127 24..31 'unknown': &&{unknown}
128 42..43 'y': &&{unknown} 128 41..42 'y': &&{unknown}
129 46..53 'unknown': &&{unknown} 129 45..52 'unknown': &&{unknown}
130 59..77 '[(x, y..., &x)]': [(&&&{unknown}, &&&{unknown}); _] 130 58..76 '[(x, y..., &x)]': [(&&&{unknown}, &&&{unknown}); _]
131 60..66 '(x, y)': (&&&{unknown}, &&&{unknown}) 131 59..65 '(x, y)': (&&&{unknown}, &&&{unknown})
132 61..62 'x': &&{unknown} 132 60..61 'x': &&{unknown}
133 64..65 'y': &&{unknown} 133 63..64 'y': &&{unknown}
134 68..76 '(&y, &x)': (&&&{unknown}, &&&{unknown}) 134 67..75 '(&y, &x)': (&&&{unknown}, &&&{unknown})
135 69..71 '&y': &&&{unknown} 135 68..70 '&y': &&&{unknown}
136 70..71 'y': &&{unknown} 136 69..70 'y': &&{unknown}
137 73..75 '&x': &&&{unknown} 137 72..74 '&x': &&&{unknown}
138 74..75 'x': &&{unknown} 138 73..74 'x': &&{unknown}
139 "### 139 "###
140 ); 140 );
141} 141}
@@ -157,12 +157,12 @@ fn write() {
157} 157}
158"#), 158"#),
159 @r###" 159 @r###"
160 54..139 '{ ... } }': () 160 53..138 '{ ... } }': ()
161 60..137 'match ... }': () 161 59..136 'match ... }': ()
162 66..83 'someth...nknown': Maybe<{unknown}> 162 65..82 'someth...nknown': Maybe<{unknown}>
163 94..124 'Maybe:...thing)': Maybe<{unknown}> 163 93..123 'Maybe:...thing)': Maybe<{unknown}>
164 106..123 'ref mu...ething': &mut {unknown} 164 105..122 'ref mu...ething': &mut {unknown}
165 128..130 '()': () 165 127..129 '()': ()
166 "### 166 "###
167 ); 167 );
168} 168}
@@ -178,13 +178,13 @@ fn test_line_buffer() {
178} 178}
179"#), 179"#),
180 @r###" 180 @r###"
181 23..53 '{ ...n']; }': () 181 22..52 '{ ...n']; }': ()
182 29..50 '&[0, b...b'\n']': &[u8; _] 182 28..49 '&[0, b...b'\n']': &[u8; _]
183 30..50 '[0, b'...b'\n']': [u8; _] 183 29..49 '[0, b'...b'\n']': [u8; _]
184 31..32 '0': u8 184 30..31 '0': u8
185 34..39 'b'\n'': u8 185 33..38 'b'\n'': u8
186 41..42 '1': u8 186 40..41 '1': u8
187 44..49 'b'\n'': u8 187 43..48 'b'\n'': u8
188 "### 188 "###
189 ); 189 );
190} 190}
@@ -201,14 +201,14 @@ pub fn compute() {
201} 201}
202"#), 202"#),
203 @r###" 203 @r###"
204 18..108 '{ ... } }': () 204 17..107 '{ ... } }': ()
205 24..106 'match ... }': () 205 23..105 'match ... }': ()
206 30..37 'nope!()': {unknown} 206 29..36 'nope!()': {unknown}
207 48..94 'SizeSk...tail }': {unknown} 207 47..93 'SizeSk...tail }': {unknown}
208 82..86 'true': bool 208 81..85 'true': bool
209 82..86 'true': bool 209 81..85 'true': bool
210 88..92 'tail': {unknown} 210 87..91 'tail': {unknown}
211 98..100 '{}': () 211 97..99 '{}': ()
212 "### 212 "###
213 ); 213 );
214} 214}
@@ -225,14 +225,14 @@ pub fn primitive_type() {
225} 225}
226"#), 226"#),
227 @r###" 227 @r###"
228 25..106 '{ ... } }': () 228 24..105 '{ ... } }': ()
229 31..104 'match ... }': () 229 30..103 'match ... }': ()
230 37..42 '*self': {unknown} 230 36..41 '*self': {unknown}
231 38..42 'self': {unknown} 231 37..41 'self': {unknown}
232 53..91 'Borrow...), ..}': {unknown} 232 52..90 'Borrow...), ..}': {unknown}
233 74..86 'Primitive(p)': {unknown} 233 73..85 'Primitive(p)': {unknown}
234 84..85 'p': {unknown} 234 83..84 'p': {unknown}
235 95..97 '{}': () 235 94..96 '{}': ()
236 "### 236 "###
237 ); 237 );
238} 238}
@@ -259,29 +259,29 @@ fn extra_compiler_flags() {
259} 259}
260"#), 260"#),
261 @r###" 261 @r###"
262 27..323 '{ ... } }': () 262 26..322 '{ ... } }': ()
263 33..321 'for co... }': () 263 32..320 'for co... }': ()
264 37..44 'content': &{unknown} 264 36..43 'content': &{unknown}
265 48..61 'doesnt_matter': {unknown} 265 47..60 'doesnt_matter': {unknown}
266 62..321 '{ ... }': () 266 61..320 '{ ... }': ()
267 76..80 'name': &&{unknown} 267 75..79 'name': &&{unknown}
268 83..167 'if doe... }': &&{unknown} 268 82..166 'if doe... }': &&{unknown}
269 86..99 'doesnt_matter': bool 269 85..98 'doesnt_matter': bool
270 100..129 '{ ... }': &&{unknown} 270 99..128 '{ ... }': &&{unknown}
271 114..119 'first': &&{unknown} 271 113..118 'first': &&{unknown}
272 135..167 '{ ... }': &&{unknown} 272 134..166 '{ ... }': &&{unknown}
273 149..157 '&content': &&{unknown} 273 148..156 '&content': &&{unknown}
274 150..157 'content': &{unknown} 274 149..156 'content': &{unknown}
275 182..189 'content': &{unknown} 275 181..188 'content': &{unknown}
276 192..314 'if ICE... }': &{unknown} 276 191..313 'if ICE... }': &{unknown}
277 195..232 'ICE_RE..._VALUE': {unknown} 277 194..231 'ICE_RE..._VALUE': {unknown}
278 195..248 'ICE_RE...&name)': bool 278 194..247 'ICE_RE...&name)': bool
279 242..247 '&name': &&&{unknown} 279 241..246 '&name': &&&{unknown}
280 243..247 'name': &&{unknown} 280 242..246 'name': &&{unknown}
281 249..277 '{ ... }': &&{unknown} 281 248..276 '{ ... }': &&{unknown}
282 263..267 'name': &&{unknown} 282 262..266 'name': &&{unknown}
283 283..314 '{ ... }': &{unknown} 283 282..313 '{ ... }': &{unknown}
284 297..304 'content': &{unknown} 284 296..303 'content': &{unknown}
285 "### 285 "###
286 ); 286 );
287} 287}
@@ -302,11 +302,11 @@ fn test<R>(query_response: Canonical<QueryResponse<R>>) {
302} 302}
303"#), 303"#),
304 @r###" 304 @r###"
305 92..106 'query_response': Canonical<QueryResponse<R>> 305 91..105 'query_response': Canonical<QueryResponse<R>>
306 137..167 '{ ...lue; }': () 306 136..166 '{ ...lue; }': ()
307 143..164 '&query....value': &QueryResponse<R> 307 142..163 '&query....value': &QueryResponse<R>
308 144..158 'query_response': Canonical<QueryResponse<R>> 308 143..157 'query_response': Canonical<QueryResponse<R>>
309 144..164 'query_....value': QueryResponse<R> 309 143..163 'query_....value': QueryResponse<R>
310 "### 310 "###
311 ); 311 );
312} 312}
@@ -322,9 +322,9 @@ fn test() {
322"#), 322"#),
323 @r###" 323 @r###"
324 !0..4 '0u32': u32 324 !0..4 '0u32': u32
325 45..70 '{ ...()); }': () 325 44..69 '{ ...()); }': ()
326 55..56 'a': u32 326 54..55 'a': u32
327 "### 327 "###
328 ); 328 );
329} 329}
330 330
@@ -344,10 +344,10 @@ pub fn main_loop() {
344} 344}
345"#), 345"#),
346 @r###" 346 @r###"
347 144..146 '{}': () 347 143..145 '{}': ()
348 169..198 '{ ...t(); }': () 348 168..197 '{ ...t(); }': ()
349 175..193 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<{unknown}, FxHasher> 349 174..192 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<{unknown}, FxHasher>
350 175..195 'FxHash...ault()': HashSet<{unknown}, FxHasher> 350 174..194 'FxHash...ault()': HashSet<{unknown}, FxHasher>
351 "### 351 "###
352 ); 352 );
353} 353}
@@ -395,9 +395,9 @@ fn test() {
395} 395}
396"#), 396"#),
397 @r###" 397 @r###"
398 26..53 '{ ...oo() }': () 398 25..52 '{ ...oo() }': ()
399 32..49 '<Trait...>::foo': {unknown} 399 31..48 '<Trait...>::foo': {unknown}
400 32..51 '<Trait...:foo()': () 400 31..50 '<Trait...:foo()': ()
401 "### 401 "###
402 ); 402 );
403} 403}
@@ -495,13 +495,13 @@ fn foo(params: &[usize]) {
495} 495}
496"#), 496"#),
497 @r###" 497 @r###"
498 8..14 'params': &[usize] 498 7..13 'params': &[usize]
499 26..81 '{ ... } }': () 499 25..80 '{ ... } }': ()
500 32..79 'match ... }': () 500 31..78 'match ... }': ()
501 38..44 'params': &[usize] 501 37..43 'params': &[usize]
502 55..67 '[ps @ .., _]': [usize] 502 54..66 '[ps @ .., _]': [usize]
503 65..66 '_': usize 503 64..65 '_': usize
504 71..73 '{}': () 504 70..72 '{}': ()
505 "### 505 "###
506 ); 506 );
507} 507}
@@ -522,13 +522,13 @@ fn foo(b: Bar) {
522} 522}
523"#), 523"#),
524 @r###" 524 @r###"
525 36..37 'b': Bar 525 35..36 'b': Bar
526 44..96 '{ ... } }': () 526 43..95 '{ ... } }': ()
527 50..94 'match ... }': () 527 49..93 'match ... }': ()
528 56..57 'b': Bar 528 55..56 'b': Bar
529 68..81 'Bar { a: .. }': Bar 529 67..80 'Bar { a: .. }': Bar
530 77..79 '..': bool 530 76..78 '..': bool
531 85..87 '{}': () 531 84..86 '{}': ()
532 "### 532 "###
533 ); 533 );
534} 534}
@@ -549,16 +549,16 @@ fn main() {
549 a.foo(); 549 a.foo();
550} 550}
551"#), @r###" 551"#), @r###"
552 32..38 'FOO {}': FOO 552 31..37 'FOO {}': FOO
553 64..68 'self': &FOO 553 63..67 'self': &FOO
554 70..72 '{}': () 554 69..71 '{}': ()
555 86..120 '{ ...o(); }': () 555 85..119 '{ ...o(); }': ()
556 96..97 'a': &FOO 556 95..96 'a': &FOO
557 100..104 '&FOO': &FOO 557 99..103 '&FOO': &FOO
558 101..104 'FOO': FOO 558 100..103 'FOO': FOO
559 110..111 'a': &FOO 559 109..110 'a': &FOO
560 110..117 'a.foo()': () 560 109..116 'a.foo()': ()
561"### 561 "###
562 ); 562 );
563} 563}
564 564
@@ -580,17 +580,17 @@ fn main() {
580 let _a = foo!(); 580 let _a = foo!();
581} 581}
582"#), @r###" 582"#), @r###"
583 45..60 '{ loop {} }': T 583 44..59 '{ loop {} }': T
584 51..58 'loop {}': ! 584 50..57 'loop {}': !
585 56..58 '{}': () 585 55..57 '{}': ()
586 !0..31 '{letr:...g();r}': Foo 586 !0..31 '{letr:...g();r}': Foo
587 !4..5 'r': Foo 587 !4..5 'r': Foo
588 !18..26 'anything': fn anything<Foo>() -> Foo 588 !18..26 'anything': fn anything<Foo>() -> Foo
589 !18..28 'anything()': Foo 589 !18..28 'anything()': Foo
590 !29..30 'r': Foo 590 !29..30 'r': Foo
591 164..188 '{ ...!(); }': () 591 163..187 '{ ...!(); }': ()
592 174..176 '_a': Foo 592 173..175 '_a': Foo
593"###); 593 "###);
594} 594}
595 595
596#[test] 596#[test]
@@ -623,13 +623,164 @@ where
623} 623}
624"#), 624"#),
625 @r###" 625 @r###"
626 66..70 'self': Self 626 65..69 'self': Self
627 268..272 'self': Self 627 267..271 'self': Self
628 467..471 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}> 628 466..470 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
629 489..523 '{ ... }': () 629 488..522 '{ ... }': ()
630 499..503 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}> 630 498..502 'self': SelectStatement<F, S, D, W, O, LOf, {unknown}, {unknown}>
631 499..509 'self.order': O 631 498..508 'self.order': O
632 499..516 'self.o...into()': dyn QueryFragment<DB> 632 498..515 'self.o...into()': dyn QueryFragment<DB>
633 "###
634 );
635}
636
637#[test]
638fn issue_4953() {
639 assert_snapshot!(
640 infer(r#"
641pub struct Foo(pub i64);
642impl Foo {
643 fn test() -> Self { Self(0i64) }
644}
645"#),
646 @r###"
647 58..72 '{ Self(0i64) }': Foo
648 60..64 'Self': Foo(i64) -> Foo
649 60..70 'Self(0i64)': Foo
650 65..69 '0i64': i64
651 "###
652 );
653 assert_snapshot!(
654 infer(r#"
655pub struct Foo<T>(pub T);
656impl Foo<i64> {
657 fn test() -> Self { Self(0i64) }
658}
659"#),
660 @r###"
661 64..78 '{ Self(0i64) }': Foo<i64>
662 66..70 'Self': Foo<i64>(i64) -> Foo<i64>
663 66..76 'Self(0i64)': Foo<i64>
664 71..75 '0i64': i64
665 "###
666 );
667}
668
669#[test]
670fn issue_4931() {
671 assert_snapshot!(
672 infer(r#"
673trait Div<T> {
674 type Output;
675}
676
677trait CheckedDiv: Div<()> {}
678
679trait PrimInt: CheckedDiv<Output = ()> {
680 fn pow(self);
681}
682
683fn check<T: PrimInt>(i: T) {
684 i.pow();
685}
686"#),
687 @r###"
688 117..121 'self': Self
689 148..149 'i': T
690 154..170 '{ ...w(); }': ()
691 160..161 'i': T
692 160..167 'i.pow()': ()
693 "###
694 );
695}
696
697#[test]
698fn issue_4885() {
699 assert_snapshot!(
700 infer(r#"
701#[lang = "coerce_unsized"]
702pub trait CoerceUnsized<T> {}
703
704trait Future {
705 type Output;
706}
707trait Foo<R> {
708 type Bar;
709}
710fn foo<R, K>(key: &K) -> impl Future<Output = K::Bar>
711where
712 K: Foo<R>,
713{
714 bar(key)
715}
716fn bar<R, K>(key: &K) -> impl Future<Output = K::Bar>
717where
718 K: Foo<R>,
719{
720}
721"#),
722 @r###"
723 136..139 'key': &K
724 198..214 '{ ...key) }': impl Future<Output = <K as Foo<R>>::Bar>
725 204..207 'bar': fn bar<R, K>(&K) -> impl Future<Output = <K as Foo<R>>::Bar>
726 204..212 'bar(key)': impl Future<Output = <K as Foo<R>>::Bar>
727 208..211 'key': &K
728 228..231 'key': &K
729 290..293 '{ }': ()
730 "###
731 );
732}
733
734#[test]
735fn issue_4800() {
736 assert_snapshot!(
737 infer(r#"
738trait Debug {}
739
740struct Foo<T>;
741
742type E1<T> = (T, T, T);
743type E2<T> = E1<E1<E1<(T, T, T)>>>;
744
745impl Debug for Foo<E2<()>> {}
746
747struct Request;
748
749pub trait Future {
750 type Output;
751}
752
753pub struct PeerSet<D>;
754
755impl<D> Service<Request> for PeerSet<D>
756where
757 D: Discover,
758 D::Key: Debug,
759{
760 type Error = ();
761 type Future = dyn Future<Output = Self::Error>;
762
763 fn call(&mut self) -> Self::Future {
764 loop {}
765 }
766}
767
768pub trait Discover {
769 type Key;
770}
771
772pub trait Service<Request> {
773 type Error;
774 type Future: Future<Output = Self::Error>;
775 fn call(&mut self) -> Self::Future;
776}
777"#),
778 @r###"
779 379..383 'self': &mut PeerSet<D>
780 401..424 '{ ... }': dyn Future<Output = ()>
781 411..418 'loop {}': !
782 416..418 '{}': ()
783 575..579 'self': &mut Self
633 "### 784 "###
634 ); 785 );
635} 786}
diff --git a/crates/ra_hir_ty/src/tests/simple.rs b/crates/ra_hir_ty/src/tests/simple.rs
index 37659cd02..d7ef9add6 100644
--- a/crates/ra_hir_ty/src/tests/simple.rs
+++ b/crates/ra_hir_ty/src/tests/simple.rs
@@ -64,9 +64,9 @@ impl S<u32> {
64} 64}
65"#, 65"#,
66 ), @r###" 66 ), @r###"
67 63..93 '{ ... }': () 67 49..79 '{ ... }': ()
68 73..86 'Self { x: 1 }': S<u32> 68 59..72 'Self { x: 1 }': S<u32>
69 83..84 '1': u32 69 69..70 '1': u32
70 "###); 70 "###);
71} 71}
72 72
@@ -85,9 +85,9 @@ fn foo() {
85 85
86"#, 86"#,
87 ), @r###" 87 ), @r###"
88 64..84 '{ ...1 }; }': () 88 50..70 '{ ...1 }; }': ()
89 70..81 'SS { x: 1 }': S<u32> 89 56..67 'SS { x: 1 }': S<u32>
90 78..79 '1': u32 90 64..65 '1': u32
91 "###); 91 "###);
92} 92}
93 93
@@ -175,19 +175,19 @@ fn test(a: u32, b: isize, c: !, d: &str) {
175 1.0f32; 175 1.0f32;
176}"#), 176}"#),
177 @r###" 177 @r###"
178 9..10 'a': u32 178 8..9 'a': u32
179 17..18 'b': isize 179 16..17 'b': isize
180 27..28 'c': ! 180 26..27 'c': !
181 33..34 'd': &str 181 32..33 'd': &str
182 42..121 '{ ...f32; }': () 182 41..120 '{ ...f32; }': ()
183 48..49 'a': u32 183 47..48 'a': u32
184 55..56 'b': isize 184 54..55 'b': isize
185 62..63 'c': ! 185 61..62 'c': !
186 69..70 'd': &str 186 68..69 'd': &str
187 76..82 '1usize': usize 187 75..81 '1usize': usize
188 88..94 '1isize': isize 188 87..93 '1isize': isize
189 100..106 '"test"': &str 189 99..105 '"test"': &str
190 112..118 '1.0f32': f32 190 111..117 '1.0f32': f32
191 "### 191 "###
192 ); 192 );
193} 193}
@@ -206,17 +206,17 @@ fn test() {
206} 206}
207"#), 207"#),
208 @r###" 208 @r###"
209 11..118 '{ ...= e; }': () 209 10..117 '{ ...= e; }': ()
210 21..22 'a': isize 210 20..21 'a': isize
211 25..31 '1isize': isize 211 24..30 '1isize': isize
212 41..42 'b': usize 212 40..41 'b': usize
213 52..53 '1': usize 213 51..52 '1': usize
214 63..64 'c': usize 214 62..63 'c': usize
215 67..68 'b': usize 215 66..67 'b': usize
216 78..79 'd': u32 216 77..78 'd': u32
217 94..95 'e': i32 217 93..94 'e': i32
218 105..106 'f': i32 218 104..105 'f': i32
219 114..115 'e': i32 219 113..114 'e': i32
220 "### 220 "###
221 ); 221 );
222} 222}
@@ -237,15 +237,15 @@ fn test() {
237} 237}
238"#), 238"#),
239 @r###" 239 @r###"
240 15..20 '{ 1 }': u32 240 14..19 '{ 1 }': u32
241 17..18 '1': u32 241 16..17 '1': u32
242 48..53 '{ 1 }': u32 242 47..52 '{ 1 }': u32
243 50..51 '1': u32 243 49..50 '1': u32
244 67..91 '{ ...c(); }': () 244 66..90 '{ ...c(); }': ()
245 73..74 'a': fn a() -> u32 245 72..73 'a': fn a() -> u32
246 73..76 'a()': u32 246 72..75 'a()': u32
247 82..86 'b::c': fn c() -> u32 247 81..85 'b::c': fn c() -> u32
248 82..88 'b::c()': u32 248 81..87 'b::c()': u32
249 "### 249 "###
250 ); 250 );
251} 251}
@@ -266,13 +266,13 @@ fn test() {
266} 266}
267"#), 267"#),
268 @r###" 268 @r###"
269 41..46 '{ 1 }': i32 269 40..45 '{ 1 }': i32
270 43..44 '1': i32 270 42..43 '1': i32
271 60..93 '{ ...o(); }': () 271 59..92 '{ ...o(); }': ()
272 66..72 'S::foo': fn foo() -> i32 272 65..71 'S::foo': fn foo() -> i32
273 66..74 'S::foo()': i32 273 65..73 'S::foo()': i32
274 80..88 '<S>::foo': fn foo() -> i32 274 79..87 '<S>::foo': fn foo() -> i32
275 80..90 '<S>::foo()': i32 275 79..89 '<S>::foo()': i32
276 "### 276 "###
277 ); 277 );
278} 278}
@@ -297,22 +297,22 @@ fn test() {
297} 297}
298"#), 298"#),
299 @r###" 299 @r###"
300 72..154 '{ ...a.c; }': () 300 71..153 '{ ...a.c; }': ()
301 82..83 'c': C 301 81..82 'c': C
302 86..87 'C': C(usize) -> C 302 85..86 'C': C(usize) -> C
303 86..90 'C(1)': C 303 85..89 'C(1)': C
304 88..89 '1': usize 304 87..88 '1': usize
305 96..97 'B': B 305 95..96 'B': B
306 107..108 'a': A 306 106..107 'a': A
307 114..133 'A { b:...C(1) }': A 307 113..132 'A { b:...C(1) }': A
308 121..122 'B': B 308 120..121 'B': B
309 127..128 'C': C(usize) -> C 309 126..127 'C': C(usize) -> C
310 127..131 'C(1)': C 310 126..130 'C(1)': C
311 129..130 '1': usize 311 128..129 '1': usize
312 139..140 'a': A 312 138..139 'a': A
313 139..142 'a.b': B 313 138..141 'a.b': B
314 148..149 'a': A 314 147..148 'a': A
315 148..151 'a.c': C 315 147..150 'a.c': C
316 "### 316 "###
317 ); 317 );
318} 318}
@@ -330,10 +330,10 @@ fn test() {
330 E::V2; 330 E::V2;
331}"#), 331}"#),
332 @r###" 332 @r###"
333 48..82 '{ E:...:V2; }': () 333 47..81 '{ E:...:V2; }': ()
334 52..70 'E::V1 ...d: 1 }': E 334 51..69 'E::V1 ...d: 1 }': E
335 67..68 '1': u32 335 66..67 '1': u32
336 74..79 'E::V2': E 336 73..78 'E::V2': E
337 "### 337 "###
338 ); 338 );
339} 339}
@@ -357,29 +357,29 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) {
357} 357}
358"#), 358"#),
359 @r###" 359 @r###"
360 9..10 'a': &u32 360 8..9 'a': &u32
361 18..19 'b': &mut u32 361 17..18 'b': &mut u32
362 31..32 'c': *const u32 362 30..31 'c': *const u32
363 46..47 'd': *mut u32 363 45..46 'd': *mut u32
364 59..150 '{ ... *d; }': () 364 58..149 '{ ... *d; }': ()
365 65..66 'a': &u32 365 64..65 'a': &u32
366 72..74 '*a': u32 366 71..73 '*a': u32
367 73..74 'a': &u32 367 72..73 'a': &u32
368 80..82 '&a': &&u32 368 79..81 '&a': &&u32
369 81..82 'a': &u32 369 80..81 'a': &u32
370 88..94 '&mut a': &mut &u32 370 87..93 '&mut a': &mut &u32
371 93..94 'a': &u32 371 92..93 'a': &u32
372 100..101 'b': &mut u32 372 99..100 'b': &mut u32
373 107..109 '*b': u32 373 106..108 '*b': u32
374 108..109 'b': &mut u32 374 107..108 'b': &mut u32
375 115..117 '&b': &&mut u32 375 114..116 '&b': &&mut u32
376 116..117 'b': &mut u32 376 115..116 'b': &mut u32
377 123..124 'c': *const u32 377 122..123 'c': *const u32
378 130..132 '*c': u32 378 129..131 '*c': u32
379 131..132 'c': *const u32 379 130..131 'c': *const u32
380 138..139 'd': *mut u32 380 137..138 'd': *mut u32
381 145..147 '*d': u32 381 144..146 '*d': u32
382 146..147 'd': *mut u32 382 145..146 'd': *mut u32
383 "### 383 "###
384 ); 384 );
385} 385}
@@ -394,12 +394,12 @@ fn test(a: i32) {
394} 394}
395"#), 395"#),
396 @r###" 396 @r###"
397 9..10 'a': i32 397 8..9 'a': i32
398 17..54 '{ ...t a; }': () 398 16..53 '{ ...t a; }': ()
399 23..33 '&raw mut a': *mut i32 399 22..32 '&raw mut a': *mut i32
400 32..33 'a': i32 400 31..32 'a': i32
401 39..51 '&raw const a': *const i32 401 38..50 '&raw const a': *const i32
402 50..51 'a': i32 402 49..50 'a': i32
403 "### 403 "###
404 ); 404 );
405} 405}
@@ -429,20 +429,20 @@ fn test() {
429} 429}
430"##), 430"##),
431 @r###" 431 @r###"
432 11..221 '{ ...o"#; }': () 432 10..220 '{ ...o"#; }': ()
433 17..21 '5i32': i32 433 16..20 '5i32': i32
434 27..31 '5f32': f32 434 26..30 '5f32': f32
435 37..41 '5f64': f64 435 36..40 '5f64': f64
436 47..54 '"hello"': &str 436 46..53 '"hello"': &str
437 60..68 'b"bytes"': &[u8; _] 437 59..67 'b"bytes"': &[u8; _]
438 74..77 ''c'': char 438 73..76 ''c'': char
439 83..87 'b'b'': u8 439 82..86 'b'b'': u8
440 93..97 '3.14': f64 440 92..96 '3.14': f64
441 103..107 '5000': i32 441 102..106 '5000': i32
442 113..118 'false': bool 442 112..117 'false': bool
443 124..128 'true': bool 443 123..127 'true': bool
444 134..202 'r#" ... "#': &str 444 133..201 'r#" ... "#': &str
445 208..218 'br#"yolo"#': &[u8; _] 445 207..217 'br#"yolo"#': &[u8; _]
446 "### 446 "###
447 ); 447 );
448} 448}
@@ -472,47 +472,47 @@ fn test(x: SomeType) {
472} 472}
473"#), 473"#),
474 @r###" 474 @r###"
475 27..28 'x': SomeType 475 26..27 'x': SomeType
476 40..272 '{ ...lo"; }': () 476 39..271 '{ ...lo"; }': ()
477 50..51 'b': bool 477 49..50 'b': bool
478 54..59 'false': bool 478 53..58 'false': bool
479 69..70 'c': bool 479 68..69 'c': bool
480 73..75 '!b': bool 480 72..74 '!b': bool
481 74..75 'b': bool 481 73..74 'b': bool
482 85..86 'a': i128 482 84..85 'a': i128
483 89..92 '100': i128 483 88..91 '100': i128
484 102..103 'd': i128 484 101..102 'd': i128
485 112..114 '-a': i128 485 111..113 '-a': i128
486 113..114 'a': i128 486 112..113 'a': i128
487 124..125 'e': i32 487 123..124 'e': i32
488 128..132 '-100': i32 488 127..131 '-100': i32
489 129..132 '100': i32 489 128..131 '100': i32
490 142..143 'f': bool 490 141..142 'f': bool
491 146..153 '!!!true': bool 491 145..152 '!!!true': bool
492 147..153 '!!true': bool 492 146..152 '!!true': bool
493 148..153 '!true': bool 493 147..152 '!true': bool
494 149..153 'true': bool 494 148..152 'true': bool
495 163..164 'g': i32 495 162..163 'g': i32
496 167..170 '!42': i32 496 166..169 '!42': i32
497 168..170 '42': i32 497 167..169 '42': i32
498 180..181 'h': u32 498 179..180 'h': u32
499 184..190 '!10u32': u32 499 183..189 '!10u32': u32
500 185..190 '10u32': u32 500 184..189 '10u32': u32
501 200..201 'j': i128 501 199..200 'j': i128
502 204..206 '!a': i128 502 203..205 '!a': i128
503 205..206 'a': i128 503 204..205 'a': i128
504 212..217 '-3.14': f64 504 211..216 '-3.14': f64
505 213..217 '3.14': f64 505 212..216 '3.14': f64
506 223..225 '!3': i32 506 222..224 '!3': i32
507 224..225 '3': i32 507 223..224 '3': i32
508 231..233 '-x': {unknown} 508 230..232 '-x': {unknown}
509 232..233 'x': SomeType 509 231..232 'x': SomeType
510 239..241 '!x': {unknown} 510 238..240 '!x': {unknown}
511 240..241 'x': SomeType 511 239..240 'x': SomeType
512 247..255 '-"hello"': {unknown} 512 246..254 '-"hello"': {unknown}
513 248..255 '"hello"': &str 513 247..254 '"hello"': &str
514 261..269 '!"hello"': {unknown} 514 260..268 '!"hello"': {unknown}
515 262..269 '"hello"': &str 515 261..268 '"hello"': &str
516 "### 516 "###
517 ); 517 );
518} 518}
@@ -535,26 +535,26 @@ fn test() -> &mut &f64 {
535} 535}
536"#), 536"#),
537 @r###" 537 @r###"
538 14..15 'x': u32 538 13..14 'x': u32
539 22..24 '{}': () 539 21..23 '{}': ()
540 78..231 '{ ...t &c }': &mut &f64 540 77..230 '{ ...t &c }': &mut &f64
541 88..89 'a': u32 541 87..88 'a': u32
542 92..108 'unknow...nction': {unknown} 542 91..107 'unknow...nction': {unknown}
543 92..110 'unknow...tion()': u32 543 91..109 'unknow...tion()': u32
544 116..125 'takes_u32': fn takes_u32(u32) 544 115..124 'takes_u32': fn takes_u32(u32)
545 116..128 'takes_u32(a)': () 545 115..127 'takes_u32(a)': ()
546 126..127 'a': u32 546 125..126 'a': u32
547 138..139 'b': i32 547 137..138 'b': i32
548 142..158 'unknow...nction': {unknown} 548 141..157 'unknow...nction': {unknown}
549 142..160 'unknow...tion()': i32 549 141..159 'unknow...tion()': i32
550 166..184 'S { i3...d: b }': S 550 165..183 'S { i3...d: b }': S
551 181..182 'b': i32 551 180..181 'b': i32
552 194..195 'c': f64 552 193..194 'c': f64
553 198..214 'unknow...nction': {unknown} 553 197..213 'unknow...nction': {unknown}
554 198..216 'unknow...tion()': f64 554 197..215 'unknow...tion()': f64
555 222..229 '&mut &c': &mut &f64 555 221..228 '&mut &c': &mut &f64
556 227..229 '&c': &f64 556 226..228 '&c': &f64
557 228..229 'c': f64 557 227..228 'c': f64
558 "### 558 "###
559 ); 559 );
560} 560}
@@ -581,16 +581,16 @@ impl S {
581} 581}
582"#), 582"#),
583 @r###" 583 @r###"
584 34..38 'self': &S 584 33..37 'self': &S
585 40..61 '{ ... }': () 585 39..60 '{ ... }': ()
586 50..54 'self': &S 586 49..53 'self': &S
587 75..79 'self': &S 587 74..78 'self': &S
588 88..109 '{ ... }': () 588 87..108 '{ ... }': ()
589 98..102 'self': &S 589 97..101 'self': &S
590 133..153 '{ ... }': S 590 132..152 '{ ... }': S
591 143..147 'S {}': S 591 142..146 'S {}': S
592 177..200 '{ ... }': S 592 176..199 '{ ... }': S
593 187..194 'Self {}': S 593 186..193 'Self {}': S
594 "### 594 "###
595 ); 595 );
596} 596}
@@ -624,17 +624,17 @@ impl E {
624} 624}
625"#), 625"#),
626 @r###" 626 @r###"
627 87..108 '{ ... }': () 627 86..107 '{ ... }': ()
628 97..101 'Self': S1 628 96..100 'Self': S1
629 135..159 '{ ... }': () 629 134..158 '{ ... }': ()
630 145..149 'Self': S2(isize) -> S2 630 144..148 'Self': S2(isize) -> S2
631 145..152 'Self(1)': S2 631 144..151 'Self(1)': S2
632 150..151 '1': isize 632 149..150 '1': isize
633 185..231 '{ ... }': () 633 184..230 '{ ... }': ()
634 195..203 'Self::V1': E 634 194..202 'Self::V1': E
635 213..221 'Self::V2': V2(u32) -> E 635 212..220 'Self::V2': V2(u32) -> E
636 213..224 'Self::V2(1)': E 636 212..223 'Self::V2(1)': E
637 222..223 '1': u32 637 221..222 '1': u32
638 "### 638 "###
639 ); 639 );
640} 640}
@@ -664,56 +664,56 @@ fn test() -> bool {
664} 664}
665"#), 665"#),
666 @r###" 666 @r###"
667 6..7 'x': bool 667 5..6 'x': bool
668 22..34 '{ 0i32 }': i32 668 21..33 '{ 0i32 }': i32
669 28..32 '0i32': i32 669 27..31 '0i32': i32
670 54..370 '{ ... < 3 }': bool 670 53..369 '{ ... < 3 }': bool
671 64..65 'x': bool 671 63..64 'x': bool
672 68..69 'a': bool 672 67..68 'a': bool
673 68..74 'a && b': bool 673 67..73 'a && b': bool
674 73..74 'b': bool 674 72..73 'b': bool
675 84..85 'y': bool 675 83..84 'y': bool
676 88..92 'true': bool 676 87..91 'true': bool
677 88..101 'true || false': bool 677 87..100 'true || false': bool
678 96..101 'false': bool 678 95..100 'false': bool
679 111..112 'z': bool 679 110..111 'z': bool
680 115..116 'x': bool 680 114..115 'x': bool
681 115..121 'x == y': bool 681 114..120 'x == y': bool
682 120..121 'y': bool 682 119..120 'y': bool
683 131..132 't': bool 683 130..131 't': bool
684 135..136 'x': bool 684 134..135 'x': bool
685 135..141 'x != y': bool 685 134..140 'x != y': bool
686 140..141 'y': bool 686 139..140 'y': bool
687 151..162 'minus_forty': isize 687 150..161 'minus_forty': isize
688 172..180 '-40isize': isize 688 171..179 '-40isize': isize
689 173..180 '40isize': isize 689 172..179 '40isize': isize
690 190..191 'h': bool 690 189..190 'h': bool
691 194..205 'minus_forty': isize 691 193..204 'minus_forty': isize
692 194..216 'minus_...ONST_2': bool 692 193..215 'minus_...ONST_2': bool
693 209..216 'CONST_2': isize 693 208..215 'CONST_2': isize
694 226..227 'c': i32 694 225..226 'c': i32
695 230..231 'f': fn f(bool) -> i32 695 229..230 'f': fn f(bool) -> i32
696 230..239 'f(z || y)': i32 696 229..238 'f(z || y)': i32
697 230..243 'f(z || y) + 5': i32 697 229..242 'f(z || y) + 5': i32
698 232..233 'z': bool 698 231..232 'z': bool
699 232..238 'z || y': bool 699 231..237 'z || y': bool
700 237..238 'y': bool 700 236..237 'y': bool
701 242..243 '5': i32 701 241..242 '5': i32
702 253..254 'd': {unknown} 702 252..253 'd': {unknown}
703 257..258 'b': {unknown} 703 256..257 'b': {unknown}
704 268..269 'g': () 704 267..268 'g': ()
705 272..283 'minus_forty': isize 705 271..282 'minus_forty': isize
706 272..288 'minus_...y ^= i': () 706 271..287 'minus_...y ^= i': ()
707 287..288 'i': isize 707 286..287 'i': isize
708 298..301 'ten': usize 708 297..300 'ten': usize
709 311..313 '10': usize 709 310..312 '10': usize
710 323..336 'ten_is_eleven': bool 710 322..335 'ten_is_eleven': bool
711 339..342 'ten': usize 711 338..341 'ten': usize
712 339..354 'ten == some_num': bool 712 338..353 'ten == some_num': bool
713 346..354 'some_num': usize 713 345..353 'some_num': usize
714 361..364 'ten': usize 714 360..363 'ten': usize
715 361..368 'ten < 3': bool 715 360..367 'ten < 3': bool
716 367..368 '3': usize 716 366..367 '3': usize
717 "### 717 "###
718 ); 718 );
719} 719}
@@ -728,13 +728,13 @@ fn test() {
728} 728}
729"#), 729"#),
730 @r###" 730 @r###"
731 11..48 '{ ...5u8; }': () 731 10..47 '{ ...5u8; }': ()
732 17..21 '1u32': u32 732 16..20 '1u32': u32
733 17..28 '1u32 << 5u8': u32 733 16..27 '1u32 << 5u8': u32
734 25..28 '5u8': u8 734 24..27 '5u8': u8
735 34..38 '1u32': u32 735 33..37 '1u32': u32
736 34..45 '1u32 >> 5u8': u32 736 33..44 '1u32 >> 5u8': u32
737 42..45 '5u8': u8 737 41..44 '5u8': u8
738 "### 738 "###
739 ); 739 );
740} 740}
@@ -767,49 +767,49 @@ fn test2(a1: *const A, a2: *mut A) {
767} 767}
768"#), 768"#),
769 @r###" 769 @r###"
770 44..45 'a': A 770 43..44 'a': A
771 50..213 '{ ...5.b; }': () 771 49..212 '{ ...5.b; }': ()
772 60..62 'a1': A 772 59..61 'a1': A
773 65..66 'a': A 773 64..65 'a': A
774 72..74 'a1': A 774 71..73 'a1': A
775 72..76 'a1.b': B 775 71..75 'a1.b': B
776 86..88 'a2': &A 776 85..87 'a2': &A
777 91..93 '&a': &A 777 90..92 '&a': &A
778 92..93 'a': A 778 91..92 'a': A
779 99..101 'a2': &A 779 98..100 'a2': &A
780 99..103 'a2.b': B 780 98..102 'a2.b': B
781 113..115 'a3': &mut A 781 112..114 'a3': &mut A
782 118..124 '&mut a': &mut A 782 117..123 '&mut a': &mut A
783 123..124 'a': A 783 122..123 'a': A
784 130..132 'a3': &mut A 784 129..131 'a3': &mut A
785 130..134 'a3.b': B 785 129..133 'a3.b': B
786 144..146 'a4': &&&&&&&A 786 143..145 'a4': &&&&&&&A
787 149..157 '&&&&&&&a': &&&&&&&A 787 148..156 '&&&&&&&a': &&&&&&&A
788 150..157 '&&&&&&a': &&&&&&A 788 149..156 '&&&&&&a': &&&&&&A
789 151..157 '&&&&&a': &&&&&A 789 150..156 '&&&&&a': &&&&&A
790 152..157 '&&&&a': &&&&A 790 151..156 '&&&&a': &&&&A
791 153..157 '&&&a': &&&A 791 152..156 '&&&a': &&&A
792 154..157 '&&a': &&A 792 153..156 '&&a': &&A
793 155..157 '&a': &A 793 154..156 '&a': &A
794 156..157 'a': A 794 155..156 'a': A
795 163..165 'a4': &&&&&&&A 795 162..164 'a4': &&&&&&&A
796 163..167 'a4.b': B 796 162..166 'a4.b': B
797 177..179 'a5': &mut &&mut &&mut A 797 176..178 'a5': &mut &&mut &&mut A
798 182..200 '&mut &...&mut a': &mut &&mut &&mut A 798 181..199 '&mut &...&mut a': &mut &&mut &&mut A
799 187..200 '&&mut &&mut a': &&mut &&mut A 799 186..199 '&&mut &&mut a': &&mut &&mut A
800 188..200 '&mut &&mut a': &mut &&mut A 800 187..199 '&mut &&mut a': &mut &&mut A
801 193..200 '&&mut a': &&mut A 801 192..199 '&&mut a': &&mut A
802 194..200 '&mut a': &mut A 802 193..199 '&mut a': &mut A
803 199..200 'a': A 803 198..199 'a': A
804 206..208 'a5': &mut &&mut &&mut A 804 205..207 'a5': &mut &&mut &&mut A
805 206..210 'a5.b': B 805 205..209 'a5.b': B
806 224..226 'a1': *const A 806 223..225 'a1': *const A
807 238..240 'a2': *mut A 807 237..239 'a2': *mut A
808 250..273 '{ ...2.b; }': () 808 249..272 '{ ...2.b; }': ()
809 256..258 'a1': *const A 809 255..257 'a1': *const A
810 256..260 'a1.b': B 810 255..259 'a1.b': B
811 266..268 'a2': *mut A 811 265..267 'a2': *mut A
812 266..270 'a2.b': B 812 265..269 'a2.b': B
813 "### 813 "###
814 ); 814 );
815} 815}
@@ -846,30 +846,30 @@ fn test() {
846} 846}
847"#), 847"#),
848 @r###" 848 @r###"
849 68..72 'self': &Self 849 67..71 'self': &Self
850 139..143 'self': &A<T> 850 138..142 'self': &A<T>
851 151..174 '{ ... }': &T 851 150..173 '{ ... }': &T
852 161..168 '&self.0': &T 852 160..167 '&self.0': &T
853 162..166 'self': &A<T> 853 161..165 'self': &A<T>
854 162..168 'self.0': T 854 161..167 'self.0': T
855 255..259 'self': &B<T> 855 254..258 'self': &B<T>
856 278..301 '{ ... }': &T 856 277..300 '{ ... }': &T
857 288..295 '&self.0': &T 857 287..294 '&self.0': &T
858 289..293 'self': &B<T> 858 288..292 'self': &B<T>
859 289..295 'self.0': T 859 288..294 'self.0': T
860 315..353 '{ ...))); }': () 860 314..352 '{ ...))); }': ()
861 325..326 't': &i32 861 324..325 't': &i32
862 329..335 'A::foo': fn foo<i32>(&A<i32>) -> &i32 862 328..334 'A::foo': fn foo<i32>(&A<i32>) -> &i32
863 329..350 'A::foo...42))))': &i32 863 328..349 'A::foo...42))))': &i32
864 336..349 '&&B(B(A(42)))': &&B<B<A<i32>>> 864 335..348 '&&B(B(A(42)))': &&B<B<A<i32>>>
865 337..349 '&B(B(A(42)))': &B<B<A<i32>>> 865 336..348 '&B(B(A(42)))': &B<B<A<i32>>>
866 338..339 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>> 866 337..338 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>>
867 338..349 'B(B(A(42)))': B<B<A<i32>>> 867 337..348 'B(B(A(42)))': B<B<A<i32>>>
868 340..341 'B': B<A<i32>>(A<i32>) -> B<A<i32>> 868 339..340 'B': B<A<i32>>(A<i32>) -> B<A<i32>>
869 340..348 'B(A(42))': B<A<i32>> 869 339..347 'B(A(42))': B<A<i32>>
870 342..343 'A': A<i32>(i32) -> A<i32> 870 341..342 'A': A<i32>(i32) -> A<i32>
871 342..347 'A(42)': A<i32> 871 341..346 'A(42)': A<i32>
872 344..346 '42': i32 872 343..345 '42': i32
873 "### 873 "###
874 ); 874 );
875} 875}
@@ -906,34 +906,34 @@ fn test(a: A<i32>) {
906} 906}
907"#), 907"#),
908 @r###" 908 @r###"
909 68..72 'self': &Self 909 67..71 'self': &Self
910 144..148 'self': &A<T> 910 143..147 'self': &A<T>
911 150..151 'x': &A<T> 911 149..150 'x': &A<T>
912 166..187 '{ ... }': &T 912 165..186 '{ ... }': &T
913 176..181 '&*x.0': &T 913 175..180 '&*x.0': &T
914 177..181 '*x.0': T 914 176..180 '*x.0': T
915 178..179 'x': &A<T> 915 177..178 'x': &A<T>
916 178..181 'x.0': *mut T 916 177..180 'x.0': *mut T
917 268..272 'self': &B<T> 917 267..271 'self': &B<T>
918 291..314 '{ ... }': &T 918 290..313 '{ ... }': &T
919 301..308 '&self.0': &T 919 300..307 '&self.0': &T
920 302..306 'self': &B<T> 920 301..305 'self': &B<T>
921 302..308 'self.0': T 921 301..307 'self.0': T
922 326..327 'a': A<i32> 922 325..326 'a': A<i32>
923 337..383 '{ ...))); }': () 923 336..382 '{ ...))); }': ()
924 347..348 't': &i32 924 346..347 't': &i32
925 351..352 'A': A<i32>(*mut i32) -> A<i32> 925 350..351 'A': A<i32>(*mut i32) -> A<i32>
926 351..365 'A(0 as *mut _)': A<i32> 926 350..364 'A(0 as *mut _)': A<i32>
927 351..380 'A(0 as...B(a)))': &i32 927 350..379 'A(0 as...B(a)))': &i32
928 353..354 '0': i32 928 352..353 '0': i32
929 353..364 '0 as *mut _': *mut i32 929 352..363 '0 as *mut _': *mut i32
930 370..379 '&&B(B(a))': &&B<B<A<i32>>> 930 369..378 '&&B(B(a))': &&B<B<A<i32>>>
931 371..379 '&B(B(a))': &B<B<A<i32>>> 931 370..378 '&B(B(a))': &B<B<A<i32>>>
932 372..373 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>> 932 371..372 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>>
933 372..379 'B(B(a))': B<B<A<i32>>> 933 371..378 'B(B(a))': B<B<A<i32>>>
934 374..375 'B': B<A<i32>>(A<i32>) -> B<A<i32>> 934 373..374 'B': B<A<i32>>(A<i32>) -> B<A<i32>>
935 374..378 'B(a)': B<A<i32>> 935 373..377 'B(a)': B<A<i32>>
936 376..377 'a': A<i32> 936 375..376 'a': A<i32>
937 "### 937 "###
938 ); 938 );
939} 939}
@@ -952,16 +952,16 @@ fn main(foo: Foo) {
952} 952}
953"#), 953"#),
954 @r###" 954 @r###"
955 35..38 'foo': Foo 955 34..37 'foo': Foo
956 45..109 '{ ... } }': () 956 44..108 '{ ... } }': ()
957 51..107 'if tru... }': () 957 50..106 'if tru... }': ()
958 54..58 'true': bool 958 53..57 'true': bool
959 59..67 '{ }': () 959 58..66 '{ }': ()
960 73..107 'if fal... }': i32 960 72..106 'if fal... }': i32
961 76..81 'false': bool 961 75..80 'false': bool
962 82..107 '{ ... }': i32 962 81..106 '{ ... }': i32
963 92..95 'foo': Foo 963 91..94 'foo': Foo
964 92..101 'foo.field': i32 964 91..100 'foo.field': i32
965 "### 965 "###
966 ) 966 )
967} 967}
@@ -993,38 +993,38 @@ fn foo() {
993 }; 993 };
994}"#), 994}"#),
995 @r###" 995 @r###"
996 10..323 '{ ... }; }': () 996 9..322 '{ ... }; }': ()
997 20..23 '_x1': i32 997 19..22 '_x1': i32
998 26..80 'if tru... }': i32 998 25..79 'if tru... }': i32
999 29..33 'true': bool 999 28..32 'true': bool
1000 34..51 '{ ... }': i32 1000 33..50 '{ ... }': i32
1001 44..45 '1': i32 1001 43..44 '1': i32
1002 57..80 '{ ... }': i32 1002 56..79 '{ ... }': i32
1003 67..73 'return': ! 1003 66..72 'return': !
1004 90..93 '_x2': i32 1004 89..92 '_x2': i32
1005 96..149 'if tru... }': i32 1005 95..148 'if tru... }': i32
1006 99..103 'true': bool 1006 98..102 'true': bool
1007 104..121 '{ ... }': i32 1007 103..120 '{ ... }': i32
1008 114..115 '2': i32 1008 113..114 '2': i32
1009 127..149 '{ ... }': ! 1009 126..148 '{ ... }': !
1010 137..143 'return': ! 1010 136..142 'return': !
1011 159..162 '_x3': i32 1011 158..161 '_x3': i32
1012 165..247 'match ... }': i32 1012 164..246 'match ... }': i32
1013 171..175 'true': bool 1013 170..174 'true': bool
1014 186..190 'true': bool 1014 185..189 'true': bool
1015 186..190 'true': bool 1015 185..189 'true': bool
1016 194..195 '3': i32 1016 193..194 '3': i32
1017 205..206 '_': bool 1017 204..205 '_': bool
1018 210..241 '{ ... }': i32 1018 209..240 '{ ... }': i32
1019 224..230 'return': ! 1019 223..229 'return': !
1020 257..260 '_x4': i32 1020 256..259 '_x4': i32
1021 263..320 'match ... }': i32 1021 262..319 'match ... }': i32
1022 269..273 'true': bool 1022 268..272 'true': bool
1023 284..288 'true': bool 1023 283..287 'true': bool
1024 284..288 'true': bool 1024 283..287 'true': bool
1025 292..293 '4': i32 1025 291..292 '4': i32
1026 303..304 '_': bool 1026 302..303 '_': bool
1027 308..314 'return': ! 1027 307..313 'return': !
1028 "### 1028 "###
1029 ) 1029 )
1030} 1030}
@@ -1052,24 +1052,24 @@ fn test(a: A) {
1052} 1052}
1053"#), 1053"#),
1054 @r###" 1054 @r###"
1055 32..36 'self': A 1055 31..35 'self': A
1056 38..39 'x': u32 1056 37..38 'x': u32
1057 53..55 '{}': () 1057 52..54 '{}': ()
1058 103..107 'self': &A 1058 102..106 'self': &A
1059 109..110 'x': u64 1059 108..109 'x': u64
1060 124..126 '{}': () 1060 123..125 '{}': ()
1061 144..145 'a': A 1061 143..144 'a': A
1062 150..198 '{ ...(1); }': () 1062 149..197 '{ ...(1); }': ()
1063 156..157 'a': A 1063 155..156 'a': A
1064 156..164 'a.foo(1)': i32 1064 155..163 'a.foo(1)': i32
1065 162..163 '1': u32 1065 161..162 '1': u32
1066 170..181 '(&a).bar(1)': i64 1066 169..180 '(&a).bar(1)': i64
1067 171..173 '&a': &A 1067 170..172 '&a': &A
1068 172..173 'a': A 1068 171..172 'a': A
1069 179..180 '1': u64 1069 178..179 '1': u64
1070 187..188 'a': A 1070 186..187 'a': A
1071 187..195 'a.bar(1)': i64 1071 186..194 'a.bar(1)': i64
1072 193..194 '1': u64 1072 192..193 '1': u64
1073 "### 1073 "###
1074 ); 1074 );
1075} 1075}
@@ -1088,11 +1088,11 @@ fn test() {
1088} 1088}
1089"#), 1089"#),
1090 @r###" 1090 @r###"
1091 40..44 'self': &str 1091 39..43 'self': &str
1092 53..55 '{}': () 1092 52..54 '{}': ()
1093 69..89 '{ ...o(); }': () 1093 68..88 '{ ...o(); }': ()
1094 75..80 '"foo"': &str 1094 74..79 '"foo"': &str
1095 75..86 '"foo".foo()': i32 1095 74..85 '"foo".foo()': i32
1096 "### 1096 "###
1097 ); 1097 );
1098} 1098}
@@ -1111,33 +1111,33 @@ fn test(x: &str, y: isize) {
1111} 1111}
1112"#), 1112"#),
1113 @r###" 1113 @r###"
1114 9..10 'x': &str 1114 8..9 'x': &str
1115 18..19 'y': isize 1115 17..18 'y': isize
1116 28..170 '{ ...d"); }': () 1116 27..169 '{ ...d"); }': ()
1117 38..39 'a': (u32, &str) 1117 37..38 'a': (u32, &str)
1118 55..63 '(1, "a")': (u32, &str) 1118 54..62 '(1, "a")': (u32, &str)
1119 56..57 '1': u32 1119 55..56 '1': u32
1120 59..62 '"a"': &str 1120 58..61 '"a"': &str
1121 73..74 'b': ((u32, &str), &str) 1121 72..73 'b': ((u32, &str), &str)
1122 77..83 '(a, x)': ((u32, &str), &str) 1122 76..82 '(a, x)': ((u32, &str), &str)
1123 78..79 'a': (u32, &str) 1123 77..78 'a': (u32, &str)
1124 81..82 'x': &str 1124 80..81 'x': &str
1125 93..94 'c': (isize, &str) 1125 92..93 'c': (isize, &str)
1126 97..103 '(y, x)': (isize, &str) 1126 96..102 '(y, x)': (isize, &str)
1127 98..99 'y': isize 1127 97..98 'y': isize
1128 101..102 'x': &str 1128 100..101 'x': &str
1129 113..114 'd': ((isize, &str), &str) 1129 112..113 'd': ((isize, &str), &str)
1130 117..123 '(c, x)': ((isize, &str), &str) 1130 116..122 '(c, x)': ((isize, &str), &str)
1131 118..119 'c': (isize, &str) 1131 117..118 'c': (isize, &str)
1132 121..122 'x': &str 1132 120..121 'x': &str
1133 133..134 'e': (i32, &str) 1133 132..133 'e': (i32, &str)
1134 137..145 '(1, "e")': (i32, &str) 1134 136..144 '(1, "e")': (i32, &str)
1135 138..139 '1': i32 1135 137..138 '1': i32
1136 141..144 '"e"': &str 1136 140..143 '"e"': &str
1137 155..156 'f': ((i32, &str), &str) 1137 154..155 'f': ((i32, &str), &str)
1138 159..167 '(e, "d")': ((i32, &str), &str) 1138 158..166 '(e, "d")': ((i32, &str), &str)
1139 160..161 'e': (i32, &str) 1139 159..160 'e': (i32, &str)
1140 163..166 '"d"': &str 1140 162..165 '"d"': &str
1141 "### 1141 "###
1142 ); 1142 );
1143} 1143}
@@ -1165,58 +1165,58 @@ fn test(x: &str, y: isize) {
1165} 1165}
1166"#), 1166"#),
1167 @r###" 1167 @r###"
1168 9..10 'x': &str 1168 8..9 'x': &str
1169 18..19 'y': isize 1169 17..18 'y': isize
1170 28..293 '{ ... []; }': () 1170 27..292 '{ ... []; }': ()
1171 38..39 'a': [&str; _] 1171 37..38 'a': [&str; _]
1172 42..45 '[x]': [&str; _] 1172 41..44 '[x]': [&str; _]
1173 43..44 'x': &str 1173 42..43 'x': &str
1174 55..56 'b': [[&str; _]; _] 1174 54..55 'b': [[&str; _]; _]
1175 59..65 '[a, a]': [[&str; _]; _] 1175 58..64 '[a, a]': [[&str; _]; _]
1176 60..61 'a': [&str; _] 1176 59..60 'a': [&str; _]
1177 63..64 'a': [&str; _] 1177 62..63 'a': [&str; _]
1178 75..76 'c': [[[&str; _]; _]; _] 1178 74..75 'c': [[[&str; _]; _]; _]
1179 79..85 '[b, b]': [[[&str; _]; _]; _] 1179 78..84 '[b, b]': [[[&str; _]; _]; _]
1180 80..81 'b': [[&str; _]; _] 1180 79..80 'b': [[&str; _]; _]
1181 83..84 'b': [[&str; _]; _] 1181 82..83 'b': [[&str; _]; _]
1182 96..97 'd': [isize; _] 1182 95..96 'd': [isize; _]
1183 100..112 '[y, 1, 2, 3]': [isize; _] 1183 99..111 '[y, 1, 2, 3]': [isize; _]
1184 101..102 'y': isize 1184 100..101 'y': isize
1185 104..105 '1': isize 1185 103..104 '1': isize
1186 107..108 '2': isize 1186 106..107 '2': isize
1187 110..111 '3': isize 1187 109..110 '3': isize
1188 122..123 'd': [isize; _] 1188 121..122 'd': [isize; _]
1189 126..138 '[1, y, 2, 3]': [isize; _] 1189 125..137 '[1, y, 2, 3]': [isize; _]
1190 127..128 '1': isize 1190 126..127 '1': isize
1191 130..131 'y': isize 1191 129..130 'y': isize
1192 133..134 '2': isize 1192 132..133 '2': isize
1193 136..137 '3': isize 1193 135..136 '3': isize
1194 148..149 'e': [isize; _] 1194 147..148 'e': [isize; _]
1195 152..155 '[y]': [isize; _] 1195 151..154 '[y]': [isize; _]
1196 153..154 'y': isize 1196 152..153 'y': isize
1197 165..166 'f': [[isize; _]; _] 1197 164..165 'f': [[isize; _]; _]
1198 169..175 '[d, d]': [[isize; _]; _] 1198 168..174 '[d, d]': [[isize; _]; _]
1199 170..171 'd': [isize; _] 1199 169..170 'd': [isize; _]
1200 173..174 'd': [isize; _] 1200 172..173 'd': [isize; _]
1201 185..186 'g': [[isize; _]; _] 1201 184..185 'g': [[isize; _]; _]
1202 189..195 '[e, e]': [[isize; _]; _] 1202 188..194 '[e, e]': [[isize; _]; _]
1203 190..191 'e': [isize; _] 1203 189..190 'e': [isize; _]
1204 193..194 'e': [isize; _] 1204 192..193 'e': [isize; _]
1205 206..207 'h': [i32; _] 1205 205..206 'h': [i32; _]
1206 210..216 '[1, 2]': [i32; _] 1206 209..215 '[1, 2]': [i32; _]
1207 211..212 '1': i32 1207 210..211 '1': i32
1208 214..215 '2': i32 1208 213..214 '2': i32
1209 226..227 'i': [&str; _] 1209 225..226 'i': [&str; _]
1210 230..240 '["a", "b"]': [&str; _] 1210 229..239 '["a", "b"]': [&str; _]
1211 231..234 '"a"': &str 1211 230..233 '"a"': &str
1212 236..239 '"b"': &str 1212 235..238 '"b"': &str
1213 251..252 'b': [[&str; _]; _] 1213 250..251 'b': [[&str; _]; _]
1214 255..265 '[a, ["b"]]': [[&str; _]; _] 1214 254..264 '[a, ["b"]]': [[&str; _]; _]
1215 256..257 'a': [&str; _] 1215 255..256 'a': [&str; _]
1216 259..264 '["b"]': [&str; _] 1216 258..263 '["b"]': [&str; _]
1217 260..263 '"b"': &str 1217 259..262 '"b"': &str
1218 275..276 'x': [u8; _] 1218 274..275 'x': [u8; _]
1219 288..290 '[]': [u8; _] 1219 287..289 '[]': [u8; _]
1220 "### 1220 "###
1221 ); 1221 );
1222} 1222}
@@ -1238,21 +1238,21 @@ fn test(a1: A<u32>, i: i32) {
1238} 1238}
1239"#), 1239"#),
1240 @r###" 1240 @r###"
1241 36..38 'a1': A<u32> 1241 35..37 'a1': A<u32>
1242 48..49 'i': i32 1242 47..48 'i': i32
1243 56..147 '{ ...3.x; }': () 1243 55..146 '{ ...3.x; }': ()
1244 62..64 'a1': A<u32> 1244 61..63 'a1': A<u32>
1245 62..66 'a1.x': u32 1245 61..65 'a1.x': u32
1246 76..78 'a2': A<i32> 1246 75..77 'a2': A<i32>
1247 81..91 'A { x: i }': A<i32> 1247 80..90 'A { x: i }': A<i32>
1248 88..89 'i': i32 1248 87..88 'i': i32
1249 97..99 'a2': A<i32> 1249 96..98 'a2': A<i32>
1250 97..101 'a2.x': i32 1250 96..100 'a2.x': i32
1251 111..113 'a3': A<i128> 1251 110..112 'a3': A<i128>
1252 116..134 'A::<i1...x: 1 }': A<i128> 1252 115..133 'A::<i1...x: 1 }': A<i128>
1253 131..132 '1': i128 1253 130..131 '1': i128
1254 140..142 'a3': A<i128> 1254 139..141 'a3': A<i128>
1255 140..144 'a3.x': i128 1255 139..143 'a3.x': i128
1256 "### 1256 "###
1257 ); 1257 );
1258} 1258}
@@ -1275,22 +1275,22 @@ fn test() {
1275} 1275}
1276"#), 1276"#),
1277 @r###" 1277 @r###"
1278 76..184 '{ ...one; }': () 1278 75..183 '{ ...one; }': ()
1279 82..83 'A': A<i32>(i32) -> A<i32> 1279 81..82 'A': A<i32>(i32) -> A<i32>
1280 82..87 'A(42)': A<i32> 1280 81..86 'A(42)': A<i32>
1281 84..86 '42': i32 1281 83..85 '42': i32
1282 93..94 'A': A<u128>(u128) -> A<u128> 1282 92..93 'A': A<u128>(u128) -> A<u128>
1283 93..102 'A(42u128)': A<u128> 1283 92..101 'A(42u128)': A<u128>
1284 95..101 '42u128': u128 1284 94..100 '42u128': u128
1285 108..112 'Some': Some<&str>(&str) -> Option<&str> 1285 107..111 'Some': Some<&str>(&str) -> Option<&str>
1286 108..117 'Some("x")': Option<&str> 1286 107..116 'Some("x")': Option<&str>
1287 113..116 '"x"': &str 1287 112..115 '"x"': &str
1288 123..135 'Option::Some': Some<&str>(&str) -> Option<&str> 1288 122..134 'Option::Some': Some<&str>(&str) -> Option<&str>
1289 123..140 'Option...e("x")': Option<&str> 1289 122..139 'Option...e("x")': Option<&str>
1290 136..139 '"x"': &str 1290 135..138 '"x"': &str
1291 146..150 'None': Option<{unknown}> 1291 145..149 'None': Option<{unknown}>
1292 160..161 'x': Option<i64> 1292 159..160 'x': Option<i64>
1293 177..181 'None': Option<i64> 1293 176..180 'None': Option<i64>
1294 "### 1294 "###
1295 ); 1295 );
1296} 1296}
@@ -1308,20 +1308,20 @@ fn test() {
1308} 1308}
1309"#), 1309"#),
1310 @r###" 1310 @r###"
1311 10..11 't': T 1311 9..10 't': T
1312 21..26 '{ t }': T 1312 20..25 '{ t }': T
1313 23..24 't': T 1313 22..23 't': T
1314 38..98 '{ ...(1); }': () 1314 37..97 '{ ...(1); }': ()
1315 44..46 'id': fn id<u32>(u32) -> u32 1315 43..45 'id': fn id<u32>(u32) -> u32
1316 44..52 'id(1u32)': u32 1316 43..51 'id(1u32)': u32
1317 47..51 '1u32': u32 1317 46..50 '1u32': u32
1318 58..68 'id::<i128>': fn id<i128>(i128) -> i128 1318 57..67 'id::<i128>': fn id<i128>(i128) -> i128
1319 58..71 'id::<i128>(1)': i128 1319 57..70 'id::<i128>(1)': i128
1320 69..70 '1': i128 1320 68..69 '1': i128
1321 81..82 'x': u64 1321 80..81 'x': u64
1322 90..92 'id': fn id<u64>(u64) -> u64 1322 89..91 'id': fn id<u64>(u64) -> u64
1323 90..95 'id(1)': u64 1323 89..94 'id(1)': u64
1324 93..94 '1': u64 1324 92..93 '1': u64
1325 "### 1325 "###
1326 ); 1326 );
1327} 1327}
@@ -1355,38 +1355,38 @@ fn test() -> i128 {
1355} 1355}
1356"#), 1356"#),
1357 @r###" 1357 @r###"
1358 74..78 'self': A<X, Y> 1358 73..77 'self': A<X, Y>
1359 85..107 '{ ... }': X 1359 84..106 '{ ... }': X
1360 95..99 'self': A<X, Y> 1360 94..98 'self': A<X, Y>
1361 95..101 'self.x': X 1361 94..100 'self.x': X
1362 117..121 'self': A<X, Y> 1362 116..120 'self': A<X, Y>
1363 128..150 '{ ... }': Y 1363 127..149 '{ ... }': Y
1364 138..142 'self': A<X, Y> 1364 137..141 'self': A<X, Y>
1365 138..144 'self.y': Y 1365 137..143 'self.y': Y
1366 163..167 'self': A<X, Y> 1366 162..166 'self': A<X, Y>
1367 169..170 't': T 1367 168..169 't': T
1368 188..223 '{ ... }': (X, Y, T) 1368 187..222 '{ ... }': (X, Y, T)
1369 198..217 '(self.....y, t)': (X, Y, T) 1369 197..216 '(self.....y, t)': (X, Y, T)
1370 199..203 'self': A<X, Y> 1370 198..202 'self': A<X, Y>
1371 199..205 'self.x': X 1371 198..204 'self.x': X
1372 207..211 'self': A<X, Y> 1372 206..210 'self': A<X, Y>
1373 207..213 'self.y': Y 1373 206..212 'self.y': Y
1374 215..216 't': T 1374 214..215 't': T
1375 245..342 '{ ...(1); }': () 1375 244..341 '{ ...(1); }': ()
1376 255..256 'a': A<u64, i64> 1376 254..255 'a': A<u64, i64>
1377 259..281 'A { x:...1i64 }': A<u64, i64> 1377 258..280 'A { x:...1i64 }': A<u64, i64>
1378 266..270 '1u64': u64 1378 265..269 '1u64': u64
1379 275..279 '1i64': i64 1379 274..278 '1i64': i64
1380 287..288 'a': A<u64, i64> 1380 286..287 'a': A<u64, i64>
1381 287..292 'a.x()': u64 1381 286..291 'a.x()': u64
1382 298..299 'a': A<u64, i64> 1382 297..298 'a': A<u64, i64>
1383 298..303 'a.y()': i64 1383 297..302 'a.y()': i64
1384 309..310 'a': A<u64, i64> 1384 308..309 'a': A<u64, i64>
1385 309..319 'a.z(1i128)': (u64, i64, i128) 1385 308..318 'a.z(1i128)': (u64, i64, i128)
1386 313..318 '1i128': i128 1386 312..317 '1i128': i128
1387 325..326 'a': A<u64, i64> 1387 324..325 'a': A<u64, i64>
1388 325..339 'a.z::<u128>(1)': (u64, i64, u128) 1388 324..338 'a.z::<u128>(1)': (u64, i64, u128)
1389 337..338 '1': u128 1389 336..337 '1': u128
1390 "### 1390 "###
1391 ); 1391 );
1392} 1392}
@@ -1408,15 +1408,15 @@ fn test(o: Option<u32>) {
1408} 1408}
1409"#), 1409"#),
1410 @r###" 1410 @r###"
1411 78..82 'self': &Option<T> 1411 77..81 'self': &Option<T>
1412 98..100 '{}': () 1412 97..99 '{}': ()
1413 111..112 'o': Option<u32> 1413 110..111 'o': Option<u32>
1414 127..165 '{ ...f(); }': () 1414 126..164 '{ ...f(); }': ()
1415 133..146 '(&o).as_ref()': Option<&u32> 1415 132..145 '(&o).as_ref()': Option<&u32>
1416 134..136 '&o': &Option<u32> 1416 133..135 '&o': &Option<u32>
1417 135..136 'o': Option<u32> 1417 134..135 'o': Option<u32>
1418 152..153 'o': Option<u32> 1418 151..152 'o': Option<u32>
1419 152..162 'o.as_ref()': Option<&u32> 1419 151..161 'o.as_ref()': Option<&u32>
1420 "### 1420 "###
1421 ); 1421 );
1422} 1422}
@@ -1445,35 +1445,35 @@ fn test() -> i128 {
1445} 1445}
1446"#), 1446"#),
1447 @r###" 1447 @r###"
1448 53..57 'self': A<T2> 1448 52..56 'self': A<T2>
1449 65..87 '{ ... }': T2 1449 64..86 '{ ... }': T2
1450 75..79 'self': A<T2> 1450 74..78 'self': A<T2>
1451 75..81 'self.x': T2 1451 74..80 'self.x': T2
1452 99..100 't': T 1452 98..99 't': T
1453 110..115 '{ t }': T 1453 109..114 '{ t }': T
1454 112..113 't': T 1454 111..112 't': T
1455 135..261 '{ ....x() }': i128 1455 134..260 '{ ....x() }': i128
1456 146..147 'x': i128 1456 145..146 'x': i128
1457 150..151 '1': i128 1457 149..150 '1': i128
1458 162..163 'y': i128 1458 161..162 'y': i128
1459 166..168 'id': fn id<i128>(i128) -> i128 1459 165..167 'id': fn id<i128>(i128) -> i128
1460 166..171 'id(x)': i128 1460 165..170 'id(x)': i128
1461 169..170 'x': i128 1461 168..169 'x': i128
1462 182..183 'a': A<i128> 1462 181..182 'a': A<i128>
1463 186..200 'A { x: id(y) }': A<i128> 1463 185..199 'A { x: id(y) }': A<i128>
1464 193..195 'id': fn id<i128>(i128) -> i128 1464 192..194 'id': fn id<i128>(i128) -> i128
1465 193..198 'id(y)': i128 1465 192..197 'id(y)': i128
1466 196..197 'y': i128 1466 195..196 'y': i128
1467 211..212 'z': i128 1467 210..211 'z': i128
1468 215..217 'id': fn id<i128>(i128) -> i128 1468 214..216 'id': fn id<i128>(i128) -> i128
1469 215..222 'id(a.x)': i128 1469 214..221 'id(a.x)': i128
1470 218..219 'a': A<i128> 1470 217..218 'a': A<i128>
1471 218..221 'a.x': i128 1471 217..220 'a.x': i128
1472 233..234 'b': A<i128> 1472 232..233 'b': A<i128>
1473 237..247 'A { x: z }': A<i128> 1473 236..246 'A { x: z }': A<i128>
1474 244..245 'z': i128 1474 243..244 'z': i128
1475 254..255 'b': A<i128> 1475 253..254 'b': A<i128>
1476 254..259 'b.x()': i128 1476 253..258 'b.x()': i128
1477 "### 1477 "###
1478 ); 1478 );
1479} 1479}
@@ -1511,16 +1511,16 @@ fn test() {
1511} 1511}
1512"#), 1512"#),
1513 @r###" 1513 @r###"
1514 52..53 '1': u32 1514 51..52 '1': u32
1515 105..106 '2': u32 1515 104..105 '2': u32
1516 213..214 '5': u32 1516 212..213 '5': u32
1517 229..307 '{ ...:ID; }': () 1517 228..306 '{ ...:ID; }': ()
1518 239..240 'x': u32 1518 238..239 'x': u32
1519 243..254 'Struct::FOO': u32 1519 242..253 'Struct::FOO': u32
1520 264..265 'y': u32 1520 263..264 'y': u32
1521 268..277 'Enum::BAR': u32 1521 267..276 'Enum::BAR': u32
1522 287..288 'z': u32 1522 286..287 'z': u32
1523 291..304 'TraitTest::ID': u32 1523 290..303 'TraitTest::ID': u32
1524 "### 1524 "###
1525 ); 1525 );
1526} 1526}
@@ -1543,22 +1543,22 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) {
1543} 1543}
1544"#), 1544"#),
1545 @r###" 1545 @r###"
1546 116..117 'x': A<u32, i128> 1546 115..116 'x': A<u32, i128>
1547 124..125 'y': A<&str, u128> 1547 123..124 'y': A<&str, u128>
1548 138..139 'z': A<u8, i8> 1548 137..138 'z': A<u8, i8>
1549 154..211 '{ ...z.y; }': () 1549 153..210 '{ ...z.y; }': ()
1550 160..161 'x': A<u32, i128> 1550 159..160 'x': A<u32, i128>
1551 160..163 'x.x': u32 1551 159..162 'x.x': u32
1552 169..170 'x': A<u32, i128> 1552 168..169 'x': A<u32, i128>
1553 169..172 'x.y': i128 1553 168..171 'x.y': i128
1554 178..179 'y': A<&str, u128> 1554 177..178 'y': A<&str, u128>
1555 178..181 'y.x': &str 1555 177..180 'y.x': &str
1556 187..188 'y': A<&str, u128> 1556 186..187 'y': A<&str, u128>
1557 187..190 'y.y': u128 1557 186..189 'y.y': u128
1558 196..197 'z': A<u8, i8> 1558 195..196 'z': A<u8, i8>
1559 196..199 'z.x': u8 1559 195..198 'z.x': u8
1560 205..206 'z': A<u8, i8> 1560 204..205 'z': A<u8, i8>
1561 205..208 'z.y': i8 1561 204..207 'z.y': i8
1562 "### 1562 "###
1563 ) 1563 )
1564} 1564}
@@ -1573,8 +1573,8 @@ type Bar = A<Bar>;
1573fn test(x: Foo) {} 1573fn test(x: Foo) {}
1574"#), 1574"#),
1575 @r###" 1575 @r###"
1576 59..60 'x': {unknown} 1576 58..59 'x': {unknown}
1577 67..69 '{}': () 1577 66..68 '{}': ()
1578 "### 1578 "###
1579 ) 1579 )
1580} 1580}
@@ -1599,26 +1599,26 @@ fn test() {
1599} 1599}
1600"#), 1600"#),
1601 @r###" 1601 @r###"
1602 10..11 'x': T 1602 9..10 'x': T
1603 21..30 '{ x }': T 1603 20..29 '{ x }': T
1604 27..28 'x': T 1604 26..27 'x': T
1605 44..45 'x': &T 1605 43..44 'x': &T
1606 56..66 '{ *x }': T 1606 55..65 '{ *x }': T
1607 62..64 '*x': T 1607 61..63 '*x': T
1608 63..64 'x': &T 1608 62..63 'x': &T
1609 78..158 '{ ...(1); }': () 1609 77..157 '{ ...(1); }': ()
1610 88..89 'y': u32 1610 87..88 'y': u32
1611 92..97 '10u32': u32 1611 91..96 '10u32': u32
1612 103..105 'id': fn id<u32>(u32) -> u32 1612 102..104 'id': fn id<u32>(u32) -> u32
1613 103..108 'id(y)': u32 1613 102..107 'id(y)': u32
1614 106..107 'y': u32 1614 105..106 'y': u32
1615 118..119 'x': bool 1615 117..118 'x': bool
1616 128..133 'clone': fn clone<bool>(&bool) -> bool 1616 127..132 'clone': fn clone<bool>(&bool) -> bool
1617 128..136 'clone(z)': bool 1617 127..135 'clone(z)': bool
1618 134..135 'z': &bool 1618 133..134 'z': &bool
1619 142..152 'id::<i128>': fn id<i128>(i128) -> i128 1619 141..151 'id::<i128>': fn id<i128>(i128) -> i128
1620 142..155 'id::<i128>(1)': i128 1620 141..154 'id::<i128>(1)': i128
1621 153..154 '1': i128 1621 152..153 '1': i128
1622 "### 1622 "###
1623 ); 1623 );
1624} 1624}
@@ -1638,16 +1638,16 @@ fn test() {
1638} 1638}
1639"#), 1639"#),
1640 @r###" 1640 @r###"
1641 49..50 '0': u32 1641 48..49 '0': u32
1642 80..83 '101': u32 1642 79..82 '101': u32
1643 95..213 '{ ...NST; }': () 1643 94..212 '{ ...NST; }': ()
1644 138..139 'x': u32 1644 137..138 'x': u32
1645 142..153 'LOCAL_CONST': u32 1645 141..152 'LOCAL_CONST': u32
1646 163..164 'z': u32 1646 162..163 'z': u32
1647 167..179 'GLOBAL_CONST': u32 1647 166..178 'GLOBAL_CONST': u32
1648 189..191 'id': u32 1648 188..190 'id': u32
1649 194..210 'Foo::A..._CONST': u32 1649 193..209 'Foo::A..._CONST': u32
1650 126..128 '99': u32 1650 125..127 '99': u32
1651 "### 1651 "###
1652 ); 1652 );
1653} 1653}
@@ -1668,19 +1668,19 @@ fn test() {
1668} 1668}
1669"#), 1669"#),
1670 @r###" 1670 @r###"
1671 29..32 '101': u32 1671 28..31 '101': u32
1672 70..73 '101': u32 1672 69..72 '101': u32
1673 85..280 '{ ...MUT; }': () 1673 84..279 '{ ...MUT; }': ()
1674 173..174 'x': u32 1674 172..173 'x': u32
1675 177..189 'LOCAL_STATIC': u32 1675 176..188 'LOCAL_STATIC': u32
1676 199..200 'y': u32 1676 198..199 'y': u32
1677 203..219 'LOCAL_...IC_MUT': u32 1677 202..218 'LOCAL_...IC_MUT': u32
1678 229..230 'z': u32 1678 228..229 'z': u32
1679 233..246 'GLOBAL_STATIC': u32 1679 232..245 'GLOBAL_STATIC': u32
1680 256..257 'w': u32 1680 255..256 'w': u32
1681 260..277 'GLOBAL...IC_MUT': u32 1681 259..276 'GLOBAL...IC_MUT': u32
1682 118..120 '99': u32 1682 117..119 '99': u32
1683 161..163 '99': u32 1683 160..162 '99': u32
1684 "### 1684 "###
1685 ); 1685 );
1686} 1686}
@@ -1748,12 +1748,12 @@ fn foo() -> u32 {
1748} 1748}
1749"#), 1749"#),
1750 @r###" 1750 @r###"
1751 17..59 '{ ...; }; }': () 1751 16..58 '{ ...; }; }': ()
1752 27..28 'x': || -> usize 1752 26..27 'x': || -> usize
1753 31..56 '|| -> ...n 1; }': || -> usize 1753 30..55 '|| -> ...n 1; }': || -> usize
1754 43..56 '{ return 1; }': usize 1754 42..55 '{ return 1; }': usize
1755 45..53 'return 1': ! 1755 44..52 'return 1': !
1756 52..53 '1': usize 1756 51..52 '1': usize
1757 "### 1757 "###
1758 ); 1758 );
1759} 1759}
@@ -1767,11 +1767,11 @@ fn foo() -> u32 {
1767} 1767}
1768"#), 1768"#),
1769 @r###" 1769 @r###"
1770 17..48 '{ ...; }; }': () 1770 16..47 '{ ...; }; }': ()
1771 27..28 'x': || -> () 1771 26..27 'x': || -> ()
1772 31..45 '|| { return; }': || -> () 1772 30..44 '|| { return; }': || -> ()
1773 34..45 '{ return; }': () 1773 33..44 '{ return; }': ()
1774 36..42 'return': ! 1774 35..41 'return': !
1775 "### 1775 "###
1776 ); 1776 );
1777} 1777}
@@ -1785,11 +1785,11 @@ fn foo() -> u32 {
1785} 1785}
1786"#), 1786"#),
1787 @r###" 1787 @r###"
1788 17..47 '{ ..." }; }': () 1788 16..46 '{ ..." }; }': ()
1789 27..28 'x': || -> &str 1789 26..27 'x': || -> &str
1790 31..44 '|| { "test" }': || -> &str 1790 30..43 '|| { "test" }': || -> &str
1791 34..44 '{ "test" }': &str 1791 33..43 '{ "test" }': &str
1792 36..42 '"test"': &str 1792 35..41 '"test"': &str
1793 "### 1793 "###
1794 ); 1794 );
1795} 1795}
@@ -1808,14 +1808,14 @@ fn main() {
1808} 1808}
1809"#), 1809"#),
1810 @r###" 1810 @r###"
1811 48..121 '{ ...hod; }': () 1811 47..120 '{ ...hod; }': ()
1812 58..64 'vtable': Vtable 1812 57..63 'vtable': Vtable
1813 67..91 'Vtable...| {} }': Vtable 1813 66..90 'Vtable...| {} }': Vtable
1814 84..89 '|| {}': || -> () 1814 83..88 '|| {}': || -> ()
1815 87..89 '{}': () 1815 86..88 '{}': ()
1816 101..102 'm': fn() 1816 100..101 'm': fn()
1817 105..111 'vtable': Vtable 1817 104..110 'vtable': Vtable
1818 105..118 'vtable.method': fn() 1818 104..117 'vtable.method': fn()
1819 "### 1819 "###
1820 ); 1820 );
1821} 1821}
@@ -1832,22 +1832,22 @@ fn main() {
1832} 1832}
1833"#), 1833"#),
1834 @r###" 1834 @r###"
1835 11..131 '{ ...2 }; }': () 1835 10..130 '{ ...2 }; }': ()
1836 21..22 'x': i32 1836 20..21 'x': i32
1837 32..38 '{ 92 }': i32 1837 31..37 '{ 92 }': i32
1838 34..36 '92': i32 1838 33..35 '92': i32
1839 48..49 'y': {unknown} 1839 47..48 'y': {unknown}
1840 58..80 '{ asyn...wait }': {unknown} 1840 57..79 '{ asyn...wait }': {unknown}
1841 60..78 'async ....await': {unknown} 1841 59..77 'async ....await': {unknown}
1842 66..72 '{ () }': () 1842 65..71 '{ () }': ()
1843 68..70 '()': () 1843 67..69 '()': ()
1844 90..91 'z': {unknown} 1844 89..90 'z': {unknown}
1845 94..104 'try { () }': {unknown} 1845 93..103 'try { () }': {unknown}
1846 98..104 '{ () }': () 1846 97..103 '{ () }': ()
1847 100..102 '()': () 1847 99..101 '()': ()
1848 114..115 't': i32 1848 113..114 't': i32
1849 122..128 '{ 92 }': i32 1849 121..127 '{ 92 }': i32
1850 124..126 '92': i32 1850 123..125 '92': i32
1851 "### 1851 "###
1852 ) 1852 )
1853} 1853}
@@ -1867,16 +1867,16 @@ fn test() {
1867} 1867}
1868"#), 1868"#),
1869 @r###" 1869 @r###"
1870 60..130 '{ ... } }': () 1870 59..129 '{ ... } }': ()
1871 70..77 'mut end': Option<bool> 1871 69..76 'mut end': Option<bool>
1872 80..84 'None': Option<bool> 1872 79..83 'None': Option<bool>
1873 90..128 'loop {... }': ! 1873 89..127 'loop {... }': !
1874 95..128 '{ ... }': () 1874 94..127 '{ ... }': ()
1875 105..108 'end': Option<bool> 1875 104..107 'end': Option<bool>
1876 105..121 'end = ...(true)': () 1876 104..120 'end = ...(true)': ()
1877 111..115 'Some': Some<bool>(bool) -> Option<bool> 1877 110..114 'Some': Some<bool>(bool) -> Option<bool>
1878 111..121 'Some(true)': Option<bool> 1878 110..120 'Some(true)': Option<bool>
1879 116..120 'true': bool 1879 115..119 'true': bool
1880 "### 1880 "###
1881 ); 1881 );
1882} 1882}
@@ -1899,19 +1899,19 @@ fn test() {
1899} 1899}
1900"#), 1900"#),
1901 @r###" 1901 @r###"
1902 60..169 '{ ... }; }': () 1902 59..168 '{ ... }; }': ()
1903 70..71 'x': Option<bool> 1903 69..70 'x': Option<bool>
1904 74..166 'loop {... }': Option<bool> 1904 73..165 'loop {... }': Option<bool>
1905 79..166 '{ ... }': () 1905 78..165 '{ ... }': ()
1906 89..133 'if fal... }': () 1906 88..132 'if fal... }': ()
1907 92..97 'false': bool 1907 91..96 'false': bool
1908 98..133 '{ ... }': () 1908 97..132 '{ ... }': ()
1909 112..122 'break None': ! 1909 111..121 'break None': !
1910 118..122 'None': Option<bool> 1910 117..121 'None': Option<bool>
1911 143..159 'break ...(true)': ! 1911 142..158 'break ...(true)': !
1912 149..153 'Some': Some<bool>(bool) -> Option<bool> 1912 148..152 'Some': Some<bool>(bool) -> Option<bool>
1913 149..159 'Some(true)': Option<bool> 1913 148..158 'Some(true)': Option<bool>
1914 154..158 'true': bool 1914 153..157 'true': bool
1915 "### 1915 "###
1916 ); 1916 );
1917} 1917}
@@ -1932,14 +1932,14 @@ fn test() {
1932} 1932}
1933"#), 1933"#),
1934 @r###" 1934 @r###"
1935 60..137 '{ ... }; }': () 1935 59..136 '{ ... }; }': ()
1936 70..71 'x': () 1936 69..70 'x': ()
1937 74..134 'loop {... }': () 1937 73..133 'loop {... }': ()
1938 79..134 '{ ... }': () 1938 78..133 '{ ... }': ()
1939 89..128 'if fal... }': () 1939 88..127 'if fal... }': ()
1940 92..97 'false': bool 1940 91..96 'false': bool
1941 98..128 '{ ... }': () 1941 97..127 '{ ... }': ()
1942 112..117 'break': ! 1942 111..116 'break': !
1943 "### 1943 "###
1944 ); 1944 );
1945} 1945}
@@ -1964,36 +1964,36 @@ fn foo() {
1964} 1964}
1965"#), 1965"#),
1966 @r###" 1966 @r###"
1967 10..336 '{ ... }; }': () 1967 9..335 '{ ... }; }': ()
1968 20..22 '_x': || -> bool 1968 19..21 '_x': || -> bool
1969 25..333 '|| 'ou... }': || -> bool 1969 24..332 '|| 'ou... }': || -> bool
1970 28..333 ''outer... }': bool 1970 27..332 ''outer... }': bool
1971 41..333 '{ ... }': () 1971 40..332 '{ ... }': ()
1972 55..60 'inner': i8 1972 54..59 'inner': i8
1973 63..301 ''inner... }': i8 1973 62..300 ''inner... }': i8
1974 76..301 '{ ... }': () 1974 75..300 '{ ... }': ()
1975 94..95 'i': bool 1975 93..94 'i': bool
1976 98..114 'Defaul...efault': {unknown} 1976 97..113 'Defaul...efault': {unknown}
1977 98..116 'Defaul...ault()': bool 1977 97..115 'Defaul...ault()': bool
1978 130..270 'if (br... }': () 1978 129..269 'if (br... }': ()
1979 134..148 'break 'outer i': ! 1979 133..147 'break 'outer i': !
1980 147..148 'i': bool 1980 146..147 'i': bool
1981 150..209 '{ ... }': () 1981 149..208 '{ ... }': ()
1982 168..194 'loop {...5i8; }': ! 1982 167..193 'loop {...5i8; }': !
1983 173..194 '{ brea...5i8; }': () 1983 172..193 '{ brea...5i8; }': ()
1984 175..191 'break ...er 5i8': ! 1984 174..190 'break ...er 5i8': !
1985 188..191 '5i8': i8 1985 187..190 '5i8': i8
1986 215..270 'if tru... }': () 1986 214..269 'if tru... }': ()
1987 218..222 'true': bool 1987 217..221 'true': bool
1988 223..270 '{ ... }': () 1988 222..269 '{ ... }': ()
1989 241..255 'break 'inner 6': ! 1989 240..254 'break 'inner 6': !
1990 254..255 '6': i8 1990 253..254 '6': i8
1991 283..290 'break 7': ! 1991 282..289 'break 7': !
1992 289..290 '7': i8 1992 288..289 '7': i8
1993 311..326 'break inner < 8': ! 1993 310..325 'break inner < 8': !
1994 317..322 'inner': i8 1994 316..321 'inner': i8
1995 317..326 'inner < 8': bool 1995 316..325 'inner < 8': bool
1996 325..326 '8': i8 1996 324..325 '8': i8
1997 "### 1997 "###
1998 ); 1998 );
1999} 1999}
@@ -2022,35 +2022,35 @@ fn test(t1: Thing, t2: OtherThing, t3: Thing<i32>, t4: OtherThing<i32>) {
2022} 2022}
2023"#), 2023"#),
2024 @r###" 2024 @r###"
2025 98..100 't1': Thing<()> 2025 97..99 't1': Thing<()>
2026 109..111 't2': OtherThing<()> 2026 108..110 't2': OtherThing<()>
2027 125..127 't3': Thing<i32> 2027 124..126 't3': Thing<i32>
2028 141..143 't4': OtherThing<i32> 2028 140..142 't4': OtherThing<i32>
2029 162..385 '{ ... } }': () 2029 161..384 '{ ... } }': ()
2030 168..170 't1': Thing<()> 2030 167..169 't1': Thing<()>
2031 168..172 't1.t': () 2031 167..171 't1.t': ()
2032 178..180 't3': Thing<i32> 2032 177..179 't3': Thing<i32>
2033 178..182 't3.t': i32 2033 177..181 't3.t': i32
2034 188..283 'match ... }': () 2034 187..282 'match ... }': ()
2035 194..196 't2': OtherThing<()> 2035 193..195 't2': OtherThing<()>
2036 207..228 'OtherT... { t }': OtherThing<()> 2036 206..227 'OtherT... { t }': OtherThing<()>
2037 225..226 't': () 2037 224..225 't': ()
2038 232..238 '{ t; }': () 2038 231..237 '{ t; }': ()
2039 234..235 't': () 2039 233..234 't': ()
2040 248..266 'OtherT...Two(t)': OtherThing<()> 2040 247..265 'OtherT...Two(t)': OtherThing<()>
2041 264..265 't': () 2041 263..264 't': ()
2042 270..276 '{ t; }': () 2042 269..275 '{ t; }': ()
2043 272..273 't': () 2043 271..272 't': ()
2044 288..383 'match ... }': () 2044 287..382 'match ... }': ()
2045 294..296 't4': OtherThing<i32> 2045 293..295 't4': OtherThing<i32>
2046 307..328 'OtherT... { t }': OtherThing<i32> 2046 306..327 'OtherT... { t }': OtherThing<i32>
2047 325..326 't': i32 2047 324..325 't': i32
2048 332..338 '{ t; }': () 2048 331..337 '{ t; }': ()
2049 334..335 't': i32 2049 333..334 't': i32
2050 348..366 'OtherT...Two(t)': OtherThing<i32> 2050 347..365 'OtherT...Two(t)': OtherThing<i32>
2051 364..365 't': i32 2051 363..364 't': i32
2052 370..376 '{ t; }': () 2052 369..375 '{ t; }': ()
2053 372..373 't': i32 2053 371..372 't': i32
2054 "### 2054 "###
2055 ); 2055 );
2056} 2056}
@@ -2078,30 +2078,30 @@ fn test() {
2078} 2078}
2079"#), 2079"#),
2080 @r###" 2080 @r###"
2081 100..320 '{ ...32); }': () 2081 99..319 '{ ...32); }': ()
2082 110..111 'x': Thing<!> 2082 109..110 'x': Thing<!>
2083 114..134 'Thing ...p {} }': Thing<!> 2083 113..133 'Thing ...p {} }': Thing<!>
2084 125..132 'loop {}': ! 2084 124..131 'loop {}': !
2085 130..132 '{}': () 2085 129..131 '{}': ()
2086 144..145 'y': Thing<()> 2086 143..144 'y': Thing<()>
2087 148..163 'Thing { t: () }': Thing<()> 2087 147..162 'Thing { t: () }': Thing<()>
2088 159..161 '()': () 2088 158..160 '()': ()
2089 173..174 'z': Thing<i32> 2089 172..173 'z': Thing<i32>
2090 177..194 'Thing ...1i32 }': Thing<i32> 2090 176..193 'Thing ...1i32 }': Thing<i32>
2091 188..192 '1i32': i32 2091 187..191 '1i32': i32
2092 200..241 'if let... }': () 2092 199..240 'if let... }': ()
2093 207..218 'Thing { t }': Thing<i32> 2093 206..217 'Thing { t }': Thing<i32>
2094 215..216 't': i32 2094 214..215 't': i32
2095 221..222 'z': Thing<i32> 2095 220..221 'z': Thing<i32>
2096 223..241 '{ ... }': () 2096 222..240 '{ ... }': ()
2097 233..234 't': i32 2097 232..233 't': i32
2098 251..252 'a': OtherThing<i32> 2098 250..251 'a': OtherThing<i32>
2099 255..282 'OtherT...1i32 }': OtherThing<i32> 2099 254..281 'OtherT...1i32 }': OtherThing<i32>
2100 276..280 '1i32': i32 2100 275..279 '1i32': i32
2101 292..293 'b': OtherThing<i32> 2101 291..292 'b': OtherThing<i32>
2102 296..311 'OtherThing::Two': Two<i32>(i32) -> OtherThing<i32> 2102 295..310 'OtherThing::Two': Two<i32>(i32) -> OtherThing<i32>
2103 296..317 'OtherT...(1i32)': OtherThing<i32> 2103 295..316 'OtherT...(1i32)': OtherThing<i32>
2104 312..316 '1i32': i32 2104 311..315 '1i32': i32
2105 "### 2105 "###
2106 ); 2106 );
2107} 2107}
diff --git a/crates/ra_hir_ty/src/tests/traits.rs b/crates/ra_hir_ty/src/tests/traits.rs
index e81193a3c..646e1715c 100644
--- a/crates/ra_hir_ty/src/tests/traits.rs
+++ b/crates/ra_hir_ty/src/tests/traits.rs
@@ -259,16 +259,16 @@ fn test() {
259} 259}
260"#), 260"#),
261 @r###" 261 @r###"
262 86..87 't': T 262 85..86 't': T
263 92..94 '{}': () 263 91..93 '{}': ()
264 105..144 '{ ...(s); }': () 264 104..143 '{ ...(s); }': ()
265 115..116 's': S<u32> 265 114..115 's': S<u32>
266 119..120 'S': S<u32>(u32) -> S<u32> 266 118..119 'S': S<u32>(u32) -> S<u32>
267 119..129 'S(unknown)': S<u32> 267 118..128 'S(unknown)': S<u32>
268 121..128 'unknown': u32 268 120..127 'unknown': u32
269 135..138 'foo': fn foo<S<u32>>(S<u32>) 269 134..137 'foo': fn foo<S<u32>>(S<u32>)
270 135..141 'foo(s)': () 270 134..140 'foo(s)': ()
271 139..140 's': S<u32> 271 138..139 's': S<u32>
272 "### 272 "###
273 ); 273 );
274} 274}
@@ -287,17 +287,17 @@ fn test() {
287} 287}
288"#), 288"#),
289 @r###" 289 @r###"
290 87..88 't': T 290 86..87 't': T
291 98..100 '{}': () 291 97..99 '{}': ()
292 111..163 '{ ...(s); }': () 292 110..162 '{ ...(s); }': ()
293 121..122 's': S<u32> 293 120..121 's': S<u32>
294 125..126 'S': S<u32>(u32) -> S<u32> 294 124..125 'S': S<u32>(u32) -> S<u32>
295 125..135 'S(unknown)': S<u32> 295 124..134 'S(unknown)': S<u32>
296 127..134 'unknown': u32 296 126..133 'unknown': u32
297 145..146 'x': u32 297 144..145 'x': u32
298 154..157 'foo': fn foo<u32, S<u32>>(S<u32>) -> u32 298 153..156 'foo': fn foo<u32, S<u32>>(S<u32>) -> u32
299 154..160 'foo(s)': u32 299 153..159 'foo(s)': u32
300 158..159 's': S<u32> 300 157..158 's': S<u32>
301 "### 301 "###
302 ); 302 );
303} 303}
@@ -315,12 +315,12 @@ trait Trait {
315} 315}
316"#), 316"#),
317 @r###" 317 @r###"
318 27..31 'self': &Self 318 26..30 'self': &Self
319 53..57 'self': &Self 319 52..56 'self': &Self
320 62..97 '{ ... }': () 320 61..96 '{ ... }': ()
321 76..77 'x': i64 321 75..76 'x': i64
322 80..84 'self': &Self 322 79..83 'self': &Self
323 80..90 'self.foo()': i64 323 79..89 'self.foo()': i64
324 "### 324 "###
325 ); 325 );
326} 326}
@@ -339,12 +339,12 @@ trait Trait: SuperTrait {
339} 339}
340"#), 340"#),
341 @r###" 341 @r###"
342 32..36 'self': &Self 342 31..35 'self': &Self
343 86..90 'self': &Self 343 85..89 'self': &Self
344 95..130 '{ ... }': () 344 94..129 '{ ... }': ()
345 109..110 'x': i64 345 108..109 'x': i64
346 113..117 'self': &Self 346 112..116 'self': &Self
347 113..123 'self.foo()': i64 347 112..122 'self.foo()': i64
348 "### 348 "###
349 ); 349 );
350} 350}
@@ -366,15 +366,15 @@ fn test<T: Iterable>() {
366} 366}
367"#), 367"#),
368 @r###" 368 @r###"
369 108..261 '{ ...ter; }': () 369 107..260 '{ ...ter; }': ()
370 118..119 'x': u32 370 117..118 'x': u32
371 145..146 '1': u32 371 144..145 '1': u32
372 156..157 'y': Iterable::Item<T> 372 155..156 'y': Iterable::Item<T>
373 183..192 'no_matter': Iterable::Item<T> 373 182..191 'no_matter': Iterable::Item<T>
374 202..203 'z': Iterable::Item<T> 374 201..202 'z': Iterable::Item<T>
375 215..224 'no_matter': Iterable::Item<T> 375 214..223 'no_matter': Iterable::Item<T>
376 234..235 'a': Iterable::Item<T> 376 233..234 'a': Iterable::Item<T>
377 249..258 'no_matter': Iterable::Item<T> 377 248..257 'no_matter': Iterable::Item<T>
378 "### 378 "###
379 ); 379 );
380} 380}
@@ -398,25 +398,25 @@ fn test() {
398} 398}
399"#), 399"#),
400 @r###" 400 @r###"
401 106..107 't': T 401 105..106 't': T
402 123..125 '{}': () 402 122..124 '{}': ()
403 147..148 't': T 403 146..147 't': T
404 178..180 '{}': () 404 177..179 '{}': ()
405 202..203 't': T 405 201..202 't': T
406 221..223 '{}': () 406 220..222 '{}': ()
407 234..300 '{ ...(S); }': () 407 233..299 '{ ...(S); }': ()
408 244..245 'x': u32 408 243..244 'x': u32
409 248..252 'foo1': fn foo1<S>(S) -> <S as Iterable>::Item 409 247..251 'foo1': fn foo1<S>(S) -> <S as Iterable>::Item
410 248..255 'foo1(S)': u32 410 247..254 'foo1(S)': u32
411 253..254 'S': S 411 252..253 'S': S
412 265..266 'y': u32 412 264..265 'y': u32
413 269..273 'foo2': fn foo2<S>(S) -> <S as Iterable>::Item 413 268..272 'foo2': fn foo2<S>(S) -> <S as Iterable>::Item
414 269..276 'foo2(S)': u32 414 268..275 'foo2(S)': u32
415 274..275 'S': S 415 273..274 'S': S
416 286..287 'z': u32 416 285..286 'z': u32
417 290..294 'foo3': fn foo3<S>(S) -> <S as Iterable>::Item 417 289..293 'foo3': fn foo3<S>(S) -> <S as Iterable>::Item
418 290..297 'foo3(S)': u32 418 289..296 'foo3(S)': u32
419 295..296 'S': S 419 294..295 'S': S
420 "### 420 "###
421 ); 421 );
422} 422}
@@ -433,9 +433,9 @@ fn test<T: Iterable<Item=u32>>() {
433} 433}
434"#), 434"#),
435 @r###" 435 @r###"
436 67..100 '{ ...own; }': () 436 66..99 '{ ...own; }': ()
437 77..78 'y': u32 437 76..77 'y': u32
438 90..97 'unknown': u32 438 89..96 'unknown': u32
439 "### 439 "###
440 ); 440 );
441} 441}
@@ -448,13 +448,13 @@ const A: u32 = 1 + 1;
448static B: u64 = { let x = 1; x }; 448static B: u64 = { let x = 1; x };
449"#), 449"#),
450 @r###" 450 @r###"
451 16..17 '1': u32 451 15..16 '1': u32
452 16..21 '1 + 1': u32 452 15..20 '1 + 1': u32
453 20..21 '1': u32 453 19..20 '1': u32
454 39..55 '{ let ...1; x }': u64 454 38..54 '{ let ...1; x }': u64
455 45..46 'x': u64 455 44..45 'x': u64
456 49..50 '1': u64 456 48..49 '1': u64
457 52..53 'x': u64 457 51..52 'x': u64
458 "### 458 "###
459 ); 459 );
460} 460}
@@ -471,17 +471,17 @@ fn test() -> u64 {
471} 471}
472"#), 472"#),
473 @r###" 473 @r###"
474 38..87 '{ ... a.1 }': u64 474 37..86 '{ ... a.1 }': u64
475 48..49 'a': S 475 47..48 'a': S
476 52..53 'S': S(i32, u64) -> S 476 51..52 'S': S(i32, u64) -> S
477 52..59 'S(4, 6)': S 477 51..58 'S(4, 6)': S
478 54..55 '4': i32 478 53..54 '4': i32
479 57..58 '6': u64 479 56..57 '6': u64
480 69..70 'b': i32 480 68..69 'b': i32
481 73..74 'a': S 481 72..73 'a': S
482 73..76 'a.0': i32 482 72..75 'a.0': i32
483 82..83 'a': S 483 81..82 'a': S
484 82..85 'a.1': u64 484 81..84 'a.1': u64
485 "### 485 "###
486 ); 486 );
487} 487}
@@ -498,24 +498,24 @@ fn test() -> u64 {
498} 498}
499"#), 499"#),
500 @r###" 500 @r###"
501 44..102 '{ ...0(2) }': u64 501 43..101 '{ ...0(2) }': u64
502 54..55 'a': S 502 53..54 'a': S
503 58..59 'S': S(fn(u32) -> u64) -> S 503 57..58 'S': S(fn(u32) -> u64) -> S
504 58..68 'S(|i| 2*i)': S 504 57..67 'S(|i| 2*i)': S
505 60..67 '|i| 2*i': |u32| -> u64 505 59..66 '|i| 2*i': |u32| -> u64
506 61..62 'i': u32 506 60..61 'i': u32
507 64..65 '2': u32 507 63..64 '2': u32
508 64..67 '2*i': u32 508 63..66 '2*i': u32
509 66..67 'i': u32 509 65..66 'i': u32
510 78..79 'b': u64 510 77..78 'b': u64
511 82..83 'a': S 511 81..82 'a': S
512 82..85 'a.0': fn(u32) -> u64 512 81..84 'a.0': fn(u32) -> u64
513 82..88 'a.0(4)': u64 513 81..87 'a.0(4)': u64
514 86..87 '4': u32 514 85..86 '4': u32
515 94..95 'a': S 515 93..94 'a': S
516 94..97 'a.0': fn(u32) -> u64 516 93..96 'a.0': fn(u32) -> u64
517 94..100 'a.0(2)': u64 517 93..99 'a.0(2)': u64
518 98..99 '2': u32 518 97..98 '2': u32
519 "### 519 "###
520 ); 520 );
521} 521}
@@ -946,34 +946,34 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u32>) {
946} 946}
947"#, true), 947"#, true),
948 @r###" 948 @r###"
949 30..34 'self': &Self 949 29..33 'self': &Self
950 55..59 'self': &Self 950 54..58 'self': &Self
951 78..79 'x': impl Trait<u16> 951 77..78 'x': impl Trait<u16>
952 98..100 '{}': () 952 97..99 '{}': ()
953 155..156 'x': impl Trait<u64> 953 154..155 'x': impl Trait<u64>
954 175..176 'y': &impl Trait<u32> 954 174..175 'y': &impl Trait<u32>
955 196..324 '{ ...2(); }': () 955 195..323 '{ ...2(); }': ()
956 202..203 'x': impl Trait<u64> 956 201..202 'x': impl Trait<u64>
957 209..210 'y': &impl Trait<u32> 957 208..209 'y': &impl Trait<u32>
958 220..221 'z': S<u16> 958 219..220 'z': S<u16>
959 224..225 'S': S<u16>(u16) -> S<u16> 959 223..224 'S': S<u16>(u16) -> S<u16>
960 224..228 'S(1)': S<u16> 960 223..227 'S(1)': S<u16>
961 226..227 '1': u16 961 225..226 '1': u16
962 234..237 'bar': fn bar(S<u16>) 962 233..236 'bar': fn bar(S<u16>)
963 234..240 'bar(z)': () 963 233..239 'bar(z)': ()
964 238..239 'z': S<u16> 964 237..238 'z': S<u16>
965 246..247 'x': impl Trait<u64> 965 245..246 'x': impl Trait<u64>
966 246..253 'x.foo()': u64 966 245..252 'x.foo()': u64
967 259..260 'y': &impl Trait<u32> 967 258..259 'y': &impl Trait<u32>
968 259..266 'y.foo()': u32 968 258..265 'y.foo()': u32
969 272..273 'z': S<u16> 969 271..272 'z': S<u16>
970 272..279 'z.foo()': u16 970 271..278 'z.foo()': u16
971 285..286 'x': impl Trait<u64> 971 284..285 'x': impl Trait<u64>
972 285..293 'x.foo2()': i64 972 284..292 'x.foo2()': i64
973 299..300 'y': &impl Trait<u32> 973 298..299 'y': &impl Trait<u32>
974 299..307 'y.foo2()': i64 974 298..306 'y.foo2()': i64
975 313..314 'z': S<u16> 975 312..313 'z': S<u16>
976 313..321 'z.foo2()': i64 976 312..320 'z.foo2()': i64
977 "### 977 "###
978 ); 978 );
979} 979}
@@ -1007,39 +1007,39 @@ fn test() {
1007} 1007}
1008"#, true), 1008"#, true),
1009 @r###" 1009 @r###"
1010 156..157 'x': impl Trait 1010 155..156 'x': impl Trait
1011 176..187 '{ loop {} }': T 1011 175..186 '{ loop {} }': T
1012 178..185 'loop {}': ! 1012 177..184 'loop {}': !
1013 183..185 '{}': () 1013 182..184 '{}': ()
1014 200..201 'x': impl Trait 1014 199..200 'x': impl Trait
1015 220..231 '{ loop {} }': T 1015 219..230 '{ loop {} }': T
1016 222..229 'loop {}': ! 1016 221..228 'loop {}': !
1017 227..229 '{}': () 1017 226..228 '{}': ()
1018 301..510 '{ ... i32 }': () 1018 300..509 '{ ... i32 }': ()
1019 307..315 'Foo::bar': fn bar<{unknown}, {unknown}>(S) -> {unknown} 1019 306..314 'Foo::bar': fn bar<{unknown}, {unknown}>(S) -> {unknown}
1020 307..318 'Foo::bar(S)': {unknown} 1020 306..317 'Foo::bar(S)': {unknown}
1021 316..317 'S': S 1021 315..316 'S': S
1022 324..339 '<F as Foo>::bar': fn bar<F, {unknown}>(S) -> {unknown} 1022 323..338 '<F as Foo>::bar': fn bar<F, {unknown}>(S) -> {unknown}
1023 324..342 '<F as ...bar(S)': {unknown} 1023 323..341 '<F as ...bar(S)': {unknown}
1024 340..341 'S': S 1024 339..340 'S': S
1025 348..354 'F::bar': fn bar<F, {unknown}>(S) -> {unknown} 1025 347..353 'F::bar': fn bar<F, {unknown}>(S) -> {unknown}
1026 348..357 'F::bar(S)': {unknown} 1026 347..356 'F::bar(S)': {unknown}
1027 355..356 'S': S 1027 354..355 'S': S
1028 363..378 'Foo::bar::<u32>': fn bar<{unknown}, u32>(S) -> u32 1028 362..377 'Foo::bar::<u32>': fn bar<{unknown}, u32>(S) -> u32
1029 363..381 'Foo::b...32>(S)': u32 1029 362..380 'Foo::b...32>(S)': u32
1030 379..380 'S': S 1030 378..379 'S': S
1031 387..409 '<F as ...:<u32>': fn bar<F, u32>(S) -> u32 1031 386..408 '<F as ...:<u32>': fn bar<F, u32>(S) -> u32
1032 387..412 '<F as ...32>(S)': u32 1032 386..411 '<F as ...32>(S)': u32
1033 410..411 'S': S 1033 409..410 'S': S
1034 419..422 'foo': fn foo<{unknown}>(S) -> {unknown} 1034 418..421 'foo': fn foo<{unknown}>(S) -> {unknown}
1035 419..425 'foo(S)': {unknown} 1035 418..424 'foo(S)': {unknown}
1036 423..424 'S': S 1036 422..423 'S': S
1037 431..441 'foo::<u32>': fn foo<u32>(S) -> u32 1037 430..440 'foo::<u32>': fn foo<u32>(S) -> u32
1038 431..444 'foo::<u32>(S)': u32 1038 430..443 'foo::<u32>(S)': u32
1039 442..443 'S': S 1039 441..442 'S': S
1040 450..465 'foo::<u32, i32>': fn foo<u32>(S) -> u32 1040 449..464 'foo::<u32, i32>': fn foo<u32>(S) -> u32
1041 450..468 'foo::<...32>(S)': u32 1041 449..467 'foo::<...32>(S)': u32
1042 466..467 'S': S 1042 465..466 'S': S
1043 "### 1043 "###
1044 ); 1044 );
1045} 1045}
@@ -1064,24 +1064,24 @@ fn test() {
1064} 1064}
1065"#, true), 1065"#, true),
1066 @r###" 1066 @r###"
1067 88..92 'self': F<T> 1067 87..91 'self': F<T>
1068 94..95 'x': impl Trait 1068 93..94 'x': impl Trait
1069 119..130 '{ loop {} }': (T, U) 1069 118..129 '{ loop {} }': (T, U)
1070 121..128 'loop {}': ! 1070 120..127 'loop {}': !
1071 126..128 '{}': () 1071 125..127 '{}': ()
1072 144..284 '{ ...ored }': () 1072 143..283 '{ ...ored }': ()
1073 150..151 'F': F<{unknown}> 1073 149..150 'F': F<{unknown}>
1074 150..158 'F.foo(S)': ({unknown}, {unknown}) 1074 149..157 'F.foo(S)': ({unknown}, {unknown})
1075 156..157 'S': S 1075 155..156 'S': S
1076 164..172 'F::<u32>': F<u32> 1076 163..171 'F::<u32>': F<u32>
1077 164..179 'F::<u32>.foo(S)': (u32, {unknown}) 1077 163..178 'F::<u32>.foo(S)': (u32, {unknown})
1078 177..178 'S': S 1078 176..177 'S': S
1079 185..193 'F::<u32>': F<u32> 1079 184..192 'F::<u32>': F<u32>
1080 185..207 'F::<u3...32>(S)': (u32, i32) 1080 184..206 'F::<u3...32>(S)': (u32, i32)
1081 205..206 'S': S 1081 204..205 'S': S
1082 213..221 'F::<u32>': F<u32> 1082 212..220 'F::<u32>': F<u32>
1083 213..240 'F::<u3...32>(S)': (u32, i32) 1083 212..239 'F::<u3...32>(S)': (u32, i32)
1084 238..239 'S': S 1084 237..238 'S': S
1085 "### 1085 "###
1086 ); 1086 );
1087} 1087}
@@ -1100,13 +1100,13 @@ fn test() {
1100} 1100}
1101"#, true), 1101"#, true),
1102 @r###" 1102 @r###"
1103 23..24 'x': impl Trait 1103 22..23 'x': impl Trait
1104 38..49 '{ loop {} }': () 1104 37..48 '{ loop {} }': ()
1105 40..47 'loop {}': ! 1105 39..46 'loop {}': !
1106 45..47 '{}': () 1106 44..46 '{}': ()
1107 91..124 '{ ...foo; }': () 1107 90..123 '{ ...foo; }': ()
1108 101..102 'f': fn(S) 1108 100..101 'f': fn(S)
1109 118..121 'foo': fn foo(S) 1109 117..120 'foo': fn foo(S)
1110 "### 1110 "###
1111 ); 1111 );
1112} 1112}
@@ -1134,29 +1134,29 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u64>) {
1134} 1134}
1135"#), 1135"#),
1136 @r###" 1136 @r###"
1137 30..34 'self': &Self 1137 29..33 'self': &Self
1138 55..59 'self': &Self 1138 54..58 'self': &Self
1139 99..101 '{}': () 1139 98..100 '{}': ()
1140 111..112 'x': impl Trait<u64> 1140 110..111 'x': impl Trait<u64>
1141 131..132 'y': &impl Trait<u64> 1141 130..131 'y': &impl Trait<u64>
1142 152..269 '{ ...2(); }': () 1142 151..268 '{ ...2(); }': ()
1143 158..159 'x': impl Trait<u64> 1143 157..158 'x': impl Trait<u64>
1144 165..166 'y': &impl Trait<u64> 1144 164..165 'y': &impl Trait<u64>
1145 176..177 'z': impl Trait<u64> 1145 175..176 'z': impl Trait<u64>
1146 180..183 'bar': fn bar() -> impl Trait<u64> 1146 179..182 'bar': fn bar() -> impl Trait<u64>
1147 180..185 'bar()': impl Trait<u64> 1147 179..184 'bar()': impl Trait<u64>
1148 191..192 'x': impl Trait<u64> 1148 190..191 'x': impl Trait<u64>
1149 191..198 'x.foo()': u64 1149 190..197 'x.foo()': u64
1150 204..205 'y': &impl Trait<u64> 1150 203..204 'y': &impl Trait<u64>
1151 204..211 'y.foo()': u64 1151 203..210 'y.foo()': u64
1152 217..218 'z': impl Trait<u64> 1152 216..217 'z': impl Trait<u64>
1153 217..224 'z.foo()': u64 1153 216..223 'z.foo()': u64
1154 230..231 'x': impl Trait<u64> 1154 229..230 'x': impl Trait<u64>
1155 230..238 'x.foo2()': i64 1155 229..237 'x.foo2()': i64
1156 244..245 'y': &impl Trait<u64> 1156 243..244 'y': &impl Trait<u64>
1157 244..252 'y.foo2()': i64 1157 243..251 'y.foo2()': i64
1158 258..259 'z': impl Trait<u64> 1158 257..258 'z': impl Trait<u64>
1159 258..266 'z.foo2()': i64 1159 257..265 'z.foo2()': i64
1160 "### 1160 "###
1161 ); 1161 );
1162} 1162}
@@ -1177,16 +1177,16 @@ fn test() {
1177} 1177}
1178"#), 1178"#),
1179 @r###" 1179 @r###"
1180 30..34 'self': &Self 1180 29..33 'self': &Self
1181 72..83 '{ loop {} }': ! 1181 71..82 '{ loop {} }': !
1182 74..81 'loop {}': ! 1182 73..80 'loop {}': !
1183 79..81 '{}': () 1183 78..80 '{}': ()
1184 95..130 '{ ...o(); }': () 1184 94..129 '{ ...o(); }': ()
1185 105..106 'a': impl Trait<u64> 1185 104..105 'a': impl Trait<u64>
1186 109..112 'bar': fn bar() -> impl Trait<u64> 1186 108..111 'bar': fn bar() -> impl Trait<u64>
1187 109..114 'bar()': impl Trait<u64> 1187 108..113 'bar()': impl Trait<u64>
1188 120..121 'a': impl Trait<u64> 1188 119..120 'a': impl Trait<u64>
1189 120..127 'a.foo()': u64 1189 119..126 'a.foo()': u64
1190 "### 1190 "###
1191 ); 1191 );
1192} 1192}
@@ -1215,37 +1215,37 @@ fn test() {
1215} 1215}
1216"#), 1216"#),
1217 @r###" 1217 @r###"
1218 50..54 'self': &mut Self 1218 49..53 'self': &mut Self
1219 102..106 'self': &Self 1219 101..105 'self': &Self
1220 185..196 '{ loop {} }': ({unknown}, {unknown}) 1220 184..195 '{ loop {} }': ({unknown}, {unknown})
1221 187..194 'loop {}': ! 1221 186..193 'loop {}': !
1222 192..194 '{}': () 1222 191..193 '{}': ()
1223 207..208 't': T 1223 206..207 't': T
1224 269..280 '{ loop {} }': ({unknown}, {unknown}) 1224 268..279 '{ loop {} }': ({unknown}, {unknown})
1225 271..278 'loop {}': ! 1225 270..277 'loop {}': !
1226 276..278 '{}': () 1226 275..277 '{}': ()
1227 292..414 '{ ...o(); }': () 1227 291..413 '{ ...o(); }': ()
1228 302..308 '(a, b)': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) 1228 301..307 '(a, b)': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1229 303..304 'a': impl Iterator<Item = impl Trait<u32>> 1229 302..303 'a': impl Iterator<Item = impl Trait<u32>>
1230 306..307 'b': impl Trait<u64> 1230 305..306 'b': impl Trait<u64>
1231 311..314 'bar': fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) 1231 310..313 'bar': fn bar() -> (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1232 311..316 'bar()': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>) 1232 310..315 'bar()': (impl Iterator<Item = impl Trait<u32>>, impl Trait<u64>)
1233 322..323 'a': impl Iterator<Item = impl Trait<u32>> 1233 321..322 'a': impl Iterator<Item = impl Trait<u32>>
1234 322..330 'a.next()': impl Trait<u32> 1234 321..329 'a.next()': impl Trait<u32>
1235 322..336 'a.next().foo()': u32 1235 321..335 'a.next().foo()': u32
1236 342..343 'b': impl Trait<u64> 1236 341..342 'b': impl Trait<u64>
1237 342..349 'b.foo()': u64 1237 341..348 'b.foo()': u64
1238 359..365 '(c, d)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 1238 358..364 '(c, d)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1239 360..361 'c': impl Iterator<Item = impl Trait<u128>> 1239 359..360 'c': impl Iterator<Item = impl Trait<u128>>
1240 363..364 'd': impl Trait<u128> 1240 362..363 'd': impl Trait<u128>
1241 368..371 'baz': fn baz<u128>(u128) -> (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 1241 367..370 'baz': fn baz<u128>(u128) -> (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1242 368..378 'baz(1u128)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>) 1242 367..377 'baz(1u128)': (impl Iterator<Item = impl Trait<u128>>, impl Trait<u128>)
1243 372..377 '1u128': u128 1243 371..376 '1u128': u128
1244 384..385 'c': impl Iterator<Item = impl Trait<u128>> 1244 383..384 'c': impl Iterator<Item = impl Trait<u128>>
1245 384..392 'c.next()': impl Trait<u128> 1245 383..391 'c.next()': impl Trait<u128>
1246 384..398 'c.next().foo()': u128 1246 383..397 'c.next().foo()': u128
1247 404..405 'd': impl Trait<u128> 1247 403..404 'd': impl Trait<u128>
1248 404..411 'd.foo()': u128 1248 403..410 'd.foo()': u128
1249 "### 1249 "###
1250 ); 1250 );
1251} 1251}
@@ -1273,29 +1273,29 @@ fn test(x: dyn Trait<u64>, y: &dyn Trait<u64>) {
1273} 1273}
1274"#), 1274"#),
1275 @r###" 1275 @r###"
1276 30..34 'self': &Self 1276 29..33 'self': &Self
1277 55..59 'self': &Self 1277 54..58 'self': &Self
1278 98..100 '{}': () 1278 97..99 '{}': ()
1279 110..111 'x': dyn Trait<u64> 1279 109..110 'x': dyn Trait<u64>
1280 129..130 'y': &dyn Trait<u64> 1280 128..129 'y': &dyn Trait<u64>
1281 149..266 '{ ...2(); }': () 1281 148..265 '{ ...2(); }': ()
1282 155..156 'x': dyn Trait<u64> 1282 154..155 'x': dyn Trait<u64>
1283 162..163 'y': &dyn Trait<u64> 1283 161..162 'y': &dyn Trait<u64>
1284 173..174 'z': dyn Trait<u64> 1284 172..173 'z': dyn Trait<u64>
1285 177..180 'bar': fn bar() -> dyn Trait<u64> 1285 176..179 'bar': fn bar() -> dyn Trait<u64>
1286 177..182 'bar()': dyn Trait<u64> 1286 176..181 'bar()': dyn Trait<u64>
1287 188..189 'x': dyn Trait<u64> 1287 187..188 'x': dyn Trait<u64>
1288 188..195 'x.foo()': u64 1288 187..194 'x.foo()': u64
1289 201..202 'y': &dyn Trait<u64> 1289 200..201 'y': &dyn Trait<u64>
1290 201..208 'y.foo()': u64 1290 200..207 'y.foo()': u64
1291 214..215 'z': dyn Trait<u64> 1291 213..214 'z': dyn Trait<u64>
1292 214..221 'z.foo()': u64 1292 213..220 'z.foo()': u64
1293 227..228 'x': dyn Trait<u64> 1293 226..227 'x': dyn Trait<u64>
1294 227..235 'x.foo2()': i64 1294 226..234 'x.foo2()': i64
1295 241..242 'y': &dyn Trait<u64> 1295 240..241 'y': &dyn Trait<u64>
1296 241..249 'y.foo2()': i64 1296 240..248 'y.foo2()': i64
1297 255..256 'z': dyn Trait<u64> 1297 254..255 'z': dyn Trait<u64>
1298 255..263 'z.foo2()': i64 1298 254..262 'z.foo2()': i64
1299 "### 1299 "###
1300 ); 1300 );
1301} 1301}
@@ -1321,17 +1321,17 @@ fn test(s: S<u32, i32>) {
1321} 1321}
1322"#), 1322"#),
1323 @r###" 1323 @r###"
1324 33..37 'self': &Self 1324 32..36 'self': &Self
1325 103..107 'self': &S<T, U> 1325 102..106 'self': &S<T, U>
1326 129..140 '{ loop {} }': &dyn Trait<T, U> 1326 128..139 '{ loop {} }': &dyn Trait<T, U>
1327 131..138 'loop {}': ! 1327 130..137 'loop {}': !
1328 136..138 '{}': () 1328 135..137 '{}': ()
1329 176..180 'self': &Self 1329 175..179 'self': &Self
1330 252..253 's': S<u32, i32> 1330 251..252 's': S<u32, i32>
1331 268..290 '{ ...z(); }': () 1331 267..289 '{ ...z(); }': ()
1332 274..275 's': S<u32, i32> 1332 273..274 's': S<u32, i32>
1333 274..281 's.bar()': &dyn Trait<u32, i32> 1333 273..280 's.bar()': &dyn Trait<u32, i32>
1334 274..287 's.bar().baz()': (u32, i32) 1334 273..286 's.bar().baz()': (u32, i32)
1335 "### 1335 "###
1336 ); 1336 );
1337} 1337}
@@ -1355,22 +1355,22 @@ fn test(x: Trait, y: &Trait) -> u64 {
1355} 1355}
1356"#), 1356"#),
1357 @r###" 1357 @r###"
1358 27..31 'self': &Self 1358 26..30 'self': &Self
1359 61..63 '{}': () 1359 60..62 '{}': ()
1360 73..74 'x': dyn Trait 1360 72..73 'x': dyn Trait
1361 83..84 'y': &dyn Trait 1361 82..83 'y': &dyn Trait
1362 101..176 '{ ...o(); }': () 1362 100..175 '{ ...o(); }': ()
1363 107..108 'x': dyn Trait 1363 106..107 'x': dyn Trait
1364 114..115 'y': &dyn Trait 1364 113..114 'y': &dyn Trait
1365 125..126 'z': dyn Trait 1365 124..125 'z': dyn Trait
1366 129..132 'bar': fn bar() -> dyn Trait 1366 128..131 'bar': fn bar() -> dyn Trait
1367 129..134 'bar()': dyn Trait 1367 128..133 'bar()': dyn Trait
1368 140..141 'x': dyn Trait 1368 139..140 'x': dyn Trait
1369 140..147 'x.foo()': u64 1369 139..146 'x.foo()': u64
1370 153..154 'y': &dyn Trait 1370 152..153 'y': &dyn Trait
1371 153..160 'y.foo()': u64 1371 152..159 'y.foo()': u64
1372 166..167 'z': dyn Trait 1372 165..166 'z': dyn Trait
1373 166..173 'z.foo()': u64 1373 165..172 'z.foo()': u64
1374 "### 1374 "###
1375 ); 1375 );
1376} 1376}
@@ -1384,13 +1384,13 @@ fn test(a: impl Trait + 'lifetime, b: impl 'lifetime, c: impl (Trait), d: impl (
1384} 1384}
1385"#), 1385"#),
1386 @r###" 1386 @r###"
1387 24..25 'a': impl Trait + {error} 1387 23..24 'a': impl Trait + {error}
1388 51..52 'b': impl {error} 1388 50..51 'b': impl {error}
1389 70..71 'c': impl Trait 1389 69..70 'c': impl Trait
1390 87..88 'd': impl {error} 1390 86..87 'd': impl {error}
1391 108..109 'e': impl {error} 1391 107..108 'e': impl {error}
1392 124..125 'f': impl Trait + {error} 1392 123..124 'f': impl Trait + {error}
1393 148..151 '{ }': () 1393 147..150 '{ }': ()
1394 "### 1394 "###
1395 ); 1395 );
1396} 1396}
@@ -1439,41 +1439,41 @@ fn test<T: Trait<Type = u32>>(x: T, y: impl Trait<Type = i64>) {
1439} 1439}
1440"#), 1440"#),
1441 @r###" 1441 @r###"
1442 50..51 't': T 1442 49..50 't': T
1443 78..80 '{}': () 1443 77..79 '{}': ()
1444 112..113 't': T 1444 111..112 't': T
1445 123..125 '{}': () 1445 122..124 '{}': ()
1446 155..156 't': T 1446 154..155 't': T
1447 166..169 '{t}': T 1447 165..168 '{t}': T
1448 167..168 't': T 1448 166..167 't': T
1449 257..258 'x': T 1449 256..257 'x': T
1450 263..264 'y': impl Trait<Type = i64> 1450 262..263 'y': impl Trait<Type = i64>
1451 290..398 '{ ...r>); }': () 1451 289..397 '{ ...r>); }': ()
1452 296..299 'get': fn get<T>(T) -> <T as Trait>::Type 1452 295..298 'get': fn get<T>(T) -> <T as Trait>::Type
1453 296..302 'get(x)': u32 1453 295..301 'get(x)': u32
1454 300..301 'x': T 1454 299..300 'x': T
1455 308..312 'get2': fn get2<u32, T>(T) -> u32 1455 307..311 'get2': fn get2<u32, T>(T) -> u32
1456 308..315 'get2(x)': u32 1456 307..314 'get2(x)': u32
1457 313..314 'x': T 1457 312..313 'x': T
1458 321..324 'get': fn get<impl Trait<Type = i64>>(impl Trait<Type = i64>) -> <impl Trait<Type = i64> as Trait>::Type 1458 320..323 'get': fn get<impl Trait<Type = i64>>(impl Trait<Type = i64>) -> <impl Trait<Type = i64> as Trait>::Type
1459 321..327 'get(y)': i64 1459 320..326 'get(y)': i64
1460 325..326 'y': impl Trait<Type = i64> 1460 324..325 'y': impl Trait<Type = i64>
1461 333..337 'get2': fn get2<i64, impl Trait<Type = i64>>(impl Trait<Type = i64>) -> i64 1461 332..336 'get2': fn get2<i64, impl Trait<Type = i64>>(impl Trait<Type = i64>) -> i64
1462 333..340 'get2(y)': i64 1462 332..339 'get2(y)': i64
1463 338..339 'y': impl Trait<Type = i64> 1463 337..338 'y': impl Trait<Type = i64>
1464 346..349 'get': fn get<S<u64>>(S<u64>) -> <S<u64> as Trait>::Type 1464 345..348 'get': fn get<S<u64>>(S<u64>) -> <S<u64> as Trait>::Type
1465 346..357 'get(set(S))': u64 1465 345..356 'get(set(S))': u64
1466 350..353 'set': fn set<S<u64>>(S<u64>) -> S<u64> 1466 349..352 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1467 350..356 'set(S)': S<u64> 1467 349..355 'set(S)': S<u64>
1468 354..355 'S': S<u64> 1468 353..354 'S': S<u64>
1469 363..367 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64 1469 362..366 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64
1470 363..375 'get2(set(S))': u64 1470 362..374 'get2(set(S))': u64
1471 368..371 'set': fn set<S<u64>>(S<u64>) -> S<u64> 1471 367..370 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1472 368..374 'set(S)': S<u64> 1472 367..373 'set(S)': S<u64>
1473 372..373 'S': S<u64> 1473 371..372 'S': S<u64>
1474 381..385 'get2': fn get2<str, S<str>>(S<str>) -> str 1474 380..384 'get2': fn get2<str, S<str>>(S<str>) -> str
1475 381..395 'get2(S::<str>)': str 1475 380..394 'get2(S::<str>)': str
1476 386..394 'S::<str>': S<str> 1476 385..393 'S::<str>': S<str>
1477 "### 1477 "###
1478 ); 1478 );
1479} 1479}
@@ -1538,11 +1538,11 @@ fn test<T: Trait1<Type = u32>>(x: T) {
1538} 1538}
1539"#), 1539"#),
1540 @r###" 1540 @r###"
1541 62..66 'self': Self 1541 61..65 'self': Self
1542 164..165 'x': T 1542 163..164 'x': T
1543 170..186 '{ ...o(); }': () 1543 169..185 '{ ...o(); }': ()
1544 176..177 'x': T 1544 175..176 'x': T
1545 176..183 'x.foo()': u32 1545 175..182 'x.foo()': u32
1546 "### 1546 "###
1547 ); 1547 );
1548} 1548}
@@ -1584,15 +1584,15 @@ fn test<T: Trait1, U: Trait2>(x: T, y: U) {
1584} 1584}
1585"#), 1585"#),
1586 @r###" 1586 @r###"
1587 50..54 'self': &Self 1587 49..53 'self': &Self
1588 63..65 '{}': () 1588 62..64 '{}': ()
1589 182..183 'x': T 1589 181..182 'x': T
1590 188..189 'y': U 1590 187..188 'y': U
1591 194..223 '{ ...o(); }': () 1591 193..222 '{ ...o(); }': ()
1592 200..201 'x': T 1592 199..200 'x': T
1593 200..207 'x.foo()': u32 1593 199..206 'x.foo()': u32
1594 213..214 'y': U 1594 212..213 'y': U
1595 213..220 'y.foo()': u32 1595 212..219 'y.foo()': u32
1596 "### 1596 "###
1597 ); 1597 );
1598} 1598}
@@ -1613,12 +1613,12 @@ fn test(x: &impl Trait1) {
1613} 1613}
1614"#), 1614"#),
1615 @r###" 1615 @r###"
1616 50..54 'self': &Self 1616 49..53 'self': &Self
1617 63..65 '{}': () 1617 62..64 '{}': ()
1618 116..117 'x': &impl Trait1 1618 115..116 'x': &impl Trait1
1619 133..149 '{ ...o(); }': () 1619 132..148 '{ ...o(); }': ()
1620 139..140 'x': &impl Trait1 1620 138..139 'x': &impl Trait1
1621 139..146 'x.foo()': u32 1621 138..145 'x.foo()': u32
1622 "### 1622 "###
1623 ); 1623 );
1624} 1624}
@@ -1636,10 +1636,10 @@ fn test<T: A>(x: T) {
1636} 1636}
1637"#), 1637"#),
1638 @r###" 1638 @r###"
1639 44..45 'x': T 1639 43..44 'x': T
1640 50..66 '{ ...o(); }': () 1640 49..65 '{ ...o(); }': ()
1641 56..57 'x': T 1641 55..56 'x': T
1642 56..63 'x.foo()': {unknown} 1642 55..62 'x.foo()': {unknown}
1643 "### 1643 "###
1644 ); 1644 );
1645} 1645}
@@ -1663,17 +1663,17 @@ fn test() {
1663} 1663}
1664"#), 1664"#),
1665 @r###" 1665 @r###"
1666 103..104 't': T 1666 102..103 't': T
1667 114..116 '{}': () 1667 113..115 '{}': ()
1668 146..147 't': T 1668 145..146 't': T
1669 157..160 '{t}': T 1669 156..159 '{t}': T
1670 158..159 't': T 1670 157..158 't': T
1671 259..280 '{ ...S)); }': () 1671 258..279 '{ ...S)); }': ()
1672 265..269 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64 1672 264..268 'get2': fn get2<u64, S<u64>>(S<u64>) -> u64
1673 265..277 'get2(set(S))': u64 1673 264..276 'get2(set(S))': u64
1674 270..273 'set': fn set<S<u64>>(S<u64>) -> S<u64> 1674 269..272 'set': fn set<S<u64>>(S<u64>) -> S<u64>
1675 270..276 'set(S)': S<u64> 1675 269..275 'set(S)': S<u64>
1676 274..275 'S': S<u64> 1676 273..274 'S': S<u64>
1677 "### 1677 "###
1678 ); 1678 );
1679} 1679}
@@ -1693,15 +1693,15 @@ fn test<F: FnOnce(u32, u64) -> u128>(f: F) {
1693} 1693}
1694"#), 1694"#),
1695 @r###" 1695 @r###"
1696 57..61 'self': Self 1696 56..60 'self': Self
1697 63..67 'args': Args 1697 62..66 'args': Args
1698 150..151 'f': F 1698 149..150 'f': F
1699 156..184 '{ ...2)); }': () 1699 155..183 '{ ...2)); }': ()
1700 162..163 'f': F 1700 161..162 'f': F
1701 162..181 'f.call...1, 2))': u128 1701 161..180 'f.call...1, 2))': u128
1702 174..180 '(1, 2)': (u32, u64) 1702 173..179 '(1, 2)': (u32, u64)
1703 175..176 '1': u32 1703 174..175 '1': u32
1704 178..179 '2': u64 1704 177..178 '2': u64
1705 "### 1705 "###
1706 ); 1706 );
1707} 1707}
@@ -1742,24 +1742,24 @@ fn test() {
1742} 1742}
1743"#), 1743"#),
1744 @r###" 1744 @r###"
174575..79 'self': Self 1745 74..78 'self': Self
174681..85 'args': Args 1746 80..84 'args': Args
1747140..144 'self': &Self 1747 139..143 'self': &Self
1748244..248 'self': &Bar<F> 1748 243..247 'self': &Bar<F>
1749261..263 '{}': () 1749 260..262 '{}': ()
1750347..351 'self': Opt<T> 1750 346..350 'self': Opt<T>
1751353..354 'f': F 1751 352..353 'f': F
1752369..371 '{}': () 1752 368..370 '{}': ()
1753385..501 '{ ...(f); }': () 1753 384..500 '{ ...(f); }': ()
1754395..398 'bar': Bar<fn(u8) -> u32> 1754 394..397 'bar': Bar<fn(u8) -> u32>
1755424..427 'bar': Bar<fn(u8) -> u32> 1755 423..426 'bar': Bar<fn(u8) -> u32>
1756424..433 'bar.foo()': {unknown} 1756 423..432 'bar.foo()': {unknown}
1757444..447 'opt': Opt<u8> 1757 443..446 'opt': Opt<u8>
1758466..467 'f': fn(u8) -> u32 1758 465..466 'f': fn(u8) -> u32
1759488..491 'opt': Opt<u8> 1759 487..490 'opt': Opt<u8>
1760488..498 'opt.map(f)': Opt<FnOnce::Output<fn(u8) -> u32, (u8,)>> 1760 487..497 'opt.map(f)': Opt<FnOnce::Output<fn(u8) -> u32, (u8,)>>
1761496..497 'f': fn(u8) -> u32 1761 495..496 'f': fn(u8) -> u32
1762"### 1762 "###
1763 ); 1763 );
1764} 1764}
1765 1765
@@ -1808,32 +1808,32 @@ fn test() {
1808} 1808}
1809"#), 1809"#),
1810 @r###" 1810 @r###"
1811 65..69 'self': &Self 1811 64..68 'self': &Self
1812 166..170 'self': Self 1812 165..169 'self': Self
1813 172..176 'args': Args 1813 171..175 'args': Args
1814 240..244 'self': &Foo 1814 239..243 'self': &Foo
1815 255..257 '{}': () 1815 254..256 '{}': ()
1816 335..336 'f': F 1816 334..335 'f': F
1817 355..357 '{}': () 1817 354..356 '{}': ()
1818 444..690 '{ ...o(); }': () 1818 443..689 '{ ...o(); }': ()
1819 454..459 'lazy1': Lazy<Foo, || -> Foo> 1819 453..458 'lazy1': Lazy<Foo, || -> Foo>
1820 476..485 'Lazy::new': fn new<Foo, || -> Foo>(|| -> Foo) -> Lazy<Foo, || -> Foo> 1820 475..484 'Lazy::new': fn new<Foo, || -> Foo>(|| -> Foo) -> Lazy<Foo, || -> Foo>
1821 476..493 'Lazy::...| Foo)': Lazy<Foo, || -> Foo> 1821 475..492 'Lazy::...| Foo)': Lazy<Foo, || -> Foo>
1822 486..492 '|| Foo': || -> Foo 1822 485..491 '|| Foo': || -> Foo
1823 489..492 'Foo': Foo 1823 488..491 'Foo': Foo
1824 503..505 'r1': usize 1824 502..504 'r1': usize
1825 508..513 'lazy1': Lazy<Foo, || -> Foo> 1825 507..512 'lazy1': Lazy<Foo, || -> Foo>
1826 508..519 'lazy1.foo()': usize 1826 507..518 'lazy1.foo()': usize
1827 561..576 'make_foo_fn_ptr': fn() -> Foo 1827 560..575 'make_foo_fn_ptr': fn() -> Foo
1828 592..603 'make_foo_fn': fn make_foo_fn() -> Foo 1828 591..602 'make_foo_fn': fn make_foo_fn() -> Foo
1829 613..618 'lazy2': Lazy<Foo, fn() -> Foo> 1829 612..617 'lazy2': Lazy<Foo, fn() -> Foo>
1830 635..644 'Lazy::new': fn new<Foo, fn() -> Foo>(fn() -> Foo) -> Lazy<Foo, fn() -> Foo> 1830 634..643 'Lazy::new': fn new<Foo, fn() -> Foo>(fn() -> Foo) -> Lazy<Foo, fn() -> Foo>
1831 635..661 'Lazy::...n_ptr)': Lazy<Foo, fn() -> Foo> 1831 634..660 'Lazy::...n_ptr)': Lazy<Foo, fn() -> Foo>
1832 645..660 'make_foo_fn_ptr': fn() -> Foo 1832 644..659 'make_foo_fn_ptr': fn() -> Foo
1833 671..673 'r2': {unknown} 1833 670..672 'r2': {unknown}
1834 676..681 'lazy2': Lazy<Foo, fn() -> Foo> 1834 675..680 'lazy2': Lazy<Foo, fn() -> Foo>
1835 676..687 'lazy2.foo()': {unknown} 1835 675..686 'lazy2.foo()': {unknown}
1836 550..552 '{}': () 1836 549..551 '{}': ()
1837 "### 1837 "###
1838 ); 1838 );
1839} 1839}
@@ -1860,32 +1860,32 @@ fn test() {
1860} 1860}
1861"#), 1861"#),
1862 @r###" 1862 @r###"
1863 148..152 'self': Option<T> 1863 147..151 'self': Option<T>
1864 154..155 'f': F 1864 153..154 'f': F
1865 173..175 '{}': () 1865 172..174 '{}': ()
1866 189..308 '{ ... 1); }': () 1866 188..307 '{ ... 1); }': ()
1867 199..200 'x': Option<u32> 1867 198..199 'x': Option<u32>
1868 203..215 'Option::Some': Some<u32>(u32) -> Option<u32> 1868 202..214 'Option::Some': Some<u32>(u32) -> Option<u32>
1869 203..221 'Option...(1u32)': Option<u32> 1869 202..220 'Option...(1u32)': Option<u32>
1870 216..220 '1u32': u32 1870 215..219 '1u32': u32
1871 227..228 'x': Option<u32> 1871 226..227 'x': Option<u32>
1872 227..243 'x.map(...v + 1)': Option<u32> 1872 226..242 'x.map(...v + 1)': Option<u32>
1873 233..242 '|v| v + 1': |u32| -> u32 1873 232..241 '|v| v + 1': |u32| -> u32
1874 234..235 'v': u32 1874 233..234 'v': u32
1875 237..238 'v': u32 1875 236..237 'v': u32
1876 237..242 'v + 1': u32 1876 236..241 'v + 1': u32
1877 241..242 '1': u32 1877 240..241 '1': u32
1878 249..250 'x': Option<u32> 1878 248..249 'x': Option<u32>
1879 249..265 'x.map(... 1u64)': Option<u64> 1879 248..264 'x.map(... 1u64)': Option<u64>
1880 255..264 '|_v| 1u64': |u32| -> u64 1880 254..263 '|_v| 1u64': |u32| -> u64
1881 256..258 '_v': u32 1881 255..257 '_v': u32
1882 260..264 '1u64': u64 1882 259..263 '1u64': u64
1883 275..276 'y': Option<i64> 1883 274..275 'y': Option<i64>
1884 292..293 'x': Option<u32> 1884 291..292 'x': Option<u32>
1885 292..305 'x.map(|_v| 1)': Option<i64> 1885 291..304 'x.map(|_v| 1)': Option<i64>
1886 298..304 '|_v| 1': |u32| -> i64 1886 297..303 '|_v| 1': |u32| -> i64
1887 299..301 '_v': u32 1887 298..300 '_v': u32
1888 303..304 '1': i64 1888 302..303 '1': i64
1889 "### 1889 "###
1890 ); 1890 );
1891} 1891}
@@ -1906,26 +1906,26 @@ fn test<F: FnOnce(u32) -> u64>(f: F) {
1906} 1906}
1907"#), 1907"#),
1908 @r###" 1908 @r###"
1909 73..74 'f': F 1909 72..73 'f': F
1910 79..155 '{ ...+ v; }': () 1910 78..154 '{ ...+ v; }': ()
1911 85..86 'f': F 1911 84..85 'f': F
1912 85..89 'f(1)': {unknown} 1912 84..88 'f(1)': {unknown}
1913 87..88 '1': i32 1913 86..87 '1': i32
1914 99..100 'g': |u64| -> i32 1914 98..99 'g': |u64| -> i32
1915 103..112 '|v| v + 1': |u64| -> i32 1915 102..111 '|v| v + 1': |u64| -> i32
1916 104..105 'v': u64 1916 103..104 'v': u64
1917 107..108 'v': u64 1917 106..107 'v': u64
1918 107..112 'v + 1': i32 1918 106..111 'v + 1': i32
1919 111..112 '1': i32 1919 110..111 '1': i32
1920 118..119 'g': |u64| -> i32 1920 117..118 'g': |u64| -> i32
1921 118..125 'g(1u64)': i32 1921 117..124 'g(1u64)': i32
1922 120..124 '1u64': u64 1922 119..123 '1u64': u64
1923 135..136 'h': |u128| -> u128 1923 134..135 'h': |u128| -> u128
1924 139..152 '|v| 1u128 + v': |u128| -> u128 1924 138..151 '|v| 1u128 + v': |u128| -> u128
1925 140..141 'v': u128 1925 139..140 'v': u128
1926 143..148 '1u128': u128 1926 142..147 '1u128': u128
1927 143..152 '1u128 + v': u128 1927 142..151 '1u128 + v': u128
1928 151..152 'v': u128 1928 150..151 'v': u128
1929 "### 1929 "###
1930 ); 1930 );
1931} 1931}
@@ -1958,54 +1958,54 @@ fn test() {
1958} 1958}
1959"#), 1959"#),
1960 @r###" 1960 @r###"
1961 95..96 'x': T 1961 94..95 'x': T
1962 101..102 'f': F 1962 100..101 'f': F
1963 112..114 '{}': () 1963 111..113 '{}': ()
1964 148..149 'f': F 1964 147..148 'f': F
1965 154..155 'x': T 1965 153..154 'x': T
1966 165..167 '{}': () 1966 164..166 '{}': ()
1967 202..206 'self': S 1967 201..205 'self': S
1968 254..258 'self': S 1968 253..257 'self': S
1969 260..261 'x': T 1969 259..260 'x': T
1970 266..267 'f': F 1970 265..266 'f': F
1971 277..279 '{}': () 1971 276..278 '{}': ()
1972 317..321 'self': S 1972 316..320 'self': S
1973 323..324 'f': F 1973 322..323 'f': F
1974 329..330 'x': T 1974 328..329 'x': T
1975 340..342 '{}': () 1975 339..341 '{}': ()
1976 356..515 '{ ... S); }': () 1976 355..514 '{ ... S); }': ()
1977 366..368 'x1': u64 1977 365..367 'x1': u64
1978 371..375 'foo1': fn foo1<S, u64, |S| -> u64>(S, |S| -> u64) -> u64 1978 370..374 'foo1': fn foo1<S, u64, |S| -> u64>(S, |S| -> u64) -> u64
1979 371..394 'foo1(S...hod())': u64 1979 370..393 'foo1(S...hod())': u64
1980 376..377 'S': S 1980 375..376 'S': S
1981 379..393 '|s| s.method()': |S| -> u64 1981 378..392 '|s| s.method()': |S| -> u64
1982 380..381 's': S 1982 379..380 's': S
1983 383..384 's': S 1983 382..383 's': S
1984 383..393 's.method()': u64 1984 382..392 's.method()': u64
1985 404..406 'x2': u64 1985 403..405 'x2': u64
1986 409..413 'foo2': fn foo2<S, u64, |S| -> u64>(|S| -> u64, S) -> u64 1986 408..412 'foo2': fn foo2<S, u64, |S| -> u64>(|S| -> u64, S) -> u64
1987 409..432 'foo2(|...(), S)': u64 1987 408..431 'foo2(|...(), S)': u64
1988 414..428 '|s| s.method()': |S| -> u64 1988 413..427 '|s| s.method()': |S| -> u64
1989 415..416 's': S 1989 414..415 's': S
1990 418..419 's': S 1990 417..418 's': S
1991 418..428 's.method()': u64 1991 417..427 's.method()': u64
1992 430..431 'S': S 1992 429..430 'S': S
1993 442..444 'x3': u64 1993 441..443 'x3': u64
1994 447..448 'S': S 1994 446..447 'S': S
1995 447..472 'S.foo1...hod())': u64 1995 446..471 'S.foo1...hod())': u64
1996 454..455 'S': S 1996 453..454 'S': S
1997 457..471 '|s| s.method()': |S| -> u64 1997 456..470 '|s| s.method()': |S| -> u64
1998 458..459 's': S 1998 457..458 's': S
1999 461..462 's': S 1999 460..461 's': S
2000 461..471 's.method()': u64 2000 460..470 's.method()': u64
2001 482..484 'x4': u64 2001 481..483 'x4': u64
2002 487..488 'S': S 2002 486..487 'S': S
2003 487..512 'S.foo2...(), S)': u64 2003 486..511 'S.foo2...(), S)': u64
2004 494..508 '|s| s.method()': |S| -> u64 2004 493..507 '|s| s.method()': |S| -> u64
2005 495..496 's': S 2005 494..495 's': S
2006 498..499 's': S 2006 497..498 's': S
2007 498..508 's.method()': u64 2007 497..507 's.method()': u64
2008 510..511 'S': S 2008 509..510 'S': S
2009 "### 2009 "###
2010 ); 2010 );
2011} 2011}
@@ -2080,18 +2080,18 @@ impl Trait for S2 {
2080} 2080}
2081"#, 2081"#,
2082 ), @r###" 2082 ), @r###"
2083 54..58 'self': &Self 2083 40..44 'self': &Self
2084 60..61 'x': Trait::Item<Self> 2084 46..47 'x': Trait::Item<Self>
2085 140..144 'self': &S 2085 126..130 'self': &S
2086 146..147 'x': u32 2086 132..133 'x': u32
2087 161..175 '{ let y = x; }': () 2087 147..161 '{ let y = x; }': ()
2088 167..168 'y': u32 2088 153..154 'y': u32
2089 171..172 'x': u32 2089 157..158 'x': u32
2090 242..246 'self': &S2 2090 228..232 'self': &S2
2091 248..249 'x': i32 2091 234..235 'x': i32
2092 265..279 '{ let y = x; }': () 2092 251..265 '{ let y = x; }': ()
2093 271..272 'y': i32 2093 257..258 'y': i32
2094 275..276 'x': i32 2094 261..262 'x': i32
2095 "###); 2095 "###);
2096} 2096}
2097 2097
@@ -2331,15 +2331,15 @@ impl TokenStream for Rustc {
2331} 2331}
2332"#), 2332"#),
2333 @r###" 2333 @r###"
2334 1062..1073 '{ loop {} }': T 2334 1061..1072 '{ loop {} }': T
2335 1064..1071 'loop {}': ! 2335 1063..1070 'loop {}': !
2336 1069..1071 '{}': () 2336 1068..1070 '{}': ()
2337 1137..1200 '{ ... }': T 2337 1136..1199 '{ ... }': T
2338 1151..1156 'group': G 2338 1150..1155 'group': G
2339 1172..1176 'make': fn make<G>() -> G 2339 1171..1175 'make': fn make<G>() -> G
2340 1172..1178 'make()': G 2340 1171..1177 'make()': G
2341 1188..1192 'make': fn make<T>() -> T 2341 1187..1191 'make': fn make<T>() -> T
2342 1188..1194 'make()': T 2342 1187..1193 'make()': T
2343 "### 2343 "###
2344 ); 2344 );
2345} 2345}
@@ -2366,37 +2366,37 @@ fn test() -> impl Trait<i32> {
2366} 2366}
2367"#, true), 2367"#, true),
2368 @r###" 2368 @r###"
2369 27..28 'x': impl Trait<u32> 2369 26..27 'x': impl Trait<u32>
2370 47..58 '{ loop {} }': () 2370 46..57 '{ loop {} }': ()
2371 49..56 'loop {}': ! 2371 48..55 'loop {}': !
2372 54..56 '{}': () 2372 53..55 '{}': ()
2373 69..70 'x': impl Trait<T> 2373 68..69 'x': impl Trait<T>
2374 92..103 '{ loop {} }': T 2374 91..102 '{ loop {} }': T
2375 94..101 'loop {}': ! 2375 93..100 'loop {}': !
2376 99..101 '{}': () 2376 98..100 '{}': ()
2377 172..183 '{ loop {} }': T 2377 171..182 '{ loop {} }': T
2378 174..181 'loop {}': ! 2378 173..180 'loop {}': !
2379 179..181 '{}': () 2379 178..180 '{}': ()
2380 214..310 '{ ...t()) }': S<{unknown}> 2380 213..309 '{ ...t()) }': S<{unknown}>
2381 224..226 's1': S<u32> 2381 223..225 's1': S<u32>
2382 229..230 'S': S<u32>(u32) -> S<u32> 2382 228..229 'S': S<u32>(u32) -> S<u32>
2383 229..241 'S(default())': S<u32> 2383 228..240 'S(default())': S<u32>
2384 231..238 'default': fn default<u32>() -> u32 2384 230..237 'default': fn default<u32>() -> u32
2385 231..240 'default()': u32 2385 230..239 'default()': u32
2386 247..250 'foo': fn foo(S<u32>) 2386 246..249 'foo': fn foo(S<u32>)
2387 247..254 'foo(s1)': () 2387 246..253 'foo(s1)': ()
2388 251..253 's1': S<u32> 2388 250..252 's1': S<u32>
2389 264..265 'x': i32 2389 263..264 'x': i32
2390 273..276 'bar': fn bar<i32>(S<i32>) -> i32 2390 272..275 'bar': fn bar<i32>(S<i32>) -> i32
2391 273..290 'bar(S(...lt()))': i32 2391 272..289 'bar(S(...lt()))': i32
2392 277..278 'S': S<i32>(i32) -> S<i32> 2392 276..277 'S': S<i32>(i32) -> S<i32>
2393 277..289 'S(default())': S<i32> 2393 276..288 'S(default())': S<i32>
2394 279..286 'default': fn default<i32>() -> i32 2394 278..285 'default': fn default<i32>() -> i32
2395 279..288 'default()': i32 2395 278..287 'default()': i32
2396 296..297 'S': S<{unknown}>({unknown}) -> S<{unknown}> 2396 295..296 'S': S<{unknown}>({unknown}) -> S<{unknown}>
2397 296..308 'S(default())': S<{unknown}> 2397 295..307 'S(default())': S<{unknown}>
2398 298..305 'default': fn default<{unknown}>() -> {unknown} 2398 297..304 'default': fn default<{unknown}>() -> {unknown}
2399 298..307 'default()': {unknown} 2399 297..306 'default()': {unknown}
2400 "### 2400 "###
2401 ); 2401 );
2402} 2402}
@@ -2430,15 +2430,15 @@ fn main() {
2430} 2430}
2431"#), 2431"#),
2432 @r###" 2432 @r###"
2433 147..149 '_v': F 2433 133..135 '_v': F
2434 192..195 '{ }': () 2434 178..181 '{ }': ()
2435 207..238 '{ ... }); }': () 2435 193..224 '{ ... }); }': ()
2436 213..223 'f::<(), _>': fn f<(), |&()| -> ()>(|&()| -> ()) 2436 199..209 'f::<(), _>': fn f<(), |&()| -> ()>(|&()| -> ())
2437 213..235 'f::<()... z; })': () 2437 199..221 'f::<()... z; })': ()
2438 224..234 '|z| { z; }': |&()| -> () 2438 210..220 '|z| { z; }': |&()| -> ()
2439 225..226 'z': &() 2439 211..212 'z': &()
2440 228..234 '{ z; }': () 2440 214..220 '{ z; }': ()
2441 230..231 'z': &() 2441 216..217 'z': &()
2442 "### 2442 "###
2443 ); 2443 );
2444} 2444}
@@ -2591,46 +2591,46 @@ fn main() {
2591} 2591}
2592"#), 2592"#),
2593 @r###" 2593 @r###"
2594 240..244 'self': Self 2594 226..230 'self': Self
2595 246..247 'f': F 2595 232..233 'f': F
2596 331..342 '{ loop {} }': FilterMap<Self, F> 2596 317..328 '{ loop {} }': FilterMap<Self, F>
2597 333..340 'loop {}': ! 2597 319..326 'loop {}': !
2598 338..340 '{}': () 2598 324..326 '{}': ()
2599 363..367 'self': Self 2599 349..353 'self': Self
2600 369..370 'f': F 2600 355..356 'f': F
2601 419..430 '{ loop {} }': () 2601 405..416 '{ loop {} }': ()
2602 421..428 'loop {}': ! 2602 407..414 'loop {}': !
2603 426..428 '{}': () 2603 412..414 '{}': ()
2604 539..543 'self': Self 2604 525..529 'self': Self
2605 868..872 'self': I 2605 854..858 'self': I
2606 879..899 '{ ... }': I 2606 865..885 '{ ... }': I
2607 889..893 'self': I 2607 875..879 'self': I
2608 958..969 '{ loop {} }': Vec<T> 2608 944..955 '{ loop {} }': Vec<T>
2609 960..967 'loop {}': ! 2609 946..953 'loop {}': !
2610 965..967 '{}': () 2610 951..953 '{}': ()
2611 1156..1287 '{ ... }); }': () 2611 1142..1273 '{ ... }); }': ()
2612 1162..1177 'Vec::<i32>::new': fn new<i32>() -> Vec<i32> 2612 1148..1163 'Vec::<i32>::new': fn new<i32>() -> Vec<i32>
2613 1162..1179 'Vec::<...:new()': Vec<i32> 2613 1148..1165 'Vec::<...:new()': Vec<i32>
2614 1162..1191 'Vec::<...iter()': IntoIter<i32> 2614 1148..1177 'Vec::<...iter()': IntoIter<i32>
2615 1162..1256 'Vec::<...one })': FilterMap<IntoIter<i32>, |i32| -> Option<u32>> 2615 1148..1242 'Vec::<...one })': FilterMap<IntoIter<i32>, |i32| -> Option<u32>>
2616 1162..1284 'Vec::<... y; })': () 2616 1148..1270 'Vec::<... y; })': ()
2617 1210..1255 '|x| if...None }': |i32| -> Option<u32> 2617 1196..1241 '|x| if...None }': |i32| -> Option<u32>
2618 1211..1212 'x': i32 2618 1197..1198 'x': i32
2619 1214..1255 'if x >...None }': Option<u32> 2619 1200..1241 'if x >...None }': Option<u32>
2620 1217..1218 'x': i32 2620 1203..1204 'x': i32
2621 1217..1222 'x > 0': bool 2621 1203..1208 'x > 0': bool
2622 1221..1222 '0': i32 2622 1207..1208 '0': i32
2623 1223..1241 '{ Some...u32) }': Option<u32> 2623 1209..1227 '{ Some...u32) }': Option<u32>
2624 1225..1229 'Some': Some<u32>(u32) -> Option<u32> 2624 1211..1215 'Some': Some<u32>(u32) -> Option<u32>
2625 1225..1239 'Some(x as u32)': Option<u32> 2625 1211..1225 'Some(x as u32)': Option<u32>
2626 1230..1231 'x': i32 2626 1216..1217 'x': i32
2627 1230..1238 'x as u32': u32 2627 1216..1224 'x as u32': u32
2628 1247..1255 '{ None }': Option<u32> 2628 1233..1241 '{ None }': Option<u32>
2629 1249..1253 'None': Option<u32> 2629 1235..1239 'None': Option<u32>
2630 1273..1283 '|y| { y; }': |u32| -> () 2630 1259..1269 '|y| { y; }': |u32| -> ()
2631 1274..1275 'y': u32 2631 1260..1261 'y': u32
2632 1277..1283 '{ y; }': () 2632 1263..1269 '{ y; }': ()
2633 1279..1280 'y': u32 2633 1265..1266 'y': u32
2634 "### 2634 "###
2635 ); 2635 );
2636} 2636}
@@ -2682,13 +2682,13 @@ fn test(x: &dyn Foo) {
2682} 2682}
2683"#, true), 2683"#, true),
2684 @r###" 2684 @r###"
2685 22..23 'x': &dyn Foo 2685 21..22 'x': &dyn Foo
2686 35..37 '{}': () 2686 34..36 '{}': ()
2687 47..48 'x': &dyn Foo 2687 46..47 'x': &dyn Foo
2688 60..75 '{ foo(x); }': () 2688 59..74 '{ foo(x); }': ()
2689 66..69 'foo': fn foo(&dyn Foo) 2689 65..68 'foo': fn foo(&dyn Foo)
2690 66..72 'foo(x)': () 2690 65..71 'foo(x)': ()
2691 70..71 'x': &dyn Foo 2691 69..70 'x': &dyn Foo
2692 "### 2692 "###
2693 ); 2693 );
2694} 2694}
@@ -2715,20 +2715,20 @@ fn test() {
2715} 2715}
2716"#, true), 2716"#, true),
2717 @r###" 2717 @r###"
2718 111..115 'self': &Self 2718 110..114 'self': &Self
2719 167..268 '{ ...t(); }': () 2719 166..267 '{ ...t(); }': ()
2720 173..179 'IsCopy': IsCopy 2720 172..178 'IsCopy': IsCopy
2721 173..186 'IsCopy.test()': bool 2721 172..185 'IsCopy.test()': bool
2722 192..199 'NotCopy': NotCopy 2722 191..198 'NotCopy': NotCopy
2723 192..206 'NotCopy.test()': {unknown} 2723 191..205 'NotCopy.test()': {unknown}
2724 212..228 '(IsCop...sCopy)': (IsCopy, IsCopy) 2724 211..227 '(IsCop...sCopy)': (IsCopy, IsCopy)
2725 212..235 '(IsCop...test()': bool 2725 211..234 '(IsCop...test()': bool
2726 213..219 'IsCopy': IsCopy 2726 212..218 'IsCopy': IsCopy
2727 221..227 'IsCopy': IsCopy 2727 220..226 'IsCopy': IsCopy
2728 241..258 '(IsCop...tCopy)': (IsCopy, NotCopy) 2728 240..257 '(IsCop...tCopy)': (IsCopy, NotCopy)
2729 241..265 '(IsCop...test()': {unknown} 2729 240..264 '(IsCop...test()': {unknown}
2730 242..248 'IsCopy': IsCopy 2730 241..247 'IsCopy': IsCopy
2731 250..257 'NotCopy': NotCopy 2731 249..256 'NotCopy': NotCopy
2732 "### 2732 "###
2733 ); 2733 );
2734} 2734}
@@ -2756,20 +2756,20 @@ fn test() {
2756} 2756}
2757"#, true), 2757"#, true),
2758 @r###" 2758 @r###"
2759 42..44 '{}': () 2759 41..43 '{}': ()
2760 61..62 'T': {unknown} 2760 60..61 'T': {unknown}
2761 69..71 '{}': () 2761 68..70 '{}': ()
2762 69..71: expected T, got () 2762 68..70: expected T, got ()
2763 146..150 'self': &Self 2763 145..149 'self': &Self
2764 202..282 '{ ...t(); }': () 2764 201..281 '{ ...t(); }': ()
2765 208..211 'foo': fn foo() 2765 207..210 'foo': fn foo()
2766 208..218 'foo.test()': bool 2766 207..217 'foo.test()': bool
2767 224..227 'bar': fn bar<{unknown}>({unknown}) -> {unknown} 2767 223..226 'bar': fn bar<{unknown}>({unknown}) -> {unknown}
2768 224..234 'bar.test()': bool 2768 223..233 'bar.test()': bool
2769 240..246 'Struct': Struct(usize) -> Struct 2769 239..245 'Struct': Struct(usize) -> Struct
2770 240..253 'Struct.test()': bool 2770 239..252 'Struct.test()': bool
2771 259..272 'Enum::Variant': Variant(usize) -> Enum 2771 258..271 'Enum::Variant': Variant(usize) -> Enum
2772 259..279 'Enum::...test()': bool 2772 258..278 'Enum::...test()': bool
2773 "### 2773 "###
2774 ); 2774 );
2775} 2775}
@@ -2791,17 +2791,17 @@ fn test(f1: fn(), f2: fn(usize) -> u8, f3: fn(u8, u8) -> &u8) {
2791} 2791}
2792"#, true), 2792"#, true),
2793 @r###" 2793 @r###"
2794 55..59 'self': &Self 2794 54..58 'self': &Self
2795 109..111 'f1': fn() 2795 108..110 'f1': fn()
2796 119..121 'f2': fn(usize) -> u8 2796 118..120 'f2': fn(usize) -> u8
2797 140..142 'f3': fn(u8, u8) -> &u8 2797 139..141 'f3': fn(u8, u8) -> &u8
2798 163..211 '{ ...t(); }': () 2798 162..210 '{ ...t(); }': ()
2799 169..171 'f1': fn() 2799 168..170 'f1': fn()
2800 169..178 'f1.test()': bool 2800 168..177 'f1.test()': bool
2801 184..186 'f2': fn(usize) -> u8 2801 183..185 'f2': fn(usize) -> u8
2802 184..193 'f2.test()': bool 2802 183..192 'f2.test()': bool
2803 199..201 'f3': fn(u8, u8) -> &u8 2803 198..200 'f3': fn(u8, u8) -> &u8
2804 199..208 'f3.test()': bool 2804 198..207 'f3.test()': bool
2805 "### 2805 "###
2806 ); 2806 );
2807} 2807}
@@ -2824,22 +2824,22 @@ fn test() {
2824} 2824}
2825"#, true), 2825"#, true),
2826 @r###" 2826 @r###"
2827 57..61 'self': &Self 2827 56..60 'self': &Self
2828 114..229 '{ ...ized }': () 2828 113..228 '{ ...ized }': ()
2829 120..123 '1u8': u8 2829 119..122 '1u8': u8
2830 120..130 '1u8.test()': bool 2830 119..129 '1u8.test()': bool
2831 136..151 '(*"foo").test()': {unknown} 2831 135..150 '(*"foo").test()': {unknown}
2832 137..143 '*"foo"': str 2832 136..142 '*"foo"': str
2833 138..143 '"foo"': &str 2833 137..142 '"foo"': &str
2834 170..180 '(1u8, 1u8)': (u8, u8) 2834 169..179 '(1u8, 1u8)': (u8, u8)
2835 170..187 '(1u8, ...test()': bool 2835 169..186 '(1u8, ...test()': bool
2836 171..174 '1u8': u8 2836 170..173 '1u8': u8
2837 176..179 '1u8': u8 2837 175..178 '1u8': u8
2838 193..206 '(1u8, *"foo")': (u8, str) 2838 192..205 '(1u8, *"foo")': (u8, str)
2839 193..213 '(1u8, ...test()': {unknown} 2839 192..212 '(1u8, ...test()': {unknown}
2840 194..197 '1u8': u8 2840 193..196 '1u8': u8
2841 199..205 '*"foo"': str 2841 198..204 '*"foo"': str
2842 200..205 '"foo"': &str 2842 199..204 '"foo"': &str
2843 "### 2843 "###
2844 ); 2844 );
2845} 2845}
@@ -2888,3 +2888,226 @@ impl<A: Step> iter::Iterator for ops::Range<A> {
2888 ); 2888 );
2889 assert_eq!(t, "i32"); 2889 assert_eq!(t, "i32");
2890} 2890}
2891
2892#[test]
2893fn infer_closure_arg() {
2894 assert_snapshot!(
2895 infer(
2896 r#"
2897 //- /lib.rs
2898
2899 enum Option<T> {
2900 None,
2901 Some(T)
2902 }
2903
2904 fn foo() {
2905 let s = Option::None;
2906 let f = |x: Option<i32>| {};
2907 (&f)(s)
2908 }
2909 "#
2910 ),
2911 @r###"
2912 52..126 '{ ...)(s) }': ()
2913 62..63 's': Option<i32>
2914 66..78 'Option::None': Option<i32>
2915 88..89 'f': |Option<i32>| -> ()
2916 92..111 '|x: Op...2>| {}': |Option<i32>| -> ()
2917 93..94 'x': Option<i32>
2918 109..111 '{}': ()
2919 117..124 '(&f)(s)': ()
2920 118..120 '&f': &|Option<i32>| -> ()
2921 119..120 'f': |Option<i32>| -> ()
2922 122..123 's': Option<i32>
2923 "###
2924 );
2925}
2926
2927#[test]
2928fn infer_fn_trait_arg() {
2929 assert_snapshot!(
2930 infer(
2931 r#"
2932 //- /lib.rs deps:std
2933
2934 #[lang = "fn_once"]
2935 pub trait FnOnce<Args> {
2936 type Output;
2937
2938 extern "rust-call" fn call_once(&self, args: Args) -> Self::Output;
2939 }
2940
2941 #[lang = "fn"]
2942 pub trait Fn<Args>:FnOnce<Args> {
2943 extern "rust-call" fn call(&self, args: Args) -> Self::Output;
2944 }
2945
2946 enum Option<T> {
2947 None,
2948 Some(T)
2949 }
2950
2951 fn foo<F, T>(f: F) -> T
2952 where
2953 F: Fn(Option<i32>) -> T,
2954 {
2955 let s = None;
2956 f(s)
2957 }
2958 "#
2959 ),
2960 @r###"
2961 101..105 'self': &Self
2962 107..111 'args': Args
2963 220..224 'self': &Self
2964 226..230 'args': Args
2965 313..314 'f': F
2966 359..389 '{ ...f(s) }': T
2967 369..370 's': Option<i32>
2968 373..377 'None': Option<i32>
2969 383..384 'f': F
2970 383..387 'f(s)': T
2971 385..386 's': Option<i32>
2972 "###
2973 );
2974}
2975
2976#[test]
2977fn infer_box_fn_arg() {
2978 assert_snapshot!(
2979 infer(
2980 r#"
2981 //- /lib.rs deps:std
2982
2983 #[lang = "fn_once"]
2984 pub trait FnOnce<Args> {
2985 type Output;
2986
2987 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
2988 }
2989
2990 #[lang = "deref"]
2991 pub trait Deref {
2992 type Target: ?Sized;
2993
2994 fn deref(&self) -> &Self::Target;
2995 }
2996
2997 #[lang = "owned_box"]
2998 pub struct Box<T: ?Sized> {
2999 inner: *mut T,
3000 }
3001
3002 impl<T: ?Sized> Deref for Box<T> {
3003 type Target = T;
3004
3005 fn deref(&self) -> &T {
3006 &self.inner
3007 }
3008 }
3009
3010 enum Option<T> {
3011 None,
3012 Some(T)
3013 }
3014
3015 fn foo() {
3016 let s = Option::None;
3017 let f: Box<dyn FnOnce(&Option<i32>)> = box (|ps| {});
3018 f(&s)
3019 }
3020 "#
3021 ),
3022 @r###"
3023 100..104 'self': Self
3024 106..110 'args': Args
3025 214..218 'self': &Self
3026 384..388 'self': &Box<T>
3027 396..423 '{ ... }': &T
3028 406..417 '&self.inner': &*mut T
3029 407..411 'self': &Box<T>
3030 407..417 'self.inner': *mut T
3031 478..575 '{ ...(&s) }': FnOnce::Output<dyn FnOnce<(&Option<i32>,)>, (&Option<i32>,)>
3032 488..489 's': Option<i32>
3033 492..504 'Option::None': Option<i32>
3034 514..515 'f': Box<dyn FnOnce<(&Option<i32>,)>>
3035 549..562 'box (|ps| {})': Box<|{unknown}| -> ()>
3036 554..561 '|ps| {}': |{unknown}| -> ()
3037 555..557 'ps': {unknown}
3038 559..561 '{}': ()
3039 568..569 'f': Box<dyn FnOnce<(&Option<i32>,)>>
3040 568..573 'f(&s)': FnOnce::Output<dyn FnOnce<(&Option<i32>,)>, (&Option<i32>,)>
3041 570..572 '&s': &Option<i32>
3042 571..572 's': Option<i32>
3043 "###
3044 );
3045}
3046
3047#[test]
3048fn infer_dyn_fn_output() {
3049 assert_snapshot!(
3050 infer(
3051 r#"
3052 //- /lib.rs deps:std
3053
3054 #[lang = "fn_once"]
3055 pub trait FnOnce<Args> {
3056 type Output;
3057
3058 extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
3059 }
3060
3061 #[lang = "fn"]
3062 pub trait Fn<Args>:FnOnce<Args> {
3063 extern "rust-call" fn call(&self, args: Args) -> Self::Output;
3064 }
3065
3066 #[lang = "deref"]
3067 pub trait Deref {
3068 type Target: ?Sized;
3069
3070 fn deref(&self) -> &Self::Target;
3071 }
3072
3073 #[lang = "owned_box"]
3074 pub struct Box<T: ?Sized> {
3075 inner: *mut T,
3076 }
3077
3078 impl<T: ?Sized> Deref for Box<T> {
3079 type Target = T;
3080
3081 fn deref(&self) -> &T {
3082 &self.inner
3083 }
3084 }
3085
3086 fn foo() {
3087 let f: Box<dyn Fn() -> i32> = box(|| 5);
3088 let x = f();
3089 }
3090 "#
3091 ),
3092 @r###"
3093 100..104 'self': Self
3094 106..110 'args': Args
3095 219..223 'self': &Self
3096 225..229 'args': Args
3097 333..337 'self': &Self
3098 503..507 'self': &Box<T>
3099 515..542 '{ ... }': &T
3100 525..536 '&self.inner': &*mut T
3101 526..530 'self': &Box<T>
3102 526..536 'self.inner': *mut T
3103 555..620 '{ ...f(); }': ()
3104 565..566 'f': Box<dyn Fn<(), Output = i32>>
3105 591..600 'box(|| 5)': Box<|| -> i32>
3106 595..599 '|| 5': || -> i32
3107 598..599 '5': i32
3108 610..611 'x': FnOnce::Output<dyn Fn<(), Output = i32>, ()>
3109 614..615 'f': Box<dyn Fn<(), Output = i32>>
3110 614..617 'f()': FnOnce::Output<dyn Fn<(), Output = i32>, ()>
3111 "###
3112 );
3113}
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 6bc6d474c..6f43c3a22 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -2,12 +2,13 @@
2use std::{panic, sync::Arc}; 2use std::{panic, sync::Arc};
3 3
4use chalk_ir::cast::Cast; 4use chalk_ir::cast::Cast;
5use hir_def::{expr::ExprId, DefWithBodyId, ImplId, TraitId, TypeAliasId}; 5use hir_def::{
6 expr::ExprId, lang_item::LangItemTarget, DefWithBodyId, ImplId, TraitId, TypeAliasId,
7};
6use ra_db::{impl_intern_key, salsa, CrateId}; 8use ra_db::{impl_intern_key, salsa, CrateId};
7use ra_prof::profile; 9use ra_prof::profile;
8use rustc_hash::FxHashSet;
9 10
10use crate::{db::HirDatabase, method_resolution::TyFingerprint, DebruijnIndex}; 11use crate::{db::HirDatabase, DebruijnIndex};
11 12
12use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk}; 13use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk};
13 14
@@ -36,34 +37,6 @@ fn create_chalk_solver() -> chalk_solve::Solver<Interner> {
36 solver_choice.into_solver() 37 solver_choice.into_solver()
37} 38}
38 39
39/// Collects impls for the given trait in the whole dependency tree of `krate`.
40pub(crate) fn impls_for_trait_query(
41 db: &dyn HirDatabase,
42 krate: CrateId,
43 trait_: TraitId,
44 self_ty_fp: Option<TyFingerprint>,
45) -> Arc<[ImplId]> {
46 // FIXME: We could be a lot smarter here - because of the orphan rules and
47 // the fact that the trait and the self type need to be in the dependency
48 // tree of a crate somewhere for an impl to exist, we could skip looking in
49 // a lot of crates completely
50 let mut impls = FxHashSet::default();
51 // We call the query recursively here. On the one hand, this means we can
52 // reuse results from queries for different crates; on the other hand, this
53 // will only ever get called for a few crates near the root of the tree (the
54 // ones the user is editing), so this may actually be a waste of memory. I'm
55 // doing it like this mainly for simplicity for now.
56 for dep in &db.crate_graph()[krate].dependencies {
57 impls.extend(db.impls_for_trait(dep.crate_id, trait_, self_ty_fp).iter());
58 }
59 let crate_impl_defs = db.impls_in_crate(krate);
60 match self_ty_fp {
61 Some(fp) => impls.extend(crate_impl_defs.lookup_impl_defs_for_trait_and_ty(trait_, fp)),
62 None => impls.extend(crate_impl_defs.lookup_impl_defs_for_trait(trait_)),
63 }
64 impls.into_iter().collect()
65}
66
67/// A set of clauses that we assume to be true. E.g. if we are inside this function: 40/// A set of clauses that we assume to be true. E.g. if we are inside this function:
68/// ```rust 41/// ```rust
69/// fn foo<T: Default>(t: T) {} 42/// fn foo<T: Default>(t: T) {}
@@ -298,6 +271,14 @@ impl FnTrait {
298 FnTrait::Fn => "fn", 271 FnTrait::Fn => "fn",
299 } 272 }
300 } 273 }
274
275 pub fn get_id(&self, db: &dyn HirDatabase, krate: CrateId) -> Option<TraitId> {
276 let target = db.lang_item(krate, self.lang_item_name().into())?;
277 match target {
278 LangItemTarget::TraitId(t) => Some(t),
279 _ => None,
280 }
281 }
301} 282}
302 283
303#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 284#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
diff --git a/crates/ra_hir_ty/src/traits/builtin.rs b/crates/ra_hir_ty/src/traits/builtin.rs
index 88a422d2c..6d5f2d46a 100644
--- a/crates/ra_hir_ty/src/traits/builtin.rs
+++ b/crates/ra_hir_ty/src/traits/builtin.rs
@@ -40,7 +40,7 @@ pub(super) fn get_builtin_impls(
40 if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Closure { def, expr }, .. }) = ty { 40 if let Ty::Apply(ApplicationTy { ctor: TypeCtor::Closure { def, expr }, .. }) = ty {
41 for &fn_trait in [super::FnTrait::FnOnce, super::FnTrait::FnMut, super::FnTrait::Fn].iter() 41 for &fn_trait in [super::FnTrait::FnOnce, super::FnTrait::FnMut, super::FnTrait::Fn].iter()
42 { 42 {
43 if let Some(actual_trait) = get_fn_trait(db, krate, fn_trait) { 43 if let Some(actual_trait) = fn_trait.get_id(db, krate) {
44 if trait_ == actual_trait { 44 if trait_ == actual_trait {
45 let impl_ = super::ClosureFnTraitImplData { def: *def, expr: *expr, fn_trait }; 45 let impl_ = super::ClosureFnTraitImplData { def: *def, expr: *expr, fn_trait };
46 if check_closure_fn_trait_impl_prerequisites(db, krate, impl_) { 46 if check_closure_fn_trait_impl_prerequisites(db, krate, impl_) {
@@ -128,7 +128,7 @@ fn check_closure_fn_trait_impl_prerequisites(
128 data: super::ClosureFnTraitImplData, 128 data: super::ClosureFnTraitImplData,
129) -> bool { 129) -> bool {
130 // the respective Fn/FnOnce/FnMut trait needs to exist 130 // the respective Fn/FnOnce/FnMut trait needs to exist
131 if get_fn_trait(db, krate, data.fn_trait).is_none() { 131 if data.fn_trait.get_id(db, krate).is_none() {
132 return false; 132 return false;
133 } 133 }
134 134
@@ -136,7 +136,7 @@ fn check_closure_fn_trait_impl_prerequisites(
136 // the traits having no type params, FnOnce being a supertrait 136 // the traits having no type params, FnOnce being a supertrait
137 137
138 // the FnOnce trait needs to exist and have an assoc type named Output 138 // the FnOnce trait needs to exist and have an assoc type named Output
139 let fn_once_trait = match get_fn_trait(db, krate, super::FnTrait::FnOnce) { 139 let fn_once_trait = match (super::FnTrait::FnOnce).get_id(db, krate) {
140 Some(t) => t, 140 Some(t) => t,
141 None => return false, 141 None => return false,
142 }; 142 };
@@ -151,7 +151,9 @@ fn closure_fn_trait_impl_datum(
151 // for some closure |X, Y| -> Z: 151 // for some closure |X, Y| -> Z:
152 // impl<T, U, V> Fn<(T, U)> for closure<fn(T, U) -> V> { Output = V } 152 // impl<T, U, V> Fn<(T, U)> for closure<fn(T, U) -> V> { Output = V }
153 153
154 let trait_ = get_fn_trait(db, krate, data.fn_trait) // get corresponding fn trait 154 let trait_ = data
155 .fn_trait
156 .get_id(db, krate) // get corresponding fn trait
155 // the existence of the Fn trait has been checked before 157 // the existence of the Fn trait has been checked before
156 .expect("fn trait for closure impl missing"); 158 .expect("fn trait for closure impl missing");
157 159
@@ -211,7 +213,7 @@ fn closure_fn_trait_output_assoc_ty_value(
211 let output_ty = Ty::Bound(BoundVar::new(DebruijnIndex::INNERMOST, num_args.into())); 213 let output_ty = Ty::Bound(BoundVar::new(DebruijnIndex::INNERMOST, num_args.into()));
212 214
213 let fn_once_trait = 215 let fn_once_trait =
214 get_fn_trait(db, krate, super::FnTrait::FnOnce).expect("assoc ty value should not exist"); 216 (super::FnTrait::FnOnce).get_id(db, krate).expect("assoc ty value should not exist");
215 217
216 let output_ty_id = db 218 let output_ty_id = db
217 .trait_data(fn_once_trait) 219 .trait_data(fn_once_trait)
@@ -360,14 +362,6 @@ fn super_trait_object_unsize_impl_datum(
360 BuiltinImplData { num_vars, trait_ref, where_clauses: Vec::new(), assoc_ty_values: Vec::new() } 362 BuiltinImplData { num_vars, trait_ref, where_clauses: Vec::new(), assoc_ty_values: Vec::new() }
361} 363}
362 364
363fn get_fn_trait(db: &dyn HirDatabase, krate: CrateId, fn_trait: super::FnTrait) -> Option<TraitId> {
364 let target = db.lang_item(krate, fn_trait.lang_item_name().into())?;
365 match target {
366 LangItemTarget::TraitId(t) => Some(t),
367 _ => None,
368 }
369}
370
371fn get_unsize_trait(db: &dyn HirDatabase, krate: CrateId) -> Option<TraitId> { 365fn get_unsize_trait(db: &dyn HirDatabase, krate: CrateId) -> Option<TraitId> {
372 let target = db.lang_item(krate, "unsize".into())?; 366 let target = db.lang_item(krate, "unsize".into())?;
373 match target { 367 match target {
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index a72a82f5a..2f35d6d49 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -74,14 +74,26 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
74 // Note: Since we're using impls_for_trait, only impls where the trait 74 // Note: Since we're using impls_for_trait, only impls where the trait
75 // can be resolved should ever reach Chalk. `impl_datum` relies on that 75 // can be resolved should ever reach Chalk. `impl_datum` relies on that
76 // and will panic if the trait can't be resolved. 76 // and will panic if the trait can't be resolved.
77 let mut result: Vec<_> = self 77 let in_deps = self.db.impls_from_deps(self.krate);
78 .db 78 let in_self = self.db.impls_in_crate(self.krate);
79 .impls_for_trait(self.krate, trait_, self_ty_fp) 79 let impl_maps = [in_deps, in_self];
80 .iter() 80
81 .copied() 81 let id_to_chalk = |id: hir_def::ImplId| Impl::ImplDef(id).to_chalk(self.db);
82 .map(Impl::ImplDef) 82
83 .map(|impl_| impl_.to_chalk(self.db)) 83 let mut result: Vec<_> = match self_ty_fp {
84 .collect(); 84 Some(fp) => impl_maps
85 .iter()
86 .flat_map(|crate_impl_defs| {
87 crate_impl_defs.lookup_impl_defs_for_trait_and_ty(trait_, fp).map(id_to_chalk)
88 })
89 .collect(),
90 None => impl_maps
91 .iter()
92 .flat_map(|crate_impl_defs| {
93 crate_impl_defs.lookup_impl_defs_for_trait(trait_).map(id_to_chalk)
94 })
95 .collect(),
96 };
85 97
86 let arg: Option<Ty> = 98 let arg: Option<Ty> =
87 parameters.get(1).map(|p| from_chalk(self.db, p.assert_ty_ref(&Interner).clone())); 99 parameters.get(1).map(|p| from_chalk(self.db, p.assert_ty_ref(&Interner).clone()));
diff --git a/crates/ra_hir_ty/src/utils.rs b/crates/ra_hir_ty/src/utils.rs
index f98350bf9..c45820ff0 100644
--- a/crates/ra_hir_ty/src/utils.rs
+++ b/crates/ra_hir_ty/src/utils.rs
@@ -143,13 +143,14 @@ pub(super) fn find_super_trait_path(
143} 143}
144 144
145pub(super) fn associated_type_by_name_including_super_traits( 145pub(super) fn associated_type_by_name_including_super_traits(
146 db: &dyn DefDatabase, 146 db: &dyn HirDatabase,
147 trait_: TraitId, 147 trait_ref: TraitRef,
148 name: &Name, 148 name: &Name,
149) -> Option<TypeAliasId> { 149) -> Option<(TraitRef, TypeAliasId)> {
150 all_super_traits(db, trait_) 150 all_super_trait_refs(db, trait_ref).into_iter().find_map(|t| {
151 .into_iter() 151 let assoc_type = db.trait_data(t.trait_).associated_type_by_name(name)?;
152 .find_map(|t| db.trait_data(t).associated_type_by_name(name)) 152 Some((t, assoc_type))
153 })
153} 154}
154 155
155pub(super) fn variant_data(db: &dyn DefDatabase, var: VariantId) -> Arc<VariantData> { 156pub(super) fn variant_data(db: &dyn DefDatabase, var: VariantId) -> Arc<VariantData> {
@@ -176,6 +177,7 @@ pub(crate) fn generics(db: &dyn DefDatabase, def: GenericDefId) -> Generics {
176 Generics { def, params: db.generic_params(def), parent_generics } 177 Generics { def, params: db.generic_params(def), parent_generics }
177} 178}
178 179
180#[derive(Debug)]
179pub(crate) struct Generics { 181pub(crate) struct Generics {
180 def: GenericDefId, 182 def: GenericDefId,
181 pub(crate) params: Arc<GenericParams>, 183 pub(crate) params: Arc<GenericParams>,