Skip to content

Rollup of 10 pull requests #143790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 37 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
2988b2c
tests: Fix duplicated-path-in-error fail with musl
Gelbpunkt Jun 10, 2025
b2299e2
fix: correct assertion to check for 'noinline' attribute presence bef…
dillona Jul 8, 2025
62f58db
Port `#[const_trait]` to the new attribute system
GrigorenkoPV Jun 23, 2025
938916d
Port `#[rustc_deny_explicit_impl]` to the new attribute system
GrigorenkoPV Jun 23, 2025
adb325f
Port `#[rustc_do_not_implement_via_object]` to the new attribute system
GrigorenkoPV Jun 23, 2025
6f8e92d
Port `#[rustc_coinductive]` to the new attribute system
GrigorenkoPV Jun 23, 2025
813ec60
Port `#[type_const]` to the new attribute system
GrigorenkoPV Jun 23, 2025
6193783
Port `#[rustc_specialization_trait]` to the new attribute system
GrigorenkoPV Jun 23, 2025
a57a885
Port `#[rustc_unsafe_specialization_marker]` to the new attribute system
GrigorenkoPV Jun 23, 2025
12f6487
Port `#[marker]` to the new attribute system
GrigorenkoPV Jun 23, 2025
507ebce
Port `#[fundamental]` to the new attribute system
GrigorenkoPV Jun 23, 2025
1bdf703
Port `#[rustc_paren_sugar]` to the new attribute system
GrigorenkoPV Jun 23, 2025
a6bc816
Reorder attribute parsers in `traits.rs`
GrigorenkoPV Jun 24, 2025
e9e6495
Port `#[rustc_allow_incoherent_impl]` to the new attribute system
GrigorenkoPV Jun 24, 2025
e584ed0
Port `#[rustc_coherence_is_core]` to the new attribute system
GrigorenkoPV Jun 24, 2025
04bb68a
compiler: recomment `needs_fn_once_adapter_shim`
workingjubilee Jul 10, 2025
a866377
Add target maintainer information for aarch64-unknown-linux-musl
Gelbpunkt Jul 10, 2025
ed96f00
fix typos in function names in the `target_feature` test
fluiderson Jul 10, 2025
3c11029
docs: clarify “dag” in std::sys_common doc comment
ColtenOuO Jul 8, 2025
2861274
x: clippy fixes
hkBst Jul 11, 2025
b87a1b1
x: move to edition 2024
hkBst Jul 11, 2025
dcf965d
x: use let-else
hkBst Jul 11, 2025
011d4aa
Call `get_switch_int_data` on a block with SwitchInt terminator
tmiasko Jul 11, 2025
ba3b7a7
build-helper: clippy fixes
hkBst Jul 11, 2025
39f7707
compiler: comment on some call-related codegen fn in cg_ssa
workingjubilee Jul 10, 2025
5b6d661
Remove support for SwitchInt edge effects in backward dataflow analyses
tmiasko Jul 11, 2025
3ffd47d
Add a comment explaining the split
Gelbpunkt Jul 11, 2025
933da97
Rollup merge of #142301 - Gelbpunkt:duplicated-path-in-error-musl, r=…
matthiaskrgr Jul 11, 2025
02df24f
Rollup merge of #143403 - GrigorenkoPV:attributes/traits, r=jdonszelmann
matthiaskrgr Jul 11, 2025
e932509
Rollup merge of #143633 - dillona:noinline-assert, r=fee1-dead
matthiaskrgr Jul 11, 2025
1412294
Rollup merge of #143647 - ColtenOuO:master, r=ChrisDenton
matthiaskrgr Jul 11, 2025
25b1232
Rollup merge of #143716 - workingjubilee:document-some-codegen-backen…
matthiaskrgr Jul 11, 2025
4d89e63
Rollup merge of #143747 - Gelbpunkt:aarch64-musl-maintainer, r=jieyouxu
matthiaskrgr Jul 11, 2025
0fb53e7
Rollup merge of #143759 - fluiderson:rdttff, r=aDotInTheVoid
matthiaskrgr Jul 11, 2025
88066c8
Rollup merge of #143767 - hkBst:cleanup-x, r=jieyouxu
matthiaskrgr Jul 11, 2025
1fbfc62
Rollup merge of #143769 - tmiasko:rm-backward-switch-int, r=lqd
matthiaskrgr Jul 11, 2025
2f82343
Rollup merge of #143770 - hkBst:build-helper-cleanup, r=Kobzol
matthiaskrgr Jul 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions compiler/rustc_attr_data_structures/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_allow_const_fn_unstable]`.
AllowConstFnUnstable(ThinVec<Symbol>, Span),

/// Represents `#[rustc_allow_incoherent_impl]`.
AllowIncoherentImpl(Span),

/// Represents `#[allow_internal_unstable]`.
AllowInternalUnstable(ThinVec<(Symbol, Span)>, Span),

Expand All @@ -211,6 +214,12 @@ pub enum AttributeKind {
span: Span,
},

/// Represents `#[rustc_coherence_is_core]`.
CoherenceIsCore,

/// Represents `#[rustc_coinductive]`.
Coinductive(Span),

/// Represents `#[cold]`.
Cold(Span),

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

/// Represents `#[const_trait]`.
ConstTrait(Span),

///Represents `#[rustc_deny_explicit_impl]`.
DenyExplicitImpl(Span),

/// Represents [`#[deprecated]`](https://doc.rust-lang.org/stable/reference/attributes/diagnostics.html#the-deprecated-attribute).
Deprecation { deprecation: Deprecation, span: Span },

/// Represents `#[rustc_do_not_implement_via_object]`.
DoNotImplementViaObject(Span),

/// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },

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

/// Represents `#[fundamental]`.
Fundamental,

/// Represents `#[ignore]`
Ignore {
span: Span,
Expand All @@ -282,6 +303,9 @@ pub enum AttributeKind {
/// Represents `#[rustc_macro_transparency]`.
MacroTransparency(Transparency),

/// Represents `#[marker]`.
Marker(Span),

/// Represents [`#[may_dangle]`](https://std-dev-guide.rust-lang.org/tricky/may-dangle.html).
MayDangle(Span),

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

/// Represents `#[rustc_paren_sugar]`.
ParenSugar(Span),

/// Represents `#[rustc_pass_by_value]` (used by the `rustc_pass_by_value` lint).
PassByValue(Span),

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

/// Represents `#[rustc_specialization_trait]`.
SpecializationTrait(Span),

/// Represents `#[stable]`, `#[unstable]` and `#[rustc_allowed_through_unstable_modules]`.
Stability {
stability: Stability,
Expand All @@ -347,6 +377,12 @@ pub enum AttributeKind {
/// Represents `#[track_caller]`
TrackCaller(Span),

/// Represents `#[type_const]`.
TypeConst(Span),

/// Represents `#[rustc_unsafe_specialization_marker]`.
UnsafeSpecializationMarker(Span),

/// Represents `#[used]`
Used { used_by: UsedBy, span: Span },
// tidy-alphabetical-end
Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_attr_data_structures/src/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,43 @@ impl AttributeKind {
// tidy-alphabetical-start
Align { .. } => No,
AllowConstFnUnstable(..) => No,
AllowIncoherentImpl(..) => No,
AllowInternalUnstable(..) => Yes,
AsPtr(..) => Yes,
BodyStability { .. } => No,
CoherenceIsCore => No,
Coinductive(..) => No,
Cold(..) => No,
Confusables { .. } => Yes,
ConstContinue(..) => No,
ConstStability { .. } => Yes,
ConstStabilityIndirect => No,
ConstTrait(..) => No,
DenyExplicitImpl(..) => No,
Deprecation { .. } => Yes,
DoNotImplementViaObject(..) => No,
DocComment { .. } => Yes,
Dummy => No,
ExportName { .. } => Yes,
ExportStable => No,
FfiConst(..) => No,
FfiPure(..) => No,
Fundamental { .. } => Yes,
Ignore { .. } => No,
Inline(..) => No,
LinkName { .. } => Yes,
LinkSection { .. } => No,
LoopMatch(..) => No,
MacroTransparency(..) => Yes,
Marker(..) => No,
MayDangle(..) => No,
MustUse { .. } => Yes,
Naked(..) => No,
NoImplicitPrelude(..) => No,
NoMangle(..) => No,
NonExhaustive(..) => Yes,
Optimize(..) => No,
ParenSugar(..) => No,
PassByValue(..) => Yes,
Path(..) => No,
PubTransparent(..) => Yes,
Expand All @@ -51,10 +60,13 @@ impl AttributeKind {
RustcLayoutScalarValidRangeStart(..) => Yes,
RustcObjectLifetimeDefault => No,
SkipDuringMethodDispatch { .. } => No,
SpecializationTrait(..) => No,
Stability { .. } => Yes,
StdInternalSymbol(..) => No,
TargetFeature(..) => No,
TrackCaller(..) => Yes,
TypeConst(..) => Yes,
UnsafeSpecializationMarker(..) => No,
Used { .. } => No,
// tidy-alphabetical-end
}
Expand Down
99 changes: 96 additions & 3 deletions compiler/rustc_attr_parsing/src/attributes/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ use core::mem;

use rustc_attr_data_structures::AttributeKind;
use rustc_feature::{AttributeTemplate, template};
use rustc_span::{Symbol, sym};
use rustc_span::{Span, Symbol, sym};

use crate::attributes::{AttributeOrder, OnDuplicate, SingleAttributeParser};
use crate::attributes::{
AttributeOrder, NoArgsAttributeParser, OnDuplicate, SingleAttributeParser,
};
use crate::context::{AcceptContext, Stage};
use crate::parser::ArgParser;

pub(crate) struct SkipDuringMethodDispatchParser;

impl<S: Stage> SingleAttributeParser<S> for SkipDuringMethodDispatchParser {
const PATH: &[Symbol] = &[sym::rustc_skip_during_method_dispatch];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
Expand Down Expand Up @@ -52,3 +53,95 @@ impl<S: Stage> SingleAttributeParser<S> for SkipDuringMethodDispatchParser {
Some(AttributeKind::SkipDuringMethodDispatch { array, boxed_slice, span: cx.attr_span })
}
}

pub(crate) struct ParenSugarParser;
impl<S: Stage> NoArgsAttributeParser<S> for ParenSugarParser {
const PATH: &[Symbol] = &[sym::rustc_paren_sugar];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ParenSugar;
}

pub(crate) struct TypeConstParser;
impl<S: Stage> NoArgsAttributeParser<S> for TypeConstParser {
const PATH: &[Symbol] = &[sym::type_const];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::TypeConst;
}

// Markers

pub(crate) struct MarkerParser;
impl<S: Stage> NoArgsAttributeParser<S> for MarkerParser {
const PATH: &[Symbol] = &[sym::marker];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Marker;
}

pub(crate) struct DenyExplicitImplParser;
impl<S: Stage> NoArgsAttributeParser<S> for DenyExplicitImplParser {
const PATH: &[Symbol] = &[sym::rustc_deny_explicit_impl];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DenyExplicitImpl;
}

pub(crate) struct DoNotImplementViaObjectParser;
impl<S: Stage> NoArgsAttributeParser<S> for DoNotImplementViaObjectParser {
const PATH: &[Symbol] = &[sym::rustc_do_not_implement_via_object];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::DoNotImplementViaObject;
}

// Const traits

pub(crate) struct ConstTraitParser;
impl<S: Stage> NoArgsAttributeParser<S> for ConstTraitParser {
const PATH: &[Symbol] = &[sym::const_trait];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Warn;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::ConstTrait;
}

// Specialization

pub(crate) struct SpecializationTraitParser;
impl<S: Stage> NoArgsAttributeParser<S> for SpecializationTraitParser {
const PATH: &[Symbol] = &[sym::rustc_specialization_trait];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::SpecializationTrait;
}

pub(crate) struct UnsafeSpecializationMarkerParser;
impl<S: Stage> NoArgsAttributeParser<S> for UnsafeSpecializationMarkerParser {
const PATH: &[Symbol] = &[sym::rustc_unsafe_specialization_marker];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::UnsafeSpecializationMarker;
}

// Coherence

pub(crate) struct CoinductiveParser;
impl<S: Stage> NoArgsAttributeParser<S> for CoinductiveParser {
const PATH: &[Symbol] = &[sym::rustc_coinductive];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::Coinductive;
}

pub(crate) struct AllowIncoherentImplParser;
impl<S: Stage> NoArgsAttributeParser<S> for AllowIncoherentImplParser {
const PATH: &[Symbol] = &[sym::rustc_allow_incoherent_impl];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::AllowIncoherentImpl;
}

pub(crate) struct CoherenceIsCoreParser;
impl<S: Stage> NoArgsAttributeParser<S> for CoherenceIsCoreParser {
const PATH: &[Symbol] = &[sym::rustc_coherence_is_core];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::CoherenceIsCore;
}

pub(crate) struct FundamentalParser;
impl<S: Stage> NoArgsAttributeParser<S> for FundamentalParser {
const PATH: &[Symbol] = &[sym::fundamental];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::Fundamental;
}
19 changes: 18 additions & 1 deletion compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ use crate::attributes::stability::{
BodyStabilityParser, ConstStabilityIndirectParser, ConstStabilityParser, StabilityParser,
};
use crate::attributes::test_attrs::IgnoreParser;
use crate::attributes::traits::SkipDuringMethodDispatchParser;
use crate::attributes::traits::{
AllowIncoherentImplParser, CoherenceIsCoreParser, CoinductiveParser, ConstTraitParser,
DenyExplicitImplParser, DoNotImplementViaObjectParser, FundamentalParser, MarkerParser,
ParenSugarParser, SkipDuringMethodDispatchParser, SpecializationTraitParser, TypeConstParser,
UnsafeSpecializationMarkerParser,
};
use crate::attributes::transparency::TransparencyParser;
use crate::attributes::{AttributeParser as _, Combine, Single, WithoutArgs};
use crate::parser::{ArgParser, MetaItemParser, PathParser};
Expand Down Expand Up @@ -146,22 +151,34 @@ attribute_parsers!(
Single<RustcObjectLifetimeDefaultParser>,
Single<SkipDuringMethodDispatchParser>,
Single<TransparencyParser>,
Single<WithoutArgs<AllowIncoherentImplParser>>,
Single<WithoutArgs<AsPtrParser>>,
Single<WithoutArgs<CoherenceIsCoreParser>>,
Single<WithoutArgs<CoinductiveParser>>,
Single<WithoutArgs<ColdParser>>,
Single<WithoutArgs<ConstContinueParser>>,
Single<WithoutArgs<ConstStabilityIndirectParser>>,
Single<WithoutArgs<ConstTraitParser>>,
Single<WithoutArgs<DenyExplicitImplParser>>,
Single<WithoutArgs<DoNotImplementViaObjectParser>>,
Single<WithoutArgs<ExportStableParser>>,
Single<WithoutArgs<FfiConstParser>>,
Single<WithoutArgs<FfiPureParser>>,
Single<WithoutArgs<FundamentalParser>>,
Single<WithoutArgs<LoopMatchParser>>,
Single<WithoutArgs<MarkerParser>>,
Single<WithoutArgs<MayDangleParser>>,
Single<WithoutArgs<NoImplicitPreludeParser>>,
Single<WithoutArgs<NoMangleParser>>,
Single<WithoutArgs<NonExhaustiveParser>>,
Single<WithoutArgs<ParenSugarParser>>,
Single<WithoutArgs<PassByValueParser>>,
Single<WithoutArgs<PubTransparentParser>>,
Single<WithoutArgs<SpecializationTraitParser>>,
Single<WithoutArgs<StdInternalSymbolParser>>,
Single<WithoutArgs<TrackCallerParser>>,
Single<WithoutArgs<TypeConstParser>>,
Single<WithoutArgs<UnsafeSpecializationMarkerParser>>,
// tidy-alphabetical-end
];
);
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ pub(crate) fn run_pass_manager(
if attributes::has_string_attr(function, enzyme_marker) {
// Sanity check: Ensure 'noinline' is present before replacing it.
assert!(
!attributes::has_attr(function, Function, llvm::AttributeKind::NoInline),
attributes::has_attr(function, Function, llvm::AttributeKind::NoInline),
"Expected __enzyme function to have 'noinline' before adding 'alwaysinline'"
);

Expand Down
23 changes: 22 additions & 1 deletion compiler/rustc_codegen_ssa/src/traits/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,33 @@ pub trait BuilderMethods<'a, 'tcx>:
/// Called for `StorageDead`
fn lifetime_end(&mut self, ptr: Self::Value, size: Size);

/// "Finally codegen the call"
///
/// ## Arguments
///
/// The `fn_attrs`, `fn_abi`, and `instance` arguments are Options because they are advisory.
/// They relate to optional codegen enhancements like LLVM CFI, and do not affect ABI per se.
/// Any ABI-related transformations should be handled by different, earlier stages of codegen.
/// For instance, in the caller of `BuilderMethods::call`.
///
/// This means that a codegen backend which disregards `fn_attrs`, `fn_abi`, and `instance`
/// should still do correct codegen, and code should not be miscompiled if they are omitted.
/// It is not a miscompilation in this sense if it fails to run under CFI, other sanitizers, or
/// in the context of other compiler-enhanced security features.
///
/// The typical case that they are None is during the codegen of intrinsics and lang-items,
/// as those are "fake functions" with only a trivial ABI if any, et cetera.
///
/// ## Return
///
/// Must return the value the function will return so it can be written to the destination,
/// assuming the function does not explicitly pass the destination as a pointer in `args`.
fn call(
&mut self,
llty: Self::Type,
fn_attrs: Option<&CodegenFnAttrs>,
fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
llfn: Self::Value,
fn_val: Self::Value,
args: &[Self::Value],
funclet: Option<&Self::Funclet>,
instance: Option<Instance<'tcx>>,
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_codegen_ssa/src/traits/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@ use crate::mir::operand::OperandRef;
use crate::mir::place::PlaceRef;

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

Expand Down
Loading
Loading