Skip to content

Commit 88fd414

Browse files
committed
Fix const flag handling
1 parent 47fd82c commit 88fd414

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

src/librustc/ty/context.rs

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,13 +2024,17 @@ macro_rules! sty_debug_print {
20242024
total: usize,
20252025
region_infer: usize,
20262026
ty_infer: usize,
2027-
both_infer: usize,
2027+
ct_infer: usize,
2028+
all_infer: usize,
20282029
}
20292030

20302031
pub fn go(tcx: TyCtxt) {
20312032
let mut total = DebugStat {
20322033
total: 0,
2033-
region_infer: 0, ty_infer: 0, both_infer: 0,
2034+
region_infer: 0,
2035+
ty_infer: 0,
2036+
ct_infer: 0,
2037+
all_infer: 0,
20342038
};
20352039
$(let mut $variant = total;)*
20362040

@@ -2044,30 +2048,33 @@ macro_rules! sty_debug_print {
20442048
};
20452049
let region = t.flags.intersects(ty::TypeFlags::HAS_RE_INFER);
20462050
let ty = t.flags.intersects(ty::TypeFlags::HAS_TY_INFER);
2047-
// TODO(const_generics)
2051+
let ct = t.flags.intersects(ty::TypeFlags::HAS_CT_INFER);
20482052

20492053
variant.total += 1;
20502054
total.total += 1;
20512055
if region { total.region_infer += 1; variant.region_infer += 1 }
20522056
if ty { total.ty_infer += 1; variant.ty_infer += 1 }
2053-
if region && ty { total.both_infer += 1; variant.both_infer += 1 }
2057+
if ct { total.ct_infer += 1; variant.ct_infer += 1 }
2058+
if region && ty && ct { total.all_infer += 1; variant.all_infer += 1 }
20542059
}
2055-
println!("Ty interner total ty region both");
2060+
println!("Ty interner total ty region ct all");
20562061
$(println!(" {:18}: {uses:6} {usespc:4.1}%, \
2057-
{ty:4.1}% {region:5.1}% {both:4.1}%",
2062+
{ty:4.1}% {region:5.1}% {ct:4.1}% {all:4.1}%",
20582063
stringify!($variant),
20592064
uses = $variant.total,
20602065
usespc = $variant.total as f64 * 100.0 / total.total as f64,
2061-
ty = $variant.ty_infer as f64 * 100.0 / total.total as f64,
2062-
region = $variant.region_infer as f64 * 100.0 / total.total as f64,
2063-
both = $variant.both_infer as f64 * 100.0 / total.total as f64);
2066+
ty = $variant.ty_infer as f64 * 100.0 / total.total as f64,
2067+
ct = $variant.ct_infer as f64 * 100.0 / total.total as f64,
2068+
region = $variant.region_infer as f64 * 100.0 / total.total as f64,
2069+
all = $variant.all_infer as f64 * 100.0 / total.total as f64);
20642070
)*
20652071
println!(" total {uses:6} \
2066-
{ty:4.1}% {region:5.1}% {both:4.1}%",
2072+
{ty:4.1}% {region:5.1}% {ct:4.1}% {all:4.1}%",
20672073
uses = total.total,
2068-
ty = total.ty_infer as f64 * 100.0 / total.total as f64,
2069-
region = total.region_infer as f64 * 100.0 / total.total as f64,
2070-
both = total.both_infer as f64 * 100.0 / total.total as f64)
2074+
ty = total.ty_infer as f64 * 100.0 / total.total as f64,
2075+
ct = total.ct_infer as f64 * 100.0 / total.total as f64,
2076+
region = total.region_infer as f64 * 100.0 / total.total as f64,
2077+
all = total.all_infer as f64 * 100.0 / total.total as f64)
20712078
}
20722079
}
20732080

src/librustc/ty/flags.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ impl FlagComputation {
232232
}
233233

234234
fn add_const(&mut self, constant: &ty::Const) {
235-
// TODO(const_generics): missing flags for inference (HAS_FREE_LOCAL_NAMES, etc.)
236235
self.add_ty(constant.ty);
237236
match constant.val {
238237
ConstValue::Unevaluated(_, substs) => {
@@ -243,6 +242,15 @@ impl FlagComputation {
243242
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES);
244243
self.add_flags(TypeFlags::HAS_PARAMS);
245244
}
245+
ConstValue::Infer(infer) => {
246+
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES);
247+
self.add_flags(TypeFlags::HAS_CT_INFER);
248+
match infer {
249+
ty::InferConst::Fresh(_) |
250+
ty::InferConst::Canonical(_) => self.add_flags(TypeFlags::HAS_CANONICAL_VARS),
251+
ty::InferConst::Var(_) => self.add_flags(TypeFlags::KEEP_IN_LOCAL_TCX),
252+
}
253+
}
246254
_ => {}
247255
}
248256
}

0 commit comments

Comments
 (0)