Skip to content

Commit 43badf9

Browse files
committed
Substitute and normalize all types of consts within collect const
1 parent cf3b561 commit 43badf9

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/librustc_mir/monomorphize/collector.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,11 +1265,12 @@ fn collect_const<'tcx>(
12651265
) {
12661266
debug!("visiting const {:?}", constant);
12671267

1268-
let substituted_constant = if let ConstValue::Param(param) = constant.val {
1269-
param_substs.const_at(param.index as usize)
1270-
} else {
1271-
constant
1272-
};
1268+
let param_env = ty::ParamEnv::reveal_all();
1269+
let substituted_constant = tcx.subst_and_normalize_erasing_regions(
1270+
param_substs,
1271+
param_env,
1272+
&constant,
1273+
);
12731274

12741275
match substituted_constant.val {
12751276
ConstValue::Scalar(Scalar::Ptr(ptr)) =>
@@ -1281,12 +1282,6 @@ fn collect_const<'tcx>(
12811282
}
12821283
}
12831284
ConstValue::Unevaluated(def_id, substs) => {
1284-
let param_env = ty::ParamEnv::reveal_all();
1285-
let substs = tcx.subst_and_normalize_erasing_regions(
1286-
param_substs,
1287-
param_env,
1288-
&substs,
1289-
);
12901285
let instance = ty::Instance::resolve(tcx,
12911286
param_env,
12921287
def_id,

0 commit comments

Comments
 (0)