diff --git a/library/core/src/marker.rs b/library/core/src/marker.rs index 385c288db12ce..1d073a6d649b8 100644 --- a/library/core/src/marker.rs +++ b/library/core/src/marker.rs @@ -817,6 +817,13 @@ pub trait DiscriminantKind { /// This can be used to declare that a constant with a generic type /// will not contain interior mutability, and subsequently allow /// placing the constant behind references. +/// +/// # Safety +/// +/// This trait is a core part of the language, it is just expressed as a trait in libcore for +/// convenience. Do *not* implement it for other types. +// FIXME: Eventually this trait should become `#[rustc_deny_explicit_impl]`. +// That requires porting the impls below to native internal impls. #[lang = "freeze"] #[unstable(feature = "freeze", issue = "121675")] pub unsafe auto trait Freeze {} diff --git a/library/core/src/slice/index.rs b/library/core/src/slice/index.rs index 127a407dae5d4..8d7b6165510a8 100644 --- a/library/core/src/slice/index.rs +++ b/library/core/src/slice/index.rs @@ -195,6 +195,7 @@ pub unsafe trait SliceIndex: private_slice_index::Sealed { fn index_mut(self, slice: &mut T) -> &mut Self::Output; } +/// The methods `index` and `index_mut` panic if the index is out of bounds. #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] unsafe impl SliceIndex<[T]> for usize { @@ -328,6 +329,9 @@ unsafe impl SliceIndex<[T]> for ops::IndexRange { } } +/// The methods `index` and `index_mut` panic if: +/// - the start of the range is greater than the end of the range or +/// - the end of the range is out of bounds. #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] unsafe impl SliceIndex<[T]> for ops::Range { @@ -416,6 +420,7 @@ unsafe impl SliceIndex<[T]> for ops::Range { } } +/// The methods `index` and `index_mut` panic if the end of the range is out of bounds. #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] unsafe impl SliceIndex<[T]> for ops::RangeTo { @@ -454,6 +459,7 @@ unsafe impl SliceIndex<[T]> for ops::RangeTo { } } +/// The methods `index` and `index_mut` panic if the start of the range is out of bounds. #[stable(feature = "slice_get_slice_impls", since = "1.15.0")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] unsafe impl SliceIndex<[T]> for ops::RangeFrom { @@ -536,6 +542,10 @@ unsafe impl SliceIndex<[T]> for ops::RangeFull { } } +/// The methods `index` and `index_mut` panic if: +/// - the end of the range is `usize::MAX` or +/// - the start of the range is greater than the end of the range or +/// - the end of the range is out of bounds. #[stable(feature = "inclusive_range", since = "1.26.0")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] unsafe impl SliceIndex<[T]> for ops::RangeInclusive { @@ -580,6 +590,7 @@ unsafe impl SliceIndex<[T]> for ops::RangeInclusive { } } +/// The methods `index` and `index_mut` panic if the end of the range is out of bounds. #[stable(feature = "inclusive_range", since = "1.26.0")] #[rustc_const_unstable(feature = "const_slice_index", issue = "none")] unsafe impl SliceIndex<[T]> for ops::RangeToInclusive { diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs index 01e3c3cbc6fde..77e31d802a38f 100644 --- a/library/std/src/sys/pal/unix/thread.rs +++ b/library/std/src/sys/pal/unix/thread.rs @@ -257,6 +257,23 @@ impl Thread { CString::new(name).ok() } + #[cfg(target_os = "haiku")] + pub fn get_name() -> Option { + unsafe { + let mut tinfo = mem::MaybeUninit::::uninit(); + // See BeOS teams group and threads api. + // https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_ThreadsAndTeams_Overview.html + let thread_self = libc::find_thread(ptr::null_mut()); + let res = libc::get_thread_info(thread_self, tinfo.as_mut_ptr()); + if res != libc::B_OK { + return None; + } + let info = tinfo.assume_init(); + let name = slice::from_raw_parts(info.name.as_ptr() as *const u8, info.name.len()); + CStr::from_bytes_until_nul(name).map(CStr::to_owned).ok() + } + } + #[cfg(not(any( target_os = "linux", target_os = "freebsd", @@ -264,7 +281,8 @@ impl Thread { target_os = "macos", target_os = "ios", target_os = "tvos", - target_os = "watchos" + target_os = "watchos", + target_os = "haiku" )))] pub fn get_name() -> Option { None diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs index d0ab8df42d282..1b358817a7957 100644 --- a/src/tools/run-make-support/src/rustc.rs +++ b/src/tools/run-make-support/src/rustc.rs @@ -104,6 +104,20 @@ impl Rustc { self } + /// Specify the crate type. + pub fn crate_type(&mut self, crate_type: &str) -> &mut Self { + self.cmd.arg("--crate-type"); + self.cmd.arg(crate_type); + self + } + + /// Specify the edition year. + pub fn edition(&mut self, edition: &str) -> &mut Self { + self.cmd.arg("--edition"); + self.cmd.arg(edition); + self + } + /// Generic command arguments provider. Use `.arg("-Zname")` over `.arg("-Z").arg("arg")`. /// This method will panic if a plain `-Z` or `-C` is passed, or if `-Z ` or `-C ` /// is passed (note the space). diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index bdee3afa6b71d..40950e6ba4432 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -31,7 +31,6 @@ run-make/compiler-rt-works-on-mingw/Makefile run-make/compressed-debuginfo/Makefile run-make/const-prop-lint/Makefile run-make/const_fn_mir/Makefile -run-make/core-no-fp-fmt-parse/Makefile run-make/core-no-oom-handling/Makefile run-make/crate-data-smoke/Makefile run-make/crate-hash-rustc-version/Makefile diff --git a/tests/run-make/core-no-fp-fmt-parse/Makefile b/tests/run-make/core-no-fp-fmt-parse/Makefile deleted file mode 100644 index 837664d92b938..0000000000000 --- a/tests/run-make/core-no-fp-fmt-parse/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -include ../tools.mk - -all: - $(RUSTC) --edition=2021 -Dwarnings --crate-type=rlib ../../../library/core/src/lib.rs --cfg no_fp_fmt_parse diff --git a/tests/run-make/core-no-fp-fmt-parse/rmake.rs b/tests/run-make/core-no-fp-fmt-parse/rmake.rs new file mode 100644 index 0000000000000..2748d4359c365 --- /dev/null +++ b/tests/run-make/core-no-fp-fmt-parse/rmake.rs @@ -0,0 +1,17 @@ +// This test checks that the core library of Rust can be compiled without enabling +// support for formatting and parsing floating-point numbers. + +extern crate run_make_support; + +use run_make_support::rustc; +use std::path::PathBuf; + +fn main() { + rustc() + .edition("2021") + .arg("-Dwarnings") + .crate_type("rlib") + .input("../../../library/core/src/lib.rs") + .cfg("no_fp_fmt_parse") + .run(); +} diff --git a/triagebot.toml b/triagebot.toml index 0df71c60d5454..55f0d32398ff1 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -788,6 +788,7 @@ compiler-team-contributors = [ "@Nadrieril", "@fmease", "@fee1-dead", + "@BoxyUwU", ] compiler = [ "compiler-team",