Skip to content

Commit 1f12b9b

Browse files
committed
Auto merge of #129665 - matthiaskrgr:rollup-hy23k7d, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #129507 (make it possible to enable const_precise_live_drops per-function) - #129581 (exit: explain our expectations for the exit handlers registered in a Rust program) - #129634 (Fix tidy to allow `edition = "2024"` in `Cargo.toml`) - #129635 (Use unsafe extern blocks throughout the compiler) - #129645 (Fix typos in floating-point primitive type docs) - #129648 (More `unreachable_pub`) - #129649 (ABI compat check: detect unadjusted ABI mismatches) - #129652 (fix Pointer to reference conversion docs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ab869e0 + ac0cc70 commit 1f12b9b

File tree

128 files changed

+871
-772
lines changed

Some content is hidden

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

128 files changed

+871
-772
lines changed

compiler/rustc_abi/src/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1700,7 +1700,9 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutS<FieldIdx, VariantIdx> {
17001700

17011701
/// Checks if these two `Layout` are equal enough to be considered "the same for all function
17021702
/// call ABIs". Note however that real ABIs depend on more details that are not reflected in the
1703-
/// `Layout`; the `PassMode` need to be compared as well.
1703+
/// `Layout`; the `PassMode` need to be compared as well. Also note that we assume
1704+
/// aggregates are passed via `PassMode::Indirect` or `PassMode::Cast`; more strict
1705+
/// checks would otherwise be required.
17041706
pub fn eq_abi(&self, other: &Self) -> bool {
17051707
// The one thing that we are not capturing here is that for unsized types, the metadata must
17061708
// also have the same ABI, and moreover that the same metadata leads to the same size. The

compiler/rustc_codegen_llvm/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
77
// tidy-alphabetical-start
88
#![allow(internal_features)]
9+
#![cfg_attr(bootstrap, feature(unsafe_extern_blocks))]
910
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1011
#![doc(rust_logo)]
1112
#![feature(assert_matches)]

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,12 @@ pub enum ArchiveKind {
564564
}
565565

566566
// LLVMRustThinLTOData
567-
extern "C" {
567+
unsafe extern "C" {
568568
pub type ThinLTOData;
569569
}
570570

571571
// LLVMRustThinLTOBuffer
572-
extern "C" {
572+
unsafe extern "C" {
573573
pub type ThinLTOBuffer;
574574
}
575575

@@ -621,7 +621,7 @@ pub enum MemoryEffects {
621621
InaccessibleMemOnly,
622622
}
623623

624-
extern "C" {
624+
unsafe extern "C" {
625625
type Opaque;
626626
}
627627
#[repr(C)]
@@ -631,54 +631,54 @@ struct InvariantOpaque<'a> {
631631
}
632632

633633
// Opaque pointer types
634-
extern "C" {
634+
unsafe extern "C" {
635635
pub type Module;
636636
}
637-
extern "C" {
637+
unsafe extern "C" {
638638
pub type Context;
639639
}
640-
extern "C" {
640+
unsafe extern "C" {
641641
pub type Type;
642642
}
643-
extern "C" {
643+
unsafe extern "C" {
644644
pub type Value;
645645
}
646-
extern "C" {
646+
unsafe extern "C" {
647647
pub type ConstantInt;
648648
}
649-
extern "C" {
649+
unsafe extern "C" {
650650
pub type Attribute;
651651
}
652-
extern "C" {
652+
unsafe extern "C" {
653653
pub type Metadata;
654654
}
655-
extern "C" {
655+
unsafe extern "C" {
656656
pub type BasicBlock;
657657
}
658658
#[repr(C)]
659659
pub struct Builder<'a>(InvariantOpaque<'a>);
660660
#[repr(C)]
661661
pub struct PassManager<'a>(InvariantOpaque<'a>);
662-
extern "C" {
662+
unsafe extern "C" {
663663
pub type Pass;
664664
}
665-
extern "C" {
665+
unsafe extern "C" {
666666
pub type TargetMachine;
667667
}
668-
extern "C" {
668+
unsafe extern "C" {
669669
pub type Archive;
670670
}
671671
#[repr(C)]
672672
pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
673673
#[repr(C)]
674674
pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
675-
extern "C" {
675+
unsafe extern "C" {
676676
pub type Twine;
677677
}
678-
extern "C" {
678+
unsafe extern "C" {
679679
pub type DiagnosticInfo;
680680
}
681-
extern "C" {
681+
unsafe extern "C" {
682682
pub type SMDiagnostic;
683683
}
684684
#[repr(C)]
@@ -688,7 +688,7 @@ pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
688688
#[repr(C)]
689689
pub struct Linker<'a>(InvariantOpaque<'a>);
690690

691-
extern "C" {
691+
unsafe extern "C" {
692692
pub type DiagnosticHandler;
693693
}
694694

@@ -823,7 +823,7 @@ bitflags! {
823823
}
824824
}
825825

826-
extern "C" {
826+
unsafe extern "C" {
827827
pub type ModuleBuffer;
828828
}
829829

@@ -834,7 +834,7 @@ pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
834834
pub type GetSymbolsCallback = unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void;
835835
pub type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void;
836836

837-
extern "C" {
837+
unsafe extern "C" {
838838
// Create and destroy contexts.
839839
pub fn LLVMContextDispose(C: &'static mut Context);
840840
pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
@@ -1518,7 +1518,7 @@ extern "C" {
15181518
}
15191519

15201520
#[link(name = "llvm-wrapper", kind = "static")]
1521-
extern "C" {
1521+
unsafe extern "C" {
15221522
pub fn LLVMRustInstallErrorHandlers();
15231523
pub fn LLVMRustDisableSystemDialogsOnCrash();
15241524

compiler/rustc_const_eval/src/check_consts/post_drop_elaboration.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,19 @@ use super::check::Qualifs;
99
use super::ops::{self, NonConstOp};
1010
use super::qualifs::{NeedsNonConstDrop, Qualif};
1111
use super::ConstCx;
12+
use crate::check_consts::rustc_allow_const_fn_unstable;
1213

1314
/// Returns `true` if we should use the more precise live drop checker that runs after drop
1415
/// elaboration.
1516
pub fn checking_enabled(ccx: &ConstCx<'_, '_>) -> bool {
16-
// Const-stable functions must always use the stable live drop checker.
17+
// Const-stable functions must always use the stable live drop checker...
1718
if ccx.is_const_stable_const_fn() {
18-
return false;
19+
// ...except if they have the feature flag set via `rustc_allow_const_fn_unstable`.
20+
return rustc_allow_const_fn_unstable(
21+
ccx.tcx,
22+
ccx.body.source.def_id().expect_local(),
23+
sym::const_precise_live_drops,
24+
);
1925
}
2026

2127
ccx.tcx.features().const_precise_live_drops

compiler/rustc_driver_impl/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// tidy-alphabetical-start
88
#![allow(internal_features)]
99
#![allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
10+
#![cfg_attr(bootstrap, feature(unsafe_extern_blocks))]
1011
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1112
#![doc(rust_logo)]
1213
#![feature(decl_macro)]
@@ -15,6 +16,7 @@
1516
#![feature(panic_update_hook)]
1617
#![feature(result_flattening)]
1718
#![feature(rustdoc_internals)]
19+
#![warn(unreachable_pub)]
1820
// tidy-alphabetical-end
1921

2022
use std::cmp::max;

compiler/rustc_driver_impl/src/signal_handler.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{fmt, mem, ptr};
66

77
use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE};
88

9-
extern "C" {
9+
unsafe extern "C" {
1010
fn backtrace_symbols_fd(buffer: *const *mut libc::c_void, size: libc::c_int, fd: libc::c_int);
1111
}
1212

compiler/rustc_error_codes/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#![deny(rustdoc::invalid_codeblock_attributes)]
77
#![doc(rust_logo)]
88
#![feature(rustdoc_internals)]
9+
#![warn(unreachable_pub)]
910
// tidy-alphabetical-end
1011

1112
// This higher-order macro defines the error codes that are in use. It is used

compiler/rustc_error_messages/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![feature(rustc_attrs)]
55
#![feature(rustdoc_internals)]
66
#![feature(type_alias_impl_trait)]
7+
#![warn(unreachable_pub)]
78
// tidy-alphabetical-end
89

910
use std::borrow::Cow;

compiler/rustc_errors/src/diagnostic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pub trait LintDiagnostic<'a, G: EmissionGuarantee> {
204204
}
205205

206206
#[derive(Clone, Debug, Encodable, Decodable)]
207-
pub struct DiagLocation {
207+
pub(crate) struct DiagLocation {
208208
file: Cow<'static, str>,
209209
line: u32,
210210
col: u32,

compiler/rustc_errors/src/emitter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2387,7 +2387,7 @@ enum DisplaySuggestion {
23872387
impl FileWithAnnotatedLines {
23882388
/// Preprocess all the annotations so that they are grouped by file and by line number
23892389
/// This helps us quickly iterate over the whole message (including secondary file spans)
2390-
pub fn collect_annotations(
2390+
pub(crate) fn collect_annotations(
23912391
emitter: &dyn Emitter,
23922392
args: &FluentArgs<'_>,
23932393
msp: &MultiSpan,

compiler/rustc_errors/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#![feature(trait_alias)]
2626
#![feature(try_blocks)]
2727
#![feature(yeet_expr)]
28+
#![warn(unreachable_pub)]
2829
// tidy-alphabetical-end
2930

3031
extern crate self as rustc_errors;
@@ -1701,7 +1702,7 @@ impl DiagCtxtInner {
17011702
}
17021703

17031704
/// Translate `message` eagerly with `args` to `SubdiagMessage::Eager`.
1704-
pub fn eagerly_translate<'a>(
1705+
fn eagerly_translate<'a>(
17051706
&self,
17061707
message: DiagMessage,
17071708
args: impl Iterator<Item = DiagArg<'a>>,
@@ -1710,7 +1711,7 @@ impl DiagCtxtInner {
17101711
}
17111712

17121713
/// Translate `message` eagerly with `args` to `String`.
1713-
pub fn eagerly_translate_to_string<'a>(
1714+
fn eagerly_translate_to_string<'a>(
17141715
&self,
17151716
message: DiagMessage,
17161717
args: impl Iterator<Item = DiagArg<'a>>,

compiler/rustc_errors/src/lock.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use std::any::Any;
1313

1414
#[cfg(windows)]
15-
pub fn acquire_global_lock(name: &str) -> Box<dyn Any> {
15+
pub(crate) fn acquire_global_lock(name: &str) -> Box<dyn Any> {
1616
use std::ffi::CString;
1717
use std::io;
1818

@@ -80,6 +80,6 @@ pub fn acquire_global_lock(name: &str) -> Box<dyn Any> {
8080
}
8181

8282
#[cfg(not(windows))]
83-
pub fn acquire_global_lock(_name: &str) -> Box<dyn Any> {
83+
pub(crate) fn acquire_global_lock(_name: &str) -> Box<dyn Any> {
8484
Box::new(())
8585
}

compiler/rustc_errors/src/markdown/parse.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ enum ParseOpt {
7474
}
7575

7676
/// Parse a buffer
77-
pub fn entrypoint(txt: &str) -> MdStream<'_> {
77+
pub(crate) fn entrypoint(txt: &str) -> MdStream<'_> {
7878
let ctx = Context { top_block: true, prev: Prev::Newline };
7979
normalize(parse_recursive(txt.trim().as_bytes(), ctx), &mut Vec::new())
8080
}

compiler/rustc_errors/src/markdown/term.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ thread_local! {
1515
}
1616

1717
/// Print to terminal output to a buffer
18-
pub fn entrypoint(stream: &MdStream<'_>, buf: &mut Buffer) -> io::Result<()> {
18+
pub(crate) fn entrypoint(stream: &MdStream<'_>, buf: &mut Buffer) -> io::Result<()> {
1919
#[cfg(not(test))]
2020
if let Some((w, _)) = termize::dimensions() {
2121
WIDTH.with(|c| c.set(std::cmp::min(w, DEFAULT_COLUMN_WIDTH)));
@@ -47,7 +47,7 @@ fn write_stream(
4747
Ok(())
4848
}
4949

50-
pub fn write_tt(tt: &MdTree<'_>, buf: &mut Buffer, indent: usize) -> io::Result<()> {
50+
fn write_tt(tt: &MdTree<'_>, buf: &mut Buffer, indent: usize) -> io::Result<()> {
5151
match tt {
5252
MdTree::CodeBlock { txt, lang: _ } => {
5353
buf.set_color(ColorSpec::new().set_dimmed(true))?;

0 commit comments

Comments
 (0)