Skip to content

Commit 8e7e405

Browse files
committed
Remove WhereClause::Error
Chalk doesn't have it, and judging from the removed code, it wasn't useful anyway.
1 parent 7a5fb37 commit 8e7e405

File tree

7 files changed

+8
-42
lines changed

7 files changed

+8
-42
lines changed

crates/hir_ty/src/display.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -731,16 +731,6 @@ fn write_bounds_like_dyn_trait(
731731
}
732732
ty.hir_fmt(f)?;
733733
}
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-
}
744734
}
745735
first = false;
746736
}
@@ -796,7 +786,7 @@ impl HirDisplay for WhereClause {
796786
)?;
797787
ty.hir_fmt(f)?;
798788
}
799-
WhereClause::AliasEq(_) | WhereClause::Error => write!(f, "{{error}}")?,
789+
WhereClause::AliasEq(_) => write!(f, "{{error}}")?,
800790
}
801791
Ok(())
802792
}

crates/hir_ty/src/lib.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,9 @@ pub enum WhereClause {
569569
Implemented(TraitRef),
570570
/// An associated type bindings like in `Iterator<Item = T>`.
571571
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,
575572
}
576573

577574
impl WhereClause {
578-
pub fn is_error(&self) -> bool {
579-
matches!(self, WhereClause::Error)
580-
}
581-
582575
pub fn is_implemented(&self) -> bool {
583576
matches!(self, WhereClause::Implemented(_))
584577
}
@@ -589,7 +582,7 @@ impl WhereClause {
589582
WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), .. }) => {
590583
Some(proj.trait_ref(db))
591584
}
592-
WhereClause::AliasEq(_) | WhereClause::Error => None,
585+
WhereClause::AliasEq(_) => None,
593586
}
594587
}
595588
}
@@ -599,7 +592,6 @@ impl TypeWalk for WhereClause {
599592
match self {
600593
WhereClause::Implemented(trait_ref) => trait_ref.walk(f),
601594
WhereClause::AliasEq(alias_eq) => alias_eq.walk(f),
602-
WhereClause::Error => {}
603595
}
604596
}
605597

@@ -611,7 +603,6 @@ impl TypeWalk for WhereClause {
611603
match self {
612604
WhereClause::Implemented(trait_ref) => trait_ref.walk_mut_binders(f, binders),
613605
WhereClause::AliasEq(alias_eq) => alias_eq.walk_mut_binders(f, binders),
614-
WhereClause::Error => {}
615606
}
616607
}
617608
}

crates/hir_ty/src/lower.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -703,10 +703,10 @@ impl<'a> TyLoweringContext<'a> {
703703
let trait_ref = match bound {
704704
TypeBound::Path(path) => {
705705
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)
707707
}
708708
TypeBound::Lifetime(_) => None,
709-
TypeBound::Error => Some(WhereClause::Error),
709+
TypeBound::Error => None,
710710
};
711711
trait_ref.into_iter().chain(
712712
bindings
@@ -919,9 +919,6 @@ pub(crate) fn trait_environment_query(
919919
let mut clauses = Vec::new();
920920
for pred in resolver.where_predicates_in_scope() {
921921
for pred in ctx.lower_where_predicate(pred) {
922-
if pred.is_error() {
923-
continue;
924-
}
925922
if let WhereClause::Implemented(tr) = &pred {
926923
traits_in_scope.push((tr.self_type_parameter().clone(), tr.hir_trait_id()));
927924
}

crates/hir_ty/src/tests/traits.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,8 +1412,8 @@ fn weird_bounds() {
14121412
50..51 'b': impl
14131413
69..70 'c': impl Trait
14141414
86..87 'd': impl
1415-
107..108 'e': impl {error}
1416-
123..124 'f': impl Trait + {error}
1415+
107..108 'e': impl
1416+
123..124 'f': impl Trait
14171417
147..149 '{}': ()
14181418
"#]],
14191419
);

crates/hir_ty/src/traits.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ impl Obligation {
100100
match predicate {
101101
WhereClause::Implemented(trait_ref) => Some(Obligation::Trait(trait_ref)),
102102
WhereClause::AliasEq(alias_eq) => Some(Obligation::AliasEq(alias_eq)),
103-
WhereClause::Error => None,
104103
}
105104
}
106105
}

crates/hir_ty/src/traits/chalk.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
187187
let data = &datas.value.impl_traits[idx as usize];
188188
let bound = OpaqueTyDatumBound {
189189
bounds: make_binders(
190-
data.bounds
191-
.value
192-
.iter()
193-
.cloned()
194-
.filter(|b| !b.is_error())
195-
.map(|b| b.to_chalk(self.db))
196-
.collect(),
190+
data.bounds.value.iter().cloned().map(|b| b.to_chalk(self.db)).collect(),
197191
1,
198192
),
199193
where_clauses: make_binders(vec![], 0),

crates/hir_ty/src/traits/chalk/mapping.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ impl ToChalk for Ty {
9898
TyKind::Dyn(predicates) => {
9999
let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter(
100100
&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)),
102102
);
103103
let bounded_ty = chalk_ir::DynTy {
104104
bounds: make_binders(where_clauses, 1),
@@ -318,7 +318,6 @@ impl ToChalk for WhereClause {
318318
chalk_ir::WhereClause::AliasEq(alias_eq.to_chalk(db).shifted_in(&Interner)),
319319
0,
320320
),
321-
WhereClause::Error => panic!("tried passing GenericPredicate::Error to Chalk"),
322321
}
323322
}
324323

@@ -521,10 +520,6 @@ pub(super) fn convert_where_clauses(
521520
let generic_predicates = db.generic_predicates(def);
522521
let mut result = Vec::with_capacity(generic_predicates.len());
523522
for pred in generic_predicates.iter() {
524-
if pred.value.is_error() {
525-
// skip errored predicates completely
526-
continue;
527-
}
528523
result.push(pred.clone().subst(substs).to_chalk(db));
529524
}
530525
result

0 commit comments

Comments
 (0)