diff options
author | Kyle Matsuda <kyle.yoshio.matsuda@gmail.com> | 2023-01-10 12:27:41 -0700 |
---|---|---|
committer | Kyle Matsuda <kyle.yoshio.matsuda@gmail.com> | 2023-01-14 00:13:07 -0700 |
commit | ef58baf8b8fecc5ca8b5e34921d33650186d4205 (patch) | |
tree | cf3615f8a9b9e2c97aaca3c0d142b21219ce2cd7 | |
parent | bd6c63597b9483aa65b0934f195716635a30a2b8 (diff) | |
download | rust-ef58baf8b8fecc5ca8b5e34921d33650186d4205.tar.gz |
change const_param_default query to return EarlyBinder; remove bound_const_param_default query; add EarlyBinder to const_param_default in metadata
-rw-r--r-- | compiler/rustc_hir_analysis/src/astconv/mod.rs | 4 | ||||
-rw-r--r-- | compiler/rustc_hir_analysis/src/check/wfcheck.rs | 4 | ||||
-rw-r--r-- | compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs | 4 | ||||
-rw-r--r-- | compiler/rustc_metadata/src/rmeta/encoder.rs | 2 | ||||
-rw-r--r-- | compiler/rustc_metadata/src/rmeta/mod.rs | 2 | ||||
-rw-r--r-- | compiler/rustc_middle/src/query/mod.rs | 2 | ||||
-rw-r--r-- | compiler/rustc_middle/src/ty/consts.rs | 4 | ||||
-rw-r--r-- | compiler/rustc_middle/src/ty/generics.rs | 2 | ||||
-rw-r--r-- | compiler/rustc_middle/src/ty/util.rs | 4 | ||||
-rw-r--r-- | compiler/rustc_privacy/src/lib.rs | 4 | ||||
-rw-r--r-- | src/librustdoc/clean/mod.rs | 2 |
11 files changed, 12 insertions, 22 deletions
diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index 3521911b055..d32c288337b 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -511,9 +511,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o { return tcx.const_error(ty).into(); } if !infer_args && has_default { - tcx.bound_const_param_default(param.def_id) - .subst(tcx, substs.unwrap()) - .into() + tcx.const_param_default(param.def_id).subst(tcx, substs.unwrap()).into() } else { if infer_args { self.astconv.ct_infer(ty, Some(param), self.span).into() diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index cc29d40c0be..7c6da009dee 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -1350,7 +1350,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id // is incorrect when dealing with unused substs, for example // for `struct Foo<const N: usize, const M: usize = { 1 - 2 }>` // we should eagerly error. - let default_ct = tcx.bound_const_param_default(param.def_id).subst_identity(); + let default_ct = tcx.const_param_default(param.def_id).subst_identity(); if !default_ct.needs_subst() { wfcx.register_wf_obligation( tcx.def_span(param.def_id), @@ -1396,7 +1396,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id GenericParamDefKind::Const { .. } => { // If the param has a default, ... if is_our_default(param) { - let default_ct = tcx.bound_const_param_default(param.def_id).subst_identity(); + let default_ct = tcx.const_param_default(param.def_id).subst_identity(); // ... and it's not a dependent default, ... if !default_ct.needs_subst() { // ... then substitute it with the default. diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs index 8570715b41e..6ed8adb4742 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs @@ -1224,9 +1224,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } GenericParamDefKind::Const { has_default } => { if !infer_args && has_default { - tcx.bound_const_param_default(param.def_id) - .subst(tcx, substs.unwrap()) - .into() + tcx.const_param_default(param.def_id).subst(tcx, substs.unwrap()).into() } else { self.fcx.var_for_def(self.span, param) } diff --git a/compiler/rustc_metadata/src/rmeta/encoder.rs b/compiler/rustc_metadata/src/rmeta/encoder.rs index f7caf30c74c..030328d1e26 100644 --- a/compiler/rustc_metadata/src/rmeta/encoder.rs +++ b/compiler/rustc_metadata/src/rmeta/encoder.rs @@ -2070,7 +2070,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { hir::GenericParamKind::Const { ref default, .. } => { let def_id = param.def_id.to_def_id(); if default.is_some() { - record!(self.tables.const_param_default[def_id] <- self.tcx.bound_const_param_default(def_id).subst_identity()) + record!(self.tables.const_param_default[def_id] <- self.tcx.const_param_default(def_id)) } } } diff --git a/compiler/rustc_metadata/src/rmeta/mod.rs b/compiler/rustc_metadata/src/rmeta/mod.rs index bf9be714daf..5beee06d521 100644 --- a/compiler/rustc_metadata/src/rmeta/mod.rs +++ b/compiler/rustc_metadata/src/rmeta/mod.rs @@ -360,7 +360,7 @@ define_tables! { fn_sig: Table<DefIndex, LazyValue<ty::PolyFnSig<'static>>>, codegen_fn_attrs: Table<DefIndex, LazyValue<CodegenFnAttrs>>, impl_trait_ref: Table<DefIndex, LazyValue<ty::TraitRef<'static>>>, - const_param_default: Table<DefIndex, LazyValue<rustc_middle::ty::Const<'static>>>, + const_param_default: Table<DefIndex, LazyValue<ty::EarlyBinder<rustc_middle::ty::Const<'static>>>>, object_lifetime_default: Table<DefIndex, LazyValue<ObjectLifetimeDefault>>, optimized_mir: Table<DefIndex, LazyValue<mir::Body<'static>>>, mir_for_ctfe: Table<DefIndex, LazyValue<mir::Body<'static>>>, diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 86655915736..cdc78a86349 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -142,7 +142,7 @@ rustc_queries! { /// Given the def_id of a const-generic parameter, computes the associated default const /// parameter. e.g. `fn example<const N: usize=3>` called on `N` would return `3`. - query const_param_default(param: DefId) -> ty::Const<'tcx> { + query const_param_default(param: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> { desc { |tcx| "computing const default for a given parameter `{}`", tcx.def_path_str(param) } cache_on_disk_if { param.is_local() } separate_provide_extern diff --git a/compiler/rustc_middle/src/ty/consts.rs b/compiler/rustc_middle/src/ty/consts.rs index 152a7e9d43f..65cbac3e8f1 100644 --- a/compiler/rustc_middle/src/ty/consts.rs +++ b/compiler/rustc_middle/src/ty/consts.rs @@ -239,7 +239,7 @@ impl<'tcx> Const<'tcx> { } } -pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> Const<'_> { +pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> ty::EarlyBinder<Const<'_>> { let default_def_id = match tcx.hir().get_by_def_id(def_id.expect_local()) { hir::Node::GenericParam(hir::GenericParam { kind: hir::GenericParamKind::Const { default: Some(ac), .. }, @@ -250,5 +250,5 @@ pub fn const_param_default(tcx: TyCtxt<'_>, def_id: DefId) -> Const<'_> { "`const_param_default` expected a generic parameter with a constant" ), }; - Const::from_anon_const(tcx, default_def_id) + ty::EarlyBinder(Const::from_anon_const(tcx, default_def_id)) } diff --git a/compiler/rustc_middle/src/ty/generics.rs b/compiler/rustc_middle/src/ty/generics.rs index 705adecd3b9..8a5e765b9a3 100644 --- a/compiler/rustc_middle/src/ty/generics.rs +++ b/compiler/rustc_middle/src/ty/generics.rs @@ -88,7 +88,7 @@ impl GenericParamDef { Some(tcx.bound_type_of(self.def_id).map_bound(|t| t.into())) } GenericParamDefKind::Const { has_default } if has_default => { - Some(tcx.bound_const_param_default(self.def_id).map_bound(|c| c.into())) + Some(tcx.const_param_default(self.def_id).map_bound(|c| c.into())) } _ => None, } diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index cc53659f827..1f0c96a93b9 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -673,10 +673,6 @@ impl<'tcx> TyCtxt<'tcx> { ty::EarlyBinder(self.item_bounds(def_id)) } - pub fn bound_const_param_default(self, def_id: DefId) -> ty::EarlyBinder<ty::Const<'tcx>> { - ty::EarlyBinder(self.const_param_default(def_id)) - } - pub fn bound_predicates_of( self, def_id: DefId, diff --git a/compiler/rustc_privacy/src/lib.rs b/compiler/rustc_privacy/src/lib.rs index 9ee1e012ef2..0d6d5ab5a18 100644 --- a/compiler/rustc_privacy/src/lib.rs +++ b/compiler/rustc_privacy/src/lib.rs @@ -838,9 +838,7 @@ impl ReachEverythingInTheInterfaceVisitor<'_, '_> { GenericParamDefKind::Const { has_default } => { self.visit(self.ev.tcx.type_of(param.def_id)); if has_default { - self.visit( - self.ev.tcx.bound_const_param_default(param.def_id).subst_identity(), - ); + self.visit(self.ev.tcx.const_param_default(param.def_id).subst_identity()); } } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 869c1e3512f..415e7d5a360 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -507,7 +507,7 @@ fn clean_generic_param_def<'tcx>( )), default: match has_default { true => Some(Box::new( - cx.tcx.bound_const_param_default(def.def_id).subst_identity().to_string(), + cx.tcx.const_param_default(def.def_id).subst_identity().to_string(), )), false => None, }, |