Skip to content

Commit 3914420

Browse files
committed
Auto merge of rust-lang#124208 - jieyouxu:rollup-gbgpu4u, r=jieyouxu
Rollup of 10 pull requests Successful merges: - rust-lang#123379 (Print note with closure signature on type mismatch) - rust-lang#123967 (static_mut_refs: use raw pointers to remove the remaining FIXME) - rust-lang#123976 (Use fake libc in core test) - rust-lang#123986 (lint-docs: Add redirects for renamed lints.) - rust-lang#124053 (coverage: Branch coverage tests for lazy boolean operators) - rust-lang#124071 (Add llvm-bitcode-linker to build manifest) - rust-lang#124103 (Improve std::fs::Metadata Debug representation) - rust-lang#124132 (llvm RustWrapper: explain OpBundlesIndirect argument type) - rust-lang#124191 (Give a name to each distinct manipulation of pretty-printer FixupContext) - rust-lang#124196 (mir-opt tests: rename unit-test -> test-mir-pass) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 63994f7 + 15cabd5 commit 3914420

File tree

3 files changed

+34
-15
lines changed

3 files changed

+34
-15
lines changed

core/src/primitive_docs.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,11 @@ impl () {}
537537
/// ## 4. Get it from C.
538538
///
539539
/// ```
540-
/// # #![feature(rustc_private)]
540+
/// # mod libc {
541+
/// # pub unsafe fn malloc(_size: usize) -> *mut core::ffi::c_void { core::ptr::NonNull::dangling().as_ptr() }
542+
/// # pub unsafe fn free(_ptr: *mut core::ffi::c_void) {}
543+
/// # }
544+
/// # #[cfg(any())]
541545
/// #[allow(unused_extern_crates)]
542546
/// extern crate libc;
543547
///
@@ -548,7 +552,7 @@ impl () {}
548552
/// if my_num.is_null() {
549553
/// panic!("failed to allocate memory");
550554
/// }
551-
/// libc::free(my_num as *mut libc::c_void);
555+
/// libc::free(my_num as *mut core::ffi::c_void);
552556
/// }
553557
/// ```
554558
///

std/src/fs.rs

+26-10
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ pub struct Permissions(fs_imp::FilePermissions);
214214
/// A structure representing a type of file with accessors for each file type.
215215
/// It is returned by [`Metadata::file_type`] method.
216216
#[stable(feature = "file_type", since = "1.1.0")]
217-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
217+
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
218218
#[cfg_attr(not(test), rustc_diagnostic_item = "FileType")]
219219
pub struct FileType(fs_imp::FileType);
220220

@@ -1410,15 +1410,20 @@ impl Metadata {
14101410
#[stable(feature = "std_debug", since = "1.16.0")]
14111411
impl fmt::Debug for Metadata {
14121412
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1413-
f.debug_struct("Metadata")
1414-
.field("file_type", &self.file_type())
1415-
.field("is_dir", &self.is_dir())
1416-
.field("is_file", &self.is_file())
1417-
.field("permissions", &self.permissions())
1418-
.field("modified", &self.modified())
1419-
.field("accessed", &self.accessed())
1420-
.field("created", &self.created())
1421-
.finish_non_exhaustive()
1413+
let mut debug = f.debug_struct("Metadata");
1414+
debug.field("file_type", &self.file_type());
1415+
debug.field("permissions", &self.permissions());
1416+
debug.field("len", &self.len());
1417+
if let Ok(modified) = self.modified() {
1418+
debug.field("modified", &modified);
1419+
}
1420+
if let Ok(accessed) = self.accessed() {
1421+
debug.field("accessed", &accessed);
1422+
}
1423+
if let Ok(created) = self.created() {
1424+
debug.field("created", &created);
1425+
}
1426+
debug.finish_non_exhaustive()
14221427
}
14231428
}
14241429

@@ -1684,6 +1689,17 @@ impl FileType {
16841689
}
16851690
}
16861691

1692+
#[stable(feature = "std_debug", since = "1.16.0")]
1693+
impl fmt::Debug for FileType {
1694+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1695+
f.debug_struct("FileType")
1696+
.field("is_file", &self.is_file())
1697+
.field("is_dir", &self.is_dir())
1698+
.field("is_symlink", &self.is_symlink())
1699+
.finish_non_exhaustive()
1700+
}
1701+
}
1702+
16871703
impl AsInner<fs_imp::FileType> for FileType {
16881704
#[inline]
16891705
fn as_inner(&self) -> &fs_imp::FileType {

std/src/sys/thread_local/static_local.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ pub macro thread_local_inner {
1111
(@key $t:ty, const $init:expr) => {{
1212
#[inline] // see comments below
1313
#[deny(unsafe_op_in_unsafe_fn)]
14-
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
15-
#[allow(static_mut_refs)]
1614
unsafe fn __getit(
1715
_init: $crate::option::Option<&mut $crate::option::Option<$t>>,
1816
) -> $crate::option::Option<&'static $t> {
@@ -25,7 +23,8 @@ pub macro thread_local_inner {
2523
// FIXME(#84224) this should come after the `target_thread_local`
2624
// block.
2725
static mut VAL: $t = INIT_EXPR;
28-
unsafe { $crate::option::Option::Some(&VAL) }
26+
// SAFETY: we only ever create shared references, so there's no mutable aliasing.
27+
unsafe { $crate::option::Option::Some(&*$crate::ptr::addr_of!(VAL)) }
2928
}
3029

3130
unsafe {

0 commit comments

Comments
 (0)