Skip to content

Commit 5e942ad

Browse files
committed
Auto merge of #143790 - matthiaskrgr:rollup-hslb9jq, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - #142301 (tests: Fix duplicated-path-in-error fail with musl) - #143403 (Port several trait/coherence-related attributes the new attribute system) - #143633 (fix: correct assertion to check for 'noinline' attribute presence before removal) - #143647 (Clarify and expand documentation for std::sys_common dependency structure) - #143716 (compiler: doc/comment some codegen-for-functions interfaces) - #143747 (Add target maintainer information for aarch64-unknown-linux-musl) - #143759 (Fix typos in function names in the `target_feature` test) - #143767 (Bump `src/tools/x` to Edition 2024 and some cleanups) - #143769 (Remove support for SwitchInt edge effects in backward dataflow) - #143770 (build-helper: clippy fixes) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 855e0fe + 2f82343 commit 5e942ad

File tree

36 files changed

+441
-194
lines changed

36 files changed

+441
-194
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ pub enum AttributeKind {
198198
/// Represents `#[rustc_allow_const_fn_unstable]`.
199199
AllowConstFnUnstable(ThinVec<Symbol>, Span),
200200

201+
/// Represents `#[rustc_allow_incoherent_impl]`.
202+
AllowIncoherentImpl(Span),
203+
201204
/// Represents `#[allow_internal_unstable]`.
202205
AllowInternalUnstable(ThinVec<(Symbol, Span)>, Span),
203206

@@ -211,6 +214,12 @@ pub enum AttributeKind {
211214
span: Span,
212215
},
213216

217+
/// Represents `#[rustc_coherence_is_core]`.
218+
CoherenceIsCore,
219+
220+
/// Represents `#[rustc_coinductive]`.
221+
Coinductive(Span),
222+
214223
/// Represents `#[cold]`.
215224
Cold(Span),
216225

@@ -234,9 +243,18 @@ pub enum AttributeKind {
234243
/// Represents `#[rustc_const_stable_indirect]`.
235244
ConstStabilityIndirect,
236245

246+
/// Represents `#[const_trait]`.
247+
ConstTrait(Span),
248+
249+
///Represents `#[rustc_deny_explicit_impl]`.
250+
DenyExplicitImpl(Span),
251+
237252
/// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
238253
Deprecation { deprecation: Deprecation, span: Span },
239254

255+
/// Represents `#[rustc_do_not_implement_via_object]`.
256+
DoNotImplementViaObject(Span),
257+
240258
/// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
241259
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },
242260

@@ -260,6 +278,9 @@ pub enum AttributeKind {
260278
/// Represents `#[ffi_pure]`.
261279
FfiPure(Span),
262280

281+
/// Represents `#[fundamental]`.
282+
Fundamental,
283+
263284
/// Represents `#[ignore]`
264285
Ignore {
265286
span: Span,
@@ -282,6 +303,9 @@ pub enum AttributeKind {
282303
/// Represents `#[rustc_macro_transparency]`.
283304
MacroTransparency(Transparency),
284305

306+
/// Represents `#[marker]`.
307+
Marker(Span),
308+
285309
/// Represents [`#[may_dangle]`](https://std-dev-guide.rust-lang.org/tricky/may-dangle.html).
286310
MayDangle(Span),
287311

@@ -307,6 +331,9 @@ pub enum AttributeKind {
307331
/// Represents `#[optimize(size|speed)]`
308332
Optimize(OptimizeAttr, Span),
309333

334+
/// Represents `#[rustc_paren_sugar]`.
335+
ParenSugar(Span),
336+
310337
/// Represents `#[rustc_pass_by_value]` (used by the `rustc_pass_by_value` lint).
311338
PassByValue(Span),
312339

@@ -331,6 +358,9 @@ pub enum AttributeKind {
331358
/// Represents `#[rustc_skip_during_method_dispatch]`.
332359
SkipDuringMethodDispatch { array: bool, boxed_slice: bool, span: Span },
333360

361+
/// Represents `#[rustc_specialization_trait]`.
362+
SpecializationTrait(Span),
363+
334364
/// Represents `#[stable]`, `#[unstable]` and `#[rustc_allowed_through_unstable_modules]`.
335365
Stability {
336366
stability: Stability,
@@ -347,6 +377,12 @@ pub enum AttributeKind {
347377
/// Represents `#[track_caller]`
348378
TrackCaller(Span),
349379

380+
/// Represents `#[type_const]`.
381+
TypeConst(Span),
382+
383+
/// Represents `#[rustc_unsafe_specialization_marker]`.
384+
UnsafeSpecializationMarker(Span),
385+
350386
/// Represents `#[used]`
351387
Used { used_by: UsedBy, span: Span },
352388
// tidy-alphabetical-end

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,43 @@ impl AttributeKind {
1515
// tidy-alphabetical-start
1616
Align { .. } => No,
1717
AllowConstFnUnstable(..) => No,
18+
AllowIncoherentImpl(..) => No,
1819
AllowInternalUnstable(..) => Yes,
1920
AsPtr(..) => Yes,
2021
BodyStability { .. } => No,
22+
CoherenceIsCore => No,
23+
Coinductive(..) => No,
2124
Cold(..) => No,
2225
Confusables { .. } => Yes,
2326
ConstContinue(..) => No,
2427
ConstStability { .. } => Yes,
2528
ConstStabilityIndirect => No,
29+
ConstTrait(..) => No,
30+
DenyExplicitImpl(..) => No,
2631
Deprecation { .. } => Yes,
32+
DoNotImplementViaObject(..) => No,
2733
DocComment { .. } => Yes,
2834
Dummy => No,
2935
ExportName { .. } => Yes,
3036
ExportStable => No,
3137
FfiConst(..) => No,
3238
FfiPure(..) => No,
39+
Fundamental { .. } => Yes,
3340
Ignore { .. } => No,
3441
Inline(..) => No,
3542
LinkName { .. } => Yes,
3643
LinkSection { .. } => No,
3744
LoopMatch(..) => No,
3845
MacroTransparency(..) => Yes,
46+
Marker(..) => No,
3947
MayDangle(..) => No,
4048
MustUse { .. } => Yes,
4149
Naked(..) => No,
4250
NoImplicitPrelude(..) => No,
4351
NoMangle(..) => No,
4452
NonExhaustive(..) => Yes,
4553
Optimize(..) => No,
54+
ParenSugar(..) => No,
4655
PassByValue(..) => Yes,
4756
Path(..) => No,
4857
PubTransparent(..) => Yes,
@@ -51,10 +60,13 @@ impl AttributeKind {
5160
RustcLayoutScalarValidRangeStart(..) => Yes,
5261
RustcObjectLifetimeDefault => No,
5362
SkipDuringMethodDispatch { .. } => No,
63+
SpecializationTrait(..) => No,
5464
Stability { .. } => Yes,
5565
StdInternalSymbol(..) => No,
5666
TargetFeature(..) => No,
5767
TrackCaller(..) => Yes,
68+
TypeConst(..) => Yes,
69+
UnsafeSpecializationMarker(..) => No,
5870
Used { .. } => No,
5971
// tidy-alphabetical-end
6072
}

compiler/rustc_attr_parsing/src/attributes/traits.rs

Lines changed: 96 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ use core::mem;
22

33
use rustc_attr_data_structures::AttributeKind;
44
use rustc_feature::{AttributeTemplate, template};
5-
use rustc_span::{Symbol, sym};
5+
use rustc_span::{Span, Symbol, sym};
66

7-
use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
7+
use crate::attributes::{
8+
AttributeOrder, NoArgsAttributeParser, OnDuplicate, SingleAttributeParser,
9+
};
810
use crate::context::{AcceptContext, Stage};
911
use crate::parser::ArgParser;
1012

1113
pub(crate) struct SkipDuringMethodDispatchParser;
12-
1314
impl<S: Stage> SingleAttributeParser<S> for SkipDuringMethodDispatchParser {
1415
const PATH: &[Symbol] = &[sym::rustc_skip_during_method_dispatch];
1516
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
@@ -52,3 +53,95 @@ impl<S: Stage> SingleAttributeParser<S> for SkipDuringMethodDispatchParser {
5253
Some(AttributeKind::SkipDuringMethodDispatch { array, boxed_slice, span: cx.attr_span })
5354
}
5455
}
56+
57+
pub(crate) struct ParenSugarParser;
58+
impl<S: Stage> NoArgsAttributeParser<S> for ParenSugarParser {
59+
const PATH: &[Symbol] = &[sym::rustc_paren_sugar];
60+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
61+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ParenSugar;
62+
}
63+
64+
pub(crate) struct TypeConstParser;
65+
impl<S: Stage> NoArgsAttributeParser<S> for TypeConstParser {
66+
const PATH: &[Symbol] = &[sym::type_const];
67+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
68+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::TypeConst;
69+
}
70+
71+
// Markers
72+
73+
pub(crate) struct MarkerParser;
74+
impl<S: Stage> NoArgsAttributeParser<S> for MarkerParser {
75+
const PATH: &[Symbol] = &[sym::marker];
76+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
77+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Marker;
78+
}
79+
80+
pub(crate) struct DenyExplicitImplParser;
81+
impl<S: Stage> NoArgsAttributeParser<S> for DenyExplicitImplParser {
82+
const PATH: &[Symbol] = &[sym::rustc_deny_explicit_impl];
83+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
84+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DenyExplicitImpl;
85+
}
86+
87+
pub(crate) struct DoNotImplementViaObjectParser;
88+
impl<S: Stage> NoArgsAttributeParser<S> for DoNotImplementViaObjectParser {
89+
const PATH: &[Symbol] = &[sym::rustc_do_not_implement_via_object];
90+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
91+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DoNotImplementViaObject;
92+
}
93+
94+
// Const traits
95+
96+
pub(crate) struct ConstTraitParser;
97+
impl<S: Stage> NoArgsAttributeParser<S> for ConstTraitParser {
98+
const PATH: &[Symbol] = &[sym::const_trait];
99+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
100+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ConstTrait;
101+
}
102+
103+
// Specialization
104+
105+
pub(crate) struct SpecializationTraitParser;
106+
impl<S: Stage> NoArgsAttributeParser<S> for SpecializationTraitParser {
107+
const PATH: &[Symbol] = &[sym::rustc_specialization_trait];
108+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
109+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::SpecializationTrait;
110+
}
111+
112+
pub(crate) struct UnsafeSpecializationMarkerParser;
113+
impl<S: Stage> NoArgsAttributeParser<S> for UnsafeSpecializationMarkerParser {
114+
const PATH: &[Symbol] = &[sym::rustc_unsafe_specialization_marker];
115+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
116+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::UnsafeSpecializationMarker;
117+
}
118+
119+
// Coherence
120+
121+
pub(crate) struct CoinductiveParser;
122+
impl<S: Stage> NoArgsAttributeParser<S> for CoinductiveParser {
123+
const PATH: &[Symbol] = &[sym::rustc_coinductive];
124+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
125+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Coinductive;
126+
}
127+
128+
pub(crate) struct AllowIncoherentImplParser;
129+
impl<S: Stage> NoArgsAttributeParser<S> for AllowIncoherentImplParser {
130+
const PATH: &[Symbol] = &[sym::rustc_allow_incoherent_impl];
131+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
132+
const CREATE: fn(Span) -> AttributeKind = AttributeKind::AllowIncoherentImpl;
133+
}
134+
135+
pub(crate) struct CoherenceIsCoreParser;
136+
impl<S: Stage> NoArgsAttributeParser<S> for CoherenceIsCoreParser {
137+
const PATH: &[Symbol] = &[sym::rustc_coherence_is_core];
138+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
139+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::CoherenceIsCore;
140+
}
141+
142+
pub(crate) struct FundamentalParser;
143+
impl<S: Stage> NoArgsAttributeParser<S> for FundamentalParser {
144+
const PATH: &[Symbol] = &[sym::fundamental];
145+
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
146+
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::Fundamental;
147+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,12 @@ use crate::attributes::stability::{
4343
BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
4444
};
4545
use crate::attributes::test_attrs::IgnoreParser;
46-
use crate::attributes::traits::SkipDuringMethodDispatchParser;
46+
use crate::attributes::traits::{
47+
AllowIncoherentImplParser, CoherenceIsCoreParser, CoinductiveParser, ConstTraitParser,
48+
DenyExplicitImplParser, DoNotImplementViaObjectParser, FundamentalParser, MarkerParser,
49+
ParenSugarParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
50+
UnsafeSpecializationMarkerParser,
51+
};
4752
use crate::attributes::transparency::TransparencyParser;
4853
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
4954
use crate::parser::{ArgParser, MetaItemParser, PathParser};
@@ -146,22 +151,34 @@ attribute_parsers!(
146151
Single<RustcObjectLifetimeDefaultParser>,
147152
Single<SkipDuringMethodDispatchParser>,
148153
Single<TransparencyParser>,
154+
Single<WithoutArgs<AllowIncoherentImplParser>>,
149155
Single<WithoutArgs<AsPtrParser>>,
156+
Single<WithoutArgs<CoherenceIsCoreParser>>,
157+
Single<WithoutArgs<CoinductiveParser>>,
150158
Single<WithoutArgs<ColdParser>>,
151159
Single<WithoutArgs<ConstContinueParser>>,
152160
Single<WithoutArgs<ConstStabilityIndirectParser>>,
161+
Single<WithoutArgs<ConstTraitParser>>,
162+
Single<WithoutArgs<DenyExplicitImplParser>>,
163+
Single<WithoutArgs<DoNotImplementViaObjectParser>>,
153164
Single<WithoutArgs<ExportStableParser>>,
154165
Single<WithoutArgs<FfiConstParser>>,
155166
Single<WithoutArgs<FfiPureParser>>,
167+
Single<WithoutArgs<FundamentalParser>>,
156168
Single<WithoutArgs<LoopMatchParser>>,
169+
Single<WithoutArgs<MarkerParser>>,
157170
Single<WithoutArgs<MayDangleParser>>,
158171
Single<WithoutArgs<NoImplicitPreludeParser>>,
159172
Single<WithoutArgs<NoMangleParser>>,
160173
Single<WithoutArgs<NonExhaustiveParser>>,
174+
Single<WithoutArgs<ParenSugarParser>>,
161175
Single<WithoutArgs<PassByValueParser>>,
162176
Single<WithoutArgs<PubTransparentParser>>,
177+
Single<WithoutArgs<SpecializationTraitParser>>,
163178
Single<WithoutArgs<StdInternalSymbolParser>>,
164179
Single<WithoutArgs<TrackCallerParser>>,
180+
Single<WithoutArgs<TypeConstParser>>,
181+
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
165182
// tidy-alphabetical-end
166183
];
167184
);

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ pub(crate) fn run_pass_manager(
680680
if attributes::has_string_attr(function, enzyme_marker) {
681681
// Sanity check: Ensure 'noinline' is present before replacing it.
682682
assert!(
683-
!attributes::has_attr(function, Function, llvm::AttributeKind::NoInline),
683+
attributes::has_attr(function, Function, llvm::AttributeKind::NoInline),
684684
"Expected __enzyme function to have 'noinline' before adding 'alwaysinline'"
685685
);
686686

compiler/rustc_codegen_ssa/src/traits/builder.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,12 +554,33 @@ pub trait BuilderMethods<'a, 'tcx>:
554554
/// Called for `StorageDead`
555555
fn lifetime_end(&mut self, ptr: Self::Value, size: Size);
556556

557+
/// "Finally codegen the call"
558+
///
559+
/// ## Arguments
560+
///
561+
/// The `fn_attrs`, `fn_abi`, and `instance` arguments are Options because they are advisory.
562+
/// They relate to optional codegen enhancements like LLVM CFI, and do not affect ABI per se.
563+
/// Any ABI-related transformations should be handled by different, earlier stages of codegen.
564+
/// For instance, in the caller of `BuilderMethods::call`.
565+
///
566+
/// This means that a codegen backend which disregards `fn_attrs`, `fn_abi`, and `instance`
567+
/// should still do correct codegen, and code should not be miscompiled if they are omitted.
568+
/// It is not a miscompilation in this sense if it fails to run under CFI, other sanitizers, or
569+
/// in the context of other compiler-enhanced security features.
570+
///
571+
/// The typical case that they are None is during the codegen of intrinsics and lang-items,
572+
/// as those are "fake functions" with only a trivial ABI if any, et cetera.
573+
///
574+
/// ## Return
575+
///
576+
/// Must return the value the function will return so it can be written to the destination,
577+
/// assuming the function does not explicitly pass the destination as a pointer in `args`.
557578
fn call(
558579
&mut self,
559580
llty: Self::Type,
560581
fn_attrs: Option<&CodegenFnAttrs>,
561582
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
562-
llfn: Self::Value,
583+
fn_val: Self::Value,
563584
args: &[Self::Value],
564585
funclet: Option<&Self::Funclet>,
565586
instance: Option<Instance<'tcx>>,

compiler/rustc_codegen_ssa/src/traits/intrinsic.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ use crate::mir::operand::OperandRef;
66
use crate::mir::place::PlaceRef;
77

88
pub trait IntrinsicCallBuilderMethods<'tcx>: BackendTypes {
9+
/// Higher-level interface to emitting calls to intrinsics
10+
///
911
/// Remember to add all intrinsics here, in `compiler/rustc_hir_analysis/src/check/mod.rs`,
1012
/// and in `library/core/src/intrinsics.rs`; if you need access to any LLVM intrinsics,
1113
/// add them to `compiler/rustc_codegen_llvm/src/context.rs`.
1214
/// Returns `Err` if another instance should be called instead. This is used to invoke
1315
/// intrinsic default bodies in case an intrinsic is not implemented by the backend.
16+
///
17+
/// NOTE: allowed to call [`BuilderMethods::call`]
18+
///
19+
/// [`BuilderMethods::call`]: super::builder::BuilderMethods::call
1420
fn codegen_intrinsic_call(
1521
&mut self,
1622
instance: ty::Instance<'tcx>,
1723
args: &[OperandRef<'tcx, Self::Value>],
18-
result: PlaceRef<'tcx, Self::Value>,
24+
result_dest: PlaceRef<'tcx, Self::Value>,
1925
span: Span,
2026
) -> Result<(), ty::Instance<'tcx>>;
2127

0 commit comments

Comments
 (0)