Repository: rust-lang/rust
File: compiler/rustc_hir_typeck/src/upvar.rs (Rust)

Code before:
                            // This is a closure without braces around the body.
                            // We add braces to add the `let` before the body.
                            lint.multipart_suggestion(
                                diagnostic_msg,
                                vec![
                                    (closure_body_span.shrink_to_lo(), format!("{{ {migration_string}; ")),
                                    (closure_body_span.shrink_to_hi(), " }".to_string()),
                                ],
                                Applicability::MachineApplicable
                            );
                        }
                    } else {
                        lint.span_suggestion(
                            closure_span,
                            diagnostic_msg,
                            migration_string,
                            Applicability::HasPlaceholders
                        );
                    }
                },
            );
        }
    }

    fn try_structurally_resolve_place_ty(&self, span: Span, place: &mut Place<'tcx>) {
        place.base_ty = self.try_structurally_resolve_type(span, place.base_ty);
        for proj in &mut place.projections {
            proj.ty = self.try_structurally_resolve_type(span, proj.ty);
        }
    }

    fn place_to_string_for_migration(&self, capture: &ty::CapturedPlace<'tcx>) -> String {
        let mut place = capture.place.clone();
        self.try_structurally_resolve_place_ty(capture.get_path_span(self.tcx), &mut place);
        ty::place_to_string_for_capture(self.tcx, &place)
    }

    /// Combines all the reasons for 2229 migrations
    fn compute_2229_migrations_reasons(
        &self,
        auto_trait_reasons: UnordSet<&'static str>,
        drop_order: bool,
    ) -> MigrationWarningReason {
        MigrationWarningReason {
            auto_traits: auto_trait_reasons.into_sorted_stable_ord(),
            drop_order,
        }
    }

    /// Figures out the list of root variables (and their types) that aren't completely
    /// captured by the closure when `capture_disjoint_fields` is enabled and auto-traits

Review comment (suggestion):
use `deeply_normalize` here. We deeply normalize types in the writeback results, so I think we should do the same here

Code after:
                        } else {
                            // This is a closure without braces around the body.
                            // We add braces to add the `let` before the body.
                            lint.multipart_suggestion(
                                diagnostic_msg,
                                vec![
                                    (closure_body_span.shrink_to_lo(), format!("{{ {migration_string}; ")),
                                    (closure_body_span.shrink_to_hi(), " }".to_string()),
                                ],
                                Applicability::MachineApplicable
                            );
                        }
                    } else {
                        lint.span_suggestion(
                            closure_span,
                            diagnostic_msg,
                            migration_string,
                            Applicability::HasPlaceholders
                        );
                    }
                },
            );
        }
    }
    fn normalize_capture_place(&self, span: Span, place: Place<'tcx>) -> Place<'tcx> {
        let mut place = self.resolve_vars_if_possible(place);

        // In the new solver, types in HIR `Place`s can contain unnormalized aliases,
        // which can ICE later (e.g. when projecting fields for diagnostics).
        if self.next_trait_solver() {
            let cause = self.misc(span);
            let at = self.at(&cause, self.param_env);
            match solve::deeply_normalize_with_skipped_universes_and_ambiguous_coroutine_goals(
                at,
                place.clone(),
                vec![],
            ) {
                Ok((normalized, goals)) => {
                    if !goals.is_empty() {
                        let mut typeck_results = self.typeck_results.borrow_mut();
                        typeck_results.coroutine_stalled_predicates.extend(
                            goals
                                .into_iter()
                                // FIXME: throwing away the param-env :(
                                .map(|goal| (goal.predicate, self.misc(span))),
                        );
                    }
                    normalized
                }
                Err(errors) => {
                    let guar = self.infcx.err_ctxt().report_fulfillment_errors(errors);