Skip to content

Commit f9b388b

Browse files
committed
Add a fast exit to lint_obligations_broken_by_never_type_fallback_change
1 parent 77da176 commit f9b388b

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;
@@ -479,6 +479,11 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
479479
) {
480480
let DivergingFallbackBehavior::FallbackToUnit = behavior else { return };
481481

482+
// Fallback happens if and only if there are diverging variables
483+
if diverging_vids.is_empty() {
484+
return;
485+
}
486+
482487
// Returns errors which happen if fallback is set to `fallback`
483488
let try_out = |fallback| {
484489
self.probe(|_| {

0 commit comments

Comments
 (0)