Skip to content

Commit 517c28e

Browse files
committed
Auto merge of rust-lang#87280 - lcnr:lazy-anon-const-default-substs, r=nikomatsakis
lazily "compute" anon const default substs Continuing the work of rust-lang#83086, this implements the discussed solution for the [unused substs problem](https://github.com/rust-lang/project-const-generics/blob/master/design-docs/anon-const-substs.md#unused-substs). As of now, anonymous constants inherit all of their parents generics, even if they do not use them, e.g. in `fn foo<T, const N: usize>() -> [T; N + 1]`, the array length has `T` as a generic parameter even though it doesn't use it. These *unused substs* cause some backwards incompatible, and imo incorrect behavior, e.g. rust-lang#78369. --- We do not actually filter any generic parameters here and the `default_anon_const_substs` query still a dummy which only checks that - we now prevent the previously existing query cycles and are able to call `predicates_of(parent)` when computing the substs of anonymous constants - the default anon consts substs only include the typeflags we assume it does. Implementing that filtering will be left as future work. --- The idea of this PR is to delay the creation of the anon const substs until after we've computed `predicates_of` for the parent of the anon const. As the predicates of the parent can however contain the anon const we still have to create a `ty::Const` for it. We do this by changing the substs field of `ty::Unevaluated` to an option and modifying accesses to instead call the method `unevaluated.substs(tcx)` which returns the substs as before. If the substs - now `substs_` - of `ty::Unevaluated` are `None`, it means that the anon const currently has its default substs, i.e. the substs it has when first constructed, which are the generic parameters it has available. To be able to call `unevaluated.substs(tcx)` in a `TypeVisitor`, we add the non-defaulted method `fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>>`. In case `tcx_for_anon_const_substs` returns `None`, unknown anon const default substs are skipped entirely. Even when `substs_` is `None` we still have to treat the constant as if it has its default substs. To do this, `TypeFlags` are modified so that it is clear whether they can still change when *exposing* any anon const default substs. A new flag, `HAS_UNKNOWN_DEFAULT_CONST_SUBSTS`, is added in case some default flags are missing. The rest of this PR are some smaller changes to either not cause cycles by trying to access the default anon const substs too early or to be able to access the `tcx` in previously unused locations. cc `@rust-lang/project-const-generics` r? `@nikomatsakis`
2 parents ad02dc4 + 7cbfa2e commit 517c28e

File tree

122 files changed

+1023
-521
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+1023
-521
lines changed

compiler/rustc_codegen_cranelift/src/constant.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ pub(crate) fn codegen_constant<'tcx>(
129129
};
130130
let const_val = match const_.val {
131131
ConstKind::Value(const_val) => const_val,
132-
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
133-
if fx.tcx.is_static(def.did) =>
132+
ConstKind::Unevaluated(uv)
133+
if fx.tcx.is_static(uv.def.did) =>
134134
{
135-
assert!(substs.is_empty());
136-
assert!(promoted.is_none());
135+
assert!(uv.substs(fx.tcx).is_empty());
136+
assert!(uv.promoted.is_none());
137137

138-
return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
138+
return codegen_static_ref(fx, uv.def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
139139
}
140140
ConstKind::Unevaluated(unevaluated) => {
141141
match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
499499
ty::Adt(def, ..) if !def.is_box() => {
500500
// Again, only create type information if full debuginfo is enabled
501501
if cx.sess().opts.debuginfo == DebugInfo::Full
502-
&& !impl_self_ty.needs_subst()
502+
&& !impl_self_ty.definitely_needs_subst(cx.tcx)
503503
{
504504
Some(type_metadata(cx, impl_self_ty, rustc_span::DUMMY_SP))
505505
} else {

compiler/rustc_codegen_ssa/src/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1398,7 +1398,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13981398
LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"),
13991399
LocalRef::Operand(None) => {
14001400
let dst_layout = bx.layout_of(self.monomorphized_place_ty(dst.as_ref()));
1401-
assert!(!dst_layout.ty.has_erasable_regions());
1401+
assert!(!dst_layout.ty.has_erasable_regions(self.cx.tcx()));
14021402
let place = PlaceRef::alloca(bx, dst_layout);
14031403
place.storage_live(bx);
14041404
self.codegen_transmute_into(bx, src, place);

compiler/rustc_codegen_ssa/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
216216
let mut allocate_local = |local| {
217217
let decl = &mir.local_decls[local];
218218
let layout = bx.layout_of(fx.monomorphize(decl.ty));
219-
assert!(!layout.ty.has_erasable_regions());
219+
assert!(!layout.ty.has_erasable_regions(cx.tcx()));
220220

221221
if local == mir::RETURN_PLACE && fx.fn_abi.ret.is_indirect() {
222222
debug!("alloc: {:?} (return place) -> place", local);

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
470470
{
471471
let needs_canonical_flags = if canonicalize_region_mode.any() {
472472
TypeFlags::NEEDS_INFER |
473-
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
473+
TypeFlags::HAS_POTENTIAL_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_POTENTIAL_FREE_REGIONS`
474474
TypeFlags::HAS_TY_PLACEHOLDER |
475475
TypeFlags::HAS_CT_PLACEHOLDER
476476
} else {

compiler/rustc_infer/src/infer/combine.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
129129
where
130130
R: ConstEquateRelation<'tcx>,
131131
{
132+
let a = self.tcx.expose_default_const_substs(a);
133+
let b = self.tcx.expose_default_const_substs(b);
132134
debug!("{}.consts({:?}, {:?})", relation.tag(), a, b);
133135
if a == b {
134136
return Ok(a);
@@ -742,10 +744,9 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
742744
}
743745
}
744746
}
745-
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
746-
if self.tcx().lazy_normalization() =>
747-
{
748-
assert_eq!(promoted, None);
747+
ty::ConstKind::Unevaluated(uv) if self.tcx().lazy_normalization() => {
748+
assert_eq!(uv.promoted, None);
749+
let substs = uv.substs(self.tcx());
749750
let substs = self.relate_with_variance(
750751
ty::Variance::Invariant,
751752
ty::VarianceDiagInfo::default(),
@@ -754,7 +755,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
754755
)?;
755756
Ok(self.tcx().mk_const(ty::Const {
756757
ty: c.ty,
757-
val: ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }),
758+
val: ty::ConstKind::Unevaluated(ty::Unevaluated::new(uv.def, substs)),
758759
}))
759760
}
760761
_ => relate::super_relate_consts(self, c, c),
@@ -976,10 +977,9 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
976977
}
977978
}
978979
}
979-
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
980-
if self.tcx().lazy_normalization() =>
981-
{
982-
assert_eq!(promoted, None);
980+
ty::ConstKind::Unevaluated(uv) if self.tcx().lazy_normalization() => {
981+
assert_eq!(uv.promoted, None);
982+
let substs = uv.substs(self.tcx());
983983
let substs = self.relate_with_variance(
984984
ty::Variance::Invariant,
985985
ty::VarianceDiagInfo::default(),
@@ -988,7 +988,7 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
988988
)?;
989989
Ok(self.tcx().mk_const(ty::Const {
990990
ty: c.ty,
991-
val: ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }),
991+
val: ty::ConstKind::Unevaluated(ty::Unevaluated::new(uv.def, substs)),
992992
}))
993993
}
994994
_ => relate::super_relate_consts(self, c, c),

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1537,6 +1537,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15371537
}
15381538

15391539
impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
1540+
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
1541+
Some(self.tcx)
1542+
}
1543+
15401544
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
15411545
if let Some((kind, def_id)) = TyCategory::from_ty(self.tcx, t) {
15421546
let span = self.tcx.def_span(def_id);

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'a, 'tcx> FindHirNodeVisitor<'a, 'tcx> {
5151

5252
fn node_ty_contains_target(&self, hir_id: HirId) -> Option<Ty<'tcx>> {
5353
self.node_type_opt(hir_id).map(|ty| self.infcx.resolve_vars_if_possible(ty)).filter(|ty| {
54-
ty.walk().any(|inner| {
54+
ty.walk(self.infcx.tcx).any(|inner| {
5555
inner == self.target
5656
|| match (inner.unpack(), self.target.unpack()) {
5757
(GenericArgKind::Type(inner_ty), GenericArgKind::Type(target_ty)) => {

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder, ErrorRepor
99
use rustc_hir::def_id::DefId;
1010
use rustc_hir::intravisit::{walk_ty, ErasedMap, NestedVisitorMap, Visitor};
1111
use rustc_hir::{self as hir, GenericBound, Item, ItemKind, Lifetime, LifetimeName, Node, TyKind};
12-
use rustc_middle::ty::{self, AssocItemContainer, RegionKind, Ty, TypeFoldable, TypeVisitor};
12+
use rustc_middle::ty::{
13+
self, AssocItemContainer, RegionKind, Ty, TyCtxt, TypeFoldable, TypeVisitor,
14+
};
1315
use rustc_span::symbol::Ident;
1416
use rustc_span::{MultiSpan, Span};
1517

@@ -476,8 +478,14 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
476478
/// Collect all the trait objects in a type that could have received an implicit `'static` lifetime.
477479
pub(super) struct TraitObjectVisitor(pub(super) FxHashSet<DefId>);
478480

479-
impl TypeVisitor<'_> for TraitObjectVisitor {
480-
fn visit_ty(&mut self, t: Ty<'_>) -> ControlFlow<Self::BreakTy> {
481+
impl<'tcx> TypeVisitor<'tcx> for TraitObjectVisitor {
482+
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
483+
// The default anon const substs cannot include
484+
// trait objects, so we don't have to bother looking.
485+
None
486+
}
487+
488+
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
481489
match t.kind() {
482490
ty::Dynamic(preds, RegionKind::ReStatic) => {
483491
if let Some(def_id) = preds.principal_def_id() {

compiler/rustc_infer/src/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
146146
}
147147

148148
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
149-
if !t.needs_infer() && !t.has_erasable_regions() {
149+
if !t.needs_infer() && !t.has_erasable_regions(self.tcx()) {
150150
return t;
151151
}
152152

compiler/rustc_infer/src/infer/mod.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -675,13 +675,10 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
675675
/// canonicalizing the consts.
676676
pub fn try_unify_abstract_consts(
677677
&self,
678-
a: ty::Unevaluated<'tcx>,
679-
b: ty::Unevaluated<'tcx>,
678+
a: ty::Unevaluated<'tcx, ()>,
679+
b: ty::Unevaluated<'tcx, ()>,
680680
) -> bool {
681-
let canonical = self.canonicalize_query(
682-
((a.def, a.substs), (b.def, b.substs)),
683-
&mut OriginalQueryValues::default(),
684-
);
681+
let canonical = self.canonicalize_query((a, b), &mut OriginalQueryValues::default());
685682
debug!("canonical consts: {:?}", &canonical.value);
686683

687684
self.tcx.try_unify_abstract_consts(canonical.value)
@@ -1592,16 +1589,16 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15921589
pub fn const_eval_resolve(
15931590
&self,
15941591
param_env: ty::ParamEnv<'tcx>,
1595-
ty::Unevaluated { def, substs, promoted }: ty::Unevaluated<'tcx>,
1592+
unevaluated: ty::Unevaluated<'tcx>,
15961593
span: Option<Span>,
15971594
) -> EvalToConstValueResult<'tcx> {
15981595
let mut original_values = OriginalQueryValues::default();
1599-
let canonical = self.canonicalize_query((param_env, substs), &mut original_values);
1596+
let canonical = self.canonicalize_query((param_env, unevaluated), &mut original_values);
16001597

1601-
let (param_env, substs) = canonical.value;
1598+
let (param_env, unevaluated) = canonical.value;
16021599
// The return value is the evaluated value which doesn't contain any reference to inference
16031600
// variables, thus we don't need to substitute back the original values.
1604-
self.tcx.const_eval_resolve(param_env, ty::Unevaluated { def, substs, promoted }, span)
1601+
self.tcx.const_eval_resolve(param_env, unevaluated, span)
16051602
}
16061603

16071604
/// If `typ` is a type variable of some kind, resolve it one level

compiler/rustc_infer/src/infer/nll_relate/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ where
202202
};
203203

204204
value.skip_binder().visit_with(&mut ScopeInstantiator {
205+
tcx: self.infcx.tcx,
205206
next_region: &mut next_region,
206207
target_index: ty::INNERMOST,
207208
bound_region_scope: &mut scope,
@@ -757,13 +758,18 @@ where
757758
/// `for<..`>. For each of those, it creates an entry in
758759
/// `bound_region_scope`.
759760
struct ScopeInstantiator<'me, 'tcx> {
761+
tcx: TyCtxt<'tcx>,
760762
next_region: &'me mut dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
761763
// The debruijn index of the scope we are instantiating.
762764
target_index: ty::DebruijnIndex,
763765
bound_region_scope: &'me mut BoundRegionScope<'tcx>,
764766
}
765767

766768
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
769+
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
770+
Some(self.tcx)
771+
}
772+
767773
fn visit_binder<T: TypeFoldable<'tcx>>(
768774
&mut self,
769775
t: &ty::Binder<'tcx, T>,

compiler/rustc_infer/src/infer/outlives/verify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl<'cx, 'tcx> VerifyBoundCx<'cx, 'tcx> {
189189
visited: &mut SsoHashSet<GenericArg<'tcx>>,
190190
) -> VerifyBound<'tcx> {
191191
let mut bounds = parent
192-
.walk_shallow(visited)
192+
.walk_shallow(self.tcx, visited)
193193
.filter_map(|child| match child.unpack() {
194194
GenericArgKind::Type(ty) => Some(self.type_bound(ty, visited)),
195195
GenericArgKind::Lifetime(lt) => {

compiler/rustc_infer/src/infer/resolve.rs

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ impl<'a, 'tcx> UnresolvedTypeFinder<'a, 'tcx> {
126126

127127
impl<'a, 'tcx> TypeVisitor<'tcx> for UnresolvedTypeFinder<'a, 'tcx> {
128128
type BreakTy = (Ty<'tcx>, Option<Span>);
129+
130+
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
131+
Some(self.infcx.tcx)
132+
}
133+
129134
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
130135
let t = self.infcx.shallow_resolve(t);
131136
if t.has_infer_types() {

compiler/rustc_lint/src/builtin.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ declare_lint! {
152152
declare_lint_pass!(BoxPointers => [BOX_POINTERS]);
153153

154154
impl BoxPointers {
155-
fn check_heap_type(&self, cx: &LateContext<'_>, span: Span, ty: Ty<'_>) {
156-
for leaf in ty.walk() {
155+
fn check_heap_type<'tcx>(&self, cx: &LateContext<'tcx>, span: Span, ty: Ty<'tcx>) {
156+
for leaf in ty.walk(cx.tcx) {
157157
if let GenericArgKind::Type(leaf_ty) = leaf.unpack() {
158158
if leaf_ty.is_box() {
159159
cx.struct_span_lint(BOX_POINTERS, span, |lint| {
@@ -1656,7 +1656,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
16561656
ConstEquate(..) |
16571657
TypeWellFormedFromEnv(..) => continue,
16581658
};
1659-
if predicate.is_global() {
1659+
if predicate.is_global(cx.tcx) {
16601660
cx.struct_span_lint(TRIVIAL_BOUNDS, span, |lint| {
16611661
lint.build(&format!(
16621662
"{} bound {} does not depend on any type \

compiler/rustc_lint/src/noop_method_call.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for NoopMethodCall {
6262
_ => return,
6363
};
6464
let substs = cx.typeck_results().node_substs(expr.hir_id);
65-
if substs.needs_subst() {
65+
if substs.definitely_needs_subst(cx.tcx) {
6666
// We can't resolve on types that require monomorphization, so we don't handle them if
6767
// we need to perfom substitution.
6868
return;

compiler/rustc_lint/src/types.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,9 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
11601160

11611161
impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
11621162
type BreakTy = Ty<'tcx>;
1163+
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
1164+
Some(self.cx.tcx)
1165+
}
11631166

11641167
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
11651168
match ty.kind() {

compiler/rustc_middle/src/mir/interpret/queries.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl<'tcx> TyCtxt<'tcx> {
3838
ct: ty::Unevaluated<'tcx>,
3939
span: Option<Span>,
4040
) -> EvalToConstValueResult<'tcx> {
41-
match ty::Instance::resolve_opt_const_arg(self, param_env, ct.def, ct.substs) {
41+
match ty::Instance::resolve_opt_const_arg(self, param_env, ct.def, ct.substs(self)) {
4242
Ok(Some(instance)) => {
4343
let cid = GlobalId { instance, promoted: ct.promoted };
4444
self.const_eval_global_id(param_env, cid, span)

compiler/rustc_middle/src/mir/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ pub struct Body<'tcx> {
242242

243243
impl<'tcx> Body<'tcx> {
244244
pub fn new(
245+
tcx: TyCtxt<'tcx>,
245246
source: MirSource<'tcx>,
246247
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
247248
source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
@@ -284,7 +285,7 @@ impl<'tcx> Body<'tcx> {
284285
predecessor_cache: PredecessorCache::new(),
285286
is_cyclic: GraphIsCyclicCache::new(),
286287
};
287-
body.is_polymorphic = body.has_param_types_or_consts();
288+
body.is_polymorphic = body.definitely_has_param_types_or_consts(tcx);
288289
body
289290
}
290291

@@ -294,7 +295,7 @@ impl<'tcx> Body<'tcx> {
294295
/// is only useful for testing but cannot be `#[cfg(test)]` because it is used in a different
295296
/// crate.
296297
pub fn new_cfg_only(basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>) -> Self {
297-
let mut body = Body {
298+
Body {
298299
phase: MirPhase::Build,
299300
source: MirSource::item(DefId::local(CRATE_DEF_INDEX)),
300301
basic_blocks,
@@ -310,9 +311,7 @@ impl<'tcx> Body<'tcx> {
310311
is_polymorphic: false,
311312
predecessor_cache: PredecessorCache::new(),
312313
is_cyclic: GraphIsCyclicCache::new(),
313-
};
314-
body.is_polymorphic = body.has_param_types_or_consts();
315-
body
314+
}
316315
}
317316

318317
#[inline]

compiler/rustc_middle/src/query/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ rustc_queries! {
114114
desc { |tcx| "compute const default for a given parameter `{}`", tcx.def_path_str(param) }
115115
}
116116

117+
query default_anon_const_substs(key: DefId) -> SubstsRef<'tcx> {
118+
desc { |tcx| "computing the default generic arguments for `{}`", tcx.def_path_str(key) }
119+
}
120+
117121
/// Records the type of every item.
118122
query type_of(key: DefId) -> Ty<'tcx> {
119123
desc { |tcx| "computing type of `{}`", tcx.def_path_str(key) }
@@ -299,12 +303,11 @@ rustc_queries! {
299303
}
300304

301305
query try_unify_abstract_consts(key: (
302-
(ty::WithOptConstParam<DefId>, SubstsRef<'tcx>),
303-
(ty::WithOptConstParam<DefId>, SubstsRef<'tcx>)
306+
ty::Unevaluated<'tcx, ()>, ty::Unevaluated<'tcx, ()>
304307
)) -> bool {
305308
desc {
306309
|tcx| "trying to unify the generic constants {} and {}",
307-
tcx.def_path_str(key.0.0.did), tcx.def_path_str(key.1.0.did)
310+
tcx.def_path_str(key.0.def.did), tcx.def_path_str(key.1.def.did)
308311
}
309312
}
310313

compiler/rustc_middle/src/ty/consts.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::mir::interpret::ConstValue;
22
use crate::mir::interpret::{LitToConstInput, Scalar};
3-
use crate::ty::subst::InternalSubsts;
43
use crate::ty::{self, Ty, TyCtxt};
54
use crate::ty::{ParamEnv, ParamEnvAnd};
65
use rustc_errors::ErrorReported;
@@ -100,7 +99,7 @@ impl<'tcx> Const<'tcx> {
10099
}
101100
_ => ty::ConstKind::Unevaluated(ty::Unevaluated {
102101
def: def.to_global(),
103-
substs: InternalSubsts::identity_for_item(tcx, def.did.to_def_id()),
102+
substs_: None,
104103
promoted: None,
105104
}),
106105
};

0 commit comments

Comments
 (0)