Skip to content

Commit ef75812

Browse files
committed
Auto merge of #162989 - JonathanBrouwer:rollup-Z3CMn0z, r=JonathanBrouwer
Rollup of 19 pull requests Successful merges: - #160401 (sparc: make ABI consistent with clang) - #162715 (don't calculate dtors if the self ty has impossible bounds) - #162740 (stdarch subtree update) - #162946 (Simplify query stack printing) - #161005 (fix: unfulfilled nested dead code lint) - #161246 (Normalize non-rigid aliases in ty_known_to_outlive) - #161803 (Fix docs of make_ascii_lowercase/make_ascii_upercase) - #162256 (Add mentions to sync back `RELEASES.md` to the `main` branch) - #162661 (simplify `Target::GenericParam`) - #162666 (Tidy footnote in `platform-support.md`) - #162803 (docs(num): add documentation for `NonZero::from_str`) - #162879 (use u64 limbs in core::num::bignum) - #162903 (PassWrapper: adapt to LLVM reading exception model from module flag) - #162905 (c-variadic: add checks for windows i686) - #162906 (Move more `rustdoc-html` tests in the right location) - #162922 (An assortment of polonius tweaks) - #162929 (Update unicode_data to Unicode version 18.0.0) - #162930 (Use niche length type for strlen to guarantee `isize::MAX` bound) - #162960 (Guard types with unstable `Allocator` params ahead of partial stabilization)
2 parents 420ed2a + bf41f01 commit ef75812

116 files changed

Lines changed: 2899 additions & 2280 deletions

File tree

Some content is hidden

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

‎compiler/rustc_attr_ir/src/target.rs‎

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ pub use rustc_ast::visit::AssocCtxt;
66
use rustc_ast::{AssocItemKind, ForeignItemKind, ast};
77
use rustc_macros::StableHash;
88

9-
#[derive(Copy, Clone, PartialEq, Debug, Eq, StableHash)]
10-
pub enum GenericParamKind {
11-
Type,
12-
Lifetime,
13-
Const,
14-
}
15-
169
#[derive(Copy, Clone, PartialEq, Debug, Eq, StableHash)]
1710
pub enum MethodKind {
1811
/// Method in a `trait Trait` block
@@ -55,7 +48,9 @@ pub enum Target {
5548
ForeignFn,
5649
ForeignStatic,
5750
ForeignTy,
58-
GenericParam { kind: GenericParamKind, has_default: bool },
51+
LifetimeParam,
52+
TypeParam,
53+
ConstParam,
5954
MacroDef,
6055
Param,
6156
PatField,
@@ -106,7 +101,9 @@ impl Target {
106101
| Target::ForeignFn
107102
| Target::ForeignStatic
108103
| Target::ForeignTy
109-
| Target::GenericParam { .. }
104+
| Target::TypeParam
105+
| Target::LifetimeParam
106+
| Target::ConstParam
110107
| Target::MacroDef
111108
| Target::Param
112109
| Target::PatField
@@ -222,11 +219,9 @@ impl Target {
222219
Target::ForeignFn => "foreign function",
223220
Target::ForeignStatic => "foreign static item",
224221
Target::ForeignTy => "foreign type",
225-
Target::GenericParam { kind, .. } => match kind {
226-
GenericParamKind::Type => "type parameter",
227-
GenericParamKind::Lifetime => "lifetime parameter",
228-
GenericParamKind::Const => "const parameter",
229-
},
222+
Target::TypeParam => "type parameter",
223+
Target::LifetimeParam => "lifetime parameter",
224+
Target::ConstParam => "const parameter",
230225
Target::MacroDef => "macro def",
231226
Target::Param => "function param",
232227
Target::PatField => "pattern field",
@@ -277,11 +272,9 @@ impl Target {
277272
Target::ForeignFn => "foreign functions",
278273
Target::ForeignStatic => "foreign statics",
279274
Target::ForeignTy => "foreign types",
280-
Target::GenericParam { kind, has_default: _ } => match kind {
281-
GenericParamKind::Type => "type parameters",
282-
GenericParamKind::Lifetime => "lifetime parameters",
283-
GenericParamKind::Const => "const parameters",
284-
},
275+
Target::TypeParam => "type parameters",
276+
Target::LifetimeParam => "lifetime parameters",
277+
Target::ConstParam => "const parameters",
285278
Target::MacroDef => "macro defs",
286279
Target::Param => "function params",
287280
Target::PatField => "pattern fields",

‎compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use std::path::PathBuf;
22

33
use rustc_ast::{LitIntType, LitKind, MetaItemLit};
44
use rustc_attr_ir::lang_items::LangItem;
5-
use rustc_attr_ir::target::GenericParamKind;
65
use rustc_attr_ir::{
76
BorrowckGraphvizFormatKind, CguFields, CguKind, RustcCleanAttribute, RustcCleanQueries,
87
RustcMirKind,
@@ -109,10 +108,8 @@ pub(crate) struct RustcPanicsWhenZeroParser;
109108

110109
impl NoArgsAttributeParser for RustcPanicsWhenZeroParser {
111110
const PATH: &[Symbol] = &[sym::rustc_panics_when_zero];
112-
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
113-
Allow(Target::GenericParam { kind: GenericParamKind::Const, has_default: true }),
114-
Allow(Target::GenericParam { kind: GenericParamKind::Const, has_default: false }),
115-
]);
111+
const ALLOWED_TARGETS: AllowedTargets<'_> =
112+
AllowedTargets::AllowList(&[Allow(Target::ConstParam)]);
116113
const STABILITY: AttributeStability = unstable!(rustc_attrs);
117114

118115
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcPanicsWhenZero;

‎compiler/rustc_attr_parsing/src/attributes/semantics.rs‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
1-
use rustc_attr_ir::target::GenericParamKind;
21
use rustc_feature::AttributeStability;
32

43
use super::prelude::*;
54

65
pub(crate) struct MayDangleParser;
76
impl NoArgsAttributeParser for MayDangleParser {
87
const PATH: &[Symbol] = &[sym::may_dangle];
9-
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
10-
Allow(Target::GenericParam { kind: GenericParamKind::Type, has_default: false }),
11-
Allow(Target::GenericParam { kind: GenericParamKind::Type, has_default: true }),
12-
Allow(Target::GenericParam { kind: GenericParamKind::Lifetime, has_default: false }),
13-
Allow(Target::GenericParam { kind: GenericParamKind::Lifetime, has_default: true }),
14-
]);
8+
const ALLOWED_TARGETS: AllowedTargets<'_> =
9+
AllowedTargets::AllowList(&[Allow(Target::TypeParam), Allow(Target::LifetimeParam)]);
1510
const STABILITY: AttributeStability = unstable!(dropck_eyepatch);
1611
const CREATE: fn(span: Span) -> AttributeKind = AttributeKind::MayDangle;
1712
}

‎compiler/rustc_attr_parsing/src/attributes/stability.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::num::NonZero;
22

3-
use rustc_attr_ir::target::{AssocCtxt, GenericParamKind, MethodKind, Target};
3+
use rustc_attr_ir::target::{AssocCtxt, MethodKind, Target};
44
use rustc_attr_ir::{
55
DefaultBodyStability, PartialConstStability, Stability, StabilityLevel, StableSince,
66
UnstableReason, UnstableRemovedFeature, VERSION_PLACEHOLDER,
@@ -40,7 +40,7 @@ const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
4040
Allow(Target::TyAlias),
4141
Allow(Target::Variant),
4242
Allow(Target::Field),
43-
Allow(Target::GenericParam { kind: GenericParamKind::Type, has_default: true }),
43+
Allow(Target::TypeParam),
4444
Allow(Target::Static),
4545
Allow(Target::ForeignFn),
4646
Allow(Target::ForeignStatic),

‎compiler/rustc_attr_parsing/src/target_checking.rs‎

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -532,30 +532,9 @@ pub(crate) const ALL_TARGETS: &[Policy] = {
532532
Allow(Target::Crate),
533533
Allow(Target::Delegation { mac: false }),
534534
Allow(Target::Delegation { mac: true }),
535-
Allow(Target::GenericParam {
536-
kind: rustc_attr_ir::target::GenericParamKind::Const,
537-
has_default: false,
538-
}),
539-
Allow(Target::GenericParam {
540-
kind: rustc_attr_ir::target::GenericParamKind::Const,
541-
has_default: true,
542-
}),
543-
Allow(Target::GenericParam {
544-
kind: rustc_attr_ir::target::GenericParamKind::Lifetime,
545-
has_default: false,
546-
}),
547-
Allow(Target::GenericParam {
548-
kind: rustc_attr_ir::target::GenericParamKind::Lifetime,
549-
has_default: true,
550-
}),
551-
Allow(Target::GenericParam {
552-
kind: rustc_attr_ir::target::GenericParamKind::Type,
553-
has_default: false,
554-
}),
555-
Allow(Target::GenericParam {
556-
kind: rustc_attr_ir::target::GenericParamKind::Type,
557-
has_default: true,
558-
}),
535+
Allow(Target::ConstParam),
536+
Allow(Target::LifetimeParam),
537+
Allow(Target::TypeParam),
559538
Allow(Target::Loop),
560539
Allow(Target::ForLoop),
561540
Allow(Target::While),

‎compiler/rustc_borrowck/src/polonius/dump.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,13 +543,15 @@ fn emit_loan_reachability(
543543
// It's useful to know whether the region we're reaching is live at this point.
544544
let node_liveness =
545545
if liveness.is_live_at(node.region, location) { "live" } else { "not live" };
546+
writeln!(out, "<span class='trace-suffix'>")?;
546547
writeln!(
547548
out,
548549
"/ at <code>{:?}</code>: <code>'{}</code> is {}",
549550
location,
550551
node.region.index(),
551552
node_liveness,
552553
)?;
554+
writeln!(out, "</span>")?;
553555
writeln!(out, "</li>")?;
554556
}
555557
writeln!(out, "</ul>")?;

‎compiler/rustc_borrowck/src/polonius/dump/polonius-mir-dump.template.html‎

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
<head>
44
<title>Polonius MIR dump</title>
55
<style>
6-
.hidden {
7-
display: none;
6+
pre {
7+
margin-top: 0;
8+
white-space: pre-wrap;
89
}
910

1011
.section + .section {
@@ -13,8 +14,8 @@
1314
padding-top: 10px;
1415
}
1516

16-
.traces .section-header {
17-
margin-bottom: 10px;
17+
.section-header {
18+
margin-bottom: 6px;
1819
}
1920

2021
.trace + .trace {
@@ -25,43 +26,63 @@
2526
margin: 5px 0px;
2627
padding-left: 15px;
2728
}
29+
30+
.trace-suffix {
31+
opacity: 0.8;
32+
margin-left: 10px;
33+
}
34+
35+
.hidden {
36+
display: none;
37+
}
2838
</style>
2939
</head>
3040

3141
<body>
3242

33-
<!-- The NLL + Polonius MIR -->
43+
<!-- Links to the other sections -->
3444
<div class="section">
45+
<div class="section-header">Quick links</div>
46+
<a href="#mir">Polonius MIR</a>
47+
<a href="#polonius-region-graph">Polonius constraint graph</a>
48+
<a href="#loan-traces">Loan traces</a>
49+
<a href="#cfg-graph">Control-flow graph</a>
50+
<a href="#nll-region-graph">NLL region graph</a>
51+
<a href="#nll-scc-graph">NLL SCC graph</a>
52+
</div>
53+
54+
<!-- The NLL + Polonius MIR -->
55+
<div class="section" id="mir">
3556
<div class="section-header">Raw MIR dump</div>
3657
<pre><code>$SECTION_MIR</code></pre>
3758
</div>
3859

3960
<!-- Mermaid visualization of the polonius constraint graph -->
40-
<div class="section">
61+
<div class="section" id="polonius-region-graph">
4162
<div class="section-header">Polonius constraint graph</div>
4263
<pre class='mermaid'>$SECTION_POLONIUS_CONSTRAINTS</pre>
4364
</div>
4465

4566
<!-- The reachability of loans while traversing the polonius constraint graph -->
46-
<div class="section traces">
67+
<div class="section traces" id="loan-traces">
4768
<div class="section-header">Loan Traces</div>
4869
$SECTION_POLONIUS_REACHABILITY
4970
</div>
5071

5172
<!-- Mermaid visualization of the CFG -->
52-
<div class="section">
73+
<div class="section" id="cfg-graph">
5374
<div class="section-header">Control-flow graph</div>
5475
<pre class='mermaid'>$SECTION_CFG</pre>
5576
</div>
5677

5778
<!-- Mermaid visualization of the NLL region graph -->
58-
<div class="section">
79+
<div class="section" id="nll-region-graph">
5980
<div class="section-header">NLL regions</div>
6081
<pre class='mermaid'>$SECTION_NLL_CONSTRAINTS</pre>
6182
</div>
6283

6384
<!-- Mermaid visualization of the NLL SCC graph -->
64-
<div class="section">
85+
<div class="section" id="nll-scc-graph">
6586
<div class="section-header">NLL SCCs</div>
6687
<pre class='mermaid'>$SECTION_NLL_SCCS</pre>
6788
</div>

‎compiler/rustc_borrowck/src/type_check/liveness/trace.rs‎

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_infer::infer::canonical::QueryRegionConstraints;
66
use rustc_infer::traits::TraitErrors;
77
use rustc_middle::mir::{BasicBlock, Body, ConstraintCategory, Local, Location};
88
use rustc_middle::traits::query::DropckOutlivesResult;
9-
use rustc_middle::ty::{GenericArg, Ty, TypeVisitable, TypeVisitableExt};
9+
use rustc_middle::ty::{Ty, TyCtxt, TypeVisitable, TypeVisitableExt};
1010
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
1111
use rustc_mir_dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
1212
use rustc_mir_dataflow::points::{DenseLocationMap, PointIndex};
@@ -553,8 +553,17 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> {
553553
/// points `live_at`.
554554
fn add_use_live_facts_for(&mut self, value: Ty<'tcx>, live_at: &IntervalSet<PointIndex>) {
555555
debug!("add_use_live_facts_for(value={:?})", value);
556-
Self::record_region_variance(self.typeck, value.into());
557-
Self::make_all_regions_live(self.location_map, self.typeck, value.into(), live_at);
556+
Self::make_all_regions_live(self.location_map, self.typeck, value, live_at);
557+
558+
// When using `-Zpolonius=next`, we also record the variance of regions in this live type.
559+
if let Some(polonius_context) = self.typeck.polonius_context.as_mut() {
560+
record_live_region_variance(
561+
self.typeck.infcx.tcx,
562+
&mut polonius_context.live_region_variances,
563+
self.typeck.universal_regions,
564+
value,
565+
);
566+
}
558567
}
559568

560569
/// Some variable with type `live_ty` is "drop live" at `location`
@@ -595,9 +604,6 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> {
595604
}
596605
}
597606

598-
// Since the entire dropped local is live, record the variance of its regions.
599-
Self::record_region_variance(self.typeck, dropped_ty.into());
600-
601607
// All things in the `outlives` array may be touched by
602608
// the destructor and must be live at this point.
603609
for &kind in &drop_data.dropck_result.kinds {
@@ -610,27 +616,24 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> {
610616
self.typeck.polonius_facts,
611617
);
612618
}
613-
}
614619

615-
/// `live_kind` is the type of a (use- or drop-) live local.
616-
/// Record the variance of any region(s) appearing in it for Polonius. Does
617-
/// nothing if Polonius is not active.
618-
fn record_region_variance(typeck: &mut TypeChecker<'_, 'tcx>, live_kind: GenericArg<'tcx>) {
619-
// When using `-Zpolonius=next`, we record the variance of each live region.
620-
if let Some(polonius_context) = typeck.polonius_context.as_mut() {
620+
// For polonius: since the local is drop live, record the variance of the regions in its
621+
// type, not the ones in the type's live components seen in the dropck results above. See
622+
// issue #160670.
623+
if let Some(polonius_context) = self.typeck.polonius_context.as_mut() {
621624
record_live_region_variance(
622-
typeck.infcx.tcx,
625+
self.typeck.infcx.tcx,
623626
&mut polonius_context.live_region_variances,
624-
typeck.universal_regions,
625-
live_kind,
627+
self.typeck.universal_regions,
628+
dropped_ty,
626629
);
627630
}
628631
}
629632

630633
fn make_all_regions_live(
631634
location_map: &DenseLocationMap,
632635
typeck: &mut TypeChecker<'_, 'tcx>,
633-
value: GenericArg<'tcx>,
636+
value: impl TypeVisitable<TyCtxt<'tcx>>,
634637
live_at: &IntervalSet<PointIndex>,
635638
) {
636639
debug!("make_all_regions_live(value={:?})", value);
@@ -647,7 +650,6 @@ impl<'tcx> LivenessContext<'_, '_, 'tcx> {
647650
typeck.constraints.liveness_constraints.add_points(live_region_vid, live_at);
648651
},
649652
});
650-
Self::record_region_variance(typeck, value);
651653
}
652654
}
653655

‎compiler/rustc_codegen_llvm/src/context.rs‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -584,13 +584,23 @@ pub(crate) unsafe fn create_module<'ll>(
584584
);
585585
}
586586

587-
if llvm_version >= (24, 0, 0) && sess.target.singlethread(&sess.internal_target_features) {
588-
llvm::add_module_flag_str(
589-
llmod,
590-
llvm::ModuleFlagMergeBehavior::Error,
591-
"thread-model",
592-
"single",
593-
);
587+
if llvm_version >= (24, 0, 0) {
588+
if sess.target.singlethread(&sess.internal_target_features) {
589+
llvm::add_module_flag_str(
590+
llmod,
591+
llvm::ModuleFlagMergeBehavior::Error,
592+
"thread-model",
593+
"single",
594+
);
595+
}
596+
if wants_wasm_eh(&sess.target) {
597+
llvm::add_module_flag_str(
598+
llmod,
599+
llvm::ModuleFlagMergeBehavior::Error,
600+
"exception-model",
601+
"wasm",
602+
);
603+
}
594604
}
595605

596606
// Add module flags specified via -Z llvm_module_flag

‎compiler/rustc_driver_impl/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ fn report_ice(
16001600

16011601
let limit_frames = if backtrace { None } else { Some(2) };
16021602

1603-
interface::try_print_query_stack(dcx, limit_frames, file);
1603+
interface::try_print_query_stack(limit_frames, file);
16041604

16051605
// We don't trust this callback not to panic itself, so run it at the end after we're sure we've
16061606
// printed all the relevant info.

0 commit comments

Comments
 (0)