Skip to content

Commit 4ad5c62

Browse files
committed
Resolve consts in OpportunisticTypeResolver
1 parent 5a585fe commit 4ad5c62

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/librustc/infer/resolve.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{InferCtxt, FixupError, FixupResult, Span, type_variable::TypeVariableOrigin};
22
use crate::mir::interpret::ConstValue;
3-
use crate::ty::{self, Ty, TyCtxt, TypeFoldable, InferConst};
3+
use crate::ty::{self, Ty, Const, TyCtxt, TypeFoldable, InferConst, TypeFlags};
44
use crate::ty::fold::{TypeFolder, TypeVisitor};
55

66
///////////////////////////////////////////////////////////////////////////
@@ -31,8 +31,17 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for OpportunisticTypeResolver<'a, 'g
3131
if !t.has_infer_types() {
3232
t // micro-optimize -- if there is nothing in this type that this fold affects...
3333
} else {
34-
let t0 = self.infcx.shallow_resolve(t);
35-
t0.super_fold_with(self)
34+
let t = self.infcx.shallow_resolve(t);
35+
t.super_fold_with(self)
36+
}
37+
}
38+
39+
fn fold_const(&mut self, ct: &'tcx Const<'tcx>) -> &'tcx Const<'tcx> {
40+
if !ct.has_type_flags(TypeFlags::HAS_CT_INFER) {
41+
ct // micro-optimize -- if there is nothing in this const that this fold affects...
42+
} else {
43+
let ct = self.infcx.shallow_resolve(ct);
44+
ct.super_fold_with(self)
3645
}
3746
}
3847
}

src/librustc/traits/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
157157
let result = self.tcx.erase_regions(&result);
158158

159159
self.tcx.lift_to_global(&result).unwrap_or_else(||
160-
bug!("Uninferred types/regions in `{:?}`", result)
160+
bug!("Uninferred types/regions/consts in `{:?}`", result)
161161
)
162162
}
163163
}

0 commit comments

Comments
 (0)