Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions compiler/rustc_hir_typeck/src/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ impl<'tcx> FnCtxt<'_, 'tcx> {
/// foo(1.0);
/// ```
fn calculate_fallback_to_f32(&self, unresolved_variables: &[Ty<'tcx>]) -> UnordSet<FloatVid> {
// Short-circuit: if no unresolved variable is a float, no f32 fallback can apply,
// so we can skip the (potentially very expensive) work in `from_float_for_f32_root_vids`.
// Under the new solver, that function walks `visit_proof_tree` for every pending
// obligation, which is O(N × proof_tree_size) and can dominate type-checking on crates
// with many large pending obligations and no f32 involvement.
if unresolved_variables.iter().all(|ty| ty.float_vid().is_none()) {
return UnordSet::new();
}
let roots: UnordSet<ty::FloatVid> = self.from_float_for_f32_root_vids();
if roots.is_empty() {
// Most functions have no `f32: From<{float}>` predicates, so short-circuit and return
Expand Down
Loading