Skip to content

Commit b0e778f

Browse files
committed
Add a fast exit to lint_obligations_broken_by_never_type_fallback_change
1 parent bc66f24 commit b0e778f

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

compiler/rustc_hir_typeck/src/fallback.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use rustc_data_structures::{
88
use rustc_hir as hir;
99
use rustc_hir::intravisit::Visitor;
1010
use rustc_hir::HirId;
11-
use rustc_middle::bug;
1211
use rustc_infer::{
1312
infer::{DefineOpaqueTypes, InferOk},
1413
traits::ObligationCause,
1514
};
15+
use rustc_middle::bug;
1616
use rustc_middle::ty::{self, Ty, TyCtxt, TypeSuperVisitable, TypeVisitable};
1717
use rustc_session::lint;
1818
use rustc_span::DUMMY_SP;
@@ -484,6 +484,11 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
484484
) {
485485
let DivergingFallbackBehavior::FallbackToUnit = behavior else { return };
486486

487+
// Fallback happens if and only if there are diverging variables
488+
if diverging_vids.is_empty() {
489+
return;
490+
}
491+
487492
// Returns errors which happen if fallback is set to `fallback`
488493
let try_out = |fallback| {
489494
self.probe(|_| {

0 commit comments

Comments
 (0)