Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5876c8c

Browse files
committed
Auto merge of rust-lang#119767 - GuillaumeGomez:rollup-fbp26yb, r=GuillaumeGomez
Rollup of 9 pull requests Successful merges: - rust-lang#117556 (Disallow reference to `static mut` and adding `static_mut_ref` lint) - rust-lang#118748 (std: getrandom simplification for freebsd.) - rust-lang#119282 (Rework and improve the unstable documentation of check-cfg) - rust-lang#119527 (don't reexport atomic::ordering via rustc_data_structures, use std import) - rust-lang#119668 (Simplify implementation of MIR promotion) - rust-lang#119699 (Merge dead bb pruning and unreachable bb deduplication.) - rust-lang#119723 (Remove `-Zdont-buffer-diagnostics`.) - rust-lang#119756 (rustdoc-search: reuse individual types in function signatures) - rust-lang#119758 (GNU/Hurd: unconditionally use inline stack probes) r? `@ghost` `@rustbot` modify labels: rollup
2 parents be00c5a + f41d773 commit 5876c8c

File tree

107 files changed

+1963
-790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+1963
-790
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3876,6 +3876,7 @@ dependencies = [
38763876
"rustc_feature",
38773877
"rustc_fluent_macro",
38783878
"rustc_hir",
3879+
"rustc_hir_pretty",
38793880
"rustc_index",
38803881
"rustc_infer",
38813882
"rustc_lint_defs",

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ fn start<T: Termination + 'static>(
111111
}
112112

113113
static mut NUM: u8 = 6 * 7;
114+
115+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
116+
#[allow(static_mut_ref)]
114117
static NUM_REF: &'static u8 = unsafe { &NUM };
115118

116119
unsafe fn zeroed<T>() -> T {

compiler/rustc_codegen_gcc/example/mini_core_hello_world.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ fn start<T: Termination + 'static>(
9898
}
9999

100100
static mut NUM: u8 = 6 * 7;
101+
102+
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_ref` lint
103+
#[allow(static_mut_ref)]
101104
static NUM_REF: &'static u8 = unsafe { &NUM };
102105

103106
macro_rules! assert {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pub mod check_consts;
2-
pub mod promote_consts;
32
pub mod validate;

compiler/rustc_data_structures/src/sync.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ mod parallel;
5656
pub use parallel::scope;
5757
pub use parallel::{join, par_for_each_in, par_map, parallel_guard, try_par_for_each_in};
5858

59-
pub use std::sync::atomic::Ordering;
60-
pub use std::sync::atomic::Ordering::SeqCst;
61-
6259
pub use vec::{AppendOnlyIndexVec, AppendOnlyVec};
6360

6461
mod vec;
@@ -67,8 +64,7 @@ mod freeze;
6764
pub use freeze::{FreezeLock, FreezeReadGuard, FreezeWriteGuard};
6865

6966
mod mode {
70-
use super::Ordering;
71-
use std::sync::atomic::AtomicU8;
67+
use std::sync::atomic::{AtomicU8, Ordering};
7268

7369
const UNINITIALIZED: u8 = 0;
7470
const DYN_NOT_THREAD_SAFE: u8 = 1;
@@ -113,6 +109,7 @@ cfg_match! {
113109
cfg(not(parallel_compiler)) => {
114110
use std::ops::Add;
115111
use std::cell::Cell;
112+
use std::sync::atomic::Ordering;
116113

117114
pub unsafe auto trait Send {}
118115
pub unsafe auto trait Sync {}

compiler/rustc_driver_impl/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
2525
use rustc_data_structures::profiling::{
2626
get_resident_set_size, print_time_passes_entry, TimePassesFormat,
2727
};
28-
use rustc_data_structures::sync::SeqCst;
2928
use rustc_errors::registry::{InvalidErrorCode, Registry};
3029
use rustc_errors::{markdown, ColorConfig};
3130
use rustc_errors::{DiagCtxt, ErrorGuaranteed, PResult};
@@ -476,7 +475,7 @@ fn run_compiler(
476475
eprintln!(
477476
"Fuel used by {}: {}",
478477
sess.opts.unstable_opts.print_fuel.as_ref().unwrap(),
479-
sess.print_fuel.load(SeqCst)
478+
sess.print_fuel.load(Ordering::SeqCst)
480479
);
481480
}
482481

compiler/rustc_error_codes/src/error_codes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ E0792: include_str!("./error_codes/E0792.md"),
515515
E0793: include_str!("./error_codes/E0793.md"),
516516
E0794: include_str!("./error_codes/E0794.md"),
517517
E0795: include_str!("./error_codes/E0795.md"),
518+
E0796: include_str!("./error_codes/E0796.md"),
518519
}
519520

520521
// Undocumented removed error codes. Note that many removed error codes are kept in the list above
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Reference of mutable static.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,edition2024,E0796
6+
static mut X: i32 = 23;
7+
static mut Y: i32 = 24;
8+
9+
unsafe {
10+
let y = &X;
11+
let ref x = X;
12+
let (x, y) = (&X, &Y);
13+
foo(&X);
14+
}
15+
16+
fn foo<'a>(_x: &'a i32) {}
17+
```
18+
19+
Mutable statics can be written to by multiple threads: aliasing violations or
20+
data races will cause undefined behavior.
21+
22+
Reference of mutable static is a hard error from 2024 edition.

compiler/rustc_errors/src/diagnostic_builder.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ impl<'a, G: EmissionGuarantee> DiagnosticBuilder<'a, G> {
266266
/// Converts the builder to a `Diagnostic` for later emission,
267267
/// unless dcx has disabled such buffering.
268268
pub fn into_diagnostic(mut self) -> Option<(Diagnostic, &'a DiagCtxt)> {
269-
let flags = self.dcx.inner.lock().flags;
270-
if flags.dont_buffer_diagnostics || flags.treat_err_as_bug.is_some() {
269+
if self.dcx.inner.lock().flags.treat_err_as_bug.is_some() {
271270
self.emit();
272271
return None;
273272
}

compiler/rustc_errors/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,6 @@ pub struct DiagCtxtFlags {
524524
/// If Some, the Nth error-level diagnostic is upgraded to bug-level.
525525
/// (rustc: see `-Z treat-err-as-bug`)
526526
pub treat_err_as_bug: Option<NonZeroUsize>,
527-
/// If true, immediately emit diagnostics that would otherwise be buffered.
528-
/// (rustc: see `-Z dont-buffer-diagnostics` and `-Z treat-err-as-bug`)
529-
pub dont_buffer_diagnostics: bool,
530527
/// Show macro backtraces.
531528
/// (rustc: see `-Z macro-backtrace`)
532529
pub macro_backtrace: bool,

0 commit comments

Comments
 (0)