Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7637653

Browse files
committed
Auto merge of rust-lang#114368 - Nilstrieb:rollup-pgvm9cf, r=Nilstrieb
Rollup of 5 pull requests Successful merges: - rust-lang#114079 (Use `upvar_tys` in more places, make it return a list) - rust-lang#114166 (Add regression test for resolving `--extern libc=test.rlib`) - rust-lang#114321 (get auto traits for parallel rustc) - rust-lang#114335 (fix and extend ptr_comparison test) - rust-lang#114347 (x.py print more detailed format files and untracked files count) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d170833 + da2b237 commit 7637653

File tree

24 files changed

+120
-165
lines changed

24 files changed

+120
-165
lines changed

compiler/rustc_ast/src/format.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ pub struct FormatArguments {
6767
names: FxHashMap<Symbol, usize>,
6868
}
6969

70-
// FIXME: Rustdoc has trouble proving Send/Sync for this. See #106930.
71-
#[cfg(parallel_compiler)]
72-
unsafe impl Sync for FormatArguments {}
73-
#[cfg(parallel_compiler)]
74-
unsafe impl Send for FormatArguments {}
75-
7670
impl FormatArguments {
7771
pub fn new() -> Self {
7872
Self {

compiler/rustc_borrowck/src/diagnostics/region_name.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,7 @@ impl<'tcx> MirBorrowckCtxt<'_, 'tcx> {
886886
.universal_regions()
887887
.defining_ty
888888
.upvar_tys()
889+
.iter()
889890
.position(|ty| self.any_param_predicate_mentions(&predicates, ty, region))
890891
{
891892
let (upvar_name, upvar_span) = self.regioncx.get_upvar_name_and_span_for_region(

compiler/rustc_borrowck/src/diagnostics/var_name.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
4343
fr: RegionVid,
4444
) -> Option<usize> {
4545
let upvar_index =
46-
self.universal_regions().defining_ty.upvar_tys().position(|upvar_ty| {
46+
self.universal_regions().defining_ty.upvar_tys().iter().position(|upvar_ty| {
4747
debug!("get_upvar_index_for_region: upvar_ty={upvar_ty:?}");
4848
tcx.any_free_region_meets(&upvar_ty, |r| {
4949
let r = r.as_var();
@@ -52,7 +52,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
5252
})
5353
})?;
5454

55-
let upvar_ty = self.universal_regions().defining_ty.upvar_tys().nth(upvar_index);
55+
let upvar_ty = self.universal_regions().defining_ty.upvar_tys().get(upvar_index);
5656

5757
debug!(
5858
"get_upvar_index_for_region: found {fr:?} in upvar {upvar_index} which has type {upvar_ty:?}",

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -791,25 +791,20 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
791791
(adt_def.variant(FIRST_VARIANT), args)
792792
}
793793
ty::Closure(_, args) => {
794-
return match args
795-
.as_closure()
796-
.tupled_upvars_ty()
797-
.tuple_fields()
798-
.get(field.index())
799-
{
794+
return match args.as_closure().upvar_tys().get(field.index()) {
800795
Some(&ty) => Ok(ty),
801796
None => Err(FieldAccessError::OutOfRange {
802-
field_count: args.as_closure().upvar_tys().count(),
797+
field_count: args.as_closure().upvar_tys().len(),
803798
}),
804799
};
805800
}
806801
ty::Generator(_, args, _) => {
807802
// Only prefix fields (upvars and current state) are
808803
// accessible without a variant index.
809-
return match args.as_generator().prefix_tys().nth(field.index()) {
810-
Some(ty) => Ok(ty),
804+
return match args.as_generator().prefix_tys().get(field.index()) {
805+
Some(ty) => Ok(*ty),
811806
None => Err(FieldAccessError::OutOfRange {
812-
field_count: args.as_generator().prefix_tys().count(),
807+
field_count: args.as_generator().prefix_tys().len(),
813808
}),
814809
};
815810
}
@@ -1772,21 +1767,21 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
17721767
}
17731768
}
17741769
AggregateKind::Closure(_, args) => {
1775-
match args.as_closure().upvar_tys().nth(field_index.as_usize()) {
1776-
Some(ty) => Ok(ty),
1770+
match args.as_closure().upvar_tys().get(field_index.as_usize()) {
1771+
Some(ty) => Ok(*ty),
17771772
None => Err(FieldAccessError::OutOfRange {
1778-
field_count: args.as_closure().upvar_tys().count(),
1773+
field_count: args.as_closure().upvar_tys().len(),
17791774
}),
17801775
}
17811776
}
17821777
AggregateKind::Generator(_, args, _) => {
17831778
// It doesn't make sense to look at a field beyond the prefix;
17841779
// these require a variant index, and are not initialized in
17851780
// aggregate rvalues.
1786-
match args.as_generator().prefix_tys().nth(field_index.as_usize()) {
1787-
Some(ty) => Ok(ty),
1781+
match args.as_generator().prefix_tys().get(field_index.as_usize()) {
1782+
Some(ty) => Ok(*ty),
17881783
None => Err(FieldAccessError::OutOfRange {
1789-
field_count: args.as_generator().prefix_tys().count(),
1784+
field_count: args.as_generator().prefix_tys().len(),
17901785
}),
17911786
}
17921787
}

compiler/rustc_borrowck/src/universal_regions.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//! The code in this file doesn't *do anything* with those results; it
1313
//! just returns them for other code to use.
1414
15-
use either::Either;
1615
use rustc_data_structures::fx::FxHashMap;
1716
use rustc_errors::Diagnostic;
1817
use rustc_hir as hir;
@@ -115,14 +114,12 @@ impl<'tcx> DefiningTy<'tcx> {
115114
/// not a closure or generator, there are no upvars, and hence it
116115
/// will be an empty list. The order of types in this list will
117116
/// match up with the upvar order in the HIR, typesystem, and MIR.
118-
pub fn upvar_tys(self) -> impl Iterator<Item = Ty<'tcx>> + 'tcx {
117+
pub fn upvar_tys(self) -> &'tcx ty::List<Ty<'tcx>> {
119118
match self {
120-
DefiningTy::Closure(_, args) => Either::Left(args.as_closure().upvar_tys()),
121-
DefiningTy::Generator(_, args, _) => {
122-
Either::Right(Either::Left(args.as_generator().upvar_tys()))
123-
}
119+
DefiningTy::Closure(_, args) => args.as_closure().upvar_tys(),
120+
DefiningTy::Generator(_, args, _) => args.as_generator().upvar_tys(),
124121
DefiningTy::FnDef(..) | DefiningTy::Const(..) | DefiningTy::InlineConst(..) => {
125-
Either::Right(Either::Right(iter::empty()))
122+
ty::List::empty()
126123
}
127124
}
128125
}

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -990,14 +990,8 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
990990
closure_or_generator_di_node: &'ll DIType,
991991
) -> SmallVec<&'ll DIType> {
992992
let (&def_id, up_var_tys) = match closure_or_generator_ty.kind() {
993-
ty::Generator(def_id, args, _) => {
994-
let upvar_tys: SmallVec<_> = args.as_generator().prefix_tys().collect();
995-
(def_id, upvar_tys)
996-
}
997-
ty::Closure(def_id, args) => {
998-
let upvar_tys: SmallVec<_> = args.as_closure().upvar_tys().collect();
999-
(def_id, upvar_tys)
1000-
}
993+
ty::Generator(def_id, args, _) => (def_id, args.as_generator().prefix_tys()),
994+
ty::Closure(def_id, args) => (def_id, args.as_closure().upvar_tys()),
1001995
_ => {
1002996
bug!(
1003997
"build_upvar_field_di_nodes() called with non-closure-or-generator-type: {:?}",
@@ -1007,9 +1001,7 @@ fn build_upvar_field_di_nodes<'ll, 'tcx>(
10071001
};
10081002

10091003
debug_assert!(
1010-
up_var_tys
1011-
.iter()
1012-
.all(|&t| t == cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), t))
1004+
up_var_tys.iter().all(|t| t == cx.tcx.normalize_erasing_regions(ParamEnv::reveal_all(), t))
10131005
);
10141006

10151007
let capture_names = cx.tcx.closure_saved_names_of_captured_variables(def_id);

compiler/rustc_codegen_llvm/src/debuginfo/metadata/enums/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ pub fn build_generator_variant_struct_type_di_node<'ll, 'tcx>(
379379
// Fields that are common to all states
380380
let common_fields: SmallVec<_> = generator_args
381381
.prefix_tys()
382+
.iter()
382383
.zip(common_upvar_names)
383384
.enumerate()
384385
.map(|(index, (upvar_ty, upvar_name))| {

compiler/rustc_const_eval/src/transform/validate.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
630630
}
631631
ty::Closure(_, args) => {
632632
let args = args.as_closure();
633-
let Some(f_ty) = args.upvar_tys().nth(f.as_usize()) else {
633+
let Some(&f_ty) = args.upvar_tys().get(f.as_usize()) else {
634634
fail_out_of_bounds(self, location);
635635
return;
636636
};
@@ -667,7 +667,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
667667

668668
f_ty.ty
669669
} else {
670-
let Some(f_ty) = args.as_generator().prefix_tys().nth(f.index()) else {
670+
let Some(&f_ty) = args.as_generator().prefix_tys().get(f.index())
671+
else {
671672
fail_out_of_bounds(self, location);
672673
return;
673674
};

compiler/rustc_infer/src/infer/opaque_types.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,15 +448,19 @@ where
448448
ty::Closure(_, ref args) => {
449449
// Skip lifetime parameters of the enclosing item(s)
450450

451-
args.as_closure().tupled_upvars_ty().visit_with(self);
451+
for upvar in args.as_closure().upvar_tys() {
452+
upvar.visit_with(self);
453+
}
452454
args.as_closure().sig_as_fn_ptr_ty().visit_with(self);
453455
}
454456

455457
ty::Generator(_, ref args, _) => {
456458
// Skip lifetime parameters of the enclosing item(s)
457459
// Also skip the witness type, because that has no free regions.
458460

459-
args.as_generator().tupled_upvars_ty().visit_with(self);
461+
for upvar in args.as_generator().upvar_tys() {
462+
upvar.visit_with(self);
463+
}
460464
args.as_generator().return_ty().visit_with(self);
461465
args.as_generator().yield_ty().visit_with(self);
462466
args.as_generator().resume_ty().visit_with(self);

compiler/rustc_middle/src/ty/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ where
911911
if i == tag_field {
912912
return TyMaybeWithLayout::TyAndLayout(tag_layout(tag));
913913
}
914-
TyMaybeWithLayout::Ty(args.as_generator().prefix_tys().nth(i).unwrap())
914+
TyMaybeWithLayout::Ty(args.as_generator().prefix_tys()[i])
915915
}
916916
},
917917

0 commit comments

Comments
 (0)