Skip to content

Commit b6d5e41

Browse files
author
The Miri Cronjob Bot
committed
Merge ref '235a4c083eb2' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: 235a4c0 Filtered ref: 548dcbbeab7592100a0ba9f2338ddc8ad1003824 Upstream diff: 36e4f5d...235a4c0 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents 75b60f1 + 235a4c0 commit b6d5e41

File tree

854 files changed

+15056
-12077
lines changed

Some content is hidden

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

854 files changed

+15056
-12077
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ jobs:
246246
run: src/ci/scripts/create-doc-artifacts.sh
247247

248248
- name: print disk usage
249+
# We also want to know the disk usage when the job fails.
250+
if: always()
249251
run: |
250252
echo "disk usage:"
251253
df -h

bootstrap.example.toml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -758,12 +758,8 @@
758758
# Currently, the only standard options supported here are `"llvm"`, `"cranelift"` and `"gcc"`.
759759
#rust.codegen-backends = ["llvm"]
760760

761-
# Indicates whether LLD will be compiled and made available in the sysroot for rustc to execute, and
762-
# whether to set it as rustc's default linker on `x86_64-unknown-linux-gnu`. This will also only be
763-
# when *not* building an external LLVM (so only when using `download-ci-llvm` or building LLVM from
764-
# the in-tree source): setting `llvm-config` in the `[target.x86_64-unknown-linux-gnu]` section will
765-
# make this default to false.
766-
#rust.lld = false in all cases, except on `x86_64-unknown-linux-gnu` as described above, where it is true
761+
# Indicates whether LLD will be compiled and made available in the sysroot for rustc to execute,
762+
#rust.lld = false, except for targets that opt into LLD (see `target.default-linker-linux-override`)
767763

768764
# Indicates if we should override the linker used to link Rust crates during bootstrap to be LLD.
769765
# If set to `true` or `"external"`, a global `lld` binary that has to be in $PATH
@@ -1067,3 +1063,17 @@
10671063
# Link the compiler and LLVM against `jemalloc` instead of the default libc allocator.
10681064
# This overrides the global `rust.jemalloc` option. See that option for more info.
10691065
#jemalloc = rust.jemalloc (bool)
1066+
1067+
# The linker configuration that will *override* the default linker used for Linux
1068+
# targets in the built compiler.
1069+
#
1070+
# The following values are supported:
1071+
# - `off` => do not apply any override and use the default linker. This can be used to opt out of
1072+
# linker overrides set by bootstrap for specific targets (see below).
1073+
# - `self-contained-lld-cc` => override the default linker to be self-contained LLD (`rust-lld`)
1074+
# that is invoked through `cc`.
1075+
#
1076+
# Currently, the following targets automatically opt into the self-contained LLD linker, unless you
1077+
# pass `off`:
1078+
# - x86_64-unknown-linux-gnu
1079+
#default-linker-linux-override = "off" (for most targets)

compiler/rustc_ast/src/entry.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use rustc_span::{Symbol, sym};
22

3-
use crate::attr::{self, AttributeExt};
4-
53
#[derive(Debug)]
64
pub enum EntryPointType {
75
/// This function is not an entrypoint.
@@ -30,11 +28,11 @@ pub enum EntryPointType {
3028
}
3129

3230
pub fn entry_point_type(
33-
attrs: &[impl AttributeExt],
31+
has_rustc_main: bool,
3432
at_root: bool,
3533
name: Option<Symbol>,
3634
) -> EntryPointType {
37-
if attr::contains_name(attrs, sym::rustc_main) {
35+
if has_rustc_main {
3836
EntryPointType::RustcMainAttr
3937
} else if let Some(name) = name
4038
&& name == sym::main

compiler/rustc_ast/src/expand/allocator.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ use rustc_span::{Symbol, sym};
33

44
#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)]
55
pub enum AllocatorKind {
6+
/// Use `#[global_allocator]` as global allocator.
67
Global,
8+
/// Use the default implementation in libstd as global allocator.
79
Default,
810
}
911

@@ -15,23 +17,22 @@ pub fn default_fn_name(base: Symbol) -> String {
1517
format!("__rdl_{base}")
1618
}
1719

18-
pub fn alloc_error_handler_name(alloc_error_handler_kind: AllocatorKind) -> &'static str {
19-
match alloc_error_handler_kind {
20-
AllocatorKind::Global => "__rg_oom",
21-
AllocatorKind::Default => "__rdl_oom",
22-
}
23-
}
24-
20+
pub const ALLOC_ERROR_HANDLER: Symbol = sym::alloc_error_handler;
2521
pub const NO_ALLOC_SHIM_IS_UNSTABLE: &str = "__rust_no_alloc_shim_is_unstable_v2";
2622

23+
/// Argument or return type for methods in the allocator shim
24+
#[derive(Copy, Clone)]
2725
pub enum AllocatorTy {
2826
Layout,
27+
Never,
2928
Ptr,
3029
ResultPtr,
3130
Unit,
3231
Usize,
3332
}
3433

34+
/// A method that will be codegened in the allocator shim.
35+
#[derive(Copy, Clone)]
3536
pub struct AllocatorMethod {
3637
pub name: Symbol,
3738
pub inputs: &'static [AllocatorMethodInput],

compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
use super::prelude::*;
22
use super::util::parse_single_integer;
33

4-
pub(crate) struct RustcLayoutScalarValidRangeStart;
4+
pub(crate) struct RustcMainParser;
55

6-
impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeStart {
6+
impl<S: Stage> NoArgsAttributeParser<S> for RustcMainParser {
7+
const PATH: &'static [Symbol] = &[sym::rustc_main];
8+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
9+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
10+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcMain;
11+
}
12+
13+
pub(crate) struct RustcLayoutScalarValidRangeStartParser;
14+
15+
impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeStartParser {
716
const PATH: &'static [Symbol] = &[sym::rustc_layout_scalar_valid_range_start];
817
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
918
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
@@ -16,9 +25,9 @@ impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeStart {
1625
}
1726
}
1827

19-
pub(crate) struct RustcLayoutScalarValidRangeEnd;
28+
pub(crate) struct RustcLayoutScalarValidRangeEndParser;
2029

21-
impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeEnd {
30+
impl<S: Stage> SingleAttributeParser<S> for RustcLayoutScalarValidRangeEndParser {
2231
const PATH: &'static [Symbol] = &[sym::rustc_layout_scalar_valid_range_end];
2332
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
2433
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use crate::attributes::proc_macro_attrs::{
5353
use crate::attributes::prototype::CustomMirParser;
5454
use crate::attributes::repr::{AlignParser, AlignStaticParser, ReprParser};
5555
use crate::attributes::rustc_internal::{
56-
RustcLayoutScalarValidRangeEnd, RustcLayoutScalarValidRangeStart,
56+
RustcLayoutScalarValidRangeEndParser, RustcLayoutScalarValidRangeStartParser, RustcMainParser,
5757
RustcObjectLifetimeDefaultParser, RustcSimdMonomorphizeLaneLimitParser,
5858
};
5959
use crate::attributes::semantics::MayDangleParser;
@@ -197,8 +197,8 @@ attribute_parsers!(
197197
Single<RecursionLimitParser>,
198198
Single<RustcBuiltinMacroParser>,
199199
Single<RustcForceInlineParser>,
200-
Single<RustcLayoutScalarValidRangeEnd>,
201-
Single<RustcLayoutScalarValidRangeStart>,
200+
Single<RustcLayoutScalarValidRangeEndParser>,
201+
Single<RustcLayoutScalarValidRangeStartParser>,
202202
Single<RustcObjectLifetimeDefaultParser>,
203203
Single<RustcSimdMonomorphizeLaneLimitParser>,
204204
Single<SanitizeParser>,
@@ -238,6 +238,7 @@ attribute_parsers!(
238238
Single<WithoutArgs<ProcMacroParser>>,
239239
Single<WithoutArgs<PubTransparentParser>>,
240240
Single<WithoutArgs<RustcCoherenceIsCoreParser>>,
241+
Single<WithoutArgs<RustcMainParser>>,
241242
Single<WithoutArgs<SpecializationTraitParser>>,
242243
Single<WithoutArgs<StdInternalSymbolParser>>,
243244
Single<WithoutArgs<TrackCallerParser>>,

compiler/rustc_borrowck/src/handle_placeholders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ pub(crate) fn compute_sccs_applying_placeholder_outlives_constraints<'tcx>(
344344
}
345345
}
346346

347-
fn rewrite_placeholder_outlives<'tcx>(
347+
pub(crate) fn rewrite_placeholder_outlives<'tcx>(
348348
sccs: &Sccs<RegionVid, ConstraintSccIndex>,
349349
annotations: &SccAnnotations<'_, '_, RegionTracker>,
350350
fr_static: RegionVid,

compiler/rustc_borrowck/src/region_infer/opaque_types/member_constraints.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(super) fn apply_member_constraints<'tcx>(
3939
debug!(?member_constraints);
4040
for scc_a in rcx.constraint_sccs.all_sccs() {
4141
debug!(?scc_a);
42-
// Start by adding the region values required by outlives constraints. This
42+
// Start by adding the region values required by outlives constraints. This
4343
// matches how we compute the final region values in `fn compute_regions`.
4444
//
4545
// We need to do this here to get a lower bound when applying member constraints.
@@ -64,6 +64,7 @@ fn apply_member_constraint<'tcx>(
6464
// If the member region lives in a higher universe, we currently choose
6565
// the most conservative option by leaving it unchanged.
6666
if !rcx.max_placeholder_universe_reached(member).is_root() {
67+
debug!("member region reached non root universe, bailing");
6768
return;
6869
}
6970

compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,6 @@ fn add_hidden_type<'tcx>(
155155
}
156156
}
157157

158-
fn get_hidden_type<'tcx>(
159-
hidden_types: &DefinitionSiteHiddenTypes<'tcx>,
160-
def_id: LocalDefId,
161-
) -> Option<EarlyBinder<'tcx, OpaqueHiddenType<'tcx>>> {
162-
hidden_types.0.get(&def_id).map(|ty| EarlyBinder::bind(*ty))
163-
}
164-
165158
#[derive(Debug)]
166159
struct DefiningUse<'tcx> {
167160
/// The opaque type using non NLL vars. This uses the actual
@@ -253,6 +246,10 @@ fn collect_defining_uses<'tcx>(
253246
}
254247
} else {
255248
errors.push(DeferredOpaqueTypeError::InvalidOpaqueTypeArgs(err));
249+
debug!(
250+
"collect_defining_uses: InvalidOpaqueTypeArgs for {:?} := {:?}",
251+
non_nll_opaque_type_key, hidden_type
252+
);
256253
}
257254
continue;
258255
}
@@ -276,6 +273,7 @@ fn collect_defining_uses<'tcx>(
276273
defining_uses
277274
}
278275

276+
#[instrument(level = "debug", skip(rcx, hidden_types, defining_uses, errors))]
279277
fn compute_definition_site_hidden_types_from_defining_uses<'tcx>(
280278
rcx: &RegionCtxt<'_, 'tcx>,
281279
hidden_types: &mut DefinitionSiteHiddenTypes<'tcx>,
@@ -287,13 +285,15 @@ fn compute_definition_site_hidden_types_from_defining_uses<'tcx>(
287285
let mut decls_modulo_regions: FxIndexMap<OpaqueTypeKey<'tcx>, (OpaqueTypeKey<'tcx>, Span)> =
288286
FxIndexMap::default();
289287
for &DefiningUse { opaque_type_key, ref arg_regions, hidden_type } in defining_uses {
288+
debug!(?opaque_type_key, ?arg_regions, ?hidden_type);
290289
// After applying member constraints, we now map all regions in the hidden type
291290
// to the `arg_regions` of this defining use. In case a region in the hidden type
292291
// ended up not being equal to any such region, we error.
293292
let hidden_type =
294293
match hidden_type.try_fold_with(&mut ToArgRegionsFolder::new(rcx, arg_regions)) {
295294
Ok(hidden_type) => hidden_type,
296295
Err(r) => {
296+
debug!("UnexpectedHiddenRegion: {:?}", r);
297297
errors.push(DeferredOpaqueTypeError::UnexpectedHiddenRegion {
298298
hidden_type,
299299
opaque_type_key,
@@ -501,7 +501,8 @@ pub(crate) fn apply_definition_site_hidden_types<'tcx>(
501501
let tcx = infcx.tcx;
502502
let mut errors = Vec::new();
503503
for &(key, hidden_type) in opaque_types {
504-
let Some(expected) = get_hidden_type(hidden_types, key.def_id) else {
504+
let Some(expected) = hidden_types.0.get(&key.def_id).map(|ty| EarlyBinder::bind(*ty))
505+
else {
505506
if !tcx.use_typing_mode_borrowck() {
506507
if let ty::Alias(ty::Opaque, alias_ty) = hidden_type.ty.kind()
507508
&& alias_ty.def_id == key.def_id.to_def_id()

compiler/rustc_borrowck/src/region_infer/opaque_types/region_ctxt.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ use crate::constraints::ConstraintSccIndex;
1111
use crate::handle_placeholders::{SccAnnotations, region_definitions};
1212
use crate::region_infer::reverse_sccs::ReverseSccGraph;
1313
use crate::region_infer::values::RegionValues;
14-
use crate::region_infer::{ConstraintSccs, RegionDefinition, RegionTracker, Representative};
14+
use crate::region_infer::{
15+
ConstraintSccs, OutlivesConstraintSet, RegionDefinition, RegionTracker, Representative,
16+
};
1517
use crate::type_check::MirTypeckRegionConstraints;
1618
use crate::type_check::free_region_relations::UniversalRegionRelations;
1719
use crate::universal_regions::UniversalRegions;
@@ -39,16 +41,36 @@ impl<'a, 'tcx> RegionCtxt<'a, 'tcx> {
3941
location_map: Rc<DenseLocationMap>,
4042
constraints: &MirTypeckRegionConstraints<'tcx>,
4143
) -> RegionCtxt<'a, 'tcx> {
44+
let mut outlives_constraints = constraints.outlives_constraints.clone();
4245
let universal_regions = &universal_region_relations.universal_regions;
4346
let (definitions, _has_placeholders) = region_definitions(infcx, universal_regions);
47+
48+
let compute_sccs =
49+
|outlives_constraints: &OutlivesConstraintSet<'tcx>,
50+
annotations: &mut SccAnnotations<'_, 'tcx, RegionTracker>| {
51+
ConstraintSccs::new_with_annotation(
52+
&outlives_constraints
53+
.graph(definitions.len())
54+
.region_graph(outlives_constraints, universal_regions.fr_static),
55+
annotations,
56+
)
57+
};
58+
4459
let mut scc_annotations = SccAnnotations::init(&definitions);
45-
let constraint_sccs = ConstraintSccs::new_with_annotation(
46-
&constraints
47-
.outlives_constraints
48-
.graph(definitions.len())
49-
.region_graph(&constraints.outlives_constraints, universal_regions.fr_static),
50-
&mut scc_annotations,
60+
let mut constraint_sccs = compute_sccs(&outlives_constraints, &mut scc_annotations);
61+
62+
let added_constraints = crate::handle_placeholders::rewrite_placeholder_outlives(
63+
&constraint_sccs,
64+
&scc_annotations,
65+
universal_regions.fr_static,
66+
&mut outlives_constraints,
5167
);
68+
69+
if added_constraints {
70+
scc_annotations = SccAnnotations::init(&definitions);
71+
constraint_sccs = compute_sccs(&outlives_constraints, &mut scc_annotations);
72+
}
73+
5274
let scc_annotations = scc_annotations.scc_to_annotation;
5375

5476
// Unlike the `RegionInferenceContext`, we only care about free regions

0 commit comments

Comments
 (0)