diff options
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r-- | crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/diagnostics/match_check/usefulness.rs | 6 | ||||
-rw-r--r-- | crates/hir_ty/src/infer.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/coerce.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 12 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/path.rs | 6 | ||||
-rw-r--r-- | crates/hir_ty/src/interner.rs | 6 | ||||
-rw-r--r-- | crates/hir_ty/src/lower.rs | 6 | ||||
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 14 |
10 files changed, 29 insertions, 29 deletions
diff --git a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs index 222141bd6..088d2791e 100644 --- a/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs +++ b/crates/hir_ty/src/diagnostics/match_check/deconstruct_pat.rs | |||
@@ -528,7 +528,7 @@ impl SplitWildcard { | |||
528 | smallvec![NonExhaustive] | 528 | smallvec![NonExhaustive] |
529 | } | 529 | } |
530 | TyKind::Never => SmallVec::new(), | 530 | TyKind::Never => SmallVec::new(), |
531 | _ if cx.is_uninhabited(&pcx.ty) => SmallVec::new(), | 531 | _ if cx.is_uninhabited(pcx.ty) => SmallVec::new(), |
532 | TyKind::Adt(..) | TyKind::Tuple(..) | TyKind::Ref(..) => smallvec![Single], | 532 | TyKind::Adt(..) | TyKind::Tuple(..) | TyKind::Ref(..) => smallvec![Single], |
533 | // This type is one for which we cannot list constructors, like `str` or `f64`. | 533 | // This type is one for which we cannot list constructors, like `str` or `f64`. |
534 | _ => smallvec![NonExhaustive], | 534 | _ => smallvec![NonExhaustive], |
diff --git a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs index bd76a606c..f5ac71444 100644 --- a/crates/hir_ty/src/diagnostics/match_check/usefulness.rs +++ b/crates/hir_ty/src/diagnostics/match_check/usefulness.rs | |||
@@ -645,7 +645,7 @@ impl SubPatSet { | |||
645 | (Seq { subpats: s_set }, Seq { subpats: mut o_set }) => { | 645 | (Seq { subpats: s_set }, Seq { subpats: mut o_set }) => { |
646 | s_set.retain(|i, s_sub_set| { | 646 | s_set.retain(|i, s_sub_set| { |
647 | // Missing entries count as full. | 647 | // Missing entries count as full. |
648 | let o_sub_set = o_set.remove(&i).unwrap_or(Full); | 648 | let o_sub_set = o_set.remove(i).unwrap_or(Full); |
649 | s_sub_set.union(o_sub_set); | 649 | s_sub_set.union(o_sub_set); |
650 | // We drop full entries. | 650 | // We drop full entries. |
651 | !s_sub_set.is_full() | 651 | !s_sub_set.is_full() |
@@ -656,7 +656,7 @@ impl SubPatSet { | |||
656 | (Alt { subpats: s_set, .. }, Alt { subpats: mut o_set, .. }) => { | 656 | (Alt { subpats: s_set, .. }, Alt { subpats: mut o_set, .. }) => { |
657 | s_set.retain(|i, s_sub_set| { | 657 | s_set.retain(|i, s_sub_set| { |
658 | // Missing entries count as empty. | 658 | // Missing entries count as empty. |
659 | let o_sub_set = o_set.remove(&i).unwrap_or(Empty); | 659 | let o_sub_set = o_set.remove(i).unwrap_or(Empty); |
660 | s_sub_set.union(o_sub_set); | 660 | s_sub_set.union(o_sub_set); |
661 | // We drop empty entries. | 661 | // We drop empty entries. |
662 | !s_sub_set.is_empty() | 662 | !s_sub_set.is_empty() |
@@ -898,7 +898,7 @@ impl Usefulness { | |||
898 | } else { | 898 | } else { |
899 | witnesses | 899 | witnesses |
900 | .into_iter() | 900 | .into_iter() |
901 | .map(|witness| witness.apply_constructor(pcx, &ctor, ctor_wild_subpatterns)) | 901 | .map(|witness| witness.apply_constructor(pcx, ctor, ctor_wild_subpatterns)) |
902 | .collect() | 902 | .collect() |
903 | }; | 903 | }; |
904 | WithWitnesses(new_witnesses) | 904 | WithWitnesses(new_witnesses) |
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index f023c1fb7..9590c2e47 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -782,7 +782,7 @@ impl Expectation { | |||
782 | fn adjust_for_branches(&self, table: &mut unify::InferenceTable) -> Expectation { | 782 | fn adjust_for_branches(&self, table: &mut unify::InferenceTable) -> Expectation { |
783 | match self { | 783 | match self { |
784 | Expectation::HasType(ety) => { | 784 | Expectation::HasType(ety) => { |
785 | let ety = table.resolve_ty_shallow(&ety); | 785 | let ety = table.resolve_ty_shallow(ety); |
786 | if !ety.is_ty_var() { | 786 | if !ety.is_ty_var() { |
787 | Expectation::HasType(ety) | 787 | Expectation::HasType(ety) |
788 | } else { | 788 | } else { |
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 03b97e7db..8647d7437 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs | |||
@@ -109,7 +109,7 @@ impl<'a> InferenceContext<'a> { | |||
109 | } | 109 | } |
110 | 110 | ||
111 | // Consider coercing the subtype to a DST | 111 | // Consider coercing the subtype to a DST |
112 | if let Ok(ret) = self.try_coerce_unsized(&from_ty, &to_ty) { | 112 | if let Ok(ret) = self.try_coerce_unsized(&from_ty, to_ty) { |
113 | return Ok(ret); | 113 | return Ok(ret); |
114 | } | 114 | } |
115 | 115 | ||
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index e34f194ff..4805c0a00 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -54,7 +54,7 @@ impl<'a> InferenceContext<'a> { | |||
54 | /// Infer type of expression with possibly implicit coerce to the expected type. | 54 | /// Infer type of expression with possibly implicit coerce to the expected type. |
55 | /// Return the type after possible coercion. | 55 | /// Return the type after possible coercion. |
56 | pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty { | 56 | pub(super) fn infer_expr_coerce(&mut self, expr: ExprId, expected: &Expectation) -> Ty { |
57 | let ty = self.infer_expr_inner(expr, &expected); | 57 | let ty = self.infer_expr_inner(expr, expected); |
58 | let ty = if let Some(target) = expected.only_has_type(&mut self.table) { | 58 | let ty = if let Some(target) = expected.only_has_type(&mut self.table) { |
59 | if !self.coerce(&ty, &target) { | 59 | if !self.coerce(&ty, &target) { |
60 | self.result | 60 | self.result |
@@ -135,11 +135,11 @@ impl<'a> InferenceContext<'a> { | |||
135 | let mut both_arms_diverge = Diverges::Always; | 135 | let mut both_arms_diverge = Diverges::Always; |
136 | 136 | ||
137 | let mut result_ty = self.table.new_type_var(); | 137 | let mut result_ty = self.table.new_type_var(); |
138 | let then_ty = self.infer_expr_inner(*then_branch, &expected); | 138 | let then_ty = self.infer_expr_inner(*then_branch, expected); |
139 | both_arms_diverge &= mem::replace(&mut self.diverges, Diverges::Maybe); | 139 | both_arms_diverge &= mem::replace(&mut self.diverges, Diverges::Maybe); |
140 | result_ty = self.coerce_merge_branch(Some(*then_branch), &result_ty, &then_ty); | 140 | result_ty = self.coerce_merge_branch(Some(*then_branch), &result_ty, &then_ty); |
141 | let else_ty = match else_branch { | 141 | let else_ty = match else_branch { |
142 | Some(else_branch) => self.infer_expr_inner(*else_branch, &expected), | 142 | Some(else_branch) => self.infer_expr_inner(*else_branch, expected), |
143 | None => TyBuilder::unit(), | 143 | None => TyBuilder::unit(), |
144 | }; | 144 | }; |
145 | both_arms_diverge &= self.diverges; | 145 | both_arms_diverge &= self.diverges; |
@@ -330,8 +330,8 @@ impl<'a> InferenceContext<'a> { | |||
330 | .infer_method_call( | 330 | .infer_method_call( |
331 | tgt_expr, | 331 | tgt_expr, |
332 | *receiver, | 332 | *receiver, |
333 | &args, | 333 | args, |
334 | &method_name, | 334 | method_name, |
335 | generic_args.as_deref(), | 335 | generic_args.as_deref(), |
336 | ), | 336 | ), |
337 | Expr::Match { expr, arms } => { | 337 | Expr::Match { expr, arms } => { |
@@ -993,7 +993,7 @@ impl<'a> InferenceContext<'a> { | |||
993 | } | 993 | } |
994 | 994 | ||
995 | fn register_obligations_for_call(&mut self, callable_ty: &Ty) { | 995 | fn register_obligations_for_call(&mut self, callable_ty: &Ty) { |
996 | let callable_ty = self.resolve_ty_shallow(&callable_ty); | 996 | let callable_ty = self.resolve_ty_shallow(callable_ty); |
997 | if let TyKind::FnDef(fn_def, parameters) = callable_ty.kind(&Interner) { | 997 | if let TyKind::FnDef(fn_def, parameters) = callable_ty.kind(&Interner) { |
998 | let def: CallableDefId = from_chalk(self.db, *fn_def); | 998 | let def: CallableDefId = from_chalk(self.db, *fn_def); |
999 | let generic_predicates = self.db.generic_predicates(def.into()); | 999 | let generic_predicates = self.db.generic_predicates(def.into()); |
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 25dff7e49..8f5db1f40 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -192,7 +192,7 @@ impl<'a> InferenceContext<'a> { | |||
192 | Pat::Path(path) => { | 192 | Pat::Path(path) => { |
193 | // FIXME use correct resolver for the surrounding expression | 193 | // FIXME use correct resolver for the surrounding expression |
194 | let resolver = self.resolver.clone(); | 194 | let resolver = self.resolver.clone(); |
195 | self.infer_path(&resolver, &path, pat.into()).unwrap_or(self.err_ty()) | 195 | self.infer_path(&resolver, path, pat.into()).unwrap_or(self.err_ty()) |
196 | } | 196 | } |
197 | Pat::Bind { mode, name: _, subpat } => { | 197 | Pat::Bind { mode, name: _, subpat } => { |
198 | let mode = if mode == &BindingAnnotation::Unannotated { | 198 | let mode = if mode == &BindingAnnotation::Unannotated { |
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index 14c99eafd..056cdb5d5 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs | |||
@@ -43,11 +43,11 @@ impl<'a> InferenceContext<'a> { | |||
43 | } | 43 | } |
44 | let ty = self.make_ty(type_ref); | 44 | let ty = self.make_ty(type_ref); |
45 | let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1); | 45 | let remaining_segments_for_ty = path.segments().take(path.segments().len() - 1); |
46 | let ctx = crate::lower::TyLoweringContext::new(self.db, &resolver); | 46 | let ctx = crate::lower::TyLoweringContext::new(self.db, resolver); |
47 | let (ty, _) = ctx.lower_ty_relative_path(ty, None, remaining_segments_for_ty); | 47 | let (ty, _) = ctx.lower_ty_relative_path(ty, None, remaining_segments_for_ty); |
48 | self.resolve_ty_assoc_item( | 48 | self.resolve_ty_assoc_item( |
49 | ty, | 49 | ty, |
50 | &path.segments().last().expect("path had at least one segment").name, | 50 | path.segments().last().expect("path had at least one segment").name, |
51 | id, | 51 | id, |
52 | )? | 52 | )? |
53 | } else { | 53 | } else { |
@@ -154,7 +154,7 @@ impl<'a> InferenceContext<'a> { | |||
154 | let segment = | 154 | let segment = |
155 | remaining_segments.last().expect("there should be at least one segment here"); | 155 | remaining_segments.last().expect("there should be at least one segment here"); |
156 | 156 | ||
157 | self.resolve_ty_assoc_item(ty, &segment.name, id) | 157 | self.resolve_ty_assoc_item(ty, segment.name, id) |
158 | } | 158 | } |
159 | } | 159 | } |
160 | } | 160 | } |
diff --git a/crates/hir_ty/src/interner.rs b/crates/hir_ty/src/interner.rs index 29ffdd9b7..5fef878e8 100644 --- a/crates/hir_ty/src/interner.rs +++ b/crates/hir_ty/src/interner.rs | |||
@@ -331,7 +331,7 @@ impl chalk_ir::interner::Interner for Interner { | |||
331 | &self, | 331 | &self, |
332 | clauses: &'a Self::InternedProgramClauses, | 332 | clauses: &'a Self::InternedProgramClauses, |
333 | ) -> &'a [chalk_ir::ProgramClause<Self>] { | 333 | ) -> &'a [chalk_ir::ProgramClause<Self>] { |
334 | &clauses | 334 | clauses |
335 | } | 335 | } |
336 | 336 | ||
337 | fn intern_quantified_where_clauses<E>( | 337 | fn intern_quantified_where_clauses<E>( |
@@ -373,7 +373,7 @@ impl chalk_ir::interner::Interner for Interner { | |||
373 | &self, | 373 | &self, |
374 | canonical_var_kinds: &'a Self::InternedCanonicalVarKinds, | 374 | canonical_var_kinds: &'a Self::InternedCanonicalVarKinds, |
375 | ) -> &'a [chalk_ir::CanonicalVarKind<Self>] { | 375 | ) -> &'a [chalk_ir::CanonicalVarKind<Self>] { |
376 | &canonical_var_kinds | 376 | canonical_var_kinds |
377 | } | 377 | } |
378 | 378 | ||
379 | fn intern_constraints<E>( | 379 | fn intern_constraints<E>( |
@@ -413,7 +413,7 @@ impl chalk_ir::interner::Interner for Interner { | |||
413 | &self, | 413 | &self, |
414 | variances: &'a Self::InternedVariances, | 414 | variances: &'a Self::InternedVariances, |
415 | ) -> &'a [chalk_ir::Variance] { | 415 | ) -> &'a [chalk_ir::Variance] { |
416 | &variances | 416 | variances |
417 | } | 417 | } |
418 | } | 418 | } |
419 | 419 | ||
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index c83933c73..0b8f21e5d 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -238,7 +238,7 @@ impl<'a> TyLoweringContext<'a> { | |||
238 | // away instead of two. | 238 | // away instead of two. |
239 | let actual_opaque_type_data = self | 239 | let actual_opaque_type_data = self |
240 | .with_debruijn(DebruijnIndex::INNERMOST, |ctx| { | 240 | .with_debruijn(DebruijnIndex::INNERMOST, |ctx| { |
241 | ctx.lower_impl_trait(&bounds) | 241 | ctx.lower_impl_trait(bounds) |
242 | }); | 242 | }); |
243 | self.opaque_type_data.borrow_mut()[idx as usize] = actual_opaque_type_data; | 243 | self.opaque_type_data.borrow_mut()[idx as usize] = actual_opaque_type_data; |
244 | 244 | ||
@@ -421,7 +421,7 @@ impl<'a> TyLoweringContext<'a> { | |||
421 | let found = self | 421 | let found = self |
422 | .db | 422 | .db |
423 | .trait_data(trait_ref.hir_trait_id()) | 423 | .trait_data(trait_ref.hir_trait_id()) |
424 | .associated_type_by_name(&segment.name); | 424 | .associated_type_by_name(segment.name); |
425 | match found { | 425 | match found { |
426 | Some(associated_ty) => { | 426 | Some(associated_ty) => { |
427 | // FIXME handle type parameters on the segment | 427 | // FIXME handle type parameters on the segment |
@@ -505,7 +505,7 @@ impl<'a> TyLoweringContext<'a> { | |||
505 | pub(crate) fn lower_path(&self, path: &Path) -> (Ty, Option<TypeNs>) { | 505 | pub(crate) fn lower_path(&self, path: &Path) -> (Ty, Option<TypeNs>) { |
506 | // Resolve the path (in type namespace) | 506 | // Resolve the path (in type namespace) |
507 | if let Some(type_ref) = path.type_anchor() { | 507 | if let Some(type_ref) = path.type_anchor() { |
508 | let (ty, res) = self.lower_ty_ext(&type_ref); | 508 | let (ty, res) = self.lower_ty_ext(type_ref); |
509 | return self.lower_ty_relative_path(ty, res, path.segments()); | 509 | return self.lower_ty_relative_path(ty, res, path.segments()); |
510 | } | 510 | } |
511 | let (resolution, remaining_index) = | 511 | let (resolution, remaining_index) = |
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index a23527f7d..8c00a6369 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -372,7 +372,7 @@ pub(crate) fn lookup_method( | |||
372 | db, | 372 | db, |
373 | env, | 373 | env, |
374 | krate, | 374 | krate, |
375 | &traits_in_scope, | 375 | traits_in_scope, |
376 | visible_from_module, | 376 | visible_from_module, |
377 | Some(name), | 377 | Some(name), |
378 | LookupMode::MethodCall, | 378 | LookupMode::MethodCall, |
@@ -484,7 +484,7 @@ fn iterate_method_candidates_impl( | |||
484 | LookupMode::Path => { | 484 | LookupMode::Path => { |
485 | // No autoderef for path lookups | 485 | // No autoderef for path lookups |
486 | iterate_method_candidates_for_self_ty( | 486 | iterate_method_candidates_for_self_ty( |
487 | &ty, | 487 | ty, |
488 | db, | 488 | db, |
489 | env, | 489 | env, |
490 | krate, | 490 | krate, |
@@ -513,7 +513,7 @@ fn iterate_method_candidates_with_autoref( | |||
513 | db, | 513 | db, |
514 | env.clone(), | 514 | env.clone(), |
515 | krate, | 515 | krate, |
516 | &traits_in_scope, | 516 | traits_in_scope, |
517 | visible_from_module, | 517 | visible_from_module, |
518 | name, | 518 | name, |
519 | &mut callback, | 519 | &mut callback, |
@@ -531,7 +531,7 @@ fn iterate_method_candidates_with_autoref( | |||
531 | db, | 531 | db, |
532 | env.clone(), | 532 | env.clone(), |
533 | krate, | 533 | krate, |
534 | &traits_in_scope, | 534 | traits_in_scope, |
535 | visible_from_module, | 535 | visible_from_module, |
536 | name, | 536 | name, |
537 | &mut callback, | 537 | &mut callback, |
@@ -549,7 +549,7 @@ fn iterate_method_candidates_with_autoref( | |||
549 | db, | 549 | db, |
550 | env, | 550 | env, |
551 | krate, | 551 | krate, |
552 | &traits_in_scope, | 552 | traits_in_scope, |
553 | visible_from_module, | 553 | visible_from_module, |
554 | name, | 554 | name, |
555 | &mut callback, | 555 | &mut callback, |
@@ -593,7 +593,7 @@ fn iterate_method_candidates_by_receiver( | |||
593 | db, | 593 | db, |
594 | env.clone(), | 594 | env.clone(), |
595 | krate, | 595 | krate, |
596 | &traits_in_scope, | 596 | traits_in_scope, |
597 | name, | 597 | name, |
598 | Some(receiver_ty), | 598 | Some(receiver_ty), |
599 | &mut callback, | 599 | &mut callback, |
@@ -870,7 +870,7 @@ fn transform_receiver_ty( | |||
870 | .fill_with_unknown() | 870 | .fill_with_unknown() |
871 | .build(), | 871 | .build(), |
872 | AssocContainerId::ImplId(impl_id) => { | 872 | AssocContainerId::ImplId(impl_id) => { |
873 | let impl_substs = inherent_impl_substs(db, env, impl_id, &self_ty)?; | 873 | let impl_substs = inherent_impl_substs(db, env, impl_id, self_ty)?; |
874 | TyBuilder::subst_for_def(db, function_id) | 874 | TyBuilder::subst_for_def(db, function_id) |
875 | .use_parent_substs(&impl_substs) | 875 | .use_parent_substs(&impl_substs) |
876 | .fill_with_unknown() | 876 | .fill_with_unknown() |