Skip to content

Commit 71bbb60

Browse files
committed
initial revert
1 parent b0ec3e0 commit 71bbb60

File tree

127 files changed

+541
-1051
lines changed

Some content is hidden

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

127 files changed

+541
-1051
lines changed

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<'me, 'typeck, 'flow, 'tcx> LivenessResults<'me, 'typeck, 'flow, 'tcx> {
171171
for (local, location) in drop_used {
172172
if !live_locals.contains(&local) {
173173
let local_ty = self.cx.body.local_decls[local].ty;
174-
if local_ty.has_free_regions(self.cx.typeck.tcx()) {
174+
if local_ty.has_free_regions() {
175175
self.cx.add_drop_live_facts_for(local, local_ty, &[location], &locations);
176176
}
177177
}

compiler/rustc_borrowck/src/type_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'tcx> {
425425
self.cx.param_env.and(type_op::ascribe_user_type::AscribeUserType::new(
426426
constant.literal.ty(),
427427
uv.def.did,
428-
UserSubsts { substs: uv.substs(self.tcx()), user_self_ty: None },
428+
UserSubsts { substs: uv.substs, user_self_ty: None },
429429
)),
430430
) {
431431
span_mirbug!(
@@ -1969,7 +1969,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
19691969
let predicates = self.prove_closure_bounds(
19701970
tcx,
19711971
def_id.expect_local(),
1972-
uv.substs(tcx),
1972+
uv.substs,
19731973
location,
19741974
);
19751975
self.normalize_and_prove_instantiated_predicates(

compiler/rustc_codegen_cranelift/src/constant.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ pub(crate) fn codegen_constant<'tcx>(
129129
};
130130
let const_val = match const_.val {
131131
ConstKind::Value(const_val) => const_val,
132-
ConstKind::Unevaluated(uv) if fx.tcx.is_static(uv.def.did) => {
133-
assert!(uv.substs(fx.tcx).is_empty());
134-
assert!(uv.promoted.is_none());
132+
ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
133+
if fx.tcx.is_static(def.did) =>
134+
{
135+
assert!(substs.is_empty());
136+
assert!(promoted.is_none());
135137

136-
return codegen_static_ref(fx, uv.def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
138+
return codegen_static_ref(fx, def.did, fx.layout_of(const_.ty)).to_cvalue(fx);
137139
}
138140
ConstKind::Unevaluated(unevaluated) => {
139141
match fx.tcx.const_eval_resolve(ParamEnv::reveal_all(), unevaluated, None) {

compiler/rustc_codegen_llvm/src/debuginfo/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ impl<'ll, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
507507
ty::Adt(def, ..) if !def.is_box() => {
508508
// Again, only create type information if full debuginfo is enabled
509509
if cx.sess().opts.debuginfo == DebugInfo::Full
510-
&& !impl_self_ty.definitely_needs_subst(cx.tcx)
510+
&& !impl_self_ty.needs_subst()
511511
{
512512
Some(type_metadata(cx, impl_self_ty, rustc_span::DUMMY_SP))
513513
} else {

compiler/rustc_codegen_ssa/src/mir/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14771477
LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"),
14781478
LocalRef::Operand(None) => {
14791479
let dst_layout = bx.layout_of(self.monomorphized_place_ty(dst.as_ref()));
1480-
assert!(!dst_layout.ty.has_erasable_regions(self.cx.tcx()));
1480+
assert!(!dst_layout.ty.has_erasable_regions());
14811481
let place = PlaceRef::alloca(bx, dst_layout);
14821482
place.storage_live(bx);
14831483
self.codegen_transmute_into(bx, src, place);

compiler/rustc_codegen_ssa/src/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
209209
let mut allocate_local = |local| {
210210
let decl = &mir.local_decls[local];
211211
let layout = bx.layout_of(fx.monomorphize(decl.ty));
212-
assert!(!layout.ty.has_erasable_regions(cx.tcx()));
212+
assert!(!layout.ty.has_erasable_regions());
213213

214214
if local == mir::RETURN_PLACE && fx.fn_abi.ret.is_indirect() {
215215
debug!("alloc: {:?} (return place) -> place", local);

compiler/rustc_const_eval/src/interpret/operand.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
568568
ty::ConstKind::Param(_) | ty::ConstKind::Bound(..) => throw_inval!(TooGeneric),
569569
ty::ConstKind::Error(_) => throw_inval!(AlreadyReported(ErrorReported)),
570570
ty::ConstKind::Unevaluated(uv) => {
571-
let instance = self.resolve(uv.def, uv.substs(*self.tcx))?;
571+
let instance = self.resolve(uv.def, uv.substs)?;
572572
Ok(self.eval_to_allocation(GlobalId { instance, promoted: uv.promoted })?.into())
573573
}
574574
ty::ConstKind::Infer(..) | ty::ConstKind::Placeholder(..) => {

compiler/rustc_const_eval/src/interpret/util.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ where
99
T: TypeFoldable<'tcx>,
1010
{
1111
debug!("ensure_monomorphic_enough: ty={:?}", ty);
12-
if !ty.potentially_needs_subst() {
12+
if !ty.needs_subst() {
1313
return Ok(());
1414
}
1515

@@ -21,12 +21,8 @@ where
2121
impl<'tcx> TypeVisitor<'tcx> for UsedParamsNeedSubstVisitor<'tcx> {
2222
type BreakTy = FoundParam;
2323

24-
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
25-
Some(self.tcx)
26-
}
27-
2824
fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
29-
if !ty.potentially_needs_subst() {
25+
if !ty.needs_subst() {
3026
return ControlFlow::CONTINUE;
3127
}
3228

@@ -44,7 +40,7 @@ where
4440
let is_used = unused_params.contains(index).map_or(true, |unused| !unused);
4541
// Only recurse when generic parameters in fns, closures and generators
4642
// are used and require substitution.
47-
match (is_used, subst.definitely_needs_subst(self.tcx)) {
43+
match (is_used, subst.needs_subst()) {
4844
// Just in case there are closures or generators within this subst,
4945
// recurse.
5046
(true, true) => return subst.super_visit_with(self),

compiler/rustc_const_eval/src/transform/check_consts/check.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ impl<'mir, 'tcx> Checker<'mir, 'tcx> {
348348
fn check_local_or_return_ty(&mut self, ty: Ty<'tcx>, local: Local) {
349349
let kind = self.body.local_kind(local);
350350

351-
for ty in ty.walk(self.tcx) {
351+
for ty in ty.walk() {
352352
let ty = match ty.unpack() {
353353
GenericArgKind::Type(ty) => ty,
354354

compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ where
338338

339339
// Check the qualifs of the value of `const` items.
340340
if let Some(ct) = constant.literal.const_for_ty() {
341-
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs_: _, promoted }) = ct.val {
341+
if let ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs: _, promoted }) = ct.val {
342342
// Use qualifs of the type for the promoted. Promoteds in MIR body should be possible
343343
// only for `NeedsNonConstDrop` with precise drop checking. This is the only const
344344
// check performed after the promotion. Verify that with an assertion.

compiler/rustc_const_eval/src/transform/promote_consts.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -843,17 +843,13 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
843843
ty,
844844
val: ty::ConstKind::Unevaluated(ty::Unevaluated {
845845
def,
846-
substs_: Some(InternalSubsts::for_item(
847-
tcx,
848-
def.did,
849-
|param, _| {
850-
if let ty::GenericParamDefKind::Lifetime = param.kind {
851-
tcx.lifetimes.re_erased.into()
852-
} else {
853-
tcx.mk_param_from_def(param)
854-
}
855-
},
856-
)),
846+
substs: InternalSubsts::for_item(tcx, def.did, |param, _| {
847+
if let ty::GenericParamDefKind::Lifetime = param.kind {
848+
tcx.lifetimes.re_erased.into()
849+
} else {
850+
tcx.mk_param_from_def(param)
851+
}
852+
}),
857853
promoted: Some(promoted_id),
858854
}),
859855
})
@@ -969,7 +965,6 @@ pub fn promote_candidates<'tcx>(
969965
scope.parent_scope = None;
970966

971967
let promoted = Body::new(
972-
tcx,
973968
body.source, // `promoted` gets filled in below
974969
IndexVec::new(),
975970
IndexVec::from_elem_n(scope, 1),

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
470470
{
471471
let needs_canonical_flags = if canonicalize_region_mode.any() {
472472
TypeFlags::NEEDS_INFER |
473-
TypeFlags::HAS_POTENTIAL_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_POTENTIAL_FREE_REGIONS`
473+
TypeFlags::HAS_FREE_REGIONS | // `HAS_RE_PLACEHOLDER` implies `HAS_FREE_REGIONS`
474474
TypeFlags::HAS_TY_PLACEHOLDER |
475475
TypeFlags::HAS_CT_PLACEHOLDER
476476
} else {

compiler/rustc_infer/src/infer/combine.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
129129
where
130130
R: ConstEquateRelation<'tcx>,
131131
{
132-
let a = self.tcx.expose_default_const_substs(a);
133-
let b = self.tcx.expose_default_const_substs(b);
134132
debug!("{}.consts({:?}, {:?})", relation.tag(), a, b);
135133
if a == b {
136134
return Ok(a);
@@ -746,9 +744,10 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
746744
}
747745
}
748746
}
749-
ty::ConstKind::Unevaluated(uv) if self.tcx().lazy_normalization() => {
750-
assert_eq!(uv.promoted, None);
751-
let substs = uv.substs(self.tcx());
747+
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
748+
if self.tcx().lazy_normalization() =>
749+
{
750+
assert_eq!(promoted, None);
752751
let substs = self.relate_with_variance(
753752
ty::Variance::Invariant,
754753
ty::VarianceDiagInfo::default(),
@@ -757,7 +756,7 @@ impl<'tcx> TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
757756
)?;
758757
Ok(self.tcx().mk_const(ty::Const {
759758
ty: c.ty,
760-
val: ty::ConstKind::Unevaluated(ty::Unevaluated::new(uv.def, substs)),
759+
val: ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }),
761760
}))
762761
}
763762
_ => relate::super_relate_consts(self, c, c),
@@ -991,9 +990,10 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
991990
}
992991
}
993992
}
994-
ty::ConstKind::Unevaluated(uv) if self.tcx().lazy_normalization() => {
995-
assert_eq!(uv.promoted, None);
996-
let substs = uv.substs(self.tcx());
993+
ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted })
994+
if self.tcx().lazy_normalization() =>
995+
{
996+
assert_eq!(promoted, None);
997997
let substs = self.relate_with_variance(
998998
ty::Variance::Invariant,
999999
ty::VarianceDiagInfo::default(),
@@ -1002,7 +1002,7 @@ impl<'tcx> TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
10021002
)?;
10031003
Ok(self.tcx().mk_const(ty::Const {
10041004
ty: c.ty,
1005-
val: ty::ConstKind::Unevaluated(ty::Unevaluated::new(uv.def, substs)),
1005+
val: ty::ConstKind::Unevaluated(ty::Unevaluated { def, substs, promoted }),
10061006
}))
10071007
}
10081008
_ => relate::super_relate_consts(self, c, c),

compiler/rustc_infer/src/infer/error_reporting/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1550,10 +1550,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15501550
}
15511551

15521552
impl<'tcx> ty::fold::TypeVisitor<'tcx> for OpaqueTypesVisitor<'tcx> {
1553-
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
1554-
Some(self.tcx)
1555-
}
1556-
15571553
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
15581554
if let Some((kind, def_id)) = TyCategory::from_ty(self.tcx, t) {
15591555
let span = self.tcx.def_span(def_id);

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'a, 'tcx> FindHirNodeVisitor<'a, 'tcx> {
5252

5353
fn node_ty_contains_target(&self, hir_id: HirId) -> Option<Ty<'tcx>> {
5454
self.node_type_opt(hir_id).map(|ty| self.infcx.resolve_vars_if_possible(ty)).filter(|ty| {
55-
ty.walk(self.infcx.tcx).any(|inner| {
55+
ty.walk().any(|inner| {
5656
inner == self.target
5757
|| match (inner.unpack(), self.target.unpack()) {
5858
(GenericArgKind::Type(inner_ty), GenericArgKind::Type(target_ty)) => {
@@ -445,9 +445,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
445445
parent: None,
446446
}
447447
}
448-
ty::ConstKind::Unevaluated(ty::Unevaluated {
449-
substs_: Some(substs), ..
450-
}) => {
448+
ty::ConstKind::Unevaluated(ty::Unevaluated { substs, .. }) => {
451449
assert!(substs.has_infer_types_or_consts());
452450

453451
// FIXME: We only use the first inference variable we encounter in

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/static_impl_trait.rs

-6
Original file line numberDiff line numberDiff line change
@@ -557,12 +557,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
557557
pub(super) struct TraitObjectVisitor(pub(super) FxHashSet<DefId>);
558558

559559
impl<'tcx> TypeVisitor<'tcx> for TraitObjectVisitor {
560-
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
561-
// The default anon const substs cannot include
562-
// trait objects, so we don't have to bother looking.
563-
None
564-
}
565-
566560
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
567561
match t.kind() {
568562
ty::Dynamic(preds, RegionKind::ReStatic) => {

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/trait_impl_difference.rs

+7-12
Original file line numberDiff line numberDiff line change
@@ -80,26 +80,21 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
8080

8181
// Mark all unnamed regions in the type with a number.
8282
// This diagnostic is called in response to lifetime errors, so be informative.
83-
struct HighlightBuilder<'tcx> {
83+
struct HighlightBuilder {
8484
highlight: RegionHighlightMode,
85-
tcx: TyCtxt<'tcx>,
8685
counter: usize,
8786
}
8887

89-
impl<'tcx> HighlightBuilder<'tcx> {
90-
fn build(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> RegionHighlightMode {
88+
impl HighlightBuilder {
89+
fn build(ty: Ty<'_>) -> RegionHighlightMode {
9190
let mut builder =
92-
HighlightBuilder { highlight: RegionHighlightMode::default(), counter: 1, tcx };
91+
HighlightBuilder { highlight: RegionHighlightMode::default(), counter: 1 };
9392
builder.visit_ty(ty);
9493
builder.highlight
9594
}
9695
}
9796

98-
impl<'tcx> ty::fold::TypeVisitor<'tcx> for HighlightBuilder<'tcx> {
99-
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
100-
Some(self.tcx)
101-
}
102-
97+
impl<'tcx> ty::fold::TypeVisitor<'tcx> for HighlightBuilder {
10398
fn visit_region(&mut self, r: ty::Region<'tcx>) -> ControlFlow<Self::BreakTy> {
10499
if !r.has_name() && self.counter <= 3 {
105100
self.highlight.highlighting_region(r, self.counter);
@@ -109,12 +104,12 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
109104
}
110105
}
111106

112-
let expected_highlight = HighlightBuilder::build(self.tcx(), expected);
107+
let expected_highlight = HighlightBuilder::build(expected);
113108
let expected = self
114109
.infcx
115110
.extract_inference_diagnostics_data(expected.into(), Some(expected_highlight))
116111
.name;
117-
let found_highlight = HighlightBuilder::build(self.tcx(), found);
112+
let found_highlight = HighlightBuilder::build(found);
118113
let found =
119114
self.infcx.extract_inference_diagnostics_data(found.into(), Some(found_highlight)).name;
120115

compiler/rustc_infer/src/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
146146
}
147147

148148
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
149-
if !t.needs_infer() && !t.has_erasable_regions(self.tcx()) {
149+
if !t.needs_infer() && !t.has_erasable_regions() {
150150
return t;
151151
}
152152

compiler/rustc_infer/src/infer/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
668668
/// canonicalizing the consts.
669669
pub fn try_unify_abstract_consts(
670670
&self,
671-
a: ty::Unevaluated<'tcx, ()>,
672-
b: ty::Unevaluated<'tcx, ()>,
671+
a: ty::Unevaluated<'tcx>,
672+
b: ty::Unevaluated<'tcx>,
673673
) -> bool {
674-
let canonical = self.canonicalize_query((a, b), &mut OriginalQueryValues::default());
674+
let canonical = self.canonicalize_query(
675+
((a.def, a.substs), (b.def, b.substs)),
676+
&mut OriginalQueryValues::default(),
677+
);
675678
debug!("canonical consts: {:?}", &canonical.value);
676679

677680
self.tcx.try_unify_abstract_consts(canonical.value)
@@ -1585,8 +1588,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15851588
unevaluated: ty::Unevaluated<'tcx>,
15861589
span: Option<Span>,
15871590
) -> EvalToConstValueResult<'tcx> {
1588-
let mut substs = unevaluated.substs(self.tcx);
1589-
substs = self.resolve_vars_if_possible(substs);
1591+
let substs = self.resolve_vars_if_possible(unevaluated.substs);
15901592

15911593
// Postpone the evaluation of constants whose substs depend on inference
15921594
// variables
@@ -1599,7 +1601,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
15991601

16001602
let unevaluated = ty::Unevaluated {
16011603
def: unevaluated.def,
1602-
substs_: Some(substs_erased),
1604+
substs: substs_erased,
16031605
promoted: unevaluated.promoted,
16041606
};
16051607

compiler/rustc_infer/src/infer/nll_relate/mod.rs

-6
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ where
201201
};
202202

203203
value.skip_binder().visit_with(&mut ScopeInstantiator {
204-
tcx: self.infcx.tcx,
205204
next_region: &mut next_region,
206205
target_index: ty::INNERMOST,
207206
bound_region_scope: &mut scope,
@@ -759,18 +758,13 @@ where
759758
/// `for<..`>. For each of those, it creates an entry in
760759
/// `bound_region_scope`.
761760
struct ScopeInstantiator<'me, 'tcx> {
762-
tcx: TyCtxt<'tcx>,
763761
next_region: &'me mut dyn FnMut(ty::BoundRegion) -> ty::Region<'tcx>,
764762
// The debruijn index of the scope we are instantiating.
765763
target_index: ty::DebruijnIndex,
766764
bound_region_scope: &'me mut BoundRegionScope<'tcx>,
767765
}
768766

769767
impl<'me, 'tcx> TypeVisitor<'tcx> for ScopeInstantiator<'me, 'tcx> {
770-
fn tcx_for_anon_const_substs(&self) -> Option<TyCtxt<'tcx>> {
771-
Some(self.tcx)
772-
}
773-
774768
fn visit_binder<T: TypeFoldable<'tcx>>(
775769
&mut self,
776770
t: &ty::Binder<'tcx, T>,

0 commit comments

Comments
 (0)