Skip to content

Commit 0dc1626

Browse files
WaffleLapkincompiler-errors
authored andcommitted
Add a fast exit to lint_obligations_broken_by_never_type_fallback_change
1 parent c17a960 commit 0dc1626

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;
@@ -483,6 +483,11 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
483483
) {
484484
let DivergingFallbackBehavior::FallbackToUnit = behavior else { return };
485485

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

0 commit comments

Comments
 (0)