Skip to content

Commit 8058136

Browse files
committed
Auto merge of #123299 - workingjubilee:rollup-2z8amaj, r=workingjubilee
Rollup of 5 pull requests Successful merges: - #123180 (Rewrite `core-no-fp-fmt-parse` test in Rust) - #123267 (std::thread: adding get_name haiku implementation.) - #123268 (warn against implementing Freeze) - #123271 (doc: describe panic conditions for SliceIndex implementations) - #123295 (add myself to compiler review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 204805a + f7d0a59 commit 8058136

File tree

8 files changed

+69
-6
lines changed

8 files changed

+69
-6
lines changed

Diff for: library/core/src/marker.rs

+7
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,13 @@ pub trait DiscriminantKind {
817817
/// This can be used to declare that a constant with a generic type
818818
/// will not contain interior mutability, and subsequently allow
819819
/// placing the constant behind references.
820+
///
821+
/// # Safety
822+
///
823+
/// This trait is a core part of the language, it is just expressed as a trait in libcore for
824+
/// convenience. Do *not* implement it for other types.
825+
// FIXME: Eventually this trait should become `#[rustc_deny_explicit_impl]`.
826+
// That requires porting the impls below to native internal impls.
820827
#[lang = "freeze"]
821828
#[unstable(feature = "freeze", issue = "121675")]
822829
pub unsafe auto trait Freeze {}

Diff for: library/core/src/slice/index.rs

+11
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
195195
fn index_mut(self, slice: &mut T) -> &mut Self::Output;
196196
}
197197

198+
/// The methods `index` and `index_mut` panic if the index is out of bounds.
198199
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
199200
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
200201
unsafe impl<T> SliceIndex<[T]> for usize {
@@ -328,6 +329,9 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
328329
}
329330
}
330331

332+
/// The methods `index` and `index_mut` panic if:
333+
/// - the start of the range is greater than the end of the range or
334+
/// - the end of the range is out of bounds.
331335
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
332336
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
333337
unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
@@ -416,6 +420,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
416420
}
417421
}
418422

423+
/// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
419424
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
420425
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
421426
unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
@@ -454,6 +459,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
454459
}
455460
}
456461

462+
/// The methods `index` and `index_mut` panic if the start of the range is out of bounds.
457463
#[stable(feature = "slice_get_slice_impls", since = "1.15.0")]
458464
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
459465
unsafe impl<T> SliceIndex<[T]> for ops::RangeFrom<usize> {
@@ -536,6 +542,10 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFull {
536542
}
537543
}
538544

545+
/// The methods `index` and `index_mut` panic if:
546+
/// - the end of the range is `usize::MAX` or
547+
/// - the start of the range is greater than the end of the range or
548+
/// - the end of the range is out of bounds.
539549
#[stable(feature = "inclusive_range", since = "1.26.0")]
540550
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
541551
unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
@@ -580,6 +590,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
580590
}
581591
}
582592

593+
/// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
583594
#[stable(feature = "inclusive_range", since = "1.26.0")]
584595
#[rustc_const_unstable(feature = "const_slice_index", issue = "none")]
585596
unsafe impl<T> SliceIndex<[T]> for ops::RangeToInclusive<usize> {

Diff for: library/std/src/sys/pal/unix/thread.rs

+19-1
Original file line numberDiff line numberDiff line change
@@ -257,14 +257,32 @@ impl Thread {
257257
CString::new(name).ok()
258258
}
259259

260+
#[cfg(target_os = "haiku")]
261+
pub fn get_name() -> Option<CString> {
262+
unsafe {
263+
let mut tinfo = mem::MaybeUninit::<libc::thread_info>::uninit();
264+
// See BeOS teams group and threads api.
265+
// https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_ThreadsAndTeams_Overview.html
266+
let thread_self = libc::find_thread(ptr::null_mut());
267+
let res = libc::get_thread_info(thread_self, tinfo.as_mut_ptr());
268+
if res != libc::B_OK {
269+
return None;
270+
}
271+
let info = tinfo.assume_init();
272+
let name = slice::from_raw_parts(info.name.as_ptr() as *const u8, info.name.len());
273+
CStr::from_bytes_until_nul(name).map(CStr::to_owned).ok()
274+
}
275+
}
276+
260277
#[cfg(not(any(
261278
target_os = "linux",
262279
target_os = "freebsd",
263280
target_os = "netbsd",
264281
target_os = "macos",
265282
target_os = "ios",
266283
target_os = "tvos",
267-
target_os = "watchos"
284+
target_os = "watchos",
285+
target_os = "haiku"
268286
)))]
269287
pub fn get_name() -> Option<CString> {
270288
None

Diff for: src/tools/run-make-support/src/rustc.rs

+14
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,20 @@ impl Rustc {
104104
self
105105
}
106106

107+
/// Specify the crate type.
108+
pub fn crate_type(&mut self, crate_type: &str) -> &mut Self {
109+
self.cmd.arg("--crate-type");
110+
self.cmd.arg(crate_type);
111+
self
112+
}
113+
114+
/// Specify the edition year.
115+
pub fn edition(&mut self, edition: &str) -> &mut Self {
116+
self.cmd.arg("--edition");
117+
self.cmd.arg(edition);
118+
self
119+
}
120+
107121
/// Generic command arguments provider. Use `.arg("-Zname")` over `.arg("-Z").arg("arg")`.
108122
/// This method will panic if a plain `-Z` or `-C` is passed, or if `-Z <name>` or `-C <name>`
109123
/// is passed (note the space).

Diff for: src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ run-make/compiler-rt-works-on-mingw/Makefile
3131
run-make/compressed-debuginfo/Makefile
3232
run-make/const-prop-lint/Makefile
3333
run-make/const_fn_mir/Makefile
34-
run-make/core-no-fp-fmt-parse/Makefile
3534
run-make/core-no-oom-handling/Makefile
3635
run-make/crate-data-smoke/Makefile
3736
run-make/crate-hash-rustc-version/Makefile

Diff for: tests/run-make/core-no-fp-fmt-parse/Makefile

-4
This file was deleted.

Diff for: tests/run-make/core-no-fp-fmt-parse/rmake.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// This test checks that the core library of Rust can be compiled without enabling
2+
// support for formatting and parsing floating-point numbers.
3+
4+
extern crate run_make_support;
5+
6+
use run_make_support::rustc;
7+
use std::path::PathBuf;
8+
9+
fn main() {
10+
rustc()
11+
.edition("2021")
12+
.arg("-Dwarnings")
13+
.crate_type("rlib")
14+
.input("../../../library/core/src/lib.rs")
15+
.cfg("no_fp_fmt_parse")
16+
.run();
17+
}

Diff for: triagebot.toml

+1
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,7 @@ compiler-team-contributors = [
788788
"@Nadrieril",
789789
"@fmease",
790790
"@fee1-dead",
791+
"@BoxyUwU",
791792
]
792793
compiler = [
793794
"compiler-team",

0 commit comments

Comments
 (0)