From 113ebe4f1d9d662de6a9ac0c944eb956cfe71062 Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Sat, 21 Oct 2017 22:50:15 +0100 Subject: [PATCH 1/9] Create NormalizeTy query --- src/librustc/dep_graph/dep_node.rs | 1 + src/librustc/infer/mod.rs | 6 +++--- src/librustc/traits/trans/mod.rs | 6 ++---- src/librustc/ty/context.rs | 3 +++ src/librustc/ty/maps/config.rs | 6 ++++++ src/librustc/ty/maps/mod.rs | 4 ++++ src/librustc_lint/types.rs | 8 ++++---- src/librustc_trans/adt.rs | 2 +- src/librustc_trans/context.rs | 2 +- src/librustc_trans/debuginfo/metadata.rs | 2 +- src/librustc_trans/debuginfo/mod.rs | 4 ++-- src/librustc_trans_utils/monomorphize.rs | 2 +- 12 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 6993ef3768a79..ebb8868642b1b 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -635,6 +635,7 @@ define_dep_nodes!( <'tcx> // We use this for most things when incr. comp. is turned off. [] Null, + [] NormalizeTy, ); trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 39bcd7035742e..78e6e9ae15338 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -480,16 +480,16 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { { assert!(!value.needs_subst()); let value = self.erase_late_bound_regions(value); - self.normalize_associated_type(&value) + self.normalize_associated_type_in(&value) } /// Fully normalizes any associated types in `value`, using an /// empty environment and `Reveal::All` mode (therefore, suitable /// only for monomorphized code during trans, basically). - pub fn normalize_associated_type(self, value: &T) -> T + pub fn normalize_associated_type_in(self, value: &T) -> T where T: TransNormalize<'tcx> { - debug!("normalize_associated_type(t={:?})", value); + debug!("normalize_associated_type_in(t={:?})", value); let param_env = ty::ParamEnv::empty(Reveal::All); let value = self.erase_regions(value); diff --git a/src/librustc/traits/trans/mod.rs b/src/librustc/traits/trans/mod.rs index aa3179dd01f56..d082fb889b7b4 100644 --- a/src/librustc/traits/trans/mod.rs +++ b/src/librustc/traits/trans/mod.rs @@ -130,10 +130,8 @@ impl<'a, 'gcx> TypeFolder<'gcx, 'gcx> for AssociatedTypeNormalizer<'a, 'gcx> { if !ty.has_projections() { ty } else { - self.tcx.trans_trait_caches.project_cache.memoize(ty, || { - debug!("AssociatedTypeNormalizer: ty={:?}", ty); - self.tcx.normalize_associated_type(&ty) - }) + debug!("AssociatedTypeNormalizer: ty={:?}", ty); + self.tcx.normalize_ty(ty) } } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 3d5e8ea583ccc..b5f04a91203ec 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2322,4 +2322,7 @@ pub fn provide(providers: &mut ty::maps::Providers) { assert_eq!(cnum, LOCAL_CRATE); tcx.sess.features.borrow().clone_closures }; + providers.normalize_ty = |tcx, ty| { + tcx.normalize_associated_type_in(&ty) + }; } diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 8f8cda0e0f1d1..0d6fc561a8350 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -532,3 +532,9 @@ impl<'tcx> QueryDescription for queries::has_copy_closures<'tcx> { format!("seeing if the crate has enabled `Copy` closures") } } + +impl<'tcx> QueryDescription for queries::normalize_ty<'tcx> { + fn describe(_tcx: TyCtxt, _: Ty) -> String { + format!("normalising types") + } +} \ No newline at end of file diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 839042bf229aa..f68e15f269511 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -349,6 +349,7 @@ define_maps! { <'tcx> // Normally you would just use `tcx.erase_regions(&value)`, // however, which uses this query as a kind of cache. [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>, + [] fn normalize_ty: normalize_ty_node(Ty<'tcx>) -> Ty<'tcx>, } ////////////////////////////////////////////////////////////////////// @@ -490,3 +491,6 @@ fn output_filenames_node<'tcx>(_: CrateNum) -> DepConstructor<'tcx> { fn vtable_methods_node<'tcx>(trait_ref: ty::PolyTraitRef<'tcx>) -> DepConstructor<'tcx> { DepConstructor::VtableMethods{ trait_ref } } +fn normalize_ty_node<'tcx>(_: Ty<'tcx>) -> DepConstructor<'tcx> { + DepConstructor::NormalizeTy +} diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index d3a5d52b295af..0baa65508b527 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -431,7 +431,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // fields are actually safe. let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.normalize_associated_type(&field.ty(cx, substs)); + let field_ty = cx.normalize_associated_type_in(&field.ty(cx, substs)); let r = self.check_type_for_ffi(cache, field_ty); match r { FfiSafe => { @@ -463,7 +463,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.normalize_associated_type(&field.ty(cx, substs)); + let field_ty = cx.normalize_associated_type_in(&field.ty(cx, substs)); let r = self.check_type_for_ffi(cache, field_ty); match r { FfiSafe => { @@ -516,7 +516,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // Check the contained variants. for variant in &def.variants { for field in &variant.fields { - let arg = cx.normalize_associated_type(&field.ty(cx, substs)); + let arg = cx.normalize_associated_type_in(&field.ty(cx, substs)); let r = self.check_type_for_ffi(cache, arg); match r { FfiSafe => {} @@ -629,7 +629,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { fn check_type_for_ffi_and_report_errors(&mut self, sp: Span, ty: Ty<'tcx>) { // it is only OK to use this function because extern fns cannot have // any generic types right now: - let ty = self.cx.tcx.normalize_associated_type(&ty); + let ty = self.cx.tcx.normalize_associated_type_in(&ty); match self.check_type_for_ffi(&mut FxHashSet(), ty) { FfiResult::FfiSafe => {} diff --git a/src/librustc_trans/adt.rs b/src/librustc_trans/adt.rs index 23a45a7962abf..6fd406037cde2 100644 --- a/src/librustc_trans/adt.rs +++ b/src/librustc_trans/adt.rs @@ -80,7 +80,7 @@ pub fn compute_fields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, ty::TyGenerator(def_id, substs, _) => { if variant_index > 0 { bug!("{} is a generator, which only has one variant", t);} substs.field_tys(def_id, cx.tcx()).map(|t| { - cx.tcx().normalize_associated_type(&t) + cx.tcx().normalize_associated_type_in(&t) }).collect() }, _ => bug!("{} is not a type that can have fields.", t) diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 1722d008a54c2..a1bf64681c00c 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -642,7 +642,7 @@ impl<'a, 'tcx> LayoutTyper<'tcx> for &'a SharedCrateContext<'a, 'tcx> { } fn normalize_projections(self, ty: Ty<'tcx>) -> Ty<'tcx> { - self.tcx().normalize_associated_type(&ty) + self.tcx().normalize_associated_type_in(&ty) } } diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index 201d786776455..a6827abd41b22 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -582,7 +582,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } ty::TyGenerator(def_id, substs, _) => { let upvar_tys : Vec<_> = substs.field_tys(def_id, cx.tcx()).map(|t| { - cx.tcx().normalize_associated_type(&t) + cx.tcx().normalize_associated_type_in(&t) }).collect(); prepare_tuple_metadata(cx, t, diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 7e2ac95cd845c..0fe5b8f4ca265 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -376,7 +376,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, name_to_append_suffix_to.push_str(","); } - let actual_type = cx.tcx().normalize_associated_type(&actual_type); + let actual_type = cx.tcx().normalize_associated_type_in(&actual_type); // Add actual type name to <...> clause of function name let actual_type_name = compute_debuginfo_type_name(cx, actual_type, @@ -389,7 +389,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo { let names = get_type_parameter_names(cx, generics); substs.types().zip(names).map(|(ty, name)| { - let actual_type = cx.tcx().normalize_associated_type(&ty); + let actual_type = cx.tcx().normalize_associated_type_in(&ty); let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP); let name = CString::new(name.as_str().as_bytes()).unwrap(); unsafe { diff --git a/src/librustc_trans_utils/monomorphize.rs b/src/librustc_trans_utils/monomorphize.rs index 471be439a8f3b..079b7ee3eaba8 100644 --- a/src/librustc_trans_utils/monomorphize.rs +++ b/src/librustc_trans_utils/monomorphize.rs @@ -131,6 +131,6 @@ pub fn field_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &'tcx ty::FieldDef) -> Ty<'tcx> { - tcx.normalize_associated_type(&f.ty(tcx, param_substs)) + tcx.normalize_associated_type_in(&f.ty(tcx, param_substs)) } From 96a006c186cffef990a5f637084b6d83cc3ae739 Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Tue, 3 Oct 2017 22:55:15 +0100 Subject: [PATCH 2/9] added newlines at the end of the file and changed 'normalising' to 'normalizing' --- src/librustc/ty/maps/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 0d6fc561a8350..e813f2b104bf5 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -535,6 +535,6 @@ impl<'tcx> QueryDescription for queries::has_copy_closures<'tcx> { impl<'tcx> QueryDescription for queries::normalize_ty<'tcx> { fn describe(_tcx: TyCtxt, _: Ty) -> String { - format!("normalising types") + format!("normalizing types") } -} \ No newline at end of file +} From 69f5f0d193bbffd880e6f23edad55ebdfd1474f1 Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Wed, 11 Oct 2017 18:03:59 +0100 Subject: [PATCH 3/9] added trans_ prefix and pluralised types. Solved failing test on the incremental test-suite. --- src/librustc/infer/mod.rs | 6 +++--- src/librustc/ty/context.rs | 2 +- src/librustc/ty/maps/plumbing.rs | 1 + src/librustc_lint/types.rs | 8 ++++---- src/librustc_trans/adt.rs | 2 +- src/librustc_trans/context.rs | 2 +- src/librustc_trans/debuginfo/metadata.rs | 2 +- src/librustc_trans/debuginfo/mod.rs | 4 ++-- src/librustc_trans_utils/monomorphize.rs | 2 +- 9 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 78e6e9ae15338..7bc9760b059dd 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -480,16 +480,16 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { { assert!(!value.needs_subst()); let value = self.erase_late_bound_regions(value); - self.normalize_associated_type_in(&value) + self.trans_normalize_associated_types_in(&value) } /// Fully normalizes any associated types in `value`, using an /// empty environment and `Reveal::All` mode (therefore, suitable /// only for monomorphized code during trans, basically). - pub fn normalize_associated_type_in(self, value: &T) -> T + pub fn trans_normalize_associated_types_in(self, value: &T) -> T where T: TransNormalize<'tcx> { - debug!("normalize_associated_type_in(t={:?})", value); + debug!("trans_normalize_associated_types_in(t={:?})", value); let param_env = ty::ParamEnv::empty(Reveal::All); let value = self.erase_regions(value); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index b5f04a91203ec..2a3b445ba31ce 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2323,6 +2323,6 @@ pub fn provide(providers: &mut ty::maps::Providers) { tcx.sess.features.borrow().clone_closures }; providers.normalize_ty = |tcx, ty| { - tcx.normalize_associated_type_in(&ty) + tcx.trans_normalize_associated_types_in(&ty) }; } diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 5f93c3de336cc..cce968177175b 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -697,6 +697,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::FulfillObligation | DepKind::VtableMethods | DepKind::EraseRegionsTy | + DepKind::NormalizeTy | // These are just odd DepKind::Null | diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 0baa65508b527..5beb23c8b82f6 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -431,7 +431,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // fields are actually safe. let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.normalize_associated_type_in(&field.ty(cx, substs)); + let field_ty = cx.trans_normalize_associated_types_in(&field.ty(cx, substs)); let r = self.check_type_for_ffi(cache, field_ty); match r { FfiSafe => { @@ -463,7 +463,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.normalize_associated_type_in(&field.ty(cx, substs)); + let field_ty = cx.trans_normalize_associated_types_in(&field.ty(cx, substs)); let r = self.check_type_for_ffi(cache, field_ty); match r { FfiSafe => { @@ -516,7 +516,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // Check the contained variants. for variant in &def.variants { for field in &variant.fields { - let arg = cx.normalize_associated_type_in(&field.ty(cx, substs)); + let arg = cx.trans_normalize_associated_types_in(&field.ty(cx, substs)); let r = self.check_type_for_ffi(cache, arg); match r { FfiSafe => {} @@ -629,7 +629,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { fn check_type_for_ffi_and_report_errors(&mut self, sp: Span, ty: Ty<'tcx>) { // it is only OK to use this function because extern fns cannot have // any generic types right now: - let ty = self.cx.tcx.normalize_associated_type_in(&ty); + let ty = self.cx.tcx.trans_normalize_associated_types_in(&ty); match self.check_type_for_ffi(&mut FxHashSet(), ty) { FfiResult::FfiSafe => {} diff --git a/src/librustc_trans/adt.rs b/src/librustc_trans/adt.rs index 6fd406037cde2..91adfe139fa15 100644 --- a/src/librustc_trans/adt.rs +++ b/src/librustc_trans/adt.rs @@ -80,7 +80,7 @@ pub fn compute_fields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, ty::TyGenerator(def_id, substs, _) => { if variant_index > 0 { bug!("{} is a generator, which only has one variant", t);} substs.field_tys(def_id, cx.tcx()).map(|t| { - cx.tcx().normalize_associated_type_in(&t) + cx.tcx().trans_normalize_associated_types_in(&t) }).collect() }, _ => bug!("{} is not a type that can have fields.", t) diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index a1bf64681c00c..d326cfe02fc29 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -642,7 +642,7 @@ impl<'a, 'tcx> LayoutTyper<'tcx> for &'a SharedCrateContext<'a, 'tcx> { } fn normalize_projections(self, ty: Ty<'tcx>) -> Ty<'tcx> { - self.tcx().normalize_associated_type_in(&ty) + self.tcx().trans_normalize_associated_types_in(&ty) } } diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index a6827abd41b22..4f23152fed1ca 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -582,7 +582,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } ty::TyGenerator(def_id, substs, _) => { let upvar_tys : Vec<_> = substs.field_tys(def_id, cx.tcx()).map(|t| { - cx.tcx().normalize_associated_type_in(&t) + cx.tcx().trans_normalize_associated_types_in(&t) }).collect(); prepare_tuple_metadata(cx, t, diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 0fe5b8f4ca265..631d6b8143eae 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -376,7 +376,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, name_to_append_suffix_to.push_str(","); } - let actual_type = cx.tcx().normalize_associated_type_in(&actual_type); + let actual_type = cx.tcx().trans_normalize_associated_types_in(&actual_type); // Add actual type name to <...> clause of function name let actual_type_name = compute_debuginfo_type_name(cx, actual_type, @@ -389,7 +389,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo { let names = get_type_parameter_names(cx, generics); substs.types().zip(names).map(|(ty, name)| { - let actual_type = cx.tcx().normalize_associated_type_in(&ty); + let actual_type = cx.tcx().trans_normalize_associated_types_in(&ty); let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP); let name = CString::new(name.as_str().as_bytes()).unwrap(); unsafe { diff --git a/src/librustc_trans_utils/monomorphize.rs b/src/librustc_trans_utils/monomorphize.rs index 079b7ee3eaba8..31d51dce6ea4e 100644 --- a/src/librustc_trans_utils/monomorphize.rs +++ b/src/librustc_trans_utils/monomorphize.rs @@ -131,6 +131,6 @@ pub fn field_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &'tcx ty::FieldDef) -> Ty<'tcx> { - tcx.normalize_associated_type_in(&f.ty(tcx, param_substs)) + tcx.trans_normalize_associated_types_in(&f.ty(tcx, param_substs)) } From f2ebe96c6347b9929756454d26dc9efff93c3925 Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Wed, 11 Oct 2017 20:31:03 +0100 Subject: [PATCH 4/9] tidier --- src/librustc_lint/types.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 5beb23c8b82f6..d4d1a94d7cec9 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -431,7 +431,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // fields are actually safe. let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.trans_normalize_associated_types_in(&field.ty(cx, substs)); + let field_ty = cx.trans_normalize_associated_types_in( + &field.ty(cx, substs) + ); let r = self.check_type_for_ffi(cache, field_ty); match r { FfiSafe => { @@ -463,7 +465,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.trans_normalize_associated_types_in(&field.ty(cx, substs)); + let field_ty = cx.trans_normalize_associated_types_in( + &field.ty(cx, substs) + ); let r = self.check_type_for_ffi(cache, field_ty); match r { FfiSafe => { @@ -516,7 +520,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // Check the contained variants. for variant in &def.variants { for field in &variant.fields { - let arg = cx.trans_normalize_associated_types_in(&field.ty(cx, substs)); + let arg = cx.trans_normalize_associated_types_in( + &field.ty(cx, substs) + ); let r = self.check_type_for_ffi(cache, arg); match r { FfiSafe => {} From d870a96f286a27997136954739ab536a9f1b8392 Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Mon, 16 Oct 2017 19:39:32 +0100 Subject: [PATCH 5/9] trans_ -> fully_ prefix --- src/librustc/infer/mod.rs | 6 +++--- src/librustc/ty/context.rs | 2 +- src/librustc_lint/types.rs | 8 ++++---- src/librustc_trans/adt.rs | 2 +- src/librustc_trans/context.rs | 2 +- src/librustc_trans/debuginfo/metadata.rs | 2 +- src/librustc_trans/debuginfo/mod.rs | 4 ++-- src/librustc_trans_utils/monomorphize.rs | 2 +- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 7bc9760b059dd..79eeebfb25031 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -480,16 +480,16 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { { assert!(!value.needs_subst()); let value = self.erase_late_bound_regions(value); - self.trans_normalize_associated_types_in(&value) + self.fully_normalize_associated_types_in(&value) } /// Fully normalizes any associated types in `value`, using an /// empty environment and `Reveal::All` mode (therefore, suitable /// only for monomorphized code during trans, basically). - pub fn trans_normalize_associated_types_in(self, value: &T) -> T + pub fn fully_normalize_associated_types_in(self, value: &T) -> T where T: TransNormalize<'tcx> { - debug!("trans_normalize_associated_types_in(t={:?})", value); + debug!("fully_normalize_associated_types_in(t={:?})", value); let param_env = ty::ParamEnv::empty(Reveal::All); let value = self.erase_regions(value); diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 2a3b445ba31ce..4616f5a42d6d2 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2323,6 +2323,6 @@ pub fn provide(providers: &mut ty::maps::Providers) { tcx.sess.features.borrow().clone_closures }; providers.normalize_ty = |tcx, ty| { - tcx.trans_normalize_associated_types_in(&ty) + tcx.fully_normalize_associated_types_in(&ty) }; } diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index d4d1a94d7cec9..38461b0b36419 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -431,7 +431,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // fields are actually safe. let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.trans_normalize_associated_types_in( + let field_ty = cx.fully_normalize_associated_types_in( &field.ty(cx, substs) ); let r = self.check_type_for_ffi(cache, field_ty); @@ -465,7 +465,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { let mut all_phantom = true; for field in &def.struct_variant().fields { - let field_ty = cx.trans_normalize_associated_types_in( + let field_ty = cx.fully_normalize_associated_types_in( &field.ty(cx, substs) ); let r = self.check_type_for_ffi(cache, field_ty); @@ -520,7 +520,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // Check the contained variants. for variant in &def.variants { for field in &variant.fields { - let arg = cx.trans_normalize_associated_types_in( + let arg = cx.fully_normalize_associated_types_in( &field.ty(cx, substs) ); let r = self.check_type_for_ffi(cache, arg); @@ -635,7 +635,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { fn check_type_for_ffi_and_report_errors(&mut self, sp: Span, ty: Ty<'tcx>) { // it is only OK to use this function because extern fns cannot have // any generic types right now: - let ty = self.cx.tcx.trans_normalize_associated_types_in(&ty); + let ty = self.cx.tcx.fully_normalize_associated_types_in(&ty); match self.check_type_for_ffi(&mut FxHashSet(), ty) { FfiResult::FfiSafe => {} diff --git a/src/librustc_trans/adt.rs b/src/librustc_trans/adt.rs index 91adfe139fa15..b06f8e4e67116 100644 --- a/src/librustc_trans/adt.rs +++ b/src/librustc_trans/adt.rs @@ -80,7 +80,7 @@ pub fn compute_fields<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>, ty::TyGenerator(def_id, substs, _) => { if variant_index > 0 { bug!("{} is a generator, which only has one variant", t);} substs.field_tys(def_id, cx.tcx()).map(|t| { - cx.tcx().trans_normalize_associated_types_in(&t) + cx.tcx().fully_normalize_associated_types_in(&t) }).collect() }, _ => bug!("{} is not a type that can have fields.", t) diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index d326cfe02fc29..6fd24c1786c69 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -642,7 +642,7 @@ impl<'a, 'tcx> LayoutTyper<'tcx> for &'a SharedCrateContext<'a, 'tcx> { } fn normalize_projections(self, ty: Ty<'tcx>) -> Ty<'tcx> { - self.tcx().trans_normalize_associated_types_in(&ty) + self.tcx().fully_normalize_associated_types_in(&ty) } } diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index 4f23152fed1ca..3bde78e2c6a60 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -582,7 +582,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, } ty::TyGenerator(def_id, substs, _) => { let upvar_tys : Vec<_> = substs.field_tys(def_id, cx.tcx()).map(|t| { - cx.tcx().trans_normalize_associated_types_in(&t) + cx.tcx().fully_normalize_associated_types_in(&t) }).collect(); prepare_tuple_metadata(cx, t, diff --git a/src/librustc_trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs index 631d6b8143eae..1a28429201618 100644 --- a/src/librustc_trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -376,7 +376,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, name_to_append_suffix_to.push_str(","); } - let actual_type = cx.tcx().trans_normalize_associated_types_in(&actual_type); + let actual_type = cx.tcx().fully_normalize_associated_types_in(&actual_type); // Add actual type name to <...> clause of function name let actual_type_name = compute_debuginfo_type_name(cx, actual_type, @@ -389,7 +389,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let template_params: Vec<_> = if cx.sess().opts.debuginfo == FullDebugInfo { let names = get_type_parameter_names(cx, generics); substs.types().zip(names).map(|(ty, name)| { - let actual_type = cx.tcx().trans_normalize_associated_types_in(&ty); + let actual_type = cx.tcx().fully_normalize_associated_types_in(&ty); let actual_type_metadata = type_metadata(cx, actual_type, syntax_pos::DUMMY_SP); let name = CString::new(name.as_str().as_bytes()).unwrap(); unsafe { diff --git a/src/librustc_trans_utils/monomorphize.rs b/src/librustc_trans_utils/monomorphize.rs index 31d51dce6ea4e..ab61dacf010ae 100644 --- a/src/librustc_trans_utils/monomorphize.rs +++ b/src/librustc_trans_utils/monomorphize.rs @@ -131,6 +131,6 @@ pub fn field_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, f: &'tcx ty::FieldDef) -> Ty<'tcx> { - tcx.trans_normalize_associated_types_in(&f.ty(tcx, param_substs)) + tcx.fully_normalize_associated_types_in(&f.ty(tcx, param_substs)) } From 73c95431ee98fde159a7e8e068cdd406bd8810d0 Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Mon, 16 Oct 2017 21:09:07 +0100 Subject: [PATCH 6/9] removed unused import --- src/librustc/traits/trans/mod.rs | 18 +----------------- src/librustc/ty/context.rs | 4 ---- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/src/librustc/traits/trans/mod.rs b/src/librustc/traits/trans/mod.rs index d082fb889b7b4..cba139133cf3e 100644 --- a/src/librustc/traits/trans/mod.rs +++ b/src/librustc/traits/trans/mod.rs @@ -13,16 +13,14 @@ // seems likely that they should eventually be merged into more // general routines. -use dep_graph::{DepGraph, DepKind, DepTrackingMap, DepTrackingMapConfig}; +use dep_graph::{DepKind, DepTrackingMapConfig}; use infer::TransNormalize; -use std::cell::RefCell; use std::marker::PhantomData; use syntax_pos::DUMMY_SP; use traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext, Vtable}; use ty::{self, Ty, TyCtxt}; use ty::subst::{Subst, Substs}; use ty::fold::{TypeFoldable, TypeFolder}; -use util::common::MemoizationMap; /// Attempts to resolve an obligation to a vtable.. The result is /// a shallow vtable resolution -- meaning that we do not @@ -136,20 +134,6 @@ impl<'a, 'gcx> TypeFolder<'gcx, 'gcx> for AssociatedTypeNormalizer<'a, 'gcx> { } } -/// Specializes caches used in trans -- in particular, they assume all -/// types are fully monomorphized and that free regions can be erased. -pub struct TransTraitCaches<'tcx> { - project_cache: RefCell>>, -} - -impl<'tcx> TransTraitCaches<'tcx> { - pub fn new(graph: DepGraph) -> Self { - TransTraitCaches { - project_cache: RefCell::new(DepTrackingMap::new(graph)), - } - } -} - // Implement DepTrackingMapConfig for `trait_cache` pub struct TraitSelectionCache<'tcx> { data: PhantomData<&'tcx ()> diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 4616f5a42d6d2..03033b6a06d68 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -851,9 +851,6 @@ pub struct GlobalCtxt<'tcx> { pub sess: &'tcx Session, - - pub trans_trait_caches: traits::trans::TransTraitCaches<'tcx>, - pub dep_graph: DepGraph, /// Common types, pre-interned for your convenience. @@ -1137,7 +1134,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { tls::enter_global(GlobalCtxt { sess: s, cstore, - trans_trait_caches: traits::trans::TransTraitCaches::new(dep_graph.clone()), global_arenas: arenas, global_interners: interners, dep_graph: dep_graph.clone(), From 20ae2d98c04621f70f166b84d64d617adeecb5d2 Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Wed, 18 Oct 2017 17:28:31 +0100 Subject: [PATCH 7/9] moved depnode --- src/librustc/dep_graph/dep_node.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index ebb8868642b1b..91c84e539cf3b 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -632,10 +632,9 @@ define_dep_nodes!( <'tcx> [] CodegenUnit(InternedString), [] CompileCodegenUnit(InternedString), [] OutputFilenames, - + [] NormalizeTy, // We use this for most things when incr. comp. is turned off. [] Null, - [] NormalizeTy, ); trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { From a3667d3209ecc560e9c8fee4a69946eb82fb5d3b Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Sat, 21 Oct 2017 20:11:27 +0100 Subject: [PATCH 8/9] anon NormalizeTy DepNode --- src/librustc/dep_graph/dep_node.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 91c84e539cf3b..7bf8c6168174c 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -632,7 +632,7 @@ define_dep_nodes!( <'tcx> [] CodegenUnit(InternedString), [] CompileCodegenUnit(InternedString), [] OutputFilenames, - [] NormalizeTy, + [anon] NormalizeTy, // We use this for most things when incr. comp. is turned off. [] Null, ); From 5c51bf5297c3abb11c815d6b8a6d8681790a6ec8 Mon Sep 17 00:00:00 2001 From: Marco Concetto Rudilosso Date: Sat, 21 Oct 2017 22:25:00 +0100 Subject: [PATCH 9/9] renamed query --- src/librustc/traits/trans/mod.rs | 2 +- src/librustc/ty/context.rs | 2 +- src/librustc/ty/maps/config.rs | 2 +- src/librustc/ty/maps/mod.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/traits/trans/mod.rs b/src/librustc/traits/trans/mod.rs index cba139133cf3e..761e7259204bf 100644 --- a/src/librustc/traits/trans/mod.rs +++ b/src/librustc/traits/trans/mod.rs @@ -129,7 +129,7 @@ impl<'a, 'gcx> TypeFolder<'gcx, 'gcx> for AssociatedTypeNormalizer<'a, 'gcx> { ty } else { debug!("AssociatedTypeNormalizer: ty={:?}", ty); - self.tcx.normalize_ty(ty) + self.tcx.fully_normalize_monormophic_ty(ty) } } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 03033b6a06d68..5e9396068c8b6 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -2318,7 +2318,7 @@ pub fn provide(providers: &mut ty::maps::Providers) { assert_eq!(cnum, LOCAL_CRATE); tcx.sess.features.borrow().clone_closures }; - providers.normalize_ty = |tcx, ty| { + providers.fully_normalize_monormophic_ty = |tcx, ty| { tcx.fully_normalize_associated_types_in(&ty) }; } diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index e813f2b104bf5..deaafd1efed45 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -533,7 +533,7 @@ impl<'tcx> QueryDescription for queries::has_copy_closures<'tcx> { } } -impl<'tcx> QueryDescription for queries::normalize_ty<'tcx> { +impl<'tcx> QueryDescription for queries::fully_normalize_monormophic_ty<'tcx> { fn describe(_tcx: TyCtxt, _: Ty) -> String { format!("normalizing types") } diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index f68e15f269511..e588cdc52d886 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -349,7 +349,7 @@ define_maps! { <'tcx> // Normally you would just use `tcx.erase_regions(&value)`, // however, which uses this query as a kind of cache. [] fn erase_regions_ty: erase_regions_ty(Ty<'tcx>) -> Ty<'tcx>, - [] fn normalize_ty: normalize_ty_node(Ty<'tcx>) -> Ty<'tcx>, + [] fn fully_normalize_monormophic_ty: normalize_ty_node(Ty<'tcx>) -> Ty<'tcx>, } //////////////////////////////////////////////////////////////////////