diff options
| author | ThePuzzlemaker <tpzker@thepuzzlemaker.info> | 2021-09-06 23:58:26 -0500 |
|---|---|---|
| committer | ThePuzzlemaker <tpzker@thepuzzlemaker.info> | 2021-09-06 23:58:26 -0500 |
| commit | 33a28254f21c792cb0bda5427e66efa91b87dd4d (patch) | |
| tree | 483b0b90a22c50cd33d96b42cdcb1eb9c8e16f18 | |
| parent | 734209ed73507e214e49ef5cb7988af8901e74c7 (diff) | |
| download | rust-33a28254f21c792cb0bda5427e66efa91b87dd4d.tar.gz rust-33a28254f21c792cb0bda5427e66efa91b87dd4d.zip | |
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
| -rw-r--r-- | compiler/rustc_typeck/src/lib.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/compiler/rustc_typeck/src/lib.rs b/compiler/rustc_typeck/src/lib.rs index e5d5ca3362b..e2cbaa47272 100644 --- a/compiler/rustc_typeck/src/lib.rs +++ b/compiler/rustc_typeck/src/lib.rs @@ -335,16 +335,20 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: DefId) { // checking trait fulfillment, not this here. I'm not sure why it // works in the example in `fn test()` given in #88609? This also // probably isn't the best way to do this. - let normalized = infcx.partially_normalize_associated_types_in( - cause.clone(), + let InferOk { value: norm_return_ty, obligations } = infcx + .partially_normalize_associated_types_in( + cause.clone(), + ty::ParamEnv::empty(), + return_ty, + ); + fulfillment_cx.register_predicate_obligations(&infcx, obligations); + fulfillment_cx.register_bound( + &infcx, ty::ParamEnv::empty(), - return_ty, + norm_return_ty, + term_id, + cause, ); - let new_ty = normalized.value; - for obligation in normalized.obligations { - fulfillment_cx.register_predicate_obligation(&infcx, obligation); - } - fulfillment_cx.register_bound(&infcx, ty::ParamEnv::empty(), new_ty, term_id, cause); if let Err(err) = fulfillment_cx.select_all_or_error(&infcx) { infcx.report_fulfillment_errors(&err, None, false); error = true; |
