Skip to content

Commit 2fa796a

Browse files
Expect clause more
1 parent 46a650f commit 2fa796a

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

compiler/rustc_hir_analysis/src/collect/item_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ fn associated_type_bounds<'tcx>(
4747
}
4848
_ => false,
4949
})
50-
.map(|(pred, span)| (pred.as_clause().unwrap(), span));
50+
.map(|(pred, span)| (pred.expect_clause(), span));
5151

5252
let all_bounds = tcx.arena.alloc_from_iter(bounds.clauses().chain(bounds_from_parent));
5353
debug!(

compiler/rustc_infer/src/traits/util.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Clause<'tcx>, Span) {
173173
}
174174

175175
fn child(&self, predicate: ty::Predicate<'tcx>) -> Self {
176-
(predicate.as_clause().unwrap(), self.1)
176+
(predicate.expect_clause(), self.1)
177177
}
178178

179179
fn child_with_derived_cause(
@@ -183,7 +183,7 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Clause<'tcx>, Span) {
183183
_parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
184184
_index: usize,
185185
) -> Self {
186-
(predicate.as_clause().unwrap(), self.1)
186+
(predicate.expect_clause(), self.1)
187187
}
188188
}
189189

@@ -193,7 +193,7 @@ impl<'tcx> Elaboratable<'tcx> for ty::Clause<'tcx> {
193193
}
194194

195195
fn child(&self, predicate: ty::Predicate<'tcx>) -> Self {
196-
predicate.as_clause().unwrap()
196+
predicate.expect_clause()
197197
}
198198

199199
fn child_with_derived_cause(
@@ -203,7 +203,7 @@ impl<'tcx> Elaboratable<'tcx> for ty::Clause<'tcx> {
203203
_parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
204204
_index: usize,
205205
) -> Self {
206-
predicate.as_clause().unwrap()
206+
predicate.expect_clause()
207207
}
208208
}
209209

compiler/rustc_middle/src/ty/codec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for ty::Predicate<'tcx>
250250
impl<'tcx, D: TyDecoder<I = TyCtxt<'tcx>>> Decodable<D> for ty::Clause<'tcx> {
251251
fn decode(decoder: &mut D) -> ty::Clause<'tcx> {
252252
let pred: ty::Predicate<'tcx> = Decodable::decode(decoder);
253-
pred.as_clause().unwrap()
253+
pred.expect_clause()
254254
}
255255
}
256256

compiler/rustc_middle/src/ty/structural_impls.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for ty::Clause<'tcx> {
666666
self,
667667
folder: &mut F,
668668
) -> Result<Self, F::Error> {
669-
Ok(folder
670-
.try_fold_predicate(self.as_predicate())?
671-
.as_clause()
672-
.expect("no sensible folder would do this"))
669+
Ok(folder.try_fold_predicate(self.as_predicate())?.expect_clause())
673670
}
674671
}
675672

0 commit comments

Comments
 (0)