Skip to content

Commit d8406ff

Browse files
authored
Rollup merge of rust-lang#64781 - Mark-Simulacrum:no-global-tcx, r=eddyb
Remove stray references to the old global tcx
2 parents d4b4b7f + 4469bdd commit d8406ff

Some content is hidden

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

44 files changed

+97
-209
lines changed

src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ impl DepGraph {
590590
// mark it as green by recursively marking all of its
591591
// dependencies green.
592592
self.try_mark_previous_green(
593-
tcx.global_tcx(),
593+
tcx,
594594
data,
595595
prev_index,
596596
&dep_node

src/librustc/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14601460
// type-checking closure types are in local tables only.
14611461
if !self.in_progress_tables.is_some() || !ty.has_closure_types() {
14621462
if !(param_env, ty).has_local_value() {
1463-
return ty.is_copy_modulo_regions(self.tcx.global_tcx(), param_env, span);
1463+
return ty.is_copy_modulo_regions(self.tcx, param_env, span);
14641464
}
14651465
}
14661466

src/librustc/infer/opaque_types/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -561,15 +561,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
561561
def_id, instantiated_ty
562562
);
563563

564-
let gcx = self.tcx.global_tcx();
565-
566564
// Use substs to build up a reverse map from regions to their
567565
// identity mappings. This is necessary because of `impl
568566
// Trait` lifetimes are computed by replacing existing
569567
// lifetimes with 'static and remapping only those used in the
570568
// `impl Trait` return type, resulting in the parameters
571569
// shifting.
572-
let id_substs = InternalSubsts::identity_for_item(gcx, def_id);
570+
let id_substs = InternalSubsts::identity_for_item(self.tcx, def_id);
573571
let map: FxHashMap<Kind<'tcx>, Kind<'tcx>> = opaque_defn
574572
.substs
575573
.iter()
@@ -851,7 +849,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
851849
)
852850
.emit();
853851

854-
self.tcx().global_tcx().mk_region(ty::ReStatic)
852+
self.tcx().mk_region(ty::ReStatic)
855853
},
856854
}
857855
}

src/librustc/middle/intrinsicck.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl ExprVisitor<'tcx> {
8282

8383
// Special-case transmutting from `typeof(function)` and
8484
// `Option<typeof(function)>` to present a clearer error.
85-
let from = unpack_option_like(self.tcx.global_tcx(), from);
85+
let from = unpack_option_like(self.tcx, from);
8686
if let (&ty::FnDef(..), SizeSkeleton::Known(size_to)) = (&from.sty, sk_to) {
8787
if size_to == Pointer.size(&self.tcx) {
8888
struct_span_err!(self.tcx.sess, span, E0591,

src/librustc/middle/mem_categorization.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> {
749749
.unwrap_or(ty::ClosureKind::LATTICE_BOTTOM),
750750

751751
None =>
752-
closure_substs.closure_kind(closure_def_id, self.tcx.global_tcx()),
752+
closure_substs.closure_kind(closure_def_id, self.tcx),
753753
}
754754
}
755755
_ => span_bug!(span, "unexpected type for fn in mem_categorization: {:?}", ty),

src/librustc/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1504,7 +1504,7 @@ impl<'tcx> TerminatorKind<'tcx> {
15041504
Goto { .. } => vec!["".into()],
15051505
SwitchInt { ref values, switch_ty, .. } => ty::tls::with(|tcx| {
15061506
let param_env = ty::ParamEnv::empty();
1507-
let switch_ty = tcx.lift_to_global(&switch_ty).unwrap();
1507+
let switch_ty = tcx.lift(&switch_ty).unwrap();
15081508
let size = tcx.layout_of(param_env.and(switch_ty)).unwrap().size;
15091509
values
15101510
.iter()

src/librustc/traits/chalk_fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl TraitEngine<'tcx> for FulfillmentContext<'tcx> {
108108
goal: obligation.goal.predicate,
109109
}, &mut orig_values);
110110

111-
match infcx.tcx.global_tcx().evaluate_goal(canonical_goal) {
111+
match infcx.tcx.evaluate_goal(canonical_goal) {
112112
Ok(response) => {
113113
if response.is_proven() {
114114
making_progress = true;

src/librustc/traits/error_reporting.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
497497
4
498498
};
499499

500-
let normalize = |candidate| self.tcx.global_tcx().infer_ctxt().enter(|ref infcx| {
500+
let normalize = |candidate| self.tcx.infer_ctxt().enter(|ref infcx| {
501501
let normalized = infcx
502502
.at(&ObligationCause::dummy(), ty::ParamEnv::empty())
503503
.normalize(candidate)
@@ -783,8 +783,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
783783
}
784784

785785
ty::Predicate::ObjectSafe(trait_def_id) => {
786-
let violations = self.tcx.global_tcx()
787-
.object_safety_violations(trait_def_id);
786+
let violations = self.tcx.object_safety_violations(trait_def_id);
788787
if let Some(err) = self.tcx.report_object_safety_error(
789788
span,
790789
trait_def_id,
@@ -920,7 +919,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
920919
}
921920

922921
TraitNotObjectSafe(did) => {
923-
let violations = self.tcx.global_tcx().object_safety_violations(did);
922+
let violations = self.tcx.object_safety_violations(did);
924923
if let Some(err) = self.tcx.report_object_safety_error(span, did, violations) {
925924
err
926925
} else {

src/librustc/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
495495
} else {
496496
if !substs.has_local_value() {
497497
let instance = ty::Instance::resolve(
498-
self.selcx.tcx().global_tcx(),
498+
self.selcx.tcx(),
499499
obligation.param_env,
500500
def_id,
501501
substs,

src/librustc/traits/query/dropck_outlives.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,11 @@ impl<'cx, 'tcx> At<'cx, 'tcx> {
4040
};
4141
}
4242

43-
let gcx = tcx.global_tcx();
4443
let mut orig_values = OriginalQueryValues::default();
4544
let c_ty = self.infcx.canonicalize_query(&self.param_env.and(ty), &mut orig_values);
4645
let span = self.cause.span;
4746
debug!("c_ty = {:?}", c_ty);
48-
if let Ok(result) = &gcx.dropck_outlives(c_ty) {
47+
if let Ok(result) = &tcx.dropck_outlives(c_ty) {
4948
if result.is_proven() {
5049
if let Ok(InferOk { value, obligations }) =
5150
self.infcx.instantiate_query_response_and_region_obligations(

src/librustc/traits/query/evaluate_obligation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
5050
// Run canonical query. If overflow occurs, rerun from scratch but this time
5151
// in standard trait query mode so that overflow is handled appropriately
5252
// within `SelectionContext`.
53-
self.tcx.global_tcx().evaluate_obligation(c_pred)
53+
self.tcx.evaluate_obligation(c_pred)
5454
}
5555

5656
// Helper function that canonicalizes and runs the query. If an

src/librustc/traits/query/normalize.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
141141
// binder). It would be better to normalize in a
142142
// binding-aware fashion.
143143

144-
let gcx = self.infcx.tcx.global_tcx();
144+
let tcx = self.infcx.tcx;
145145

146146
let mut orig_values = OriginalQueryValues::default();
147147
// HACK(matthewjasper) `'static` is special-cased in selection,
@@ -150,7 +150,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
150150
&self.param_env.and(*data), &mut orig_values);
151151
debug!("QueryNormalizer: c_data = {:#?}", c_data);
152152
debug!("QueryNormalizer: orig_values = {:#?}", orig_values);
153-
match gcx.normalize_projection_ty(c_data) {
153+
match tcx.normalize_projection_ty(c_data) {
154154
Ok(result) => {
155155
// We don't expect ambiguity.
156156
if result.is_ambiguous() {

src/librustc/traits/query/outlives_bounds.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
9797

9898
let mut orig_values = OriginalQueryValues::default();
9999
let key = self.canonicalize_query(&param_env.and(ty), &mut orig_values);
100-
let result = match self.tcx.global_tcx().implied_outlives_bounds(key) {
100+
let result = match self.tcx.implied_outlives_bounds(key) {
101101
Ok(r) => r,
102102
Err(NoSolution) => {
103103
self.tcx.sess.delay_span_bug(

src/librustc/traits/query/type_op/ascribe_user_type.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::hir::def_id::DefId;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
@@ -37,12 +37,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for AscribeUserType<'tcx> {
3737
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
3838
tcx.type_op_ascribe_user_type(canonicalized)
3939
}
40-
41-
fn shrink_to_tcx_lifetime(
42-
v: &'a CanonicalizedQueryResponse<'tcx, ()>,
43-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> {
44-
v
45-
}
4640
}
4741

4842
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/eq.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
44

@@ -34,12 +34,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for Eq<'tcx> {
3434
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
3535
tcx.type_op_eq(canonicalized)
3636
}
37-
38-
fn shrink_to_tcx_lifetime(
39-
v: &'a CanonicalizedQueryResponse<'tcx, ()>,
40-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> {
41-
v
42-
}
4337
}
4438

4539
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/implied_outlives_bounds.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::outlives_bounds::OutlivesBound;
33
use crate::traits::query::Fallible;
44
use crate::ty::{ParamEnvAnd, Ty, TyCtxt};
@@ -38,12 +38,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ImpliedOutlivesBounds<'tcx> {
3838

3939
tcx.implied_outlives_bounds(canonicalized)
4040
}
41-
42-
fn shrink_to_tcx_lifetime(
43-
v: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
44-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> {
45-
v
46-
}
4741
}
4842

4943
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/mod.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::infer::canonical::{
2-
Canonical, Canonicalized, CanonicalizedQueryResponse, OriginalQueryValues,
3-
QueryRegionConstraints, QueryResponse,
2+
Canonicalized, CanonicalizedQueryResponse, OriginalQueryValues,
3+
QueryRegionConstraints,
44
};
55
use crate::infer::{InferCtxt, InferOk};
66
use std::fmt;
@@ -66,22 +66,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx {
6666
canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
6767
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>>;
6868

69-
/// Casts a lifted query result (which is in the gcx lifetime)
70-
/// into the tcx lifetime. This is always just an identity cast,
71-
/// but the generic code doesn't realize it -- put another way, in
72-
/// the generic code, we have a `Lifted<'tcx, Self::QueryResponse>`
73-
/// and we want to convert that to a `Self::QueryResponse`. This is
74-
/// not a priori valid, so we can't do it -- but in practice, it
75-
/// is always a no-op (e.g., the lifted form of a type,
76-
/// `Ty<'tcx>`, is a subtype of `Ty<'tcx>`). So we have to push
77-
/// the operation into the impls that know more specifically what
78-
/// `QueryResponse` is. This operation would (maybe) be nicer with
79-
/// something like HKTs or GATs, since then we could make
80-
/// `QueryResponse` parametric and `'tcx` and `'tcx` etc.
81-
fn shrink_to_tcx_lifetime(
82-
lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
83-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>>;
84-
8569
fn fully_perform_into(
8670
query_key: ParamEnvAnd<'tcx, Self>,
8771
infcx: &InferCtxt<'_, 'tcx>,
@@ -99,7 +83,6 @@ pub trait QueryTypeOp<'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + 'tcx {
9983
let canonical_self =
10084
infcx.canonicalize_hr_query_hack(&query_key, &mut canonical_var_values);
10185
let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?;
102-
let canonical_result = Self::shrink_to_tcx_lifetime(&canonical_result);
10386

10487
let param_env = query_key.param_env;
10588

src/librustc/traits/query/type_op/normalize.rs

+1-37
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use std::fmt;
33
use crate::traits::query::Fallible;
44
use crate::ty::fold::TypeFoldable;
@@ -38,25 +38,13 @@ where
3838
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self::QueryResponse>> {
3939
T::type_op_method(tcx, canonicalized)
4040
}
41-
42-
fn shrink_to_tcx_lifetime(
43-
v: &'a CanonicalizedQueryResponse<'tcx, T>,
44-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, T>> {
45-
T::shrink_to_tcx_lifetime(v)
46-
}
4741
}
4842

4943
pub trait Normalizable<'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'tcx> + Copy {
5044
fn type_op_method(
5145
tcx: TyCtxt<'tcx>,
5246
canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
5347
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>>;
54-
55-
/// Converts from the `'tcx` (lifted) form of `Self` into the `tcx`
56-
/// form of `Self`.
57-
fn shrink_to_tcx_lifetime(
58-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
59-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>>;
6048
}
6149

6250
impl Normalizable<'tcx> for Ty<'tcx> {
@@ -66,12 +54,6 @@ impl Normalizable<'tcx> for Ty<'tcx> {
6654
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
6755
tcx.type_op_normalize_ty(canonicalized)
6856
}
69-
70-
fn shrink_to_tcx_lifetime(
71-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
72-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
73-
v
74-
}
7557
}
7658

7759
impl Normalizable<'tcx> for ty::Predicate<'tcx> {
@@ -81,12 +63,6 @@ impl Normalizable<'tcx> for ty::Predicate<'tcx> {
8163
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
8264
tcx.type_op_normalize_predicate(canonicalized)
8365
}
84-
85-
fn shrink_to_tcx_lifetime(
86-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
87-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
88-
v
89-
}
9066
}
9167

9268
impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
@@ -96,12 +72,6 @@ impl Normalizable<'tcx> for ty::PolyFnSig<'tcx> {
9672
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
9773
tcx.type_op_normalize_poly_fn_sig(canonicalized)
9874
}
99-
100-
fn shrink_to_tcx_lifetime(
101-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
102-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
103-
v
104-
}
10575
}
10676

10777
impl Normalizable<'tcx> for ty::FnSig<'tcx> {
@@ -111,12 +81,6 @@ impl Normalizable<'tcx> for ty::FnSig<'tcx> {
11181
) -> Fallible<CanonicalizedQueryResponse<'tcx, Self>> {
11282
tcx.type_op_normalize_fn_sig(canonicalized)
11383
}
114-
115-
fn shrink_to_tcx_lifetime(
116-
v: &'a CanonicalizedQueryResponse<'tcx, Self>,
117-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self>> {
118-
v
119-
}
12084
}
12185

12286
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/outlives.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::dropck_outlives::trivial_dropck_outlives;
33
use crate::traits::query::dropck_outlives::DropckOutlivesResult;
44
use crate::traits::query::Fallible;
@@ -53,12 +53,6 @@ impl super::QueryTypeOp<'tcx> for DropckOutlives<'tcx> {
5353

5454
tcx.dropck_outlives(canonicalized)
5555
}
56-
57-
fn shrink_to_tcx_lifetime(
58-
lifted_query_result: &'a CanonicalizedQueryResponse<'tcx, Self::QueryResponse>,
59-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, Self::QueryResponse>> {
60-
lifted_query_result
61-
}
6256
}
6357

6458
BraceStructTypeFoldableImpl! {

src/librustc/traits/query/type_op/prove_predicate.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse};
1+
use crate::infer::canonical::{Canonicalized, CanonicalizedQueryResponse};
22
use crate::traits::query::Fallible;
33
use crate::ty::{ParamEnvAnd, Predicate, TyCtxt};
44

@@ -43,12 +43,6 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
4343
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
4444
tcx.type_op_prove_predicate(canonicalized)
4545
}
46-
47-
fn shrink_to_tcx_lifetime(
48-
v: &'a CanonicalizedQueryResponse<'tcx, ()>,
49-
) -> &'a Canonical<'tcx, QueryResponse<'tcx, ()>> {
50-
v
51-
}
5246
}
5347

5448
BraceStructTypeFoldableImpl! {

0 commit comments

Comments
 (0)