aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-03-20 09:51:00 +0000
committerFlorian Diebold <[email protected]>2021-03-20 09:51:00 +0000
commit8e7e405f6ab0c1ee10bfdd3d55a97628fe4cd6dd (patch)
treeebdcea14c479ddfca358bbeabdde1da8f45b2423 /crates
parent7a5fb37cf12f4e25ce1ba7e464dd257408444bfb (diff)
Remove WhereClause::Error
Chalk doesn't have it, and judging from the removed code, it wasn't useful anyway.
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/display.rs12
-rw-r--r--crates/hir_ty/src/lib.rs11
-rw-r--r--crates/hir_ty/src/lower.rs7
-rw-r--r--crates/hir_ty/src/tests/traits.rs4
-rw-r--r--crates/hir_ty/src/traits.rs1
-rw-r--r--crates/hir_ty/src/traits/chalk.rs8
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs7
7 files changed, 8 insertions, 42 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index 2721b8312..4765c99a4 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -731,16 +731,6 @@ fn write_bounds_like_dyn_trait(
731 } 731 }
732 ty.hir_fmt(f)?; 732 ty.hir_fmt(f)?;
733 } 733 }
734 WhereClause::Error => {
735 if angle_open {
736 // impl Trait<X, {error}>
737 write!(f, ", ")?;
738 } else if !first {
739 // impl Trait + {error}
740 write!(f, " + ")?;
741 }
742 p.hir_fmt(f)?;
743 }
744 } 734 }
745 first = false; 735 first = false;
746 } 736 }
@@ -796,7 +786,7 @@ impl HirDisplay for WhereClause {
796 )?; 786 )?;
797 ty.hir_fmt(f)?; 787 ty.hir_fmt(f)?;
798 } 788 }
799 WhereClause::AliasEq(_) | WhereClause::Error => write!(f, "{{error}}")?, 789 WhereClause::AliasEq(_) => write!(f, "{{error}}")?,
800 } 790 }
801 Ok(()) 791 Ok(())
802 } 792 }
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 5c4d5a7d7..8de2d422f 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -569,16 +569,9 @@ pub enum WhereClause {
569 Implemented(TraitRef), 569 Implemented(TraitRef),
570 /// An associated type bindings like in `Iterator<Item = T>`. 570 /// An associated type bindings like in `Iterator<Item = T>`.
571 AliasEq(AliasEq), 571 AliasEq(AliasEq),
572 /// We couldn't resolve the trait reference. (If some type parameters can't
573 /// be resolved, they will just be Unknown).
574 Error,
575} 572}
576 573
577impl WhereClause { 574impl WhereClause {
578 pub fn is_error(&self) -> bool {
579 matches!(self, WhereClause::Error)
580 }
581
582 pub fn is_implemented(&self) -> bool { 575 pub fn is_implemented(&self) -> bool {
583 matches!(self, WhereClause::Implemented(_)) 576 matches!(self, WhereClause::Implemented(_))
584 } 577 }
@@ -589,7 +582,7 @@ impl WhereClause {
589 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), .. }) => { 582 WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), .. }) => {
590 Some(proj.trait_ref(db)) 583 Some(proj.trait_ref(db))
591 } 584 }
592 WhereClause::AliasEq(_) | WhereClause::Error => None, 585 WhereClause::AliasEq(_) => None,
593 } 586 }
594 } 587 }
595} 588}
@@ -599,7 +592,6 @@ impl TypeWalk for WhereClause {
599 match self { 592 match self {
600 WhereClause::Implemented(trait_ref) => trait_ref.walk(f), 593 WhereClause::Implemented(trait_ref) => trait_ref.walk(f),
601 WhereClause::AliasEq(alias_eq) => alias_eq.walk(f), 594 WhereClause::AliasEq(alias_eq) => alias_eq.walk(f),
602 WhereClause::Error => {}
603 } 595 }
604 } 596 }
605 597
@@ -611,7 +603,6 @@ impl TypeWalk for WhereClause {
611 match self { 603 match self {
612 WhereClause::Implemented(trait_ref) => trait_ref.walk_mut_binders(f, binders), 604 WhereClause::Implemented(trait_ref) => trait_ref.walk_mut_binders(f, binders),
613 WhereClause::AliasEq(alias_eq) => alias_eq.walk_mut_binders(f, binders), 605 WhereClause::AliasEq(alias_eq) => alias_eq.walk_mut_binders(f, binders),
614 WhereClause::Error => {}
615 } 606 }
616 } 607 }
617} 608}
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 4199dc7a6..cbbb535e5 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -703,10 +703,10 @@ impl<'a> TyLoweringContext<'a> {
703 let trait_ref = match bound { 703 let trait_ref = match bound {
704 TypeBound::Path(path) => { 704 TypeBound::Path(path) => {
705 bindings = self.lower_trait_ref_from_path(path, Some(self_ty)); 705 bindings = self.lower_trait_ref_from_path(path, Some(self_ty));
706 Some(bindings.clone().map_or(WhereClause::Error, WhereClause::Implemented)) 706 bindings.clone().map(WhereClause::Implemented)
707 } 707 }
708 TypeBound::Lifetime(_) => None, 708 TypeBound::Lifetime(_) => None,
709 TypeBound::Error => Some(WhereClause::Error), 709 TypeBound::Error => None,
710 }; 710 };
711 trait_ref.into_iter().chain( 711 trait_ref.into_iter().chain(
712 bindings 712 bindings
@@ -919,9 +919,6 @@ pub(crate) fn trait_environment_query(
919 let mut clauses = Vec::new(); 919 let mut clauses = Vec::new();
920 for pred in resolver.where_predicates_in_scope() { 920 for pred in resolver.where_predicates_in_scope() {
921 for pred in ctx.lower_where_predicate(pred) { 921 for pred in ctx.lower_where_predicate(pred) {
922 if pred.is_error() {
923 continue;
924 }
925 if let WhereClause::Implemented(tr) = &pred { 922 if let WhereClause::Implemented(tr) = &pred {
926 traits_in_scope.push((tr.self_type_parameter().clone(), tr.hir_trait_id())); 923 traits_in_scope.push((tr.self_type_parameter().clone(), tr.hir_trait_id()));
927 } 924 }
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index 8270fa219..8f2bdffc0 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -1412,8 +1412,8 @@ fn weird_bounds() {
1412 50..51 'b': impl 1412 50..51 'b': impl
1413 69..70 'c': impl Trait 1413 69..70 'c': impl Trait
1414 86..87 'd': impl 1414 86..87 'd': impl
1415 107..108 'e': impl {error} 1415 107..108 'e': impl
1416 123..124 'f': impl Trait + {error} 1416 123..124 'f': impl Trait
1417 147..149 '{}': () 1417 147..149 '{}': ()
1418 "#]], 1418 "#]],
1419 ); 1419 );
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs
index 6feb64ceb..87c92bd12 100644
--- a/crates/hir_ty/src/traits.rs
+++ b/crates/hir_ty/src/traits.rs
@@ -100,7 +100,6 @@ impl Obligation {
100 match predicate { 100 match predicate {
101 WhereClause::Implemented(trait_ref) => Some(Obligation::Trait(trait_ref)), 101 WhereClause::Implemented(trait_ref) => Some(Obligation::Trait(trait_ref)),
102 WhereClause::AliasEq(alias_eq) => Some(Obligation::AliasEq(alias_eq)), 102 WhereClause::AliasEq(alias_eq) => Some(Obligation::AliasEq(alias_eq)),
103 WhereClause::Error => None,
104 } 103 }
105 } 104 }
106} 105}
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index 4144035cd..734679414 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -187,13 +187,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
187 let data = &datas.value.impl_traits[idx as usize]; 187 let data = &datas.value.impl_traits[idx as usize];
188 let bound = OpaqueTyDatumBound { 188 let bound = OpaqueTyDatumBound {
189 bounds: make_binders( 189 bounds: make_binders(
190 data.bounds 190 data.bounds.value.iter().cloned().map(|b| b.to_chalk(self.db)).collect(),
191 .value
192 .iter()
193 .cloned()
194 .filter(|b| !b.is_error())
195 .map(|b| b.to_chalk(self.db))
196 .collect(),
197 1, 191 1,
198 ), 192 ),
199 where_clauses: make_binders(vec![], 0), 193 where_clauses: make_binders(vec![], 0),
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 5756e9754..7841c216c 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -98,7 +98,7 @@ impl ToChalk for Ty {
98 TyKind::Dyn(predicates) => { 98 TyKind::Dyn(predicates) => {
99 let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter( 99 let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter(
100 &Interner, 100 &Interner,
101 predicates.iter().filter(|p| !p.is_error()).cloned().map(|p| p.to_chalk(db)), 101 predicates.iter().cloned().map(|p| p.to_chalk(db)),
102 ); 102 );
103 let bounded_ty = chalk_ir::DynTy { 103 let bounded_ty = chalk_ir::DynTy {
104 bounds: make_binders(where_clauses, 1), 104 bounds: make_binders(where_clauses, 1),
@@ -318,7 +318,6 @@ impl ToChalk for WhereClause {
318 chalk_ir::WhereClause::AliasEq(alias_eq.to_chalk(db).shifted_in(&Interner)), 318 chalk_ir::WhereClause::AliasEq(alias_eq.to_chalk(db).shifted_in(&Interner)),
319 0, 319 0,
320 ), 320 ),
321 WhereClause::Error => panic!("tried passing GenericPredicate::Error to Chalk"),
322 } 321 }
323 } 322 }
324 323
@@ -521,10 +520,6 @@ pub(super) fn convert_where_clauses(
521 let generic_predicates = db.generic_predicates(def); 520 let generic_predicates = db.generic_predicates(def);
522 let mut result = Vec::with_capacity(generic_predicates.len()); 521 let mut result = Vec::with_capacity(generic_predicates.len());
523 for pred in generic_predicates.iter() { 522 for pred in generic_predicates.iter() {
524 if pred.value.is_error() {
525 // skip errored predicates completely
526 continue;
527 }
528 result.push(pred.clone().subst(substs).to_chalk(db)); 523 result.push(pred.clone().subst(substs).to_chalk(db));
529 } 524 }
530 result 525 result