From 38d626a8c165a741de0c8c31e348bca07be31c18 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sat, 28 Nov 2020 15:18:29 -0500 Subject: [PATCH] Run `normalize_project_ty` in Canonical mode This allows recovering from overflow errors when normalizing a type. --- compiler/rustc_trait_selection/src/traits/select/mod.rs | 9 +-------- compiler/rustc_traits/src/normalize_projection_ty.rs | 3 ++- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs index 5b31998b7d33f..b4a59a107c85f 100644 --- a/compiler/rustc_trait_selection/src/traits/select/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs @@ -223,14 +223,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { } pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx>) -> SelectionContext<'cx, 'tcx> { - SelectionContext { - infcx, - freshener: infcx.freshener(), - intercrate: true, - intercrate_ambiguity_causes: None, - allow_negative_impls: false, - query_mode: TraitQueryMode::Standard, - } + SelectionContext { intercrate: true, ..SelectionContext::new(infcx) } } pub fn with_negative( diff --git a/compiler/rustc_traits/src/normalize_projection_ty.rs b/compiler/rustc_traits/src/normalize_projection_ty.rs index a8e376838e218..cd17ae2d39828 100644 --- a/compiler/rustc_traits/src/normalize_projection_ty.rs +++ b/compiler/rustc_traits/src/normalize_projection_ty.rs @@ -24,7 +24,8 @@ fn normalize_projection_ty<'tcx>( tcx.infer_ctxt().enter_canonical_trait_query( &goal, |infcx, fulfill_cx, ParamEnvAnd { param_env, value: goal }| { - let selcx = &mut SelectionContext::new(infcx); + let selcx = + &mut SelectionContext::with_query_mode(infcx, traits::TraitQueryMode::Canonical); let cause = ObligationCause::dummy(); let mut obligations = vec![]; let answer = traits::normalize_projection_type(