From 8cbc623c3a81b49b7f669b659cf3fa202bcbf7d7 Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 9 Jan 2026 22:28:05 +0900 Subject: [PATCH 1/8] Add avr_target_feature --- compiler/rustc_feature/src/unstable.rs | 2 ++ compiler/rustc_span/src/symbol.rs | 1 + compiler/rustc_target/src/target_features.rs | 29 ++++++++++++++++++-- tests/ui/check-cfg/target_feature.stderr | 17 ++++++++++++ tests/ui/target-feature/gate.rs | 1 + tests/ui/target-feature/gate.stderr | 2 +- 6 files changed, 48 insertions(+), 4 deletions(-) diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index c99af9658cdef..e2abf50cbd397 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -373,6 +373,8 @@ declare_features! ( (unstable, async_for_loop, "1.77.0", Some(118898)), /// Allows `async` trait bound modifier. (unstable, async_trait_bounds, "1.85.0", Some(62290)), + /// Target features on avr. + (unstable, avr_target_feature, "CURRENT_RUSTC_VERSION", Some(146889)), /// Allows using Intel AVX10 target features and intrinsics (unstable, avx10_target_feature, "1.88.0", Some(138843)), /// Target features on bpf. diff --git a/compiler/rustc_span/src/symbol.rs b/compiler/rustc_span/src/symbol.rs index aac4cf1de8c2b..1915ff0380fda 100644 --- a/compiler/rustc_span/src/symbol.rs +++ b/compiler/rustc_span/src/symbol.rs @@ -577,6 +577,7 @@ symbols! { automatically_derived, available_externally, avr, + avr_target_feature, avx, avx10_target_feature, avx512_target_feature, diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index bc12e1eb97370..3b10613b64575 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -898,6 +898,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), &[]), + ("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. /// @@ -919,6 +941,7 @@ pub fn all_rust_features() -> impl Iterator { .chain(IBMZ_FEATURES) .chain(SPARC_FEATURES) .chain(M68K_FEATURES) + .chain(AVR_FEATURES) .cloned() .map(|(f, s, _)| (f, s)) } @@ -996,8 +1019,8 @@ impl Target { Arch::S390x => IBMZ_FEATURES, Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES, Arch::M68k => M68K_FEATURES, + Arch::Avr => AVR_FEATURES, Arch::AmdGpu - | Arch::Avr | Arch::Msp430 | Arch::SpirV | Arch::Xtensa @@ -1023,11 +1046,11 @@ impl Target { MIPS_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI } Arch::AmdGpu => AMDGPU_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI, - Arch::Nvptx64 | Arch::Bpf | Arch::M68k => &[], // no vector ABI + Arch::Nvptx64 | Arch::Bpf | Arch::M68k | Arch::Avr => &[], // no vector ABI Arch::CSky => CSKY_FEATURES_FOR_CORRECT_FIXED_LENGTH_VECTOR_ABI, // FIXME: for some tier3 targets, we are overly cautious and always give warnings // when passing args in vector registers. - Arch::Avr | Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[], + Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[], } } diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 89123c9100825..8f887eaaca8c1 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -14,6 +14,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `7e10` `a` `aclass` +`addsubiw` `adx` `aes` `altivec` @@ -57,6 +58,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `bf16` `bmi1` `bmi2` +`break` `bti` `bulk-memory` `c` @@ -83,6 +85,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `e2` `ecv` `edsp` +`eijmpcall` +`elpm` +`elpmx` `elrw` `enhanced-sort` `ermsb` @@ -148,6 +153,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `hvxv79` `hwdiv` `i8mm` +`ijmpcall` `isa-68000` `isa-68010` `isa-68020` @@ -156,6 +162,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `isa-68060` `isa-68881` `isa-68882` +`jmpcall` `jsconv` `kl` `lahfsahf` @@ -166,6 +173,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `ld-seq-sa` `leoncasa` `lor` +`lowbytefirst` +`lpm` +`lpmx` `lse` `lse128` `lse2` @@ -187,11 +197,13 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `mops` `movbe` `movrs` +`movw` `mp` `mp1e2` `msa` `msync` `mte` +`mul` `multivalue` `mutable-globals` `neon` @@ -256,6 +268,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `reference-types` `relax` `relaxed-simd` +`rmw` `rtm` `rva23u64` `sb` @@ -308,6 +321,9 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `sme2p1` `soft-float` `spe` +`spm` +`spmx` +`sram` `ssbs` `sse` `sse2` @@ -332,6 +348,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `tbm` `thumb-mode` `thumb2` +`tinyencoding` `tme` `transactional-execution` `trust` diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index fc3763820cbec..ea3bbbed273c8 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -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 diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index 67df09fd369e4..f0de5a958e860 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -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")] | ^^^^^^^^^^^^^^ From 895ea0c2f5e06e77849e3530600944054af2a39a Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Fri, 6 Feb 2026 09:29:24 +0900 Subject: [PATCH 2/8] Require sram target feature on AVR --- compiler/rustc_target/src/target_features.rs | 14 ++++++++------ src/doc/rustc/src/platform-support/avr-none.md | 2 ++ tests/ui/abi/avr-sram.disable_sram.stderr | 12 ++++++++++++ tests/ui/abi/avr-sram.no_sram.stderr | 7 +++++++ tests/ui/abi/avr-sram.rs | 15 +++++++++++++++ tests/ui/check-cfg/target_feature.stderr | 1 - 6 files changed, 44 insertions(+), 7 deletions(-) create mode 100644 tests/ui/abi/avr-sram.disable_sram.stderr create mode 100644 tests/ui/abi/avr-sram.no_sram.stderr create mode 100644 tests/ui/abi/avr-sram.rs diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 3b10613b64575..a8e9d2e9dcaab 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -915,7 +915,7 @@ static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("rmw", Unstable(sym::avr_target_feature), &[]), ("spm", Unstable(sym::avr_target_feature), &[]), ("spmx", Unstable(sym::avr_target_feature), &[]), - ("sram", Unstable(sym::avr_target_feature), &[]), + ("sram", Forbidden { reason: "devices that have no SRAM are unsupported" }, &[]), ("tinyencoding", Unstable(sym::avr_target_feature), &[]), // tidy-alphabetical-end ]; @@ -1020,11 +1020,7 @@ impl Target { Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES, Arch::M68k => M68K_FEATURES, Arch::Avr => AVR_FEATURES, - Arch::AmdGpu - | Arch::Msp430 - | Arch::SpirV - | Arch::Xtensa - | Arch::Other(_) => &[], + Arch::AmdGpu | Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[], } } @@ -1247,6 +1243,12 @@ impl Target { // because the vector and float registers overlap. FeatureConstraints { required: &[], incompatible: &["soft-float"] } } + Arch::Avr => { + // SRAM is minimum requirement for C/C++ in both avr-gcc and Clang, + // and backends of them only support assembly for devices have no SRAM. + // See the discussion in https://github.com/rust-lang/rust/pull/146900 for more. + FeatureConstraints { required: &["sram"], incompatible: &[] } + } _ => NOTHING, } } diff --git a/src/doc/rustc/src/platform-support/avr-none.md b/src/doc/rustc/src/platform-support/avr-none.md index 5218f19adf3b8..36874387b8048 100644 --- a/src/doc/rustc/src/platform-support/avr-none.md +++ b/src/doc/rustc/src/platform-support/avr-none.md @@ -68,6 +68,8 @@ the possible variants: https://github.com/llvm/llvm-project/blob/093d4db2f3c874d4683fb01194b00dbb20e5c713/clang/lib/Basic/Targets/AVR.cpp#L32 +Note that devices that have no SRAM are not supported, same as when compiling C/C++ programs with avr-gcc or Clang. + ## Testing You can use [`simavr`](https://github.com/buserror/simavr) to emulate the diff --git a/tests/ui/abi/avr-sram.disable_sram.stderr b/tests/ui/abi/avr-sram.disable_sram.stderr new file mode 100644 index 0000000000000..31b9084f73a48 --- /dev/null +++ b/tests/ui/abi/avr-sram.disable_sram.stderr @@ -0,0 +1,12 @@ +warning: target feature `sram` cannot be disabled with `-Ctarget-feature`: devices that have no SRAM are unsupported + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116344 + +warning: target feature `sram` must be enabled to ensure that the ABI of the current target can be implemented correctly + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116344 + +warning: 2 warnings emitted + diff --git a/tests/ui/abi/avr-sram.no_sram.stderr b/tests/ui/abi/avr-sram.no_sram.stderr new file mode 100644 index 0000000000000..3f74bf66f190d --- /dev/null +++ b/tests/ui/abi/avr-sram.no_sram.stderr @@ -0,0 +1,7 @@ +warning: target feature `sram` must be enabled to ensure that the ABI of the current target can be implemented correctly + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116344 + +warning: 1 warning emitted + diff --git a/tests/ui/abi/avr-sram.rs b/tests/ui/abi/avr-sram.rs new file mode 100644 index 0000000000000..0266f7d6b22ca --- /dev/null +++ b/tests/ui/abi/avr-sram.rs @@ -0,0 +1,15 @@ +//@ revisions: has_sram no_sram disable_sram +//@ build-pass +//@[has_sram] compile-flags: --target avr-none -C target-cpu=atmega328p +//@[has_sram] needs-llvm-components: avr +//@[no_sram] compile-flags: --target avr-none -C target-cpu=attiny11 +//@[no_sram] needs-llvm-components: avr +//@[disable_sram] compile-flags: --target avr-none -C target-cpu=atmega328p -C target-feature=-sram +//@[disable_sram] needs-llvm-components: avr +//@ ignore-backends: gcc +//[no_sram,disable_sram]~? WARN target feature `sram` must be enabled +//[disable_sram]~? WARN target feature `sram` cannot be disabled with `-Ctarget-feature` + +#![feature(no_core)] +#![no_core] +#![crate_type = "lib"] diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 8f887eaaca8c1..06a7f477a7fdf 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -323,7 +323,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `spe` `spm` `spmx` -`sram` `ssbs` `sse` `sse2` From f71347c611fde0b28699c85db0858f52ff2e5002 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 6 Feb 2026 19:28:22 +0100 Subject: [PATCH 3/8] Remove tidy fluent file checks --- src/tools/tidy/src/fluent_alphabetical.rs | 125 ---------------------- src/tools/tidy/src/fluent_lowercase.rs | 65 ----------- src/tools/tidy/src/fluent_period.rs | 88 --------------- src/tools/tidy/src/fluent_used.rs | 42 -------- src/tools/tidy/src/lib.rs | 4 - src/tools/tidy/src/main.rs | 3 - 6 files changed, 327 deletions(-) delete mode 100644 src/tools/tidy/src/fluent_alphabetical.rs delete mode 100644 src/tools/tidy/src/fluent_lowercase.rs delete mode 100644 src/tools/tidy/src/fluent_period.rs delete mode 100644 src/tools/tidy/src/fluent_used.rs diff --git a/src/tools/tidy/src/fluent_alphabetical.rs b/src/tools/tidy/src/fluent_alphabetical.rs deleted file mode 100644 index 7583241ea638a..0000000000000 --- a/src/tools/tidy/src/fluent_alphabetical.rs +++ /dev/null @@ -1,125 +0,0 @@ -//! Checks that all Flunt files have messages in alphabetical order - -use std::collections::HashMap; -use std::fs::OpenOptions; -use std::io::Write; -use std::path::Path; - -use fluent_syntax::ast::Entry; -use fluent_syntax::parser; -use regex::Regex; - -use crate::diagnostics::{CheckId, RunningCheck, TidyCtx}; -use crate::walk::{filter_dirs, walk}; - -fn message() -> &'static Regex { - static_regex!(r#"(?m)^([a-zA-Z0-9_]+)\s*=\s*"#) -} - -fn is_fluent(path: &Path) -> bool { - path.extension().is_some_and(|ext| ext == "ftl") -} - -fn check_alphabetic( - filename: &str, - fluent: &str, - check: &mut RunningCheck, - all_defined_msgs: &mut HashMap, -) { - let Ok(resource) = parser::parse(fluent) else { - panic!("Errors encountered while parsing fluent file `{filename}`"); - }; - - let mut prev: Option<&str> = None; - - for entry in &resource.body { - if let Entry::Message(msg) = entry { - let name: &str = msg.id.name; - if let Some(defined_filename) = all_defined_msgs.get(name) { - check.error(format!( - "{filename}: message `{name}` is already defined in {defined_filename}", - )); - } else { - all_defined_msgs.insert(name.to_string(), filename.to_owned()); - } - if let Some(prev) = prev - && prev > name - { - check.error(format!( - "{filename}: message `{prev}` appears before `{name}`, but is alphabetically \ -later than it. Run `./x.py test tidy --bless` to sort the file correctly", - )); - } - prev = Some(name); - } - } -} - -fn sort_messages( - filename: &str, - fluent: &str, - check: &mut RunningCheck, - all_defined_msgs: &mut HashMap, -) -> String { - let mut chunks = vec![]; - let mut cur = String::new(); - for line in fluent.lines() { - if let Some(name) = message().find(line) { - if let Some(defined_filename) = all_defined_msgs.get(name.as_str()) { - check.error(format!( - "{filename}: message `{}` is already defined in {defined_filename}", - name.as_str(), - )); - } - - all_defined_msgs.insert(name.as_str().to_owned(), filename.to_owned()); - chunks.push(std::mem::take(&mut cur)); - } - - cur += line; - cur.push('\n'); - } - chunks.push(cur); - chunks.sort(); - let mut out = chunks.join(""); - out = out.trim().to_string(); - out.push('\n'); - out -} - -pub fn check(path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("fluent_alphabetical").path(path)); - let bless = tidy_ctx.is_bless_enabled(); - - let mut all_defined_msgs = HashMap::new(); - walk( - path, - |path, is_dir| filter_dirs(path) || (!is_dir && !is_fluent(path)), - &mut |ent, contents| { - if bless { - let sorted = sort_messages( - ent.path().to_str().unwrap(), - contents, - &mut check, - &mut all_defined_msgs, - ); - if sorted != contents { - let mut f = - OpenOptions::new().write(true).truncate(true).open(ent.path()).unwrap(); - f.write_all(sorted.as_bytes()).unwrap(); - } - } else { - check_alphabetic( - ent.path().to_str().unwrap(), - contents, - &mut check, - &mut all_defined_msgs, - ); - } - }, - ); - - assert!(!all_defined_msgs.is_empty()); - - crate::fluent_used::check(path, all_defined_msgs, tidy_ctx); -} diff --git a/src/tools/tidy/src/fluent_lowercase.rs b/src/tools/tidy/src/fluent_lowercase.rs deleted file mode 100644 index 690b733a5b648..0000000000000 --- a/src/tools/tidy/src/fluent_lowercase.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! Checks that the error messages start with a lowercased letter (except when allowed to). - -use std::path::Path; - -use fluent_syntax::ast::{Entry, Message, PatternElement}; - -use crate::diagnostics::{CheckId, RunningCheck, TidyCtx}; -use crate::walk::{filter_dirs, walk}; - -#[rustfmt::skip] -const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[ - // tidy-alphabetical-start - "ABI", - "ABIs", - "ADT", - "C", - "CGU", - "Ferris", - "MIR", - "OK", - "Rust", - "VS", // VS Code - // tidy-alphabetical-end -]; - -fn filter_fluent(path: &Path) -> bool { - if let Some(ext) = path.extension() { ext.to_str() != Some("ftl") } else { true } -} - -fn is_allowed_capitalized_word(msg: &str) -> bool { - ALLOWED_CAPITALIZED_WORDS.iter().any(|word| { - msg.strip_prefix(word) - .map(|tail| tail.chars().next().map(|c| c == '-' || c.is_whitespace()).unwrap_or(true)) - .unwrap_or_default() - }) -} - -fn check_lowercase(filename: &str, contents: &str, check: &mut RunningCheck) { - let (Ok(parse) | Err((parse, _))) = fluent_syntax::parser::parse(contents); - - for entry in &parse.body { - if let Entry::Message(msg) = entry - && let Message { value: Some(pattern), .. } = msg - && let [first_pattern, ..] = &pattern.elements[..] - && let PatternElement::TextElement { value } = first_pattern - && value.chars().next().is_some_and(char::is_uppercase) - && !is_allowed_capitalized_word(value) - { - check.error(format!( - "{filename}: message `{value}` starts with an uppercase letter. Fix it or add it to `ALLOWED_CAPITALIZED_WORDS`" - )); - } - } -} - -pub fn check(path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("fluent_lowercase").path(path)); - walk( - path, - |path, is_dir| filter_dirs(path) || (!is_dir && filter_fluent(path)), - &mut |ent, contents| { - check_lowercase(ent.path().to_str().unwrap(), contents, &mut check); - }, - ); -} diff --git a/src/tools/tidy/src/fluent_period.rs b/src/tools/tidy/src/fluent_period.rs deleted file mode 100644 index e7d59e2ce2a9c..0000000000000 --- a/src/tools/tidy/src/fluent_period.rs +++ /dev/null @@ -1,88 +0,0 @@ -//! Checks that no Fluent messages or attributes end in periods (except ellipses) - -use std::path::Path; - -use fluent_syntax::ast::{Entry, PatternElement}; - -use crate::diagnostics::{CheckId, RunningCheck, TidyCtx}; -use crate::walk::{filter_dirs, walk}; - -fn filter_fluent(path: &Path) -> bool { - if let Some(ext) = path.extension() { ext.to_str() != Some("ftl") } else { true } -} - -/// Messages allowed to have `.` at their end. -/// -/// These should probably be reworked eventually. -const ALLOWLIST: &[&str] = &[ - "const_eval_long_running", - "const_eval_validation_failure_note", - "driver_impl_ice", - "incremental_corrupt_file", -]; - -fn check_period(filename: &str, contents: &str, check: &mut RunningCheck) { - if filename.contains("codegen") { - // FIXME: Too many codegen messages have periods right now... - return; - } - - let (Ok(parse) | Err((parse, _))) = fluent_syntax::parser::parse(contents); - for entry in &parse.body { - if let Entry::Message(m) = entry { - if ALLOWLIST.contains(&m.id.name) { - continue; - } - - if let Some(pat) = &m.value - && let Some(PatternElement::TextElement { value }) = pat.elements.last() - { - // We don't care about ellipses. - if value.ends_with(".") && !value.ends_with("...") { - let ll = find_line(contents, value); - let name = m.id.name; - check.error(format!("{filename}:{ll}: message `{name}` ends in a period")); - } - } - - for attr in &m.attributes { - // Teach notes usually have long messages. - if attr.id.name == "teach_note" { - continue; - } - - if let Some(PatternElement::TextElement { value }) = attr.value.elements.last() - && value.ends_with(".") - && !value.ends_with("...") - { - let ll = find_line(contents, value); - let name = attr.id.name; - check.error(format!("{filename}:{ll}: attr `{name}` ends in a period")); - } - } - } - } -} - -/// Evil cursed bad hack. Requires that `value` be a substr (in memory) of `contents`. -fn find_line(haystack: &str, needle: &str) -> usize { - for (ll, line) in haystack.lines().enumerate() { - if line.as_ptr() > needle.as_ptr() { - return ll; - } - } - - 1 -} - -pub fn check(path: &Path, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("fluent_period").path(path)); - - walk( - path, - |path, is_dir| filter_dirs(path) || (!is_dir && filter_fluent(path)), - &mut |ent, contents| { - check_period(ent.path().to_str().unwrap(), contents, &mut check); - }, - ); -} diff --git a/src/tools/tidy/src/fluent_used.rs b/src/tools/tidy/src/fluent_used.rs deleted file mode 100644 index 75da1d7ea49d7..0000000000000 --- a/src/tools/tidy/src/fluent_used.rs +++ /dev/null @@ -1,42 +0,0 @@ -//! Checks that all Fluent messages appear at least twice - -use std::collections::HashMap; -use std::path::Path; - -use crate::diagnostics::{CheckId, TidyCtx}; -use crate::walk::{filter_dirs, walk}; - -fn filter_used_messages( - contents: &str, - msgs_not_appeared_yet: &mut HashMap, - msgs_appeared_only_once: &mut HashMap, -) { - // we don't just check messages never appear in Rust files, - // because messages can be used as parts of other fluent messages in Fluent files, - // so we check messages appear only once in all Rust and Fluent files. - let matches = static_regex!(r"\w+").find_iter(contents); - for name in matches { - if let Some((name, filename)) = msgs_not_appeared_yet.remove_entry(name.as_str()) { - // if one msg appears for the first time, - // remove it from `msgs_not_appeared_yet` and insert it into `msgs_appeared_only_once`. - msgs_appeared_only_once.insert(name, filename); - } else { - // if one msg appears for the second time, - // remove it from `msgs_appeared_only_once`. - msgs_appeared_only_once.remove(name.as_str()); - } - } -} - -pub fn check(path: &Path, mut all_defined_msgs: HashMap, tidy_ctx: TidyCtx) { - let mut check = tidy_ctx.start_check(CheckId::new("fluent_used").path(path)); - - let mut msgs_appear_only_once = HashMap::new(); - walk(path, |path, _| filter_dirs(path), &mut |_, contents| { - filter_used_messages(contents, &mut all_defined_msgs, &mut msgs_appear_only_once); - }); - - for (name, filename) in msgs_appear_only_once { - check.error(format!("{filename}: message `{name}` is not used")); - } -} diff --git a/src/tools/tidy/src/lib.rs b/src/tools/tidy/src/lib.rs index 19a9fa80d9f04..ed41130f5d299 100644 --- a/src/tools/tidy/src/lib.rs +++ b/src/tools/tidy/src/lib.rs @@ -168,10 +168,6 @@ pub mod extdeps; pub mod extra_checks; pub mod features; pub mod filenames; -pub mod fluent_alphabetical; -pub mod fluent_lowercase; -pub mod fluent_period; -mod fluent_used; pub mod gcc_submodule; pub(crate) mod iter_header; pub mod known_bug; diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index 2485dc802ed53..09c08e1baf503 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -107,9 +107,6 @@ fn main() { // Checks that only make sense for the compiler. check!(error_codes, &root_path, &[&compiler_path, &librustdoc_path], &ci_info); - check!(fluent_alphabetical, &compiler_path); - check!(fluent_period, &compiler_path); - check!(fluent_lowercase, &compiler_path); check!(target_policy, &root_path); check!(gcc_submodule, &root_path, &compiler_path); From ca9c2277008aee9310155c5e6131f0f93f67e3ad Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 6 Feb 2026 21:15:02 +0100 Subject: [PATCH 4/8] Check style of messages in `rustc_macros` --- .../rustc_macros/src/diagnostics/message.rs | 71 +++++++++++++++---- 1 file changed, 56 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_macros/src/diagnostics/message.rs b/compiler/rustc_macros/src/diagnostics/message.rs index 6c8aded89f165..16ee3c657611d 100644 --- a/compiler/rustc_macros/src/diagnostics/message.rs +++ b/compiler/rustc_macros/src/diagnostics/message.rs @@ -23,9 +23,7 @@ impl Message { quote! { crate::fluent_generated::#slug } } Message::Inline(message_span, message) => { - if let Some(variant) = variant { - verify_fluent_message(*message_span, &message, variant); - } + verify_fluent_message(*message_span, &message, variant); quote! { rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed(#message)) } } } @@ -86,30 +84,37 @@ impl Message { } } -fn verify_fluent_message(msg_span: Span, message: &str, variant: &VariantInfo<'_>) { +fn verify_fluent_message(msg_span: Span, message_str: &str, variant: Option<&VariantInfo<'_>>) { // Parse the fluent message const GENERATED_MSG_ID: &str = "generated_msg"; - let resource = FluentResource::try_new(format!("{GENERATED_MSG_ID} = {message}\n")).unwrap(); + let resource = + FluentResource::try_new(format!("{GENERATED_MSG_ID} = {message_str}\n")).unwrap(); assert_eq!(resource.entries().count(), 1); let Some(fluent_syntax::ast::Entry::Message(message)) = resource.get_entry(0) else { panic!("Did not parse into a message") }; // Check if all variables are used - let fields: Vec = variant - .bindings() - .iter() - .flat_map(|b| b.ast().ident.as_ref()) - .map(|id| id.to_string()) - .collect(); - for variable in variable_references(&message) { - if !fields.iter().any(|f| f == variable) { - span_err(msg_span.unwrap(), format!("Variable `{variable}` not found in diagnostic ")) + if let Some(variant) = variant { + let fields: Vec = variant + .bindings() + .iter() + .flat_map(|b| b.ast().ident.as_ref()) + .map(|id| id.to_string()) + .collect(); + for variable in variable_references(&message) { + if !fields.iter().any(|f| f == variable) { + span_err( + msg_span.unwrap(), + format!("Variable `{variable}` not found in diagnostic "), + ) .help(format!("Available fields: {:?}", fields.join(", "))) .emit(); + } } - // assert!(, ); } + + verify_message_style(msg_span, message_str); } fn variable_references<'a>(msg: &fluent_syntax::ast::Message<&'a str>) -> Vec<&'a str> { @@ -136,3 +141,39 @@ fn variable_references<'a>(msg: &fluent_syntax::ast::Message<&'a str>) -> Vec<&' } refs } + +const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[ + // tidy-alphabetical-start + "ABI", + "ABIs", + "ADT", + "C-variadic", + "CGU-reuse", + "Cargo", + "Ferris", + "GCC", + "MIR", + "OK", + "VS", + // tidy-alphabetical-end +]; + +/// See: https://rustc-dev-guide.rust-lang.org/diagnostics.html#diagnostic-output-style-guide +fn verify_message_style(msg_span: Span, message: &str) { + // Verify that message starts with lowercase char + let Some(first_word) = message.split_whitespace().next() else { + span_err(msg_span.unwrap(), "message must not be empty").emit(); + return; + }; + let first_char = first_word.chars().next().expect("Word is not empty"); + if first_char.is_uppercase() && !ALLOWED_CAPITALIZED_WORDS.contains(&first_word) { + span_err(msg_span.unwrap(), "message `{value}` starts with an uppercase letter. Fix it or add it to `ALLOWED_CAPITALIZED_WORDS`").emit(); + return; + } + + // Verify that message does not end in `.` + if message.ends_with(".") && !message.ends_with("...") { + span_err(msg_span.unwrap(), "message `{value}` ends with a period").emit(); + return; + } +} From 1d45191420955de75d400e7c53ccffa9f38f48fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Thu, 5 Feb 2026 14:02:06 +0100 Subject: [PATCH 5/8] Port rustc_intrinsic to the new attribute parser --- compiler/rustc_ast_lowering/src/item.rs | 2 +- .../src/attributes/rustc_internal.rs | 11 +++++++++++ compiler/rustc_attr_parsing/src/context.rs | 1 + compiler/rustc_hir/src/attrs/data_structures.rs | 3 +++ compiler/rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_middle/src/ty/util.rs | 6 ++++-- compiler/rustc_mir_transform/src/check_inline.rs | 5 +++-- .../rustc_mir_transform/src/cross_crate_inline.rs | 7 ++++--- compiler/rustc_passes/src/check_attr.rs | 2 +- src/tools/clippy/clippy_lints/src/loops/empty_loop.rs | 7 ++++--- 10 files changed, 33 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index cde8b8f9fe2e9..12eaa99143e90 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1397,7 +1397,7 @@ impl<'hir> LoweringContext<'_, 'hir> { // create a fake body so that the entire rest of the compiler doesn't have to deal with // this as a special case. return self.lower_fn_body(decl, contract, |this| { - if attrs.iter().any(|a| a.has_name(sym::rustc_intrinsic)) + if find_attr!(attrs, AttributeKind::RustcIntrinsic) || this.tcx.is_sdylib_interface_build() { let span = this.lower_span(span); diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index bde4904e9655d..4cc6cd959cc31 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -721,6 +721,8 @@ impl CombineAttributeParser for RustcThenThisWouldNeedParser { Some(ident) } } +<<<<<<< Conflict 1 of 1 ++++++++ Contents of side #1 pub(crate) struct RustcEffectiveVisibilityParser; @@ -760,3 +762,12 @@ impl NoArgsAttributeParser for RustcEffectiveVisibilityParser { ]); const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcEffectiveVisibility; } + +pub(crate) struct RustcIntrinsicParser; + +impl NoArgsAttributeParser for RustcIntrinsicParser { + const PATH: &'static [Symbol] = &[sym::rustc_intrinsic]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic; +} diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index 9008e9edf9653..a21690d3a5b80 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -262,6 +262,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 426363dcd7253..76458ecedd688 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -1117,6 +1117,9 @@ pub enum AttributeKind { /// Represents `#[rustc_if_this_changed]` RustcIfThisChanged(Span, Option), + /// Represents `#[rustc_intrinsic]` + RustcIntrinsic, + /// Represents `#[rustc_layout]` RustcLayout(ThinVec), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index eb1e35ed9b257..d2af11e479ce6 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -117,6 +117,7 @@ impl AttributeKind { RustcHasIncoherentInherentImpls => Yes, RustcHiddenTypeOfOpaques => No, RustcIfThisChanged(..) => No, + RustcIntrinsic => Yes, RustcLayout(..) => No, RustcLayoutScalarValidRangeEnd(..) => Yes, RustcLayoutScalarValidRangeStart(..) => Yes, diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index d6e6ffae7300d..47b9bb95f830e 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -10,11 +10,11 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::stack::ensure_sufficient_stack; use rustc_errors::ErrorGuaranteed; use rustc_hashes::Hash128; -use rustc_hir as hir; use rustc_hir::attrs::AttributeKind; use rustc_hir::def::{CtorOf, DefKind, Res}; use rustc_hir::def_id::{CrateNum, DefId, LocalDefId}; use rustc_hir::limit::Limit; +use rustc_hir::{self as hir, find_attr}; use rustc_index::bit_set::GrowableBitSet; use rustc_macros::{HashStable, TyDecodable, TyEncodable, extension}; use rustc_span::sym; @@ -1679,7 +1679,9 @@ pub fn is_doc_notable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool { /// the compiler to make some assumptions about its shape; if the user doesn't use a feature gate, they may /// cause an ICE that we otherwise may want to prevent. pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option { - if tcx.features().intrinsics() && tcx.has_attr(def_id, sym::rustc_intrinsic) { + if tcx.features().intrinsics() + && find_attr!(tcx.get_all_attrs(def_id), AttributeKind::RustcIntrinsic) + { let must_be_overridden = match tcx.hir_node_by_def_id(def_id) { hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn { has_body, .. }, .. }) => { !has_body diff --git a/compiler/rustc_mir_transform/src/check_inline.rs b/compiler/rustc_mir_transform/src/check_inline.rs index 8d28cb3ca003d..2d18764267276 100644 --- a/compiler/rustc_mir_transform/src/check_inline.rs +++ b/compiler/rustc_mir_transform/src/check_inline.rs @@ -1,8 +1,9 @@ //! Check that a body annotated with `#[rustc_force_inline]` will not fail to inline based on its //! definition alone (irrespective of any specific caller). -use rustc_hir::attrs::InlineAttr; +use rustc_hir::attrs::{AttributeKind, InlineAttr}; use rustc_hir::def_id::DefId; +use rustc_hir::find_attr; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::{Body, TerminatorKind}; use rustc_middle::ty; @@ -62,7 +63,7 @@ pub(super) fn is_inline_valid_on_fn<'tcx>( // but at this stage we don't know whether codegen knows the intrinsic, // so just conservatively don't inline it. This also ensures that we do not // accidentally inline the body of an intrinsic that *must* be overridden. - if tcx.has_attr(def_id, sym::rustc_intrinsic) { + if find_attr!(tcx.get_all_attrs(def_id), AttributeKind::RustcIntrinsic) { return Err("callee is an intrinsic"); } diff --git a/compiler/rustc_mir_transform/src/cross_crate_inline.rs b/compiler/rustc_mir_transform/src/cross_crate_inline.rs index 71bdafa958ca1..da133861617f1 100644 --- a/compiler/rustc_mir_transform/src/cross_crate_inline.rs +++ b/compiler/rustc_mir_transform/src/cross_crate_inline.rs @@ -1,6 +1,7 @@ -use rustc_hir::attrs::InlineAttr; +use rustc_hir::attrs::{AttributeKind, InlineAttr}; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; +use rustc_hir::find_attr; use rustc_middle::bug; use rustc_middle::mir::visit::Visitor; use rustc_middle::mir::*; @@ -43,7 +44,7 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool { return true; } - if tcx.has_attr(def_id, sym::rustc_intrinsic) { + if find_attr!(tcx.get_all_attrs(def_id), AttributeKind::RustcIntrinsic) { // Intrinsic fallback bodies are always cross-crate inlineable. // To ensure that the MIR inliner doesn't cluelessly try to inline fallback // bodies even when the backend would implement something better, we stop @@ -157,7 +158,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> { // But intrinsics don't have a body that gets assigned to a CGU, so they are // ignored. if let Some((fn_def_id, _)) = func.const_fn_def() - && self.tcx.has_attr(fn_def_id, sym::rustc_intrinsic) + && find_attr!(tcx.get_all_attrs(fn_def_id), AttributeKind::RustcIntrinsic) { return; } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index c207d7455f749..6f4f5ea7e206b 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -312,6 +312,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | AttributeKind::RustcHasIncoherentInherentImpls | AttributeKind::RustcHiddenTypeOfOpaques | AttributeKind::RustcIfThisChanged(..) + | AttributeKind::RustcIntrinsic | AttributeKind::RustcLayout(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) | AttributeKind::RustcLayoutScalarValidRangeStart(..) @@ -383,7 +384,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | sym::rustc_no_mir_inline | sym::rustc_insignificant_dtor | sym::rustc_nonnull_optimization_guaranteed - | sym::rustc_intrinsic | sym::rustc_inherit_overflow_checks | sym::rustc_intrinsic_const_stable_indirect | sym::rustc_trivial_field_reads diff --git a/src/tools/clippy/clippy_lints/src/loops/empty_loop.rs b/src/tools/clippy/clippy_lints/src/loops/empty_loop.rs index e809987d75a00..0a5b26bfa6898 100644 --- a/src/tools/clippy/clippy_lints/src/loops/empty_loop.rs +++ b/src/tools/clippy/clippy_lints/src/loops/empty_loop.rs @@ -1,8 +1,9 @@ use super::EMPTY_LOOP; use clippy_utils::diagnostics::span_lint_and_help; -use clippy_utils::{is_in_panic_handler, is_no_std_crate, sym}; +use clippy_utils::{is_in_panic_handler, is_no_std_crate}; -use rustc_hir::{Block, Expr, ItemKind, Node}; +use rustc_hir::attrs::AttributeKind; +use rustc_hir::{Block, Expr, ItemKind, Node, find_attr}; use rustc_lint::LateContext; pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, loop_block: &Block<'_>) { @@ -10,7 +11,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, loop_block: &Block<'_ if let Node::Item(parent_node) = cx.tcx.hir_node(parent_hir_id) && matches!(parent_node.kind, ItemKind::Fn { .. }) && let attrs = cx.tcx.hir_attrs(parent_hir_id) - && attrs.iter().any(|attr| attr.has_name(sym::rustc_intrinsic)) + && find_attr!(attrs, AttributeKind::RustcIntrinsic) { // Intrinsic functions are expanded into an empty loop when lowering the AST // to simplify the job of later passes which might expect any function to have a body. From 087c014385df4d8d5a2eb707b9d710ae08c16340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jana=20D=C3=B6nszelmann?= Date: Thu, 5 Feb 2026 14:09:40 +0100 Subject: [PATCH 6/8] Port rustc_intrinsic_const_stable_indirect to the new attribute parser --- .../src/attributes/rustc_internal.rs | 10 ++++++++++ compiler/rustc_attr_parsing/src/context.rs | 1 + compiler/rustc_hir/src/attrs/data_structures.rs | 3 +++ compiler/rustc_hir/src/attrs/encode_cross_crate.rs | 1 + compiler/rustc_middle/src/ty/util.rs | 5 ++++- compiler/rustc_passes/src/check_attr.rs | 2 +- 6 files changed, 20 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs index 4cc6cd959cc31..c3c3187b2934e 100644 --- a/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs +++ b/compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs @@ -490,6 +490,7 @@ impl CombineAttributeParser for RustcMirParser { .collect() } } + pub(crate) struct RustcNonConstTraitMethodParser; impl NoArgsAttributeParser for RustcNonConstTraitMethodParser { @@ -771,3 +772,12 @@ impl NoArgsAttributeParser for RustcIntrinsicParser { const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]); const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsic; } + +pub(crate) struct RustcIntrinsicConstStableIndirectParser; + +impl NoArgsAttributeParser for RustcIntrinsicConstStableIndirectParser { + const PATH: &'static [Symbol] = &[sym::rustc_intrinsic_const_stable_indirect]; + const ON_DUPLICATE: OnDuplicate = OnDuplicate::Error; + const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]); + const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcIntrinsicConstStableIndirect; +} diff --git a/compiler/rustc_attr_parsing/src/context.rs b/compiler/rustc_attr_parsing/src/context.rs index a21690d3a5b80..f18dcc15b3833 100644 --- a/compiler/rustc_attr_parsing/src/context.rs +++ b/compiler/rustc_attr_parsing/src/context.rs @@ -262,6 +262,7 @@ attribute_parsers!( Single>, Single>, Single>, + Single>, Single>, Single>, Single>, diff --git a/compiler/rustc_hir/src/attrs/data_structures.rs b/compiler/rustc_hir/src/attrs/data_structures.rs index 76458ecedd688..b8a286db036eb 100644 --- a/compiler/rustc_hir/src/attrs/data_structures.rs +++ b/compiler/rustc_hir/src/attrs/data_structures.rs @@ -1120,6 +1120,9 @@ pub enum AttributeKind { /// Represents `#[rustc_intrinsic]` RustcIntrinsic, + /// Represents `#[rustc_intrinsic_const_stable_indirect]` + RustcIntrinsicConstStableIndirect, + /// Represents `#[rustc_layout]` RustcLayout(ThinVec), diff --git a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs index d2af11e479ce6..d164f3e3d98a6 100644 --- a/compiler/rustc_hir/src/attrs/encode_cross_crate.rs +++ b/compiler/rustc_hir/src/attrs/encode_cross_crate.rs @@ -118,6 +118,7 @@ impl AttributeKind { RustcHiddenTypeOfOpaques => No, RustcIfThisChanged(..) => No, RustcIntrinsic => Yes, + RustcIntrinsicConstStableIndirect => No, RustcLayout(..) => No, RustcLayoutScalarValidRangeEnd(..) => Yes, RustcLayoutScalarValidRangeStart(..) => Yes, diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index 47b9bb95f830e..e01a5721a5e03 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -1691,7 +1691,10 @@ pub fn intrinsic_raw(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option CheckAttrVisitor<'tcx> { | AttributeKind::RustcHiddenTypeOfOpaques | AttributeKind::RustcIfThisChanged(..) | AttributeKind::RustcIntrinsic + | AttributeKind::RustcIntrinsicConstStableIndirect | AttributeKind::RustcLayout(..) | AttributeKind::RustcLayoutScalarValidRangeEnd(..) | AttributeKind::RustcLayoutScalarValidRangeStart(..) @@ -385,7 +386,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> { | sym::rustc_insignificant_dtor | sym::rustc_nonnull_optimization_guaranteed | sym::rustc_inherit_overflow_checks - | sym::rustc_intrinsic_const_stable_indirect | sym::rustc_trivial_field_reads | sym::rustc_on_unimplemented | sym::rustc_do_not_const_check From edd43c9e1f9fbca3e7f95447fbade7cb1bf11d7c Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 6 Feb 2026 21:16:48 +0100 Subject: [PATCH 7/8] Fix existing messages in the diag structs --- compiler/rustc_codegen_llvm/src/errors.rs | 2 +- compiler/rustc_codegen_ssa/src/errors.rs | 10 +++++----- compiler/rustc_const_eval/src/errors.rs | 4 ++-- compiler/rustc_driver_impl/src/session_diagnostics.rs | 2 +- compiler/rustc_hir_typeck/src/errors.rs | 2 +- compiler/rustc_incremental/src/errors.rs | 2 +- compiler/rustc_macros/src/diagnostics/message.rs | 1 + compiler/rustc_mir_build/src/errors.rs | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index 23fa05f3d02f3..20eba352bc41e 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -214,5 +214,5 @@ pub(crate) struct FixedX18InvalidArch<'a> { } #[derive(Diagnostic)] -#[diag("`-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later.")] +#[diag("`-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later")] pub(crate) struct SanitizerKcfiArityRequiresLLVM2100; diff --git a/compiler/rustc_codegen_ssa/src/errors.rs b/compiler/rustc_codegen_ssa/src/errors.rs index 742e05973ee58..82a6525adcc99 100644 --- a/compiler/rustc_codegen_ssa/src/errors.rs +++ b/compiler/rustc_codegen_ssa/src/errors.rs @@ -59,7 +59,7 @@ pub(crate) struct MissingQueryDepGraph { #[derive(Diagnostic)] #[diag( - "found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case)." + "found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case)" )] pub(crate) struct MalformedCguName { #[primary_span] @@ -562,12 +562,12 @@ pub(crate) struct SelfContainedLinkerMissing; #[derive(Diagnostic)] #[diag( - "please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option." + "please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option" )] pub(crate) struct CheckInstalledVisualStudio; #[derive(Diagnostic)] -#[diag("VS Code is a different product, and is not sufficient.")] +#[diag("VS Code is a different product, and is not sufficient")] pub(crate) struct InsufficientVSCodeProduct; #[derive(Diagnostic)] @@ -610,13 +610,13 @@ pub(crate) struct LinkerFileStem; #[derive(Diagnostic)] #[diag( - "link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms." + "link against the following native artifacts when linking against this static library. The order and any duplication can be significant on some platforms" )] pub(crate) struct StaticLibraryNativeArtifacts; #[derive(Diagnostic)] #[diag( - "native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms." + "native artifacts to link against have been written to {$path}. The order and any duplication can be significant on some platforms" )] pub(crate) struct StaticLibraryNativeArtifactsToFile<'a> { pub path: &'a Path, diff --git a/compiler/rustc_const_eval/src/errors.rs b/compiler/rustc_const_eval/src/errors.rs index 39f98b8449203..3b49dbd907c8f 100644 --- a/compiler/rustc_const_eval/src/errors.rs +++ b/compiler/rustc_const_eval/src/errors.rs @@ -309,7 +309,7 @@ pub(crate) struct UnallowedHeapAllocations { pub span: Span, pub kind: ConstContext, #[note( - "The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created." + "the runtime heap is not yet available at compile-time, so no runtime heap allocations can be created" )] pub teach: bool, } @@ -347,7 +347,7 @@ pub(crate) struct InteriorMutableBorrowEscaping { #[diag("constant evaluation is taking a long time")] #[note( "this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint." + If your compilation actually takes a long time, you can safely allow the lint" )] pub struct LongRunning { #[help("the constant being evaluated")] diff --git a/compiler/rustc_driver_impl/src/session_diagnostics.rs b/compiler/rustc_driver_impl/src/session_diagnostics.rs index 565c176645dee..97972185ebc4c 100644 --- a/compiler/rustc_driver_impl/src/session_diagnostics.rs +++ b/compiler/rustc_driver_impl/src/session_diagnostics.rs @@ -51,7 +51,7 @@ pub(crate) struct RlinkCorruptFile<'a> { } #[derive(Diagnostic)] -#[diag("the compiler unexpectedly panicked. this is a bug.")] +#[diag("the compiler unexpectedly panicked. This is a bug")] pub(crate) struct Ice; #[derive(Diagnostic)] diff --git a/compiler/rustc_hir_typeck/src/errors.rs b/compiler/rustc_hir_typeck/src/errors.rs index 0f330c3021c0f..a5de1014dd7a3 100644 --- a/compiler/rustc_hir_typeck/src/errors.rs +++ b/compiler/rustc_hir_typeck/src/errors.rs @@ -1145,7 +1145,7 @@ pub(crate) struct CastThinPointerToWidePointer<'tcx> { pub expr_ty: Ty<'tcx>, pub cast_ty: Ty<'tcx>, #[note( - "Thin pointers are \"simple\" pointers: they are purely a reference to a + "thin pointers are \"simple\" pointers: they are purely a reference to a memory address. Wide pointers are pointers referencing \"Dynamically Sized Types\" (also diff --git a/compiler/rustc_incremental/src/errors.rs b/compiler/rustc_incremental/src/errors.rs index 9b33b49d4406a..3354689d0ca33 100644 --- a/compiler/rustc_incremental/src/errors.rs +++ b/compiler/rustc_incremental/src/errors.rs @@ -281,7 +281,7 @@ pub(crate) struct DeleteWorkProduct<'a> { #[derive(Diagnostic)] #[diag( - "corrupt incremental compilation artifact found at `{$path}`. This file will automatically be ignored and deleted. If you see this message repeatedly or can provoke it without manually manipulating the compiler's artifacts, please file an issue. The incremental compilation system relies on hardlinks and filesystem locks behaving correctly, and may not deal well with OS crashes, so whatever information you can provide about your filesystem or other state may be very relevant." + "corrupt incremental compilation artifact found at `{$path}`. This file will automatically be ignored and deleted. If you see this message repeatedly or can provoke it without manually manipulating the compiler's artifacts, please file an issue. The incremental compilation system relies on hardlinks and filesystem locks behaving correctly, and may not deal well with OS crashes, so whatever information you can provide about your filesystem or other state may be very relevant" )] pub(crate) struct CorruptFile<'a> { pub path: &'a Path, diff --git a/compiler/rustc_macros/src/diagnostics/message.rs b/compiler/rustc_macros/src/diagnostics/message.rs index 16ee3c657611d..948cc9e93064b 100644 --- a/compiler/rustc_macros/src/diagnostics/message.rs +++ b/compiler/rustc_macros/src/diagnostics/message.rs @@ -153,6 +153,7 @@ const ALLOWED_CAPITALIZED_WORDS: &[&str] = &[ "Ferris", "GCC", "MIR", + "NaNs", "OK", "VS", // tidy-alphabetical-end diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index f51e130ea47a5..13d8211999e66 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -849,7 +849,7 @@ pub(crate) struct LowerRangeBoundMustBeLessThanOrEqualToUpper { #[label("lower bound larger than upper bound")] pub(crate) span: Span, #[note( - "When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range." + "when matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range" )] pub(crate) teach: bool, } From c1091da34c052b2260c7d4d5e0d4c6a63a34a0b8 Mon Sep 17 00:00:00 2001 From: Jonathan Brouwer Date: Fri, 6 Feb 2026 21:16:53 +0100 Subject: [PATCH 8/8] Fix existing messages in stderrs --- tests/rustdoc-ui/ice-bug-report-url.stderr | 2 +- .../field-access-after-const-eval-fail-in-ty.stderr | 2 +- tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr | 2 +- tests/ui/consts/const-eval/infinite_loop.no_ice.stderr | 2 +- tests/ui/consts/const-eval/issue-52475.stderr | 2 +- tests/ui/consts/const-eval/issue-70723.stderr | 2 +- tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr | 2 +- .../consts/const-eval/stable-metric/ctfe-labelled-loop.stderr | 2 +- .../ui/consts/const-eval/stable-metric/ctfe-recursion.stderr | 2 +- .../const-eval/stable-metric/ctfe-simple-loop.warn.stderr | 4 ++-- .../do-not-ice-long-constant-evaluation-in-for-loop.stderr | 2 +- tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr | 2 +- tests/ui/consts/timeout.stderr | 2 +- tests/ui/error-codes/E0010-teach.stderr | 2 +- tests/ui/error-codes/E0030-teach.stderr | 2 +- .../ui/explicit-tail-calls/infinite-recursion-in-ctfe.stderr | 2 +- tests/ui/layout/valid_range_oob.stderr | 2 +- tests/ui/mir/lint/storage-live.stderr | 2 +- tests/ui/panics/default-backtrace-ice.stderr | 2 +- tests/ui/privacy/no-ice-on-inference-failure.stderr | 2 +- tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs | 2 +- tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr | 2 +- tests/ui/treat-err-as-bug/err.stderr | 2 +- tests/ui/treat-err-as-bug/span_delayed_bug.stderr | 2 +- 24 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/rustdoc-ui/ice-bug-report-url.stderr b/tests/rustdoc-ui/ice-bug-report-url.stderr index b6eb8a1792df6..bc46b226a703e 100644 --- a/tests/rustdoc-ui/ice-bug-report-url.stderr +++ b/tests/rustdoc-ui/ice-bug-report-url.stderr @@ -9,7 +9,7 @@ LL | fn wrong() aborting due to `-Z treat-err-as-bug=1` stack backtrace: -error: the compiler unexpectedly panicked. this is a bug. +error: the compiler unexpectedly panicked. This is a bug note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-rustdoc&template=ice.md diff --git a/tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.stderr b/tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.stderr index 9d62bbc2187f7..735409b77953b 100644 --- a/tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.stderr +++ b/tests/ui/consts/const-eval/field-access-after-const-eval-fail-in-ty.stderr @@ -5,7 +5,7 @@ LL | [(); loop {}].field; | ^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/field-access-after-const-eval-fail-in-ty.rs:4:10 | diff --git a/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr b/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr index f326da8e26af5..a11915d47861b 100644 --- a/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr +++ b/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr @@ -8,7 +8,7 @@ LL | | } | |_________^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/infinite_loop.rs:13:18 | diff --git a/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr b/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr index f326da8e26af5..a11915d47861b 100644 --- a/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr +++ b/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr @@ -8,7 +8,7 @@ LL | | } | |_________^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/infinite_loop.rs:13:18 | diff --git a/tests/ui/consts/const-eval/issue-52475.stderr b/tests/ui/consts/const-eval/issue-52475.stderr index daaee03787f4d..5ba0f8732d806 100644 --- a/tests/ui/consts/const-eval/issue-52475.stderr +++ b/tests/ui/consts/const-eval/issue-52475.stderr @@ -9,7 +9,7 @@ LL | | } | |_________^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/issue-52475.rs:2:18 | diff --git a/tests/ui/consts/const-eval/issue-70723.stderr b/tests/ui/consts/const-eval/issue-70723.stderr index 7cece4ed5d6c4..50faa3353e91a 100644 --- a/tests/ui/consts/const-eval/issue-70723.stderr +++ b/tests/ui/consts/const-eval/issue-70723.stderr @@ -5,7 +5,7 @@ LL | static _X: () = loop {}; | ^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/issue-70723.rs:1:1 | diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr index f087c9960c28f..47e26c3ed9356 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr @@ -5,7 +5,7 @@ LL | foo(); | ^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/ctfe-fn-call.rs:32:1 | diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr index ecb48fc62a3d8..95e2803980502 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr @@ -11,7 +11,7 @@ LL | | } | |_____^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/ctfe-labelled-loop.rs:16:1 | diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr index a05d792c95ca8..25928b766bda6 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr @@ -5,7 +5,7 @@ LL | recurse(n - 1) | ^^^^^^^^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/ctfe-recursion.rs:13:1 | diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr index 2bb9a8a98ec4d..44abf8be6bdfa 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr @@ -7,7 +7,7 @@ LL | | } | |_____^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/ctfe-simple-loop.rs:19:1 | @@ -28,7 +28,7 @@ LL | | } | |_____^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/ctfe-simple-loop.rs:20:1 | diff --git a/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr b/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr index 32a18469ab9e5..c28f37bc16705 100644 --- a/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr +++ b/tests/ui/consts/do-not-ice-long-constant-evaluation-in-for-loop.stderr @@ -5,7 +5,7 @@ LL | [(); loop {}]; | ^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:10:14 | diff --git a/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr b/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr index 02b8904fbdedd..ebf659814e737 100644 --- a/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr +++ b/tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr @@ -5,7 +5,7 @@ LL | let array = [(); { loop {} }]; | ^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/do-not-ice-on-field-access-of-err-type.rs:5:22 | diff --git a/tests/ui/consts/timeout.stderr b/tests/ui/consts/timeout.stderr index 6afb317c3affa..e96e5875058a8 100644 --- a/tests/ui/consts/timeout.stderr +++ b/tests/ui/consts/timeout.stderr @@ -7,7 +7,7 @@ error: constant evaluation is taking a long time = note: in this macro invocation | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/timeout.rs:7:1 | diff --git a/tests/ui/error-codes/E0010-teach.stderr b/tests/ui/error-codes/E0010-teach.stderr index 9318e8df7e25c..b035cf343e956 100644 --- a/tests/ui/error-codes/E0010-teach.stderr +++ b/tests/ui/error-codes/E0010-teach.stderr @@ -4,7 +4,7 @@ error[E0010]: allocations are not allowed in constants LL | const CON: Vec = vec![1, 2, 3]; | ^^^^^^^^^^^^^ allocation not allowed in constants | - = note: The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created. + = note: the runtime heap is not yet available at compile-time, so no runtime heap allocations can be created error[E0015]: cannot call non-const method `slice::::into_vec::` in constants --> $DIR/E0010-teach.rs:5:23 diff --git a/tests/ui/error-codes/E0030-teach.stderr b/tests/ui/error-codes/E0030-teach.stderr index 50c7d1eee1f4e..81c9236b00376 100644 --- a/tests/ui/error-codes/E0030-teach.stderr +++ b/tests/ui/error-codes/E0030-teach.stderr @@ -4,7 +4,7 @@ error[E0030]: lower bound for range pattern must be less than or equal to upper LL | 1000 ..= 5 => {} | ^^^^^^^^^^ lower bound larger than upper bound | - = note: When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range. + = note: when matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range error: aborting due to 1 previous error diff --git a/tests/ui/explicit-tail-calls/infinite-recursion-in-ctfe.stderr b/tests/ui/explicit-tail-calls/infinite-recursion-in-ctfe.stderr index b5a96114a5837..7bc6281c4674f 100644 --- a/tests/ui/explicit-tail-calls/infinite-recursion-in-ctfe.stderr +++ b/tests/ui/explicit-tail-calls/infinite-recursion-in-ctfe.stderr @@ -5,7 +5,7 @@ LL | become f(); | ^^^^^^^^^^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/infinite-recursion-in-ctfe.rs:4:1 | diff --git a/tests/ui/layout/valid_range_oob.stderr b/tests/ui/layout/valid_range_oob.stderr index 1a0c384125038..fc6ebcf1692fe 100644 --- a/tests/ui/layout/valid_range_oob.stderr +++ b/tests/ui/layout/valid_range_oob.stderr @@ -1,6 +1,6 @@ 257 > 255 -error: the compiler unexpectedly panicked. this is a bug. +error: the compiler unexpectedly panicked. This is a bug query stack during panic: #0 [layout_of] computing layout of `Foo` diff --git a/tests/ui/mir/lint/storage-live.stderr b/tests/ui/mir/lint/storage-live.stderr index ef0d253b15a8c..c8d07314f0758 100644 --- a/tests/ui/mir/lint/storage-live.stderr +++ b/tests/ui/mir/lint/storage-live.stderr @@ -13,7 +13,7 @@ LL | StorageLive(a); aborting due to `-Z treat-err-as-bug=1` -error: the compiler unexpectedly panicked. this is a bug. +error: the compiler unexpectedly panicked. This is a bug query stack during panic: end of query stack diff --git a/tests/ui/panics/default-backtrace-ice.stderr b/tests/ui/panics/default-backtrace-ice.stderr index a7d99e325d9b9..4e48e769d9d51 100644 --- a/tests/ui/panics/default-backtrace-ice.stderr +++ b/tests/ui/panics/default-backtrace-ice.stderr @@ -13,7 +13,7 @@ stack backtrace: (end_short_backtrace) (begin_short_backtrace) -error: the compiler unexpectedly panicked. this is a bug. +error: the compiler unexpectedly panicked. This is a bug diff --git a/tests/ui/privacy/no-ice-on-inference-failure.stderr b/tests/ui/privacy/no-ice-on-inference-failure.stderr index 67476e6e21899..91b99c2890b87 100644 --- a/tests/ui/privacy/no-ice-on-inference-failure.stderr +++ b/tests/ui/privacy/no-ice-on-inference-failure.stderr @@ -8,7 +8,7 @@ LL | | } | |_________^ | = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval. - If your compilation actually takes a long time, you can safely allow the lint. + If your compilation actually takes a long time, you can safely allow the lint help: the constant being evaluated --> $DIR/no-ice-on-inference-failure.rs:2:22 | diff --git a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs index 8a724b853e13a..c3046708e4eba 100644 --- a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs +++ b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.rs @@ -5,7 +5,7 @@ //@ build-fail //@ max-llvm-major-version: 20 -//~? ERROR `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later. +//~? ERROR `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later #![feature(no_core)] #![no_core] #![no_main] diff --git a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr index ac6bd7411fd81..c5f886e3a3907 100644 --- a/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr +++ b/tests/ui/sanitizer/kcfi-arity-requires-llvm-21-0-0.stderr @@ -1,4 +1,4 @@ -error: `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later. +error: `-Zsanitizer-kcfi-arity` requires LLVM 21.0.0 or later error: aborting due to 1 previous error diff --git a/tests/ui/treat-err-as-bug/err.stderr b/tests/ui/treat-err-as-bug/err.stderr index 2a9935c5d22bd..8ff267deacef5 100644 --- a/tests/ui/treat-err-as-bug/err.stderr +++ b/tests/ui/treat-err-as-bug/err.stderr @@ -5,7 +5,7 @@ LL | pub static C: u32 = 0 - 1; | ^^^^^ evaluation of `C` failed here -error: the compiler unexpectedly panicked. this is a bug. +error: the compiler unexpectedly panicked. This is a bug query stack during panic: #0 [eval_static_initializer] evaluating initializer of static `C` diff --git a/tests/ui/treat-err-as-bug/span_delayed_bug.stderr b/tests/ui/treat-err-as-bug/span_delayed_bug.stderr index 88983e95cee77..ae1bad55960ee 100644 --- a/tests/ui/treat-err-as-bug/span_delayed_bug.stderr +++ b/tests/ui/treat-err-as-bug/span_delayed_bug.stderr @@ -5,7 +5,7 @@ LL | fn main() {} | ^^^^^^^^^ -error: the compiler unexpectedly panicked. this is a bug. +error: the compiler unexpectedly panicked. This is a bug query stack during panic: #0 [trigger_delayed_bug] triggering a delayed bug for testing incremental