Skip to content

Commit 6c031fb

Browse files
committed
Apply review nits
1 parent b0e778f commit 6c031fb

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

compiler/rustc_hir_typeck/src/fallback.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,13 @@ use rustc_data_structures::{
88
use rustc_hir as hir;
99
use rustc_hir::intravisit::Visitor;
1010
use rustc_hir::HirId;
11-
use rustc_infer::{
12-
infer::{DefineOpaqueTypes, InferOk},
13-
traits::ObligationCause,
14-
};
11+
use rustc_infer::infer::{DefineOpaqueTypes, InferOk};
1512
use rustc_middle::bug;
1613
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable};
1714
use rustc_session::lint;
1815
use rustc_span::DUMMY_SP;
1916
use rustc_span::{def_id::LocalDefId, Span};
20-
use rustc_trait_selection::traits::ObligationCtxt;
21-
use rustc_type_ir::TyVid;
17+
use rustc_trait_selection::traits::{ObligationCause, ObligationCtxt};
2218

2319
#[derive(Copy, Clone)]
2420
pub enum DivergingFallbackBehavior {
@@ -480,7 +476,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
480476
fn lint_obligations_broken_by_never_type_fallback_change(
481477
&self,
482478
behavior: DivergingFallbackBehavior,
483-
diverging_vids: &[TyVid],
479+
diverging_vids: &[ty::TyVid],
484480
) {
485481
let DivergingFallbackBehavior::FallbackToUnit = behavior else { return };
486482

@@ -490,7 +486,7 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
490486
}
491487

492488
// Returns errors which happen if fallback is set to `fallback`
493-
let try_out = |fallback| {
489+
let remaining_errors_if_fallback_to = |fallback| {
494490
self.probe(|_| {
495491
let obligations = self.fulfillment_cx.borrow().pending_obligations();
496492
let ocx = ObligationCtxt::new(&self.infcx);
@@ -499,7 +495,8 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
499495
for &diverging_vid in diverging_vids {
500496
let diverging_ty = Ty::new_var(self.tcx, diverging_vid);
501497

502-
_ = ocx.eq(&ObligationCause::dummy(), self.param_env, diverging_ty, fallback);
498+
ocx.eq(&ObligationCause::dummy(), self.param_env, diverging_ty, fallback)
499+
.expect("expected diverging var to be unconstrained");
503500
}
504501

505502
ocx.select_where_possible()
@@ -508,9 +505,9 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
508505

509506
// If we have no errors with `fallback = ()`, but *do* have errors with `fallback = !`,
510507
// then this code will be broken by the never type fallback change.qba
511-
let unit_errors = try_out(self.tcx.types.unit);
508+
let unit_errors = remaining_errors_if_fallback_to(self.tcx.types.unit);
512509
if unit_errors.is_empty()
513-
&& let never_errors = try_out(self.tcx.types.never)
510+
&& let never_errors = remaining_errors_if_fallback_to(self.tcx.types.never)
514511
&& !never_errors.is_empty()
515512
{
516513
self.tcx.emit_node_span_lint(

0 commit comments

Comments
 (0)