Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ declare_features! (
(unstable, aarch64_ver_target_feature, "1.27.0", Some(44839)),
(unstable, apx_target_feature, "1.88.0", Some(139284)),
(unstable, arm_target_feature, "1.27.0", Some(44839)),
(unstable, avr_target_feature, "CURRENT_RUSTC_VERSION", Some(146889)),
(unstable, bpf_target_feature, "1.54.0", Some(44839)),
(unstable, csky_target_feature, "1.73.0", Some(44839)),
(unstable, ermsb_target_feature, "1.49.0", Some(44839)),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,7 @@ symbols! {
autodiff_reverse,
automatically_derived,
available_externally,
avr_target_feature,
avx,
avx10_target_feature,
avx512_target_feature,
Expand Down
26 changes: 25 additions & 1 deletion compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,28 @@ static M68K_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-end
];

static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start
("addsubiw", Unstable(sym::avr_target_feature), &[]),
("break", Unstable(sym::avr_target_feature), &[]),
Copy link
Contributor

@Patryk27 Patryk27 Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: what about name collisions? 👀

The RFC doesn't seem to mention this, but I can see AVR's break (or other "generic" word like mul) accidentally colliding with another arch in future - on the other hand, keeping the mapping 1:1 with LLVM (FeatureBREAK in this case) is important as well, IMO.

Other than that LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Target feature name collisions with other architectures are fine. (e.g., the aes target feature exists on x86/x86_64 (AES-NI) and arm/aarch64/arm64ec (FEAT_AES) respectively.)

("eijmpcall", Unstable(sym::avr_target_feature), &[]),
("elpm", Unstable(sym::avr_target_feature), &[]),
("elpmx", Unstable(sym::avr_target_feature), &[]),
("ijmpcall", Unstable(sym::avr_target_feature), &[]),
("jmpcall", Unstable(sym::avr_target_feature), &[]),
("lowbytefirst", Unstable(sym::avr_target_feature), &[]),
("lpm", Unstable(sym::avr_target_feature), &[]),
("lpmx", Unstable(sym::avr_target_feature), &[]),
("movw", Unstable(sym::avr_target_feature), &[]),
("mul", Unstable(sym::avr_target_feature), &[]),
("rmw", Unstable(sym::avr_target_feature), &[]),
("spm", Unstable(sym::avr_target_feature), &[]),
("spmx", Unstable(sym::avr_target_feature), &[]),
("sram", Unstable(sym::avr_target_feature), &[]),
("tinyencoding", Unstable(sym::avr_target_feature), &[]),
// tidy-alphabetical-end
];

/// When rustdoc is running, provide a list of all known features so that all their respective
/// primitives may be documented.
///
Expand All @@ -905,6 +927,7 @@ pub fn all_rust_features() -> impl Iterator<Item = (&'static str, Stability)> {
.chain(IBMZ_FEATURES)
.chain(SPARC_FEATURES)
.chain(M68K_FEATURES)
.chain(AVR_FEATURES)
.cloned()
.map(|(f, s, _)| (f, s))
}
Expand Down Expand Up @@ -972,6 +995,7 @@ impl Target {
"s390x" => IBMZ_FEATURES,
"sparc" | "sparc64" => SPARC_FEATURES,
"m68k" => M68K_FEATURES,
"avr" => AVR_FEATURES,
_ => &[],
}
}
Expand All @@ -989,7 +1013,7 @@ impl Target {
"sparc" | "sparc64" => SPARC_FEATURES_FOR_CORRECT_VECTOR_ABI,
"hexagon" => HEXAGON_FEATURES_FOR_CORRECT_VECTOR_ABI,
"mips" | "mips32r6" | "mips64" | "mips64r6" => MIPS_FEATURES_FOR_CORRECT_VECTOR_ABI,
"nvptx64" | "bpf" | "m68k" => &[], // no vector ABI
"nvptx64" | "bpf" | "m68k" | "avr" => &[], // no vector ABI
"csky" => CSKY_FEATURES_FOR_CORRECT_VECTOR_ABI,
// FIXME: for some tier3 targets, we are overly cautious and always give warnings
// when passing args in vector registers.
Expand Down
17 changes: 17 additions & 0 deletions tests/ui/check-cfg/target_feature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`7e10`
`a`
`aclass`
`addsubiw`
`adx`
`aes`
`altivec`
Expand Down Expand Up @@ -58,6 +59,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`bf16`
`bmi1`
`bmi2`
`break`
`bti`
`bulk-memory`
`c`
Expand All @@ -84,6 +86,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`e2`
`ecv`
`edsp`
`eijmpcall`
`elpm`
`elpmx`
`elrw`
`enhanced-sort`
`ermsb`
Expand Down Expand Up @@ -134,6 +139,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`hvx-length128b`
`hwdiv`
`i8mm`
`ijmpcall`
`isa-68000`
`isa-68010`
`isa-68020`
Expand All @@ -142,6 +148,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`isa-68060`
`isa-68881`
`isa-68882`
`jmpcall`
`jsconv`
`kl`
`lahfsahf`
Expand All @@ -152,6 +159,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`ld-seq-sa`
`leoncasa`
`lor`
`lowbytefirst`
`lpm`
`lpmx`
`lse`
`lse128`
`lse2`
Expand All @@ -173,11 +183,13 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`mops`
`movbe`
`movrs`
`movw`
`mp`
`mp1e2`
`msa`
`msync`
`mte`
`mul`
`multivalue`
`mutable-globals`
`neon`
Expand Down Expand Up @@ -242,6 +254,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`reference-types`
`relax`
`relaxed-simd`
`rmw`
`rtm`
`rva23u64`
`sb`
Expand Down Expand Up @@ -294,6 +307,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`sme2p1`
`soft-float`
`spe`
`spm`
`spmx`
`sram`
`ssbs`
`sse`
`sse2`
Expand All @@ -318,6 +334,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`tbm`
`thumb-mode`
`thumb2`
`tinyencoding`
`tme`
`transactional-execution`
`trust`
Expand Down
1 change: 1 addition & 0 deletions tests/ui/target-feature/gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// gate-test-sparc_target_feature
// gate-test-x87_target_feature
// gate-test-m68k_target_feature
// gate-test-avr_target_feature

#[target_feature(enable = "x87")]
//~^ ERROR: currently unstable
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/target-feature/gate.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0658]: the target feature `x87` is currently unstable
--> $DIR/gate.rs:24:18
--> $DIR/gate.rs:25:18
|
LL | #[target_feature(enable = "x87")]
| ^^^^^^^^^^^^^^
Expand Down
Loading