Skip to content

Commit ba8b4a4

Browse files
committed
Use let else here
1 parent 9c076f3 commit ba8b4a4

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

compiler/rustc_trait_selection/src/traits/coherence.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -387,42 +387,42 @@ fn resolve_negative_obligation<'cx, 'tcx>(
387387
) -> bool {
388388
let tcx = infcx.tcx;
389389

390-
if let Some(o) = o.flip_polarity(tcx) {
391-
let mut fulfillment_cx = FulfillmentContext::new();
392-
fulfillment_cx.register_predicate_obligation(infcx, o);
390+
let Some(o) = o.flip_polarity(tcx) else {
391+
return false;
392+
};
393393

394-
let errors = fulfillment_cx.select_all_or_error(infcx);
394+
let mut fulfillment_cx = FulfillmentContext::new();
395+
fulfillment_cx.register_predicate_obligation(infcx, o);
395396

396-
if !errors.is_empty() {
397-
return false;
398-
}
397+
let errors = fulfillment_cx.select_all_or_error(infcx);
399398

400-
let mut outlives_env = OutlivesEnvironment::new(param_env);
401-
// FIXME -- add "assumed to be well formed" types into the `outlives_env`
399+
if !errors.is_empty() {
400+
return false;
401+
}
402402

403-
// "Save" the accumulated implied bounds into the outlives environment
404-
// (due to the FIXME above, there aren't any, but this step is still needed).
405-
// The "body id" is given as `CRATE_HIR_ID`, which is the same body-id used
406-
// by the "dummy" causes elsewhere (body-id is only relevant when checking
407-
// function bodies with closures).
408-
outlives_env.save_implied_bounds(CRATE_HIR_ID);
403+
let mut outlives_env = OutlivesEnvironment::new(param_env);
404+
// FIXME -- add "assumed to be well formed" types into the `outlives_env`
409405

410-
infcx.process_registered_region_obligations(
411-
outlives_env.region_bound_pairs_map(),
412-
Some(tcx.lifetimes.re_root_empty),
413-
param_env,
414-
);
406+
// "Save" the accumulated implied bounds into the outlives environment
407+
// (due to the FIXME above, there aren't any, but this step is still needed).
408+
// The "body id" is given as `CRATE_HIR_ID`, which is the same body-id used
409+
// by the "dummy" causes elsewhere (body-id is only relevant when checking
410+
// function bodies with closures).
411+
outlives_env.save_implied_bounds(CRATE_HIR_ID);
415412

416-
let errors = infcx.resolve_regions(region_context, &outlives_env, RegionckMode::default());
413+
infcx.process_registered_region_obligations(
414+
outlives_env.region_bound_pairs_map(),
415+
Some(tcx.lifetimes.re_root_empty),
416+
param_env,
417+
);
417418

418-
if !errors.is_empty() {
419-
return false;
420-
}
419+
let errors = infcx.resolve_regions(region_context, &outlives_env, RegionckMode::default());
421420

422-
return true;
421+
if !errors.is_empty() {
422+
return false;
423423
}
424424

425-
false
425+
true
426426
}
427427

428428
pub fn trait_ref_is_knowable<'tcx>(

0 commit comments

Comments
 (0)