Skip to content

Commit 818ed69

Browse files
committed
dropck: simplify common patterns
1 parent e7b4bc3 commit 818ed69

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/librustc/traits/query/dropck_outlives.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
5555
let c_ty = self.infcx.canonicalize_query(&self.param_env.and(ty), &mut orig_values);
5656
let span = self.cause.span;
5757
debug!("c_ty = {:?}", c_ty);
58-
match &gcx.dropck_outlives(c_ty) {
59-
Ok(result) if result.is_proven() => {
58+
if let Ok(result) = &gcx.dropck_outlives(c_ty) {
59+
if result.is_proven() {
6060
if let Ok(InferOk { value, obligations }) =
6161
self.infcx.instantiate_query_response_and_region_obligations(
6262
self.cause,
@@ -72,8 +72,6 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
7272
};
7373
}
7474
}
75-
76-
_ => { /* fallthrough to error-handling code below */ }
7775
}
7876

7977
// Errors and ambiuity in dropck occur in two cases:
@@ -82,10 +80,11 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
8280
// Either of these should have created an error before.
8381
tcx.sess
8482
.delay_span_bug(span, "dtorck encountered internal error");
85-
return InferOk {
83+
84+
InferOk {
8685
value: vec![],
8786
obligations: vec![],
88-
};
87+
}
8988
}
9089
}
9190

@@ -102,7 +101,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
102101
span: Span,
103102
ty: Ty<'tcx>,
104103
) {
105-
for overflow_ty in self.overflows.iter().take(1) {
104+
if let Some(overflow_ty) = self.overflows.iter().next() {
106105
let mut err = struct_span_err!(
107106
tcx.sess,
108107
span,

0 commit comments

Comments
 (0)