Skip to content

Commit d6c1e45

Browse files
committed
Auto merge of rust-lang#140127 - ChrisDenton:rollup-2kye32h, r=ChrisDenton
Rollup of 11 pull requests Successful merges: - rust-lang#134213 (Stabilize `naked_functions`) - rust-lang#139711 (Hermit: Unify `std::env::args` with Unix) - rust-lang#139795 (Clarify why SGX code specifies linkage/symbol names for certain statics) - rust-lang#140036 (Advent of `tests/ui` (misc cleanups and improvements) [4/N]) - rust-lang#140047 (remove a couple clones) - rust-lang#140052 (Fix error when an intra doc link is trying to resolve an empty associated item) - rust-lang#140074 (rustdoc-json: Improve test for auto-trait impls) - rust-lang#140076 (jsondocck: Require command is at start of line) - rust-lang#140107 (rustc-dev-guide subtree update) - rust-lang#140111 (cleanup redundant pattern instances) - rust-lang#140118 ({B,C}Str: minor cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8f2819b + 1cb9a0d commit d6c1e45

File tree

90 files changed

+325
-405
lines changed

Some content is hidden

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

90 files changed

+325
-405
lines changed

compiler/rustc_builtin_macros/src/autodiff.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -596,15 +596,14 @@ mod llvm_enzyme {
596596
}
597597
};
598598
let arg = ty.kind.is_simple_path().unwrap();
599-
let sl: Vec<Symbol> = vec![arg, kw::Default];
600-
let tmp = ecx.def_site_path(&sl);
599+
let tmp = ecx.def_site_path(&[arg, kw::Default]);
601600
let default_call_expr = ecx.expr_path(ecx.path(span, tmp));
602601
let default_call_expr = ecx.expr_call(new_decl_span, default_call_expr, thin_vec![]);
603602
body.stmts.push(ecx.stmt_expr(default_call_expr));
604603
return body;
605604
}
606605

607-
let mut exprs: P<ast::Expr> = primal_call.clone();
606+
let mut exprs: P<ast::Expr> = primal_call;
608607
let d_ret_ty = match d_sig.decl.output {
609608
FnRetTy::Ty(ref ty) => ty.clone(),
610609
FnRetTy::Default(span) => {
@@ -622,7 +621,7 @@ mod llvm_enzyme {
622621
// type due to the Const return activity.
623622
exprs = ecx.expr_call(new_decl_span, bb_call_expr, thin_vec![exprs]);
624623
} else {
625-
let q = QSelf { ty: d_ret_ty.clone(), path_span: span, position: 0 };
624+
let q = QSelf { ty: d_ret_ty, path_span: span, position: 0 };
626625
let y =
627626
ExprKind::Path(Some(P(q)), ecx.path_ident(span, Ident::from_str("default")));
628627
let default_call_expr = ecx.expr(span, y);
@@ -640,8 +639,7 @@ mod llvm_enzyme {
640639
let mut exprs2 = thin_vec![exprs];
641640
for arg in args.iter().skip(1) {
642641
let arg = arg.kind.is_simple_path().unwrap();
643-
let sl: Vec<Symbol> = vec![arg, kw::Default];
644-
let tmp = ecx.def_site_path(&sl);
642+
let tmp = ecx.def_site_path(&[arg, kw::Default]);
645643
let default_call_expr = ecx.expr_path(ecx.path(span, tmp));
646644
let default_call_expr =
647645
ecx.expr_call(new_decl_span, default_call_expr, thin_vec![]);

compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
#![feature(
2-
no_core,
3-
lang_items,
4-
never_type,
5-
linkage,
6-
extern_types,
7-
naked_functions,
8-
thread_local,
9-
repr_simd
10-
)]
1+
#![feature(no_core, lang_items, never_type, linkage, extern_types, thread_local, repr_simd)]
112
#![no_core]
123
#![allow(dead_code, non_camel_case_types, internal_features)]
134

compiler/rustc_error_codes/src/error_codes/E0787.md

-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ An unsupported naked function definition.
33
Erroneous code example:
44

55
```compile_fail,E0787
6-
#![feature(naked_functions)]
7-
86
#[unsafe(naked)]
97
pub extern "C" fn f() -> u32 {
108
42

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,8 @@ declare_features! (
300300
/// Allows patterns with concurrent by-move and by-ref bindings.
301301
/// For example, you can write `Foo(a, ref b)` where `a` is by-move and `b` is by-ref.
302302
(accepted, move_ref_pattern, "1.49.0", Some(68354)),
303+
/// Allows using `#[naked]` on functions.
304+
(accepted, naked_functions, "CURRENT_RUSTC_VERSION", Some(90957)),
303305
/// Allows specifying modifiers in the link attribute: `#[link(modifiers = "...")]`
304306
(accepted, native_link_modifiers, "1.61.0", Some(81490)),
305307
/// Allows specifying the bundle link modifier

compiler/rustc_feature/src/builtin_attrs.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
443443
ungated!(unsafe(Edition2024) no_mangle, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
444444
ungated!(used, Normal, template!(Word, List: "compiler|linker"), WarnFollowing, EncodeCrossCrate::No),
445445
ungated!(link_ordinal, Normal, template!(List: "ordinal"), ErrorPreceding, EncodeCrossCrate::Yes),
446+
ungated!(unsafe naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No),
446447

447448
// Limits:
448449
ungated!(
@@ -515,12 +516,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
515516
// Unstable attributes:
516517
// ==========================================================================
517518

518-
// Linking:
519-
gated!(
520-
unsafe naked, Normal, template!(Word), WarnFollowing, EncodeCrossCrate::No,
521-
naked_functions, experimental!(naked)
522-
),
523-
524519
// Testing:
525520
gated!(
526521
test_runner, CrateLevel, template!(List: "path"), ErrorFollowing,

compiler/rustc_feature/src/unstable.rs

-2
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,6 @@ declare_features! (
563563
(unstable, must_not_suspend, "1.57.0", Some(83310)),
564564
/// Allows `mut ref` and `mut ref mut` identifier patterns.
565565
(incomplete, mut_ref, "1.79.0", Some(123076)),
566-
/// Allows using `#[naked]` on functions.
567-
(unstable, naked_functions, "1.9.0", Some(90957)),
568566
/// Allows using `#[naked]` on `extern "Rust"` functions.
569567
(unstable, naked_functions_rustic_abi, "CURRENT_RUSTC_VERSION", Some(138997)),
570568
/// Allows using `#[target_feature(enable = "...")]` on `#[naked]` on functions.

compiler/rustc_middle/src/ty/assoc.rs

+2
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ impl AssocItems {
246246
}
247247

248248
/// Returns an iterator over all associated items with the given name, ignoring hygiene.
249+
///
250+
/// Panics if `name.is_empty()` returns `true`.
249251
pub fn filter_by_name_unhygienic(
250252
&self,
251253
name: Symbol,

compiler/rustc_mir_build/src/builder/scope.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@ fn build_scope_drops<'tcx>(
15301530
// path, then don't generate the drop. (We only take this into
15311531
// account for non-unwind paths so as not to disturb the
15321532
// caching mechanism.)
1533-
if scope.moved_locals.iter().any(|&o| o == local) {
1533+
if scope.moved_locals.contains(&local) {
15341534
continue;
15351535
}
15361536

compiler/rustc_passes/src/check_attr.rs

-7
Original file line numberDiff line numberDiff line change
@@ -690,13 +690,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
690690
}
691691
}
692692
}
693-
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
694-
// `#[naked]` attribute with just a lint, because we previously
695-
// erroneously allowed it and some crates used it accidentally, to be compatible
696-
// with crates depending on them, we can't throw an error here.
697-
Target::Field | Target::Arm | Target::MacroDef => {
698-
self.inline_attr_str_error_with_macro_def(hir_id, attr, "naked")
699-
}
700693
_ => {
701694
self.dcx().emit_err(errors::AttrShouldBeAppliedToFn {
702695
attr_span: attr.span(),

compiler/rustc_transmute/src/layout/tree.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ pub(crate) mod rustc {
514514
}
515515
}
516516
ty::Tuple(fields) => fields[i.as_usize()],
517-
kind @ _ => unimplemented!(
517+
kind => unimplemented!(
518518
"only a subset of `Ty::ty_and_layout_field`'s functionality is implemented. implementation needed for {:?}",
519519
kind
520520
),

library/alloc/src/ffi/c_str.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl CString {
574574
#[stable(feature = "as_c_str", since = "1.20.0")]
575575
#[rustc_diagnostic_item = "cstring_as_c_str"]
576576
pub fn as_c_str(&self) -> &CStr {
577-
&*self
577+
unsafe { CStr::from_bytes_with_nul_unchecked(self.as_bytes_with_nul()) }
578578
}
579579

580580
/// Converts this `CString` into a boxed [`CStr`].
@@ -705,14 +705,14 @@ impl ops::Deref for CString {
705705

706706
#[inline]
707707
fn deref(&self) -> &CStr {
708-
unsafe { CStr::from_bytes_with_nul_unchecked(self.as_bytes_with_nul()) }
708+
self.as_c_str()
709709
}
710710
}
711711

712712
#[stable(feature = "rust1", since = "1.0.0")]
713713
impl fmt::Debug for CString {
714714
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
715-
fmt::Debug::fmt(&**self, f)
715+
fmt::Debug::fmt(self.as_c_str(), f)
716716
}
717717
}
718718

library/alloctests/tests/c_str2.rs

-6
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ fn build_with_zero2() {
3333
assert!(CString::new(vec![0]).is_err());
3434
}
3535

36-
#[test]
37-
fn formatted() {
38-
let s = CString::new(&b"abc\x01\x02\n\xE2\x80\xA6\xFF"[..]).unwrap();
39-
assert_eq!(format!("{s:?}"), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#);
40-
}
41-
4236
#[test]
4337
fn borrowed() {
4438
unsafe {

library/core/src/arch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub macro asm("assembly template", $(operands,)* $(options($(option),*))?) {
3232
///
3333
/// [Rust By Example]: https://doc.rust-lang.org/nightly/rust-by-example/unsafe/asm.html
3434
/// [reference]: https://doc.rust-lang.org/nightly/reference/inline-assembly.html
35-
#[unstable(feature = "naked_functions", issue = "90957")]
35+
#[stable(feature = "naked_functions", since = "CURRENT_RUSTC_VERSION")]
3636
#[rustc_builtin_macro]
3737
pub macro naked_asm("assembly template", $(operands,)* $(options($(option),*))?) {
3838
/* compiler built-in */

library/core/src/bstr/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ use crate::ops::{Deref, DerefMut, DerefPure};
3636
/// presented as hex escape sequences.
3737
///
3838
/// The `Display` implementation behaves as if the `ByteStr` were first lossily converted to a
39-
/// `str`, with invalid UTF-8 presented as the Unicode replacement character: �
40-
///
39+
/// `str`, with invalid UTF-8 presented as the Unicode replacement character (�).
4140
#[unstable(feature = "bstr", issue = "134915")]
4241
#[repr(transparent)]
4342
#[doc(alias = "BStr")]

library/core/src/ffi/c_str.rs

-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ impl Error for FromBytesWithNulError {
150150
/// within the slice.
151151
///
152152
/// This error is created by the [`CStr::from_bytes_until_nul`] method.
153-
///
154153
#[derive(Clone, PartialEq, Eq, Debug)]
155154
#[stable(feature = "cstr_from_bytes_until_nul", since = "1.69.0")]
156155
pub struct FromBytesUntilNulError(());

library/coretests/tests/ffi/cstr.rs

+6
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,9 @@ fn compares_as_u8s() {
1313
assert_eq!(Ord::cmp(a, b), Ord::cmp(a_bytes, b_bytes));
1414
assert_eq!(PartialOrd::partial_cmp(a, b), PartialOrd::partial_cmp(a_bytes, b_bytes));
1515
}
16+
17+
#[test]
18+
fn debug() {
19+
let s = c"abc\x01\x02\n\xE2\x80\xA6\xFF";
20+
assert_eq!(format!("{s:?}"), r#""abc\x01\x02\n\xe2\x80\xa6\xff""#);
21+
}

library/std/src/path.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3265,7 +3265,7 @@ impl Hash for Path {
32653265
if !verbatim {
32663266
component_start += match tail {
32673267
[b'.'] => 1,
3268-
[b'.', sep @ _, ..] if is_sep_byte(*sep) => 1,
3268+
[b'.', sep, ..] if is_sep_byte(*sep) => 1,
32693269
_ => 0,
32703270
};
32713271
}

library/std/src/sys/alloc/sgx.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ use crate::sys::pal::waitqueue::SpinMutex;
1010
// The current allocator here is the `dlmalloc` crate which we've got included
1111
// in the rust-lang/rust repository as a submodule. The crate is a port of
1212
// dlmalloc.c from C to Rust.
13+
//
14+
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
1315
#[cfg_attr(test, linkage = "available_externally")]
14-
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx5alloc8DLMALLOCE")]
16+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys5alloc3sgx8DLMALLOCE")]
1517
static DLMALLOC: SpinMutex<dlmalloc::Dlmalloc<Sgx>> =
1618
SpinMutex::new(dlmalloc::Dlmalloc::new_with_allocator(Sgx {}));
1719

library/std/src/sys/args/hermit.rs

-35
This file was deleted.

library/std/src/sys/args/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
#![forbid(unsafe_op_in_unsafe_fn)]
44

55
cfg_if::cfg_if! {
6-
if #[cfg(all(target_family = "unix", not(any(target_os = "espidf", target_os = "vita"))))] {
6+
if #[cfg(any(
7+
all(target_family = "unix", not(any(target_os = "espidf", target_os = "vita"))),
8+
target_os = "hermit",
9+
))] {
710
mod unix;
811
pub use unix::*;
912
} else if #[cfg(target_family = "windows")] {
1013
mod windows;
1114
pub use windows::*;
12-
} else if #[cfg(target_os = "hermit")] {
13-
mod hermit;
14-
pub use hermit::*;
1515
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
1616
mod sgx;
1717
pub use sgx::*;

library/std/src/sys/args/sgx.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::sys::pal::abi::usercalls::raw::ByteBuffer;
88
use crate::sys_common::FromInner;
99
use crate::{fmt, slice};
1010

11+
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
1112
#[cfg_attr(test, linkage = "available_externally")]
1213
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE")]
1314
static ARGS: AtomicUsize = AtomicUsize::new(0);

library/std/src/sys/args/unix.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
#![allow(dead_code)] // runtime init functions not used during testing
77

88
use crate::ffi::CStr;
9+
#[cfg(target_os = "hermit")]
10+
use crate::os::hermit::ffi::OsStringExt;
11+
#[cfg(not(target_os = "hermit"))]
912
use crate::os::unix::ffi::OsStringExt;
1013

1114
#[path = "common.rs"]
@@ -73,6 +76,7 @@ pub fn args() -> Args {
7376
target_os = "illumos",
7477
target_os = "emscripten",
7578
target_os = "haiku",
79+
target_os = "hermit",
7680
target_os = "l4re",
7781
target_os = "fuchsia",
7882
target_os = "redox",
@@ -100,7 +104,7 @@ mod imp {
100104

101105
unsafe fn really_init(argc: isize, argv: *const *const u8) {
102106
// These don't need to be ordered with each other or other stores,
103-
// because they only hold the unmodified system-provide argv/argc.
107+
// because they only hold the unmodified system-provided argv/argc.
104108
ARGC.store(argc, Ordering::Relaxed);
105109
ARGV.store(argv as *mut _, Ordering::Relaxed);
106110
}

library/std/src/sys/pal/sgx/abi/tls/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,17 @@ const USIZE_BITS: usize = 64;
1111
const TLS_KEYS: usize = 128; // Same as POSIX minimum
1212
const TLS_KEYS_BITSET_SIZE: usize = (TLS_KEYS + (USIZE_BITS - 1)) / USIZE_BITS;
1313

14+
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
1415
#[cfg_attr(test, linkage = "available_externally")]
15-
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_KEY_IN_USEE")]
16+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx3abi3tls14TLS_KEY_IN_USEE")]
1617
static TLS_KEY_IN_USE: SyncBitset = SYNC_BITSET_INIT;
1718
macro_rules! dup {
1819
((* $($exp:tt)*) $($val:tt)*) => (dup!( ($($exp)*) $($val)* $($val)* ));
1920
(() $($val:tt)*) => ([$($val),*])
2021
}
22+
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
2123
#[cfg_attr(test, linkage = "available_externally")]
22-
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx3abi3tls14TLS_DESTRUCTORE")]
24+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx3abi3tls14TLS_DESTRUCTORE")]
2325
static TLS_DESTRUCTOR: [AtomicUsize; TLS_KEYS] = dup!((* * * * * * *) (AtomicUsize::new(0)));
2426

2527
unsafe extern "C" {

library/std/src/sys/pal/sgx/os.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,13 @@ pub fn current_exe() -> io::Result<PathBuf> {
7373
unsupported()
7474
}
7575

76+
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
7677
#[cfg_attr(test, linkage = "available_externally")]
77-
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os3ENVE")]
78+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx2os3ENVE")]
7879
static ENV: AtomicUsize = AtomicUsize::new(0);
80+
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
7981
#[cfg_attr(test, linkage = "available_externally")]
80-
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx2os8ENV_INITE")]
82+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx2os8ENV_INITE")]
8183
static ENV_INIT: Once = Once::new();
8284
type EnvStore = Mutex<HashMap<OsString, OsString>>;
8385

library/std/src/sys/pal/sgx/thread.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ mod task_queue {
4545
}
4646
}
4747

48+
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
4849
#[cfg_attr(test, linkage = "available_externally")]
49-
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx6thread10TASK_QUEUEE")]
50+
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3pal3sgx6thread10TASK_QUEUEE")]
5051
static TASK_QUEUE: Mutex<Vec<Task>> = Mutex::new(Vec::new());
5152

5253
pub(super) fn lock() -> MutexGuard<'static, Vec<Task>> {

src/doc/rustc-dev-guide/rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
a7c39b68616668a45f0afd62849a1da7c8ad2516
1+
b8005bff3248cfc6e327faf4fa631ac49bb49ba9

0 commit comments

Comments
 (0)