File tree Expand file tree Collapse file tree
compiler/rustc_hir_typeck/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,6 +147,14 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
147147 /// foo(1.0);
148148 /// ```
149149 fn calculate_fallback_to_f32 ( & self , unresolved_variables : & [ Ty < ' tcx > ] ) -> UnordSet < FloatVid > {
150+ // Short-circuit: if no unresolved variable is a float, no f32 fallback can apply,
151+ // so we can skip the (potentially very expensive) work in `from_float_for_f32_root_vids`.
152+ // Under the new solver, that function walks `visit_proof_tree` for every pending
153+ // obligation, which is O(N × proof_tree_size) and can dominate type-checking on crates
154+ // with many large pending obligations and no f32 involvement.
155+ if unresolved_variables. iter ( ) . all ( |ty| ty. float_vid ( ) . is_none ( ) ) {
156+ return UnordSet :: new ( ) ;
157+ }
150158 let roots: UnordSet < ty:: FloatVid > = self . from_float_for_f32_root_vids ( ) ;
151159 if roots. is_empty ( ) {
152160 // Most functions have no `f32: From<{float}>` predicates, so short-circuit and return
You can’t perform that action at this time.
0 commit comments