Skip to content

Commit 6b12e7e

Browse files
committed
Auto merge of #127837 - tgross35:rollup-bq4ffc3, r=tgross35
Rollup of 11 pull requests Successful merges: - #125206 (Simplify environment variable examples) - #126208 (Migrate `compiler-lookup-paths`, `dump-mono-stats` and `prune-link-args` `run-make` tests to `rmake` or `ui` format) - #126271 (Skip fast path for dec2flt when optimize_for_size) - #126776 (Clean up more comments near use declarations) - #127444 (`impl Send + Sync` and override `count` for the `CStr::bytes` iterator) - #127792 (std: Use `read_unaligned` for reads from DWARF) - #127807 (Use futex.rs for Windows thread parking) - #127810 (Rename `tcx` to `cx` in `rustc_type_ir`) - #127816 (Update method name to reflect changes to its internals) - #127833 (zkvm: add `#[forbid(unsafe_op_in_unsafe_fn)]` in `stdlib`) - #127836 (std: Forbid unwrapped unsafe ops in xous and uefi modules) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7d356eb + e6dcab8 commit 6b12e7e

File tree

79 files changed

+516
-376
lines changed

Some content is hidden

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

79 files changed

+516
-376
lines changed

Cargo.lock

-7
Original file line numberDiff line numberDiff line change
@@ -228,12 +228,6 @@ dependencies = [
228228
"backtrace",
229229
]
230230

231-
[[package]]
232-
name = "ar"
233-
version = "0.9.0"
234-
source = "registry+https://github.com/rust-lang/crates.io-index"
235-
checksum = "d67af77d68a931ecd5cbd8a3b5987d63a1d1d1278f7f6a60ae33db485cdebb69"
236-
237231
[[package]]
238232
name = "ar_archive_writer"
239233
version = "0.3.0"
@@ -3451,7 +3445,6 @@ dependencies = [
34513445
name = "run_make_support"
34523446
version = "0.2.0"
34533447
dependencies = [
3454-
"ar",
34553448
"bstr",
34563449
"build_helper",
34573450
"gimli 0.31.0",

compiler/rustc_borrowck/src/type_check/relate_tys.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ impl<'me, 'bccx, 'tcx> NllTypeRelating<'me, 'bccx, 'tcx> {
309309
}
310310

311311
impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx> {
312-
fn tcx(&self) -> TyCtxt<'tcx> {
312+
fn cx(&self) -> TyCtxt<'tcx> {
313313
self.type_checker.infcx.tcx
314314
}
315315

@@ -370,7 +370,7 @@ impl<'bccx, 'tcx> TypeRelation<TyCtxt<'tcx>> for NllTypeRelating<'_, 'bccx, 'tcx
370370
// shouldn't ever fail. Instead, it unconditionally emits an
371371
// alias-relate goal.
372372
assert!(!self.type_checker.infcx.next_trait_solver());
373-
self.tcx().dcx().span_delayed_bug(
373+
self.cx().dcx().span_delayed_bug(
374374
self.span(),
375375
"failure to relate an opaque to itself should result in an error later on",
376376
);
@@ -540,7 +540,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
540540
&mut self,
541541
obligations: impl IntoIterator<Item: ty::Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
542542
) {
543-
let tcx = self.tcx();
543+
let tcx = self.cx();
544544
let param_env = self.param_env();
545545
self.register_goals(
546546
obligations.into_iter().map(|to_pred| Goal::new(tcx, param_env, to_pred)),
@@ -559,7 +559,7 @@ impl<'bccx, 'tcx> PredicateEmittingRelation<InferCtxt<'tcx>> for NllTypeRelating
559559
.into_iter()
560560
.map(|goal| {
561561
Obligation::new(
562-
self.tcx(),
562+
self.cx(),
563563
ObligationCause::dummy_with_span(self.span()),
564564
goal.param_env,
565565
goal.predicate,

compiler/rustc_const_eval/src/interpret/validity.rs

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use super::{
3434
Pointer, Projectable, Scalar, ValueVisitor,
3535
};
3636

37-
// for the validation errors
3837
use super::InterpError::UndefinedBehavior as Ub;
3938
use super::InterpError::Unsupported as Unsup;
4039
use super::UndefinedBehaviorInfo::*;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1930,7 +1930,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19301930
struct SameTypeModuloInfer<'a, 'tcx>(&'a InferCtxt<'tcx>);
19311931

19321932
impl<'tcx> TypeRelation<TyCtxt<'tcx>> for SameTypeModuloInfer<'_, 'tcx> {
1933-
fn tcx(&self) -> TyCtxt<'tcx> {
1933+
fn cx(&self) -> TyCtxt<'tcx> {
19341934
self.0.tcx
19351935
}
19361936

compiler/rustc_infer/src/infer/outlives/test_type_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstHigherRankedOutlives<'tcx>
137137
"MatchAgainstHigherRankedOutlives"
138138
}
139139

140-
fn tcx(&self) -> TyCtxt<'tcx> {
140+
fn cx(&self) -> TyCtxt<'tcx> {
141141
self.tcx
142142
}
143143

compiler/rustc_infer/src/infer/relate/generalize.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
372372

373373
let is_nested_alias = mem::replace(&mut self.in_alias, true);
374374
let result = match self.relate(alias, alias) {
375-
Ok(alias) => Ok(alias.to_ty(self.tcx())),
375+
Ok(alias) => Ok(alias.to_ty(self.cx())),
376376
Err(e) => {
377377
if is_nested_alias {
378378
return Err(e);
@@ -397,7 +397,7 @@ impl<'tcx> Generalizer<'_, 'tcx> {
397397
}
398398

399399
impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
400-
fn tcx(&self) -> TyCtxt<'tcx> {
400+
fn cx(&self) -> TyCtxt<'tcx> {
401401
self.infcx.tcx
402402
}
403403

@@ -417,7 +417,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
417417
// (e.g., #41849).
418418
relate::relate_args_invariantly(self, a_arg, b_arg)
419419
} else {
420-
let tcx = self.tcx();
420+
let tcx = self.cx();
421421
let opt_variances = tcx.variances_of(item_def_id);
422422
relate::relate_args_with_variances(
423423
self,
@@ -525,7 +525,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
525525
}
526526

527527
debug!("replacing original vid={:?} with new={:?}", vid, new_var_id);
528-
Ok(Ty::new_var(self.tcx(), new_var_id))
528+
Ok(Ty::new_var(self.cx(), new_var_id))
529529
}
530530
}
531531
}
@@ -654,7 +654,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
654654
{
655655
variable_table.union(vid, new_var_id);
656656
}
657-
Ok(ty::Const::new_var(self.tcx(), new_var_id))
657+
Ok(ty::Const::new_var(self.cx(), new_var_id))
658658
}
659659
}
660660
}
@@ -672,7 +672,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Generalizer<'_, 'tcx> {
672672
args,
673673
args,
674674
)?;
675-
Ok(ty::Const::new_unevaluated(self.tcx(), ty::UnevaluatedConst { def, args }))
675+
Ok(ty::Const::new_unevaluated(self.cx(), ty::UnevaluatedConst { def, args }))
676676
}
677677
ty::ConstKind::Placeholder(placeholder) => {
678678
if self.for_universe.can_name(placeholder.universe) {

compiler/rustc_infer/src/infer/relate/glb.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
2727
"Glb"
2828
}
2929

30-
fn tcx(&self) -> TyCtxt<'tcx> {
30+
fn cx(&self) -> TyCtxt<'tcx> {
3131
self.fields.tcx()
3232
}
3333

@@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Glb<'_, '_, 'tcx> {
6161
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
6262
// GLB(&'static u8, &'a u8) == &RegionLUB('static, 'a) u8 == &'static u8
6363
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().lub_regions(
64-
self.tcx(),
64+
self.cx(),
6565
origin,
6666
a,
6767
b,

compiler/rustc_infer/src/infer/relate/lub.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
2727
"Lub"
2828
}
2929

30-
fn tcx(&self) -> TyCtxt<'tcx> {
30+
fn cx(&self) -> TyCtxt<'tcx> {
3131
self.fields.tcx()
3232
}
3333

@@ -61,7 +61,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for Lub<'_, '_, 'tcx> {
6161
let origin = SubregionOrigin::Subtype(Box::new(self.fields.trace.clone()));
6262
// LUB(&'static u8, &'a u8) == &RegionGLB('static, 'a) u8 == &'a u8
6363
Ok(self.fields.infcx.inner.borrow_mut().unwrap_region_constraints().glb_regions(
64-
self.tcx(),
64+
self.cx(),
6565
origin,
6666
a,
6767
b,

compiler/rustc_infer/src/infer/relate/type_relating.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
3232
"TypeRelating"
3333
}
3434

35-
fn tcx(&self) -> TyCtxt<'tcx> {
35+
fn cx(&self) -> TyCtxt<'tcx> {
3636
self.fields.infcx.tcx
3737
}
3838

@@ -48,7 +48,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
4848
// (e.g., #41849).
4949
relate_args_invariantly(self, a_arg, b_arg)
5050
} else {
51-
let tcx = self.tcx();
51+
let tcx = self.cx();
5252
let opt_variances = tcx.variances_of(item_def_id);
5353
relate_args_with_variances(self, item_def_id, opt_variances, a_arg, b_arg, false)
5454
}
@@ -88,7 +88,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
8888
// can't make progress on `A <: B` if both A and B are
8989
// type variables, so record an obligation.
9090
self.fields.goals.push(Goal::new(
91-
self.tcx(),
91+
self.cx(),
9292
self.fields.param_env,
9393
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
9494
a_is_expected: true,
@@ -101,7 +101,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
101101
// can't make progress on `B <: A` if both A and B are
102102
// type variables, so record an obligation.
103103
self.fields.goals.push(Goal::new(
104-
self.tcx(),
104+
self.cx(),
105105
self.fields.param_env,
106106
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
107107
a_is_expected: false,
@@ -134,7 +134,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for TypeRelating<'_, '_, 'tcx> {
134134

135135
(&ty::Error(e), _) | (_, &ty::Error(e)) => {
136136
infcx.set_tainted_by_errors(e);
137-
return Ok(Ty::new_error(self.tcx(), e));
137+
return Ok(Ty::new_error(self.cx(), e));
138138
}
139139

140140
(

compiler/rustc_lint/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ use types::*;
120120
use unit_bindings::*;
121121
use unused::*;
122122

123-
/// Useful for other parts of the compiler / Clippy.
124123
pub use builtin::{MissingDoc, SoftLints};
125124
pub use context::{CheckLintNameResult, FindLintError, LintStore};
126125
pub use context::{EarlyContext, LateContext, LintContext};

compiler/rustc_macros/src/lift.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub fn lift_derive(mut s: synstructure::Structure<'_>) -> proc_macro2::TokenStre
4545
quote! {
4646
type Lifted = #lifted;
4747

48-
fn lift_to_tcx(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
48+
fn lift_to_interner(self, __tcx: ::rustc_middle::ty::TyCtxt<'__lifted>) -> Option<#lifted> {
4949
Some(match self { #body })
5050
}
5151
},

compiler/rustc_middle/src/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ macro_rules! TrivialLiftImpls {
5959
$(
6060
impl<'tcx> $crate::ty::Lift<$crate::ty::TyCtxt<'tcx>> for $ty {
6161
type Lifted = Self;
62-
fn lift_to_tcx(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
62+
fn lift_to_interner(self, _: $crate::ty::TyCtxt<'tcx>) -> Option<Self> {
6363
Some(self)
6464
}
6565
}

compiler/rustc_middle/src/ty/context.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1484,7 +1484,7 @@ impl<'tcx> TyCtxt<'tcx> {
14841484
}
14851485

14861486
pub fn lift<T: Lift<TyCtxt<'tcx>>>(self, value: T) -> Option<T::Lifted> {
1487-
value.lift_to_tcx(self)
1487+
value.lift_to_interner(self)
14881488
}
14891489

14901490
/// Creates a type context. To use the context call `fn enter` which
@@ -2087,7 +2087,7 @@ macro_rules! nop_lift {
20872087
($set:ident; $ty:ty => $lifted:ty) => {
20882088
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for $ty {
20892089
type Lifted = $lifted;
2090-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
2090+
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
20912091
// Assert that the set has the right type.
20922092
// Given an argument that has an interned type, the return type has the type of
20932093
// the corresponding interner set. This won't actually return anything, we're
@@ -2122,7 +2122,7 @@ macro_rules! nop_list_lift {
21222122
($set:ident; $ty:ty => $lifted:ty) => {
21232123
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a List<$ty> {
21242124
type Lifted = &'tcx List<$lifted>;
2125-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
2125+
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
21262126
// Assert that the set has the right type.
21272127
if false {
21282128
let _x: &InternedSet<'tcx, List<$lifted>> = &tcx.interners.$set;
@@ -2160,7 +2160,7 @@ macro_rules! nop_slice_lift {
21602160
($ty:ty => $lifted:ty) => {
21612161
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for &'a [$ty] {
21622162
type Lifted = &'tcx [$lifted];
2163-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
2163+
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
21642164
if self.is_empty() {
21652165
return Some(&[]);
21662166
}

compiler/rustc_middle/src/ty/generic_args.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ impl<'tcx> GenericArg<'tcx> {
308308
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> {
309309
type Lifted = GenericArg<'tcx>;
310310

311-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
311+
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
312312
match self.unpack() {
313313
GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()),
314314
GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()),

compiler/rustc_middle/src/ty/relate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::Pattern<'tcx> {
6969
if inc_a != inc_b {
7070
todo!()
7171
}
72-
Ok(relation.tcx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a }))
72+
Ok(relation.cx().mk_pat(ty::PatternKind::Range { start, end, include_end: inc_a }))
7373
}
7474
}
7575
}
@@ -81,7 +81,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for &'tcx ty::List<ty::PolyExistentialPredicate<
8181
a: Self,
8282
b: Self,
8383
) -> RelateResult<'tcx, Self> {
84-
let tcx = relation.tcx();
84+
let tcx = relation.cx();
8585

8686
// FIXME: this is wasteful, but want to do a perf run to see how slow it is.
8787
// We need to perform this deduplication as we sometimes generate duplicate projections

compiler/rustc_middle/src/ty/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ TrivialTypeTraversalAndLiftImpls! {
283283

284284
impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
285285
type Lifted = Option<T::Lifted>;
286-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
286+
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
287287
Some(match self {
288288
Some(x) => Some(tcx.lift(x)?),
289289
None => None,
@@ -293,7 +293,7 @@ impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
293293

294294
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> {
295295
type Lifted = ty::Term<'tcx>;
296-
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
296+
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
297297
match self.unpack() {
298298
TermKind::Ty(ty) => tcx.lift(ty).map(Into::into),
299299
TermKind::Const(c) => tcx.lift(c).map(Into::into),

compiler/rustc_pattern_analysis/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
2121

2222
use std::fmt;
2323

24-
// Re-exports to avoid rustc_index version issues.
25-
pub use rustc_index::Idx;
26-
pub use rustc_index::IndexVec;
24+
pub use rustc_index::{Idx, IndexVec}; // re-exported to avoid rustc_index version issues
2725

2826
#[cfg(feature = "rustc")]
2927
use rustc_middle::ty::Ty;

compiler/rustc_smir/src/rustc_internal/internal.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
//! due to incomplete stable coverage.
55
66
// Prefer importing stable_mir over internal rustc constructs to make this file more readable.
7+
78
use crate::rustc_smir::Tables;
89
use rustc_middle::ty::{self as rustc_ty, Const as InternalConst, Ty as InternalTy, TyCtxt};
910
use rustc_span::Symbol;

compiler/rustc_trait_selection/src/traits/select/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
3636
"MatchAgainstFreshVars"
3737
}
3838

39-
fn tcx(&self) -> TyCtxt<'tcx> {
39+
fn cx(&self) -> TyCtxt<'tcx> {
4040
self.tcx
4141
}
4242

@@ -77,7 +77,7 @@ impl<'tcx> TypeRelation<TyCtxt<'tcx>> for MatchAgainstFreshVars<'tcx> {
7777
Err(TypeError::Sorts(ExpectedFound::new(true, a, b)))
7878
}
7979

80-
(&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.tcx(), guar)),
80+
(&ty::Error(guar), _) | (_, &ty::Error(guar)) => Ok(Ty::new_error(self.cx(), guar)),
8181

8282
_ => structurally_relate_tys(self, a, b),
8383
}

0 commit comments

Comments
 (0)