MaybeDangling {
/// Wraps a value in a `MaybeDangling`, allowing it to dangle.
+ #[rustc_no_writable]
pub const fn new(x: P) -> Self
where
P: Sized,
diff --git a/library/core/src/mem/mod.rs b/library/core/src/mem/mod.rs
index e24b220acb43b..2317999d2f888 100644
--- a/library/core/src/mem/mod.rs
+++ b/library/core/src/mem/mod.rs
@@ -187,6 +187,7 @@ pub mod type_info;
#[rustc_const_stable(feature = "const_forget", since = "1.46.0")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "mem_forget"]
+#[rustc_no_writable]
pub const fn forget(t: T) {
let _ = ManuallyDrop::new(t);
}
@@ -1204,6 +1205,7 @@ pub const unsafe fn transmute_copy(src: &Src) -> Dst {
/// let _: std::mem::MaybeUninit = unsafe { transmute_prefix(123_u8) };
/// ```
#[unstable(feature = "transmute_prefix", issue = "155079")]
+#[rustc_no_writable]
pub const unsafe fn transmute_prefix(src: Src) -> Dst {
#[repr(C)]
union Transmute {
@@ -1253,6 +1255,7 @@ pub const unsafe fn transmute_prefix(src: Src) -> Dst {
#[unstable(feature = "transmute_neo", issue = "155079")]
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
#[inline]
+#[rustc_no_writable]
pub const unsafe fn transmute_neo(src: Src) -> Dst {
const { assert!(Src::SIZE == Dst::SIZE) };
diff --git a/library/core/src/pin.rs b/library/core/src/pin.rs
index 40f774806046a..b766a767df64d 100644
--- a/library/core/src/pin.rs
+++ b/library/core/src/pin.rs
@@ -2025,6 +2025,7 @@ unsafe impl PinCoerceUnsized for Pin {}
#[rustc_diagnostic_item = "pin_macro"]
// `super` gets removed by rustfmt
#[rustfmt::skip]
+#[diagnostic::opaque]
pub macro pin($value:expr $(,)?) {
'p: {
super let mut pinned = $value;
diff --git a/library/std/src/macros.rs b/library/std/src/macros.rs
index 829945d08e2a9..ea574fc4146e7 100644
--- a/library/std/src/macros.rs
+++ b/library/std/src/macros.rs
@@ -82,6 +82,7 @@ macro_rules! panic {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "print_macro")]
#[allow_internal_unstable(print_internals)]
+#[rustc_diagnostic_opaque]
macro_rules! print {
($($arg:tt)*) => {{
$crate::io::_print($crate::format_args!($($arg)*));
@@ -138,6 +139,7 @@ macro_rules! print {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "println_macro")]
#[allow_internal_unstable(print_internals, format_args_nl)]
+#[rustc_diagnostic_opaque]
macro_rules! println {
() => {
$crate::print!("\n")
@@ -352,6 +354,7 @@ macro_rules! eprintln {
#[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "dbg_macro")]
#[stable(feature = "dbg_macro", since = "1.32.0")]
+#[rustc_diagnostic_opaque]
macro_rules! dbg {
// NOTE: We cannot use `concat!` to make a static string as a format argument
// of `eprintln!` because `file!` could contain a `{` or
diff --git a/library/std/src/thread/functions.rs b/library/std/src/thread/functions.rs
index 70642108e1e01..21e7a2b2ed087 100644
--- a/library/std/src/thread/functions.rs
+++ b/library/std/src/thread/functions.rs
@@ -640,10 +640,13 @@ pub fn park_timeout(dur: Duration) {
///
/// On Windows:
/// - It may undercount the amount of parallelism available on systems with more
-/// than 64 logical CPUs. However, programs typically need specific support to
-/// take advantage of more than 64 logical CPUs, and in the absence of such
-/// support, the number returned by this function accurately reflects the
-/// number of logical CPUs the program can use by default.
+/// than 64 logical CPUs, because it reports only the logical CPUs in one
+/// processor group. Before Windows 11 and Windows Server 2022, a process was by
+/// default confined to a single processor group, so this count reflected the CPUs
+/// it could use without explicitly opting into other groups. Starting with Windows
+/// 11 and Windows Server 2022, a process and its threads have affinities that by
+/// default span all processor groups, so on systems with more than 64 logical CPUs
+/// this may report fewer CPUs than are available to the program.
/// - It may overcount the amount of parallelism available on systems limited by
/// process-wide affinity masks, or job object limitations.
///
diff --git a/library/std/src/thread/local.rs b/library/std/src/thread/local.rs
index 321fc4440f330..118d9e07cd4eb 100644
--- a/library/std/src/thread/local.rs
+++ b/library/std/src/thread/local.rs
@@ -346,6 +346,7 @@ pub macro thread_local_process_attrs {
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "thread_local_macro")]
#[allow_internal_unstable(thread_local_internals)]
+#[rustc_diagnostic_opaque]
macro_rules! thread_local {
() => {};
diff --git a/library/std_detect/src/detect/arch/x86.rs b/library/std_detect/src/detect/arch/x86.rs
index ede4a80c088ed..e054546afcb19 100644
--- a/library/std_detect/src/detect/arch/x86.rs
+++ b/library/std_detect/src/detect/arch/x86.rs
@@ -91,7 +91,6 @@ features! {
/// * `"amx-avx512"`
/// * `"amx-fp8"`
/// * `"amx-movrs"`
- /// * `"amx-tf32"`
/// * `"f16c"`
/// * `"fma"`
/// * `"bmi1"`
@@ -228,8 +227,6 @@ features! {
/// AMX-FP8 (Float8 Operations)
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_movrs: "amx-movrs";
/// AMX-MOVRS (Matrix MOVERS operations)
- @FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_tf32: "amx-tf32";
- /// AMX-TF32 (TensorFloat32 Operations)
@FEATURE: #[unstable(feature = "apx_target_feature", issue = "139284")] apxf: "apxf";
/// APX-F (Advanced Performance Extensions - Foundation)
@FEATURE: #[unstable(feature = "avx10_target_feature", issue = "138843")] avx10_1: "avx10.1";
diff --git a/library/std_detect/src/detect/os/x86.rs b/library/std_detect/src/detect/os/x86.rs
index 2b75cd6257087..4e739fb38d56e 100644
--- a/library/std_detect/src/detect/os/x86.rs
+++ b/library/std_detect/src/detect/os/x86.rs
@@ -216,7 +216,6 @@ pub(crate) fn detect_features() -> cache::Initializer {
__cpuid_count(0x1e_u32, 1);
enable(amx_feature_flags_eax, 4, Feature::amx_fp8);
- enable(amx_feature_flags_eax, 6, Feature::amx_tf32);
enable(amx_feature_flags_eax, 7, Feature::amx_avx512);
enable(amx_feature_flags_eax, 8, Feature::amx_movrs);
}
diff --git a/library/std_detect/tests/x86-specific.rs b/library/std_detect/tests/x86-specific.rs
index 4b02f78b7944e..117182558f46a 100644
--- a/library/std_detect/tests/x86-specific.rs
+++ b/library/std_detect/tests/x86-specific.rs
@@ -83,7 +83,6 @@ fn dump() {
println!("widekl: {:?}", is_x86_feature_detected!("widekl"));
println!("movrs: {:?}", is_x86_feature_detected!("movrs"));
println!("amx-fp8: {:?}", is_x86_feature_detected!("amx-fp8"));
- println!("amx-tf32: {:?}", is_x86_feature_detected!("amx-tf32"));
println!("amx-avx512: {:?}", is_x86_feature_detected!("amx-avx512"));
println!("amx-movrs: {:?}", is_x86_feature_detected!("amx-movrs"));
}
diff --git a/src/librustdoc/clean/auto_trait.rs b/src/librustdoc/clean/auto_trait.rs
index f90cae4fb7e72..31ff38b78e70f 100644
--- a/src/librustdoc/clean/auto_trait.rs
+++ b/src/librustdoc/clean/auto_trait.rs
@@ -172,34 +172,36 @@ fn clean_param_env<'tcx>(
// FIXME(#111101): Incorporate the explicit predicates of the item here...
let item_clauses: FxIndexSet<_> = tcx.param_env(item_def_id).caller_bounds().iter().collect();
- let where_predicates = param_env
- .caller_bounds()
- .iter()
- // FIXME: ...which hopefully allows us to simplify this:
- .filter(|clause| {
- !item_clauses.contains(clause)
- || clause
- .as_trait_clause()
- .is_some_and(|clause| tcx.lang_items().sized_trait() == Some(clause.def_id()))
- })
- .map(|clause| {
- fold_regions(tcx, clause, |r, _| match r.kind() {
- // FIXME: Don't `unwrap_or`, I think we should panic if we encounter an infer var that
- // we can't map to a concrete region. However, `AutoTraitFinder` *does* leak those kinds
- // of `ReVar`s for some reason at the time of writing. See `rustdoc-ui/` tests.
- // This is in dire need of an investigation into `AutoTraitFinder`.
- ty::ReVar(vid) => vid_to_region.get(&vid).copied().unwrap_or(r),
- ty::ReEarlyParam(_) | ty::ReStatic | ty::ReBound(..) | ty::ReError(_) => r,
- // FIXME(#120606): `AutoTraitFinder` can actually leak placeholder regions which feels
- // incorrect. Needs investigation.
- ty::ReLateParam(_) | ty::RePlaceholder(_) | ty::ReErased => {
- bug!("unexpected region kind: {r:?}")
- }
+ let where_predicates = cx.with_exact_param_env(param_env, |cx| {
+ param_env
+ .caller_bounds()
+ .iter()
+ // FIXME: ...which hopefully allows us to simplify this:
+ .filter(|clause| {
+ !item_clauses.contains(clause)
+ || clause.as_trait_clause().is_some_and(|clause| {
+ tcx.lang_items().sized_trait() == Some(clause.def_id())
+ })
})
- })
- .flat_map(|clause| clean_predicate(clause, cx))
- .chain(clean_region_outlives_constraints(®ion_data, generics))
- .collect();
+ .map(|clause| {
+ fold_regions(tcx, clause, |r, _| match r.kind() {
+ // FIXME: Don't `unwrap_or`, I think we should panic if we encounter an infer var that
+ // we can't map to a concrete region. However, `AutoTraitFinder` *does* leak those kinds
+ // of `ReVar`s for some reason at the time of writing. See `rustdoc-ui/` tests.
+ // This is in dire need of an investigation into `AutoTraitFinder`.
+ ty::ReVar(vid) => vid_to_region.get(&vid).copied().unwrap_or(r),
+ ty::ReEarlyParam(_) | ty::ReStatic | ty::ReBound(..) | ty::ReError(_) => r,
+ // FIXME(#120606): `AutoTraitFinder` can actually leak placeholder regions which feels
+ // incorrect. Needs investigation.
+ ty::ReLateParam(_) | ty::RePlaceholder(_) | ty::ReErased => {
+ bug!("unexpected region kind: {r:?}")
+ }
+ })
+ })
+ .flat_map(|clause| clean_predicate(clause, cx))
+ .chain(clean_region_outlives_constraints(®ion_data, generics))
+ .collect()
+ });
let mut generics = clean::Generics { params, where_predicates };
simplify::sizedness_bounds(cx, &mut generics);
diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs
index 5bdedf7ae3d54..c1ae5f977cb89 100644
--- a/src/librustdoc/core.rs
+++ b/src/librustdoc/core.rs
@@ -87,7 +87,15 @@ impl<'tcx> DocContext<'tcx> {
def_id: DefId,
f: F,
) -> T {
- let old_param_env = mem::replace(&mut self.param_env, self.tcx.param_env(def_id));
+ self.with_exact_param_env(self.tcx.param_env(def_id), f)
+ }
+
+ pub(crate) fn with_exact_param_env T>(
+ &mut self,
+ param_env: ParamEnv<'tcx>,
+ f: F,
+ ) -> T {
+ let old_param_env = mem::replace(&mut self.param_env, param_env);
let ret = f(self);
self.param_env = old_param_env;
ret
diff --git a/src/tools/miri/tests/pass/tree_borrows/mem_forget-implicit_writes.rs b/src/tools/miri/tests/pass/tree_borrows/mem_forget-implicit_writes.rs
new file mode 100644
index 0000000000000..77cf6997761bb
--- /dev/null
+++ b/src/tools/miri/tests/pass/tree_borrows/mem_forget-implicit_writes.rs
@@ -0,0 +1,20 @@
+// Regression test. This failed before applying `#[rustc_no_writable]` to `mem::forget`, `ManuallyDrop::new`, and `MaybeDangling::new`.
+//@compile-flags: -Zmiri-tree-borrows -Zmiri-tree-borrows-implicit-writes
+
+use std::mem;
+
+// This function is taken from the crate `derive_more`, from the file `into.rs`
+unsafe fn transmute(from: From) -> To {
+ let to = unsafe { mem::transmute_copy(&from) };
+ mem::forget(from);
+ to
+}
+
+fn main() {
+ let mut val = 10u32;
+ let r: &mut u32 = &mut val;
+
+ let to: &mut i32 = unsafe { transmute(r) };
+
+ assert_eq!(*to, 10);
+}
diff --git a/tests/rustdoc-html/synthetic_auto/issue-159065.rs b/tests/rustdoc-html/synthetic_auto/issue-159065.rs
new file mode 100644
index 0000000000000..ff809c732cc35
--- /dev/null
+++ b/tests/rustdoc-html/synthetic_auto/issue-159065.rs
@@ -0,0 +1,6 @@
+//@ compile-flags: -Znext-solver=globally -Znormalize-docs
+
+#![crate_name = "foo"]
+
+#[doc(inline)]
+pub use std as other;
diff --git a/tests/ui/async-await/async-closures/higher-ranked-return.stderr b/tests/ui/async-await/async-closures/higher-ranked-return.stderr
index 23ce3df661654..efd5698e9731f 100644
--- a/tests/ui/async-await/async-closures/higher-ranked-return.stderr
+++ b/tests/ui/async-await/async-closures/higher-ranked-return.stderr
@@ -2,9 +2,9 @@ error: lifetime may not live long enough
--> $DIR/higher-ranked-return.rs:11:46
|
LL | let x = async move |x: &str| -> &str {
- | ________________________________-________----_^
+ | ________________________________-________-____^
| | | |
- | | | return type of async closure `{async closure body@$DIR/higher-ranked-return.rs:11:46: 13:10}` contains a lifetime `'2`
+ | | | let's call the lifetime of this reference `'2`
| | let's call the lifetime of this reference `'1`
LL | | x
LL | | };
diff --git a/tests/ui/async-await/async-closures/not-lending.stderr b/tests/ui/async-await/async-closures/not-lending.stderr
index fb941502d3646..989b9ccb88a76 100644
--- a/tests/ui/async-await/async-closures/not-lending.stderr
+++ b/tests/ui/async-await/async-closures/not-lending.stderr
@@ -4,7 +4,7 @@ error: lifetime may not live long enough
LL | let x = async move || -> &String { &s };
| ------------------------ ^^^^^^ returning this value requires that `'1` must outlive `'2`
| | |
- | | return type of async closure `{async closure body@$DIR/not-lending.rs:12:42: 12:48}` contains a lifetime `'2`
+ | | let's call the lifetime of this reference `'2`
| lifetime `'1` represents this closure's body
|
= note: closure implements `AsyncFn`, so references to captured variables can't escape the closure
@@ -15,7 +15,7 @@ error: lifetime may not live long enough
LL | let x = async move || { &s };
| ------------- ^^^^^^ returning this value requires that `'1` must outlive `'2`
| | |
- | | return type of async closure `{async closure body@$DIR/not-lending.rs:16:31: 16:37}` contains a lifetime `'2`
+ | | return type of async closure is &'2 String
| lifetime `'1` represents this closure's body
|
= note: closure implements `AsyncFn`, so references to captured variables can't escape the closure
diff --git a/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr b/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr
index c479adfa56d7e..3cf2d20f155fd 100644
--- a/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr
+++ b/tests/ui/async-await/issue-74072-lifetime-name-annotations.stderr
@@ -29,7 +29,7 @@ error: lifetime may not live long enough
LL | (async move || {
| ______-------------_^
| | | |
- | | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:13:20: 19:6}` contains a lifetime `'2`
+ | | | return type of async closure is &'2 i32
| | lifetime `'1` represents this closure's body
LL | |
LL | |
@@ -78,7 +78,7 @@ error: lifetime may not live long enough
LL | (async move || -> &i32 {
| ______---------------------_^
| | | |
- | | | return type of async closure `{async closure body@$DIR/issue-74072-lifetime-name-annotations.rs:23:28: 29:6}` contains a lifetime `'2`
+ | | | let's call the lifetime of this reference `'2`
| | lifetime `'1` represents this closure's body
LL | |
LL | |
diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr
index 98ba1de498bbe..eca0813e6a286 100644
--- a/tests/ui/check-cfg/target_feature.stderr
+++ b/tests/ui/check-cfg/target_feature.stderr
@@ -28,7 +28,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`amx-fp8`
`amx-int8`
`amx-movrs`
-`amx-tf32`
`amx-tile`
`apxf`
`atomics`
diff --git a/tests/ui/delegation/eager-format-glob-delegation-ice-159233.rs b/tests/ui/delegation/eager-format-glob-delegation-ice-159233.rs
new file mode 100644
index 0000000000000..3c909b18dea5c
--- /dev/null
+++ b/tests/ui/delegation/eager-format-glob-delegation-ice-159233.rs
@@ -0,0 +1,10 @@
+//@ edition: 2024
+
+#![feature(fn_delegation)]
+
+static REGEX: () = format!(|| { reuse impl Trait for S; });
+//~^ ERROR format argument must be a string literal
+//~| ERROR cannot find type `Trait` in this scope
+//~| ERROR mismatched types
+
+fn main() {}
diff --git a/tests/ui/delegation/eager-format-glob-delegation-ice-159233.stderr b/tests/ui/delegation/eager-format-glob-delegation-ice-159233.stderr
new file mode 100644
index 0000000000000..0b644cbc7f879
--- /dev/null
+++ b/tests/ui/delegation/eager-format-glob-delegation-ice-159233.stderr
@@ -0,0 +1,27 @@
+error: format argument must be a string literal
+ --> $DIR/eager-format-glob-delegation-ice-159233.rs:5:28
+ |
+LL | static REGEX: () = format!(|| { reuse impl Trait for S; });
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+help: you might be missing a string literal to format with
+ |
+LL | static REGEX: () = format!("{}", || { reuse impl Trait for S; });
+ | +++++
+
+error[E0433]: cannot find type `Trait` in this scope
+ --> $DIR/eager-format-glob-delegation-ice-159233.rs:5:44
+ |
+LL | static REGEX: () = format!(|| { reuse impl Trait for S; });
+ | ^^^^^ use of undeclared type `Trait`
+
+error[E0308]: mismatched types
+ --> $DIR/eager-format-glob-delegation-ice-159233.rs:5:20
+ |
+LL | static REGEX: () = format!(|| { reuse impl Trait for S; });
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `String`
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0308, E0433.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/diagnostic_namespace/opaque/auxiliary/wrap.rs b/tests/ui/diagnostic_namespace/opaque/auxiliary/wrap.rs
new file mode 100644
index 0000000000000..f046e82b8f9e7
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/auxiliary/wrap.rs
@@ -0,0 +1,9 @@
+#![feature(diagnostic_opaque)]
+
+#[diagnostic::opaque]
+#[macro_export]
+macro_rules! wrap {
+ ($x:ident) => {{
+ let x = blah::$x;
+ }};
+}
diff --git a/tests/ui/diagnostic_namespace/opaque/duplicate.rs b/tests/ui/diagnostic_namespace/opaque/duplicate.rs
new file mode 100644
index 0000000000000..2341e72ddc5e3
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/duplicate.rs
@@ -0,0 +1,9 @@
+#![crate_type = "lib"]
+#![feature(diagnostic_opaque)]
+#![deny(unused_attributes)]
+#[diagnostic::opaque]
+#[diagnostic::opaque]
+//~^ERROR unused attribute
+macro_rules! m {
+ () => {}
+}
diff --git a/tests/ui/diagnostic_namespace/opaque/duplicate.stderr b/tests/ui/diagnostic_namespace/opaque/duplicate.stderr
new file mode 100644
index 0000000000000..d4420d3b63a9f
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/duplicate.stderr
@@ -0,0 +1,19 @@
+error: unused attribute
+ --> $DIR/duplicate.rs:5:1
+ |
+LL | #[diagnostic::opaque]
+ | ^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute
+ |
+note: attribute also specified here
+ --> $DIR/duplicate.rs:4:1
+ |
+LL | #[diagnostic::opaque]
+ | ^^^^^^^^^^^^^^^^^^^^^
+note: the lint level is defined here
+ --> $DIR/duplicate.rs:3:9
+ |
+LL | #![deny(unused_attributes)]
+ | ^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/diagnostic_namespace/opaque/highlight_maccall.-Zmacro-backtrace.stderr b/tests/ui/diagnostic_namespace/opaque/highlight_maccall.-Zmacro-backtrace.stderr
new file mode 100644
index 0000000000000..d53e5cb526061
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/highlight_maccall.-Zmacro-backtrace.stderr
@@ -0,0 +1,16 @@
+error: oh no
+ --> $DIR/highlight_maccall.rs:9:9
+ |
+LL | / macro_rules! my_error {
+LL | | () => {{
+LL | | compile_error!("oh no")
+ | | ^^^^^^^^^^^^^^^^^^^^^^^
+... |
+LL | | }
+ | |_- in this expansion of `my_error!`
+...
+LL | my_error!();
+ | ----------- in this macro invocation
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/diagnostic_namespace/opaque/highlight_maccall.default.stderr b/tests/ui/diagnostic_namespace/opaque/highlight_maccall.default.stderr
new file mode 100644
index 0000000000000..07521e003e3e2
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/highlight_maccall.default.stderr
@@ -0,0 +1,8 @@
+error: oh no
+ --> $DIR/highlight_maccall.rs:16:5
+ |
+LL | my_error!();
+ | ^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/diagnostic_namespace/opaque/highlight_maccall.rs b/tests/ui/diagnostic_namespace/opaque/highlight_maccall.rs
new file mode 100644
index 0000000000000..f8095838b2368
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/highlight_maccall.rs
@@ -0,0 +1,17 @@
+//@revisions: default -Zmacro-backtrace
+//@[-Zmacro-backtrace] compile-flags: -Z macro-backtrace
+
+#![feature(diagnostic_opaque)]
+
+#[diagnostic::opaque]
+macro_rules! my_error {
+ () => {{
+ compile_error!("oh no")
+ //~^ ERROR oh no
+ }}
+}
+
+
+fn main() {
+ my_error!();
+}
diff --git a/tests/ui/diagnostic_namespace/opaque/only_point_at_input.-Zmacro-backtrace.stderr b/tests/ui/diagnostic_namespace/opaque/only_point_at_input.-Zmacro-backtrace.stderr
new file mode 100644
index 0000000000000..47ed10e2bcfdc
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/only_point_at_input.-Zmacro-backtrace.stderr
@@ -0,0 +1,18 @@
+error[E0425]: cannot find value `x` in module `blah`
+ --> $DIR/only_point_at_input.rs:17:17
+ |
+LL | wrap::wrap!(x);
+ | ^ not found in `blah`
+
+error[E0425]: cannot find value `x` in module `blah`
+ --> $DIR/only_point_at_input.rs:20:17
+ |
+LL | let x = blah::$x;
+ | -- due to this macro variable
+...
+LL | local_wrap!(x);
+ | ^ not found in `blah`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/diagnostic_namespace/opaque/only_point_at_input.default.stderr b/tests/ui/diagnostic_namespace/opaque/only_point_at_input.default.stderr
new file mode 100644
index 0000000000000..366e1c3aead24
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/only_point_at_input.default.stderr
@@ -0,0 +1,15 @@
+error[E0425]: cannot find value `x` in module `blah`
+ --> $DIR/only_point_at_input.rs:17:17
+ |
+LL | wrap::wrap!(x);
+ | ^ not found in `blah`
+
+error[E0425]: cannot find value `x` in module `blah`
+ --> $DIR/only_point_at_input.rs:20:17
+ |
+LL | local_wrap!(x);
+ | ^ not found in `blah`
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0425`.
diff --git a/tests/ui/diagnostic_namespace/opaque/only_point_at_input.rs b/tests/ui/diagnostic_namespace/opaque/only_point_at_input.rs
new file mode 100644
index 0000000000000..003b6dbacf6c0
--- /dev/null
+++ b/tests/ui/diagnostic_namespace/opaque/only_point_at_input.rs
@@ -0,0 +1,23 @@
+//@revisions: default -Zmacro-backtrace
+//@[-Zmacro-backtrace] compile-flags: -Z macro-backtrace
+//@ aux-crate:wrap=wrap.rs
+#![feature(diagnostic_opaque)]
+
+mod blah {}
+
+#[diagnostic::opaque]
+macro_rules! local_wrap {
+ ($x:ident) => {{
+ let x = blah::$x;
+ }};
+}
+
+
+fn main() {
+ wrap::wrap!(x);
+ //~^ ERROR cannot find value `x` in module `blah`
+
+ local_wrap!(x);
+ //~^ ERROR cannot find value `x` in module `blah`
+
+}
diff --git a/tests/ui/feature-gates/feature-gate-diagnostic-opaque.rs b/tests/ui/feature-gates/feature-gate-diagnostic-opaque.rs
new file mode 100644
index 0000000000000..0dc3a4569098f
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-diagnostic-opaque.rs
@@ -0,0 +1,13 @@
+#![crate_type = "lib"]
+#![feature(decl_macro)]
+#![deny(unknown_diagnostic_attributes)]
+
+#[diagnostic::opaque]
+//~^ ERROR unknown diagnostic attribute
+macro_rules! foo {
+ () => {}
+}
+
+#[diagnostic::opaque]
+//~^ ERROR unknown diagnostic attribute
+macro bar() {}
diff --git a/tests/ui/feature-gates/feature-gate-diagnostic-opaque.stderr b/tests/ui/feature-gates/feature-gate-diagnostic-opaque.stderr
new file mode 100644
index 0000000000000..90426a1324e81
--- /dev/null
+++ b/tests/ui/feature-gates/feature-gate-diagnostic-opaque.stderr
@@ -0,0 +1,23 @@
+error: unknown diagnostic attribute
+ --> $DIR/feature-gate-diagnostic-opaque.rs:5:15
+ |
+LL | #[diagnostic::opaque]
+ | ^^^^^^
+ |
+ = help: add `#![feature(diagnostic_opaque)]` to the crate attributes to enable
+note: the lint level is defined here
+ --> $DIR/feature-gate-diagnostic-opaque.rs:3:9
+ |
+LL | #![deny(unknown_diagnostic_attributes)]
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: unknown diagnostic attribute
+ --> $DIR/feature-gate-diagnostic-opaque.rs:11:15
+ |
+LL | #[diagnostic::opaque]
+ | ^^^^^^
+ |
+ = help: add `#![feature(diagnostic_opaque)]` to the crate attributes to enable
+
+error: aborting due to 2 previous errors
+
diff --git a/tests/ui/include-macros/mismatched-types.stderr b/tests/ui/include-macros/mismatched-types.stderr
index 4fab832c2d8e8..ab6b599c2beda 100644
--- a/tests/ui/include-macros/mismatched-types.stderr
+++ b/tests/ui/include-macros/mismatched-types.stderr
@@ -1,13 +1,8 @@
error[E0308]: mismatched types
- --> $DIR/file.txt:0:1
- |
-LL |
- | ^ expected `&[u8]`, found `&str`
- |
- ::: $DIR/mismatched-types.rs:2:12
+ --> $DIR/mismatched-types.rs:2:20
|
LL | let b: &[u8] = include_str!("file.txt");
- | ----- ------------------------ in this macro invocation
+ | ----- ^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[u8]`, found `&str`
| |
| expected due to this
|
diff --git a/tests/ui/lint/static-mut-refs-interior-mutability-no-sugg.stderr b/tests/ui/lint/static-mut-refs-interior-mutability-no-sugg.stderr
index 5ce69e1a14d83..e5db09a670cc9 100644
--- a/tests/ui/lint/static-mut-refs-interior-mutability-no-sugg.stderr
+++ b/tests/ui/lint/static-mut-refs-interior-mutability-no-sugg.stderr
@@ -5,7 +5,6 @@ LL | let _lock = unsafe { MACRO_MUTEX.lock().unwrap() };
| ^^^^^^^^^^^^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
- = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
= note: `#[deny(static_mut_refs)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
diff --git a/tests/ui/lint/static-mut-refs-interior-mutability.stderr b/tests/ui/lint/static-mut-refs-interior-mutability.stderr
index 29ab5a5c404de..d6a644374d8a2 100644
--- a/tests/ui/lint/static-mut-refs-interior-mutability.stderr
+++ b/tests/ui/lint/static-mut-refs-interior-mutability.stderr
@@ -7,7 +7,7 @@ LL | let _lock = unsafe { STDINOUT_MUTEX.lock().unwrap() };
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
= note: for more information, see
= note: `#[deny(static_mut_refs)]` (part of `#[deny(rust_2024_compatibility)]`) on by default
-help: this type already provides "interior mutability", so its binding doesn't need to be declared as mutable
+help: this type already provides "interior mutability", so its binding doesn't need to be declared as mutable when borrowed with a shared reference
|
LL - static mut STDINOUT_MUTEX: Mutex = Mutex::new(false);
LL + static STDINOUT_MUTEX: Mutex = Mutex::new(false);
diff --git a/tests/ui/lint/static-mut-refs.e2021.stderr b/tests/ui/lint/static-mut-refs.e2021.stderr
index 56b4ad239afe3..e616ba0aa4b28 100644
--- a/tests/ui/lint/static-mut-refs.e2021.stderr
+++ b/tests/ui/lint/static-mut-refs.e2021.stderr
@@ -32,6 +32,7 @@ LL | let ref _a = X;
| ^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: creating a shared reference to mutable static
@@ -80,6 +81,7 @@ LL | let _ = Z.len();
| ^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: creating a shared reference to mutable static
@@ -89,6 +91,7 @@ LL | let _ = format!("{:?}", Z);
| ^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: creating a shared reference to mutable static
@@ -124,6 +127,7 @@ LL | let ref _v = A.value;
| ^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: creating a mutable reference to mutable static
@@ -136,6 +140,7 @@ LL | let _x = bar!(FOO);
| --------- in this macro invocation
|
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
= note: this warning originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/lint/static-mut-refs.e2024.stderr b/tests/ui/lint/static-mut-refs.e2024.stderr
index 0b7f48a507c94..a8985fc8a1763 100644
--- a/tests/ui/lint/static-mut-refs.e2024.stderr
+++ b/tests/ui/lint/static-mut-refs.e2024.stderr
@@ -32,6 +32,7 @@ LL | let ref _a = X;
| ^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
error: creating a shared reference to mutable static
@@ -80,6 +81,7 @@ LL | let _ = Z.len();
| ^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
error: creating a shared reference to mutable static
@@ -89,6 +91,7 @@ LL | let _ = format!("{:?}", Z);
| ^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
error: creating a shared reference to mutable static
@@ -124,6 +127,7 @@ LL | let ref _v = A.value;
| ^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
error: creating a mutable reference to mutable static
@@ -136,6 +140,7 @@ LL | let _x = bar!(FOO);
| --------- in this macro invocation
|
= note: mutable references to mutable statics are dangerous; it's undefined behavior if any other pointer to the static is used or if any other reference is created for the static while the mutable reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
= note: this error originates in the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info)
diff --git a/tests/ui/statics/static-lazy-init-with-arena-set.stderr b/tests/ui/statics/static-lazy-init-with-arena-set.stderr
index 43b244607885d..4aed8b06166c8 100644
--- a/tests/ui/statics/static-lazy-init-with-arena-set.stderr
+++ b/tests/ui/statics/static-lazy-init-with-arena-set.stderr
@@ -12,7 +12,7 @@ LL | | });
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
= note: for more information, see
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
-help: this type already provides "interior mutability", so its binding doesn't need to be declared as mutable
+help: this type already provides "interior mutability", so its binding doesn't need to be declared as mutable when borrowed with a shared reference
|
LL - static mut ONCE: Once = Once::new();
LL + static ONCE: Once = Once::new();
diff --git a/tests/ui/statics/static-mut-xc.stderr b/tests/ui/statics/static-mut-xc.stderr
index d0b30ce6f8514..f8fa25e152f67 100644
--- a/tests/ui/statics/static-mut-xc.stderr
+++ b/tests/ui/statics/static-mut-xc.stderr
@@ -5,6 +5,7 @@ LL | assert_eq!(static_mut_xc::a, 3);
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
= note: `#[warn(static_mut_refs)]` (part of `#[warn(rust_2024_compatibility)]`) on by default
@@ -15,6 +16,7 @@ LL | assert_eq!(static_mut_xc::a, 4);
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: creating a shared reference to mutable static
@@ -24,6 +26,7 @@ LL | assert_eq!(static_mut_xc::a, 5);
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: creating a shared reference to mutable static
@@ -33,6 +36,7 @@ LL | assert_eq!(static_mut_xc::a, 15);
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: creating a shared reference to mutable static
@@ -42,6 +46,7 @@ LL | assert_eq!(static_mut_xc::a, -3);
| ^^^^^^^^^^^^^^^^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: creating a shared reference to mutable static
diff --git a/tests/ui/statics/static-recursive.stderr b/tests/ui/statics/static-recursive.stderr
index 1ae96dfd5a832..9578808ec7b03 100644
--- a/tests/ui/statics/static-recursive.stderr
+++ b/tests/ui/statics/static-recursive.stderr
@@ -19,6 +19,7 @@ LL | assert_eq!(S, *(S as *const *const u8));
| ^ shared reference to mutable static
|
= note: shared references to mutable statics are dangerous; it's undefined behavior if the static is mutated or if a mutable reference is created for it while the shared reference lives
+ = help: use a type that relies on "interior mutability" instead; to read more on this, visit
= note: for more information, see
warning: 2 warnings emitted
diff --git a/triagebot.toml b/triagebot.toml
index 9fd7bad75160f..e817e99ddf375 100644
--- a/triagebot.toml
+++ b/triagebot.toml
@@ -779,8 +779,8 @@ PR #{number} "{title}" fixes a regression and has been nominated for backport.
This topic will help T-compiler getting context about it.
Tip: to approve or decline from this Zulip thread, use:
-@_**triagebot** backport approve beta #{number}
-@_**triagebot** backport decline beta #{number}
+@_**triagebot** backport approve
+@_**triagebot** backport decline
""",
"""\
/poll Should #{number} be beta backported?
@@ -809,8 +809,8 @@ PR #{number} "{title}" fixes a regression and has been nominated for backport.
This topic will help T-compiler getting context about it.
Tip: to approve or decline from this Zulip thread, use:
-@_**triagebot** backport approve stable #{number}
-@_**triagebot** backport decline stable #{number}
+@_**triagebot** backport approve
+@_**triagebot** backport decline
""",
"""\
/poll Approve stable backport of #{number}?