Skip to content

Commit c51eb81

Browse files
committed
Merge from rustc
2 parents eee5a77 + 59c217f commit c51eb81

File tree

168 files changed

+2338
-671
lines changed

Some content is hidden

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

168 files changed

+2338
-671
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3784,6 +3784,7 @@ dependencies = [
37843784
name = "rustc_driver_impl"
37853785
version = "0.0.0"
37863786
dependencies = [
3787+
"ctrlc",
37873788
"libc",
37883789
"rustc_ast",
37893790
"rustc_ast_lowering",

compiler/rustc_borrowck/src/region_infer/mod.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,11 @@ pub struct RegionInferenceContext<'tcx> {
9595
/// visible from this index.
9696
scc_universes: IndexVec<ConstraintSccIndex, ty::UniverseIndex>,
9797

98-
/// Contains a "representative" from each SCC. This will be the
99-
/// minimal RegionVid belonging to that universe. It is used as a
100-
/// kind of hacky way to manage checking outlives relationships,
98+
/// Contains the "representative" region of each SCC.
99+
/// It is defined as the one with the minimal RegionVid, favoring
100+
/// free regions, then placeholders, then existential regions.
101+
///
102+
/// It is a hacky way to manage checking regions for equality,
101103
/// since we can 'canonicalize' each region to the representative
102104
/// of its SCC and be sure that -- if they have the same repr --
103105
/// they *must* be equal (though not having the same repr does not
@@ -481,22 +483,28 @@ impl<'tcx> RegionInferenceContext<'tcx> {
481483
scc_universes
482484
}
483485

484-
/// For each SCC, we compute a unique `RegionVid` (in fact, the
485-
/// minimal one that belongs to the SCC). See
486+
/// For each SCC, we compute a unique `RegionVid`. See the
486487
/// `scc_representatives` field of `RegionInferenceContext` for
487488
/// more details.
488489
fn compute_scc_representatives(
489490
constraints_scc: &Sccs<RegionVid, ConstraintSccIndex>,
490491
definitions: &IndexSlice<RegionVid, RegionDefinition<'tcx>>,
491492
) -> IndexVec<ConstraintSccIndex, ty::RegionVid> {
492493
let num_sccs = constraints_scc.num_sccs();
493-
let next_region_vid = definitions.next_index();
494-
let mut scc_representatives = IndexVec::from_elem_n(next_region_vid, num_sccs);
495-
496-
for region_vid in definitions.indices() {
497-
let scc = constraints_scc.scc(region_vid);
498-
let prev_min = scc_representatives[scc];
499-
scc_representatives[scc] = region_vid.min(prev_min);
494+
let mut scc_representatives = IndexVec::from_elem_n(RegionVid::MAX, num_sccs);
495+
496+
// Iterate over all RegionVids *in-order* and pick the least RegionVid as the
497+
// representative of its SCC. This naturally prefers free regions over others.
498+
for (vid, def) in definitions.iter_enumerated() {
499+
let repr = &mut scc_representatives[constraints_scc.scc(vid)];
500+
if *repr == ty::RegionVid::MAX {
501+
*repr = vid;
502+
} else if matches!(def.origin, NllRegionVariableOrigin::Placeholder(_))
503+
&& matches!(definitions[*repr].origin, NllRegionVariableOrigin::Existential { .. })
504+
{
505+
// Pick placeholders over existentials even if they have a greater RegionVid.
506+
*repr = vid;
507+
}
500508
}
501509

502510
scc_representatives

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

Lines changed: 210 additions & 169 deletions
Large diffs are not rendered by default.

compiler/rustc_borrowck/src/region_infer/reverse_sccs.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use crate::constraints::ConstraintSccIndex;
22
use crate::RegionInferenceContext;
3-
use itertools::Itertools;
43
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
54
use rustc_data_structures::graph::vec_graph::VecGraph;
65
use rustc_data_structures::graph::WithSuccessors;
@@ -48,16 +47,16 @@ impl RegionInferenceContext<'_> {
4847
.universal_regions
4948
.universal_regions()
5049
.map(|region| (self.constraint_sccs.scc(region), region))
51-
.collect_vec();
50+
.collect::<Vec<_>>();
5251
paired_scc_regions.sort();
5352
let universal_regions = paired_scc_regions.iter().map(|&(_, region)| region).collect();
5453

5554
let mut scc_regions = FxIndexMap::default();
5655
let mut start = 0;
57-
for (scc, group) in &paired_scc_regions.into_iter().group_by(|(scc, _)| *scc) {
58-
let group_size = group.count();
59-
scc_regions.insert(scc, start..start + group_size);
60-
start += group_size;
56+
for chunk in paired_scc_regions.chunk_by(|&(scc1, _), &(scc2, _)| scc1 == scc2) {
57+
let (scc, _) = chunk[0];
58+
scc_regions.insert(scc, start..start + chunk.len());
59+
start += chunk.len();
6160
}
6261

6362
self.rev_scc_graph = Some(ReverseSccGraph { graph, scc_regions, universal_regions });

compiler/rustc_borrowck/src/type_check/free_region_relations.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ impl UniversalRegionRelations<'_> {
164164
self.outlives.contains(fr1, fr2)
165165
}
166166

167+
/// Returns `true` if fr1 is known to equal fr2.
168+
///
169+
/// This will only ever be true for universally quantified regions.
170+
pub(crate) fn equal(&self, fr1: RegionVid, fr2: RegionVid) -> bool {
171+
self.outlives.contains(fr1, fr2) && self.outlives.contains(fr2, fr1)
172+
}
173+
167174
/// Returns a vector of free regions `x` such that `fr1: x` is
168175
/// known to hold.
169176
pub(crate) fn regions_outlived_by(&self, fr1: RegionVid) -> Vec<RegionVid> {

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,22 @@ pub(crate) fn type_check<'mir, 'tcx>(
229229
);
230230
}
231231

232+
// Convert all regions to nll vars.
233+
let (opaque_type_key, hidden_type) =
234+
infcx.tcx.fold_regions((opaque_type_key, hidden_type), |region, _| {
235+
match region.kind() {
236+
ty::ReVar(_) => region,
237+
ty::RePlaceholder(placeholder) => checker
238+
.borrowck_context
239+
.constraints
240+
.placeholder_region(infcx, placeholder),
241+
_ => ty::Region::new_var(
242+
infcx.tcx,
243+
checker.borrowck_context.universal_regions.to_region_vid(region),
244+
),
245+
}
246+
});
247+
232248
(opaque_type_key, hidden_type)
233249
})
234250
.collect();

compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,6 @@ rm tests/ui/parser/unclosed-delimiter-in-dep.rs # submodule contains //~ERROR
4141
# missing features
4242
# ================
4343

44-
# requires stack unwinding
45-
# FIXME add needs-unwind to these tests
46-
rm -r tests/run-make/libtest-junit
47-
rm tests/ui/asm/may_unwind.rs
48-
rm tests/ui/stable-mir-print/basic_function.rs
49-
50-
# extra warning about -Cpanic=abort for proc macros
51-
rm tests/ui/proc-macro/crt-static.rs
52-
rm tests/ui/proc-macro/proc-macro-deprecated-attr.rs
53-
rm tests/ui/proc-macro/quote-debug.rs
54-
rm tests/ui/proc-macro/no-missing-docs.rs
55-
rm tests/ui/rust-2018/proc-macro-crate-in-paths.rs
56-
rm tests/ui/proc-macro/allowed-signatures.rs
57-
rm tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs
58-
5944
# vendor intrinsics
6045
rm tests/ui/simd/array-type.rs # "Index argument for `simd_insert` is not a constant"
6146
rm tests/ui/asm/x86_64/evex512-implicit-feature.rs # unimplemented AVX512 x86 vendor intrinsic
@@ -154,7 +139,6 @@ rm tests/ui/codegen/subtyping-enforces-type-equality.rs # assert_assignable bug
154139
# ======================
155140
rm tests/ui/backtrace.rs # TODO warning
156141
rm tests/ui/process/nofile-limit.rs # TODO some AArch64 linking issue
157-
rm tests/ui/async-await/async-closures/once.rs # FIXME bug in the rustc FnAbi calculation code
158142

159143
rm tests/ui/stdio-is-blocking.rs # really slow with unoptimized libstd
160144

compiler/rustc_codegen_llvm/src/builder.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use rustc_middle::ty::layout::{
2020
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers, TyAndLayout,
2121
};
2222
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
23+
use rustc_session::config::OptLevel;
2324
use rustc_span::Span;
2425
use rustc_symbol_mangling::typeid::{
2526
kcfi_typeid_for_fnabi, kcfi_typeid_for_instance, typeid_for_fnabi, typeid_for_instance,
@@ -551,6 +552,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
551552
layout: TyAndLayout<'tcx>,
552553
offset: Size,
553554
) {
555+
if bx.cx.sess().opts.optimize == OptLevel::No {
556+
// Don't emit metadata we're not going to use
557+
return;
558+
}
559+
554560
if !scalar.is_uninit_valid() {
555561
bx.noundef_metadata(load);
556562
}
@@ -667,6 +673,11 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
667673
return;
668674
}
669675

676+
if self.cx.sess().opts.optimize == OptLevel::No {
677+
// Don't emit metadata we're not going to use
678+
return;
679+
}
680+
670681
unsafe {
671682
let llty = self.cx.val_ty(load);
672683
let v = [
@@ -1630,7 +1641,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
16301641
}
16311642

16321643
let typeid = if let Some(instance) = instance {
1633-
typeid_for_instance(self.tcx, &instance, options)
1644+
typeid_for_instance(self.tcx, instance, options)
16341645
} else {
16351646
typeid_for_fnabi(self.tcx, fn_abi, options)
16361647
};
@@ -1678,7 +1689,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
16781689
}
16791690

16801691
let kcfi_typeid = if let Some(instance) = instance {
1681-
kcfi_typeid_for_instance(self.tcx, &instance, options)
1692+
kcfi_typeid_for_instance(self.tcx, instance, options)
16821693
} else {
16831694
kcfi_typeid_for_fnabi(self.tcx, fn_abi, options)
16841695
};

compiler/rustc_codegen_llvm/src/declare.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,17 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
141141

142142
if self.tcx.sess.is_sanitizer_cfi_enabled() {
143143
if let Some(instance) = instance {
144-
let typeid = typeid_for_instance(self.tcx, &instance, TypeIdOptions::empty());
144+
let typeid = typeid_for_instance(self.tcx, instance, TypeIdOptions::empty());
145145
self.set_type_metadata(llfn, typeid);
146146
let typeid =
147-
typeid_for_instance(self.tcx, &instance, TypeIdOptions::GENERALIZE_POINTERS);
147+
typeid_for_instance(self.tcx, instance, TypeIdOptions::GENERALIZE_POINTERS);
148148
self.add_type_metadata(llfn, typeid);
149149
let typeid =
150-
typeid_for_instance(self.tcx, &instance, TypeIdOptions::NORMALIZE_INTEGERS);
150+
typeid_for_instance(self.tcx, instance, TypeIdOptions::NORMALIZE_INTEGERS);
151151
self.add_type_metadata(llfn, typeid);
152152
let typeid = typeid_for_instance(
153153
self.tcx,
154-
&instance,
154+
instance,
155155
TypeIdOptions::GENERALIZE_POINTERS | TypeIdOptions::NORMALIZE_INTEGERS,
156156
);
157157
self.add_type_metadata(llfn, typeid);
@@ -182,7 +182,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
182182
}
183183

184184
if let Some(instance) = instance {
185-
let kcfi_typeid = kcfi_typeid_for_instance(self.tcx, &instance, options);
185+
let kcfi_typeid = kcfi_typeid_for_instance(self.tcx, instance, options);
186186
self.set_kcfi_type_metadata(llfn, kcfi_typeid);
187187
} else {
188188
let kcfi_typeid = kcfi_typeid_for_fnabi(self.tcx, fn_abi, options);

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ fn produce_final_output_artifacts(
592592
.unwrap()
593593
.to_owned();
594594

595-
if crate_output.outputs.contains_key(&output_type) {
595+
if crate_output.outputs.contains_explicit_name(&output_type) {
596596
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
597597
// no good solution for this case, so warn the user.
598598
sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });

0 commit comments

Comments
 (0)