Skip to content

Commit 8e92849

Browse files
committed
changes from review
1 parent c183110 commit 8e92849

File tree

11 files changed

+53
-12
lines changed

11 files changed

+53
-12
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
690690
assert!(self.tcx.is_static(def_id));
691691
assert!(!self.tcx.is_thread_local_static(def_id));
692692
// Use size and align of the type.
693-
let ty = self.tcx.type_of(def_id).subst_identity();
693+
let ty = self
694+
.tcx
695+
.type_of(def_id)
696+
.no_bound_vars()
697+
.expect("statics should not have generic parameters");
694698
let layout = self.tcx.layout_of(ParamEnv::empty().and(ty)).unwrap();
695699
assert!(layout.is_sized());
696700
(layout.size, layout.align.abi, AllocKind::LiveData)

compiler/rustc_hir_analysis/src/astconv/mod.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
450450
.into()
451451
}
452452
(&GenericParamDefKind::Const { .. }, hir::GenericArg::Infer(inf)) => {
453-
let ty = tcx.at(self.span).type_of(param.def_id).subst_identity();
453+
let ty = tcx
454+
.at(self.span)
455+
.type_of(param.def_id)
456+
.no_bound_vars()
457+
.expect("const parameter types cannot be generic");
454458
if self.astconv.allow_ty_infer() {
455459
self.astconv.ct_infer(ty, Some(param), inf.span).into()
456460
} else {
@@ -503,7 +507,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
503507
}
504508
}
505509
GenericParamDefKind::Const { has_default } => {
506-
let ty = tcx.at(self.span).type_of(param.def_id).subst_identity();
510+
let ty = tcx
511+
.at(self.span)
512+
.type_of(param.def_id)
513+
.no_bound_vars()
514+
.expect("const parameter types cannot be generic");
507515
if ty.references_error() {
508516
return tcx.const_error(ty).into();
509517
}

compiler/rustc_hir_typeck/src/demand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2037,7 +2037,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20372037
args: &[hir::Expr<'_>],
20382038
kind: CallableKind| {
20392039
let arg_idx = args.iter().position(|a| a.hir_id == expr.hir_id).unwrap();
2040-
let fn_ty = self.tcx.type_of(def_id).0;
2040+
let fn_ty = self.tcx.type_of(def_id).skip_binder();
20412041
if !fn_ty.is_fn() {
20422042
return;
20432043
}

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1228,7 +1228,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
12281228
let tcx = self.fcx.tcx();
12291229
self.fcx
12301230
.ct_infer(
1231-
tcx.type_of(param.def_id).subst_identity(),
1231+
tcx.type_of(param.def_id)
1232+
.no_bound_vars()
1233+
.expect("const parameter types cannot be generic"),
12321234
Some(param),
12331235
inf.span,
12341236
)

compiler/rustc_hir_typeck/src/method/confirm.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,9 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
386386
let tcx = self.cfcx.tcx();
387387
self.cfcx
388388
.ct_infer(
389-
tcx.type_of(param.def_id).subst_identity(),
389+
tcx.type_of(param.def_id)
390+
.no_bound_vars()
391+
.expect("const parameter types cannot be generic"),
390392
Some(param),
391393
inf.span,
392394
)

compiler/rustc_hir_typeck/src/method/probe.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,14 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
19581958
kind: ConstVariableOriginKind::SubstitutionPlaceholder,
19591959
span,
19601960
};
1961-
self.next_const_var(self.tcx.type_of(param.def_id).subst_identity(), origin).into()
1961+
self.next_const_var(
1962+
self.tcx
1963+
.type_of(param.def_id)
1964+
.no_bound_vars()
1965+
.expect("const parameter types cannot be generic"),
1966+
origin,
1967+
)
1968+
.into()
19621969
}
19631970
})
19641971
}

compiler/rustc_infer/src/infer/mod.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,13 @@ impl<'tcx> InferCtxt<'tcx> {
11671167
val: ConstVariableValue::Unknown { universe: self.universe() },
11681168
});
11691169
self.tcx
1170-
.mk_const(const_var_id, self.tcx.type_of(param.def_id).subst_identity())
1170+
.mk_const(
1171+
const_var_id,
1172+
self.tcx
1173+
.type_of(param.def_id)
1174+
.no_bound_vars()
1175+
.expect("const parameter types cannot be generic"),
1176+
)
11711177
.into()
11721178
}
11731179
}

compiler/rustc_middle/src/ty/consts.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@ impl<'tcx> Const<'tcx> {
7171
let expr = &tcx.hir().body(body_id).value;
7272
debug!(?expr);
7373

74-
let ty = tcx.type_of(def.def_id_for_type_of()).subst_identity();
74+
let ty = tcx
75+
.type_of(def.def_id_for_type_of())
76+
.no_bound_vars()
77+
.expect("const parameter types cannot be generic");
7578

7679
match Self::try_eval_lit_or_param(tcx, ty, expr) {
7780
Some(v) => v,

compiler/rustc_middle/src/ty/context.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -2002,7 +2002,9 @@ impl<'tcx> TyCtxt<'tcx> {
20022002
GenericParamDefKind::Const { .. } => self
20032003
.mk_const(
20042004
ParamConst { index: param.index, name: param.name },
2005-
self.type_of(param.def_id).subst_identity(),
2005+
self.type_of(param.def_id)
2006+
.no_bound_vars()
2007+
.expect("const parameter types cannot be generic"),
20062008
)
20072009
.into(),
20082010
}

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
557557
ty::INNERMOST,
558558
ty::BoundVar::from_usize(bound_vars.len() - 1),
559559
),
560-
tcx.type_of(param.def_id).subst_identity(),
560+
tcx.type_of(param.def_id)
561+
.no_bound_vars()
562+
.expect("const parameter types cannot be generic"),
561563
)
562564
.into()
563565
}

src/librustdoc/clean/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,12 @@ fn clean_generic_param_def<'tcx>(
508508
GenericParamDefKind::Const {
509509
did: def.def_id,
510510
ty: Box::new(clean_middle_ty(
511-
ty::Binder::dummy(cx.tcx.type_of(def.def_id).subst_identity()),
511+
ty::Binder::dummy(
512+
cx.tcx
513+
.type_of(def.def_id)
514+
.no_bound_vars()
515+
.expect("const parameter types cannot be generic"),
516+
),
512517
cx,
513518
Some(def.def_id),
514519
)),

0 commit comments

Comments
 (0)