Skip to content

Commit 33a2825

Browse files
Clean up the fix a bit
Use register_predicate_obligations rather than a for loop, since I didn't see that before. Also destructure in the `let` rather than projecting the fields individually
1 parent 734209e commit 33a2825

File tree

1 file changed

+12
-8
lines changed
  • compiler/rustc_typeck/src

1 file changed

+12
-8
lines changed

compiler/rustc_typeck/src/lib.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,20 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) {
335335
// checking trait fulfillment, not this here. I'm not sure why it
336336
// works in the example in `fn test()` given in #88609? This also
337337
// probably isn't the best way to do this.
338-
let normalized = infcx.partially_normalize_associated_types_in(
339-
cause.clone(),
338+
let InferOk { value: norm_return_ty, obligations } = infcx
339+
.partially_normalize_associated_types_in(
340+
cause.clone(),
341+
ty::ParamEnv::empty(),
342+
return_ty,
343+
);
344+
fulfillment_cx.register_predicate_obligations(&infcx, obligations);
345+
fulfillment_cx.register_bound(
346+
&infcx,
340347
ty::ParamEnv::empty(),
341-
return_ty,
348+
norm_return_ty,
349+
term_id,
350+
cause,
342351
);
343-
let new_ty = normalized.value;
344-
for obligation in normalized.obligations {
345-
fulfillment_cx.register_predicate_obligation(&infcx, obligation);
346-
}
347-
fulfillment_cx.register_bound(&infcx, ty::ParamEnv::empty(), new_ty, term_id, cause);
348352
if let Err(err) = fulfillment_cx.select_all_or_error(&infcx) {
349353
infcx.report_fulfillment_errors(&err, None, false);
350354
error = true;

0 commit comments

Comments
 (0)