Skip to content

Commit 80423d6

Browse files
committed
update TypeFlags to deal with missing ct substs
1 parent 2e13be1 commit 80423d6

File tree

45 files changed

+307
-167
lines changed

Some content is hidden

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

45 files changed

+307
-167
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

Lines changed: 1 addition & 1 deletion
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.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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
13911391
LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"),
13921392
LocalRef::Operand(None) => {
13931393
let dst_layout = bx.layout_of(self.monomorphized_place_ty(dst.as_ref()));
1394-
assert!(!dst_layout.ty.has_erasable_regions());
1394+
assert!(!dst_layout.ty.has_erasable_regions(self.cx.tcx()));
13951395
let place = PlaceRef::alloca(bx, dst_layout);
13961396
place.storage_live(bx);
13971397
self.codegen_transmute_into(bx, src, place);

compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
479479
{
480480
let needs_canonical_flags = if canonicalize_region_mode.any() {
481481
TypeFlags::NEEDS_INFER |
482-
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
482+
TypeFlags::HAS_POTENTIAL_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_xxx_FREE_REGIONS`
483483
TypeFlags::HAS_TY_PLACEHOLDER |
484484
TypeFlags::HAS_CT_PLACEHOLDER
485485
} else {

compiler/rustc_infer/src/infer/freshen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
138138
}
139139

140140
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
141-
if !t.needs_infer() && !t.has_erasable_regions() {
141+
if !t.needs_infer() && !t.has_erasable_regions(self.tcx()) {
142142
return t;
143143
}
144144

compiler/rustc_lint/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1614,7 +1614,7 @@ impl<'tcx> LateLintPass<'tcx> for TrivialConstraints {
16141614
ConstEquate(..) |
16151615
TypeWellFormedFromEnv(..) => continue,
16161616
};
1617-
if predicate.is_global() {
1617+
if predicate.is_global(cx.tcx) {
16181618
cx.struct_span_lint(TRIVIAL_BOUNDS, span, |lint| {
16191619
lint.build(&format!(
16201620
"{} bound {} does not depend on any type \

compiler/rustc_lint/src/noop_method_call.rs

Lines changed: 1 addition & 1 deletion
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.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_middle/src/mir/mod.rs

Lines changed: 7 additions & 3 deletions
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.has_param_types_or_consts(tcx);
288289
body
289290
}
290291

@@ -293,7 +294,10 @@ impl<'tcx> Body<'tcx> {
293294
/// The returned MIR contains no `LocalDecl`s (even for the return place) or source scopes. It
294295
/// is only useful for testing but cannot be `#[cfg(test)]` because it is used in a different
295296
/// crate.
296-
pub fn new_cfg_only(basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>) -> Self {
297+
pub fn new_cfg_only(
298+
tcx: TyCtxt<'tcx>,
299+
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
300+
) -> Self {
297301
let mut body = Body {
298302
phase: MirPhase::Build,
299303
source: MirSource::item(DefId::local(CRATE_DEF_INDEX)),
@@ -311,7 +315,7 @@ impl<'tcx> Body<'tcx> {
311315
predecessor_cache: PredecessorCache::new(),
312316
is_cyclic: GraphIsCyclicCache::new(),
313317
};
314-
body.is_polymorphic = body.has_param_types_or_consts();
318+
body.is_polymorphic = body.has_param_types_or_consts(tcx);
315319
body
316320
}
317321

compiler/rustc_middle/src/ty/consts/kind.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ use rustc_target::abi::Size;
1212

1313
use super::ScalarInt;
1414
/// An unevaluated, potentially generic, constant.
15+
///
16+
/// If `substs_` is `None` it means that this anon const
17+
/// still has its default substs.
18+
///
19+
/// We check for all possible substs in `fn default_anon_const_substs`,
20+
/// so refer to that check for more info.
1521
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, TyEncodable, TyDecodable)]
1622
#[derive(Hash, HashStable)]
1723
pub struct Unevaluated<'tcx> {

compiler/rustc_middle/src/ty/erase_regions.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ impl<'tcx> TyCtxt<'tcx> {
2121
T: TypeFoldable<'tcx>,
2222
{
2323
// If there's nothing to erase avoid performing the query at all
24-
if !value.has_type_flags(TypeFlags::HAS_RE_LATE_BOUND | TypeFlags::HAS_FREE_REGIONS) {
24+
if !value
25+
.has_type_flags(TypeFlags::HAS_RE_LATE_BOUND | TypeFlags::HAS_POTENTIAL_FREE_REGIONS)
26+
{
2527
return value;
2628
}
2729
debug!("erase_regions({:?})", value);

0 commit comments

Comments
 (0)