Skip to content

Commit

Permalink
dropck: simplify common patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
ljedrz committed Dec 19, 2018
1 parent e7b4bc3 commit 818ed69
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/librustc/traits/query/dropck_outlives.rs
Expand Up @@ -55,8 +55,8 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
let c_ty = self.infcx.canonicalize_query(&self.param_env.and(ty), &mut orig_values);
let span = self.cause.span;
debug!("c_ty = {:?}", c_ty);
match &gcx.dropck_outlives(c_ty) {
Ok(result) if result.is_proven() => {
if let Ok(result) = &gcx.dropck_outlives(c_ty) {
if result.is_proven() {
if let Ok(InferOk { value, obligations }) =
self.infcx.instantiate_query_response_and_region_obligations(
self.cause,
Expand All @@ -72,8 +72,6 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
};
}
}

_ => { /* fallthrough to error-handling code below */ }
}

// Errors and ambiuity in dropck occur in two cases:
Expand All @@ -82,10 +80,11 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
// Either of these should have created an error before.
tcx.sess
.delay_span_bug(span, "dtorck encountered internal error");
return InferOk {

InferOk {
value: vec![],
obligations: vec![],
};
}
}
}

Expand All @@ -102,7 +101,7 @@ impl<'tcx> DropckOutlivesResult<'tcx> {
span: Span,
ty: Ty<'tcx>,
) {
for overflow_ty in self.overflows.iter().take(1) {
if let Some(overflow_ty) = self.overflows.iter().next() {
let mut err = struct_span_err!(
tcx.sess,
span,
Expand Down

0 comments on commit 818ed69

Please sign in to comment.