Skip to content

Rollup of 5 pull requests #125010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 50 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
0ca3591
unix/fs: a bit of cleanup around host-specific code
RalfJung May 5, 2024
a418b2d
Auto merge of #3573 - RalfJung:fs-cfg, r=RalfJung
bors May 5, 2024
37087db
reduce tokio features
RalfJung May 5, 2024
6a47bd4
remove rand test
RalfJung May 5, 2024
a5baa15
getrandom: test with and without isolation
RalfJung May 5, 2024
629d57e
Auto merge of #3574 - RalfJung:deps, r=RalfJung
bors May 5, 2024
fb84198
solaris support start.
devnexen May 5, 2024
e43458c
Auto merge of #3570 - devnexen:solaris_build_fix, r=RalfJung
bors May 5, 2024
82e2144
avoid code duplication between realloc and malloc
RalfJung May 6, 2024
e477895
Auto merge of #3578 - RalfJung:realloc, r=RalfJung
bors May 6, 2024
43c9916
Implement wcslen
tyilo Apr 16, 2024
3d269e9
Auto merge of #3474 - tyilo:wcslen, r=RalfJung
bors May 6, 2024
dd5437f
organize libc tests into a proper folder, and run some of them on Win…
RalfJung May 6, 2024
4d6d9a9
Auto merge of #3579 - RalfJung:libc, r=RalfJung
bors May 6, 2024
d2472ba
README: update introduction
RalfJung May 7, 2024
34f64cd
remove problems that I do not think we have seen in a while
RalfJung May 7, 2024
720ff0d
Auto merge of #3583 - RalfJung:readme, r=saethlin
bors May 8, 2024
1601b27
io::Error handling: keep around the full io::Error for longer so we c…
RalfJung May 8, 2024
15305a7
Auto merge of #3589 - RalfJung:io-error, r=RalfJung
bors May 8, 2024
4ab79e5
Implement non-null pointer for malloc(0)
tiif May 8, 2024
2e1d417
Auto merge of #3580 - tiif:feat/malloc0-non-null-pointer, r=RalfJung
bors May 8, 2024
6580a22
Allow test targets to be set via CLI args
RossSmyth May 8, 2024
6e564ed
Update CI script for the miri-script test changes
RossSmyth May 8, 2024
620bf34
Update documentation for miri-script test changes
RossSmyth May 8, 2024
d43cb71
minor tweaks
RalfJung May 9, 2024
42d9b68
Auto merge of #3588 - RossSmyth:CliTarget, r=RalfJung
bors May 9, 2024
e16f46c
make MIRI_TEST_TARGET entirely an internal thing
RalfJung May 9, 2024
cb44843
make RUSTC_BLESS entirely an internal thing
RalfJung May 9, 2024
3028864
Auto merge of #3590 - RalfJung:miri-test-target, r=RalfJung
bors May 9, 2024
1edd3d5
do not run symlink tests on Windows hosts
RalfJung May 9, 2024
d3f4d06
Auto merge of #3591 - RalfJung:win-symlink-trouble, r=RalfJung
bors May 9, 2024
c21c5ba
Document proper usage of `fmt::Error` and `fmt()`'s `Result`.
kpreid May 9, 2024
c9fb74e
check if `x test tests` missing any test directory
onur-ozkan May 10, 2024
569e547
remap missing path `tests/crashes` to `tests`
onur-ozkan May 10, 2024
0a0b40a
add "tidy-alphabetical" check on "tests" remap list
onur-ozkan May 10, 2024
25a3b66
rename 'extern-so' to 'native-lib'
RalfJung May 10, 2024
2bb25d3
Handle Deref expressions in invalid_reference_casting
saethlin May 10, 2024
6f4c7d9
Auto merge of #3593 - RalfJung:native-lib, r=RalfJung
bors May 10, 2024
9fb49fa
Stabilize `byte_slice_trim_ascii` for `&[u8]`/`&str`
okaneco Feb 7, 2024
4d63d0a
Preparing for merge from rustc
May 11, 2024
ce3daac
Merge from rustc
May 11, 2024
2427bf9
Auto merge of #3597 - rust-lang:rustup-2024-05-11, r=RalfJung
bors May 11, 2024
7a0ee91
alloc: update comments around malloc() alignment
RalfJung May 11, 2024
01b151e
separate windows heap functions from C heap shims
RalfJung May 11, 2024
79a85d4
Auto merge of #3598 - RalfJung:heap, r=RalfJung
bors May 11, 2024
03ff775
Rollup merge of #124928 - okaneco:trim_ascii, r=workingjubilee
matthiaskrgr May 11, 2024
6c3fce9
Rollup merge of #124954 - kpreid:fmterr, r=Nilstrieb
matthiaskrgr May 11, 2024
7d7a182
Rollup merge of #124969 - onur-ozkan:test-tests-remap, r=Mark-Simulacrum
matthiaskrgr May 11, 2024
8eac6d2
Rollup merge of #124978 - saethlin:ref-casting_derefs, r=Urgau,Nilstrieb
matthiaskrgr May 11, 2024
8f03405
Rollup merge of #125005 - RalfJung:miri-sync, r=RalfJung
matthiaskrgr May 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/rustc_lint/src/reference_casting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ fn is_cast_to_bigger_memory_layout<'tcx>(

// if the current expr looks like this `&mut expr[index]` then just looking
// at `expr[index]` won't give us the underlying allocation, so we just skip it
// the same logic applies field access like `&mut expr.field`
if let ExprKind::Index(..) | ExprKind::Field(..) = e_alloc.kind {
// the same logic applies field access `&mut expr.field` and reborrows `&mut *expr`.
if let ExprKind::Index(..) | ExprKind::Field(..) | ExprKind::Unary(UnOp::Deref, ..) =
e_alloc.kind
{
return None;
}

Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
//! is, a formatting implementation must and may only return an error if the
//! passed-in [`Formatter`] returns an error. This is because, contrary to what
//! the function signature might suggest, string formatting is an infallible
//! operation. This function only returns a result because writing to the
//! operation. This function only returns a [`Result`] because writing to the
//! underlying stream might fail and it must provide a way to propagate the fact
//! that an error has occurred back up the stack.
//!
Expand Down
8 changes: 8 additions & 0 deletions library/core/src/fmt/fmt_trait_method_doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Formats the value using the given formatter.

# Errors

This function should return [`Err`] if, and only if, the provided [`Formatter`] returns [`Err`].
String formatting is considered an infallible operation; this function only
returns a [`Result`] because writing to the underlying stream might fail and it must
provide a way to propagate the fact that an error has occurred back up the stack.
42 changes: 27 additions & 15 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,24 @@ pub type Result = result::Result<(), Error>;
/// The error type which is returned from formatting a message into a stream.
///
/// This type does not support transmission of an error other than that an error
/// occurred. Any extra information must be arranged to be transmitted through
/// some other means.
///
/// An important thing to remember is that the type `fmt::Error` should not be
/// occurred. This is because, despite the existence of this error,
/// string formatting is considered an infallible operation.
/// `fmt()` implementors should not return this `Error` unless they received it from their
/// [`Formatter`]. The only time your code should create a new instance of this
/// error is when implementing `fmt::Write`, in order to cancel the formatting operation when
/// writing to the underlying stream fails.
///
/// Any extra information must be arranged to be transmitted through some other means,
/// such as storing it in a field to be consulted after the formatting operation has been
/// cancelled. (For example, this is how [`std::io::Write::write_fmt()`] propagates IO errors
/// during writing.)
///
/// This type, `fmt::Error`, should not be
/// confused with [`std::io::Error`] or [`std::error::Error`], which you may also
/// have in scope.
///
/// [`std::io::Error`]: ../../std/io/struct.Error.html
/// [`std::io::Write::write_fmt()`]: ../../std/io/trait.Write.html#method.write_fmt
/// [`std::error::Error`]: ../../std/error/trait.Error.html
///
/// # Examples
Expand Down Expand Up @@ -118,8 +128,10 @@ pub trait Write {
/// This function will return an instance of [`std::fmt::Error`][Error] on error.
///
/// The purpose of that error is to abort the formatting operation when the underlying
/// destination encounters some error preventing it from accepting more text; it should
/// generally be propagated rather than handled, at least when implementing formatting traits.
/// destination encounters some error preventing it from accepting more text;
/// in particular, it does not communicate any information about *what* error occurred.
/// It should generally be propagated rather than handled, at least when implementing
/// formatting traits.
///
/// # Examples
///
Expand Down Expand Up @@ -586,7 +598,7 @@ impl Display for Arguments<'_> {
#[rustc_diagnostic_item = "Debug"]
#[rustc_trivial_field_reads]
pub trait Debug {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
///
/// # Examples
///
Expand Down Expand Up @@ -703,7 +715,7 @@ pub use macros::Debug;
#[rustc_diagnostic_item = "Display"]
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Display {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
///
/// # Examples
///
Expand Down Expand Up @@ -777,7 +789,7 @@ pub trait Display {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Octal {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
Expand Down Expand Up @@ -836,7 +848,7 @@ pub trait Octal {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub trait Binary {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
Expand Down Expand Up @@ -891,7 +903,7 @@ pub trait Binary {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub trait LowerHex {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
Expand Down Expand Up @@ -946,7 +958,7 @@ pub trait LowerHex {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub trait UpperHex {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
Expand Down Expand Up @@ -997,7 +1009,7 @@ pub trait UpperHex {
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "Pointer"]
pub trait Pointer {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
Expand Down Expand Up @@ -1048,7 +1060,7 @@ pub trait Pointer {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub trait LowerExp {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
Expand Down Expand Up @@ -1099,7 +1111,7 @@ pub trait LowerExp {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub trait UpperExp {
/// Formats the value using the given formatter.
#[doc = include_str!("fmt_trait_method_doc.md")]
#[stable(feature = "rust1", since = "1.0.0")]
fn fmt(&self, f: &mut Formatter<'_>) -> Result;
}
Expand Down
21 changes: 9 additions & 12 deletions library/core/src/slice/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,17 @@ impl [u8] {
/// Returns a byte slice with leading ASCII whitespace bytes removed.
///
/// 'Whitespace' refers to the definition used by
/// `u8::is_ascii_whitespace`.
/// [`u8::is_ascii_whitespace`].
///
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!(b" \t hello world\n".trim_ascii_start(), b"hello world\n");
/// assert_eq!(b" ".trim_ascii_start(), b"");
/// assert_eq!(b"".trim_ascii_start(), b"");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii_start(&self) -> &[u8] {
let mut bytes = self;
Expand All @@ -144,18 +143,17 @@ impl [u8] {
/// Returns a byte slice with trailing ASCII whitespace bytes removed.
///
/// 'Whitespace' refers to the definition used by
/// `u8::is_ascii_whitespace`.
/// [`u8::is_ascii_whitespace`].
///
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!(b"\r hello world\n ".trim_ascii_end(), b"\r hello world");
/// assert_eq!(b" ".trim_ascii_end(), b"");
/// assert_eq!(b"".trim_ascii_end(), b"");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii_end(&self) -> &[u8] {
let mut bytes = self;
Expand All @@ -175,18 +173,17 @@ impl [u8] {
/// removed.
///
/// 'Whitespace' refers to the definition used by
/// `u8::is_ascii_whitespace`.
/// [`u8::is_ascii_whitespace`].
///
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!(b"\r hello world\n ".trim_ascii(), b"hello world");
/// assert_eq!(b" ".trim_ascii(), b"");
/// assert_eq!(b"".trim_ascii(), b"");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii(&self) -> &[u8] {
self.trim_ascii_start().trim_ascii_end()
Expand Down
15 changes: 6 additions & 9 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2531,15 +2531,14 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!(" \t \u{3000}hello world\n".trim_ascii_start(), "\u{3000}hello world\n");
/// assert_eq!(" ".trim_ascii_start(), "");
/// assert_eq!("".trim_ascii_start(), "");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii_start(&self) -> &str {
// SAFETY: Removing ASCII characters from a `&str` does not invalidate
Expand All @@ -2557,15 +2556,14 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!("\r hello world\u{3000}\n ".trim_ascii_end(), "\r hello world\u{3000}");
/// assert_eq!(" ".trim_ascii_end(), "");
/// assert_eq!("".trim_ascii_end(), "");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii_end(&self) -> &str {
// SAFETY: Removing ASCII characters from a `&str` does not invalidate
Expand All @@ -2584,15 +2582,14 @@ impl str {
/// # Examples
///
/// ```
/// #![feature(byte_slice_trim_ascii)]
///
/// assert_eq!("\r hello world\n ".trim_ascii(), "hello world");
/// assert_eq!(" ".trim_ascii(), "");
/// assert_eq!("".trim_ascii(), "");
/// ```
#[unstable(feature = "byte_slice_trim_ascii", issue = "94035")]
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "byte_slice_trim_ascii", since = "CURRENT_RUSTC_VERSION")]
#[inline]
pub const fn trim_ascii(&self) -> &str {
// SAFETY: Removing ASCII characters from a `&str` does not invalidate
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,11 +320,13 @@ const PATH_REMAP: &[(&str, &[&str])] = &[
(
"tests",
&[
// tidy-alphabetical-start
"tests/assembly",
"tests/codegen",
"tests/codegen-units",
"tests/coverage",
"tests/coverage-run-rustdoc",
"tests/crashes",
"tests/debuginfo",
"tests/incremental",
"tests/mir-opt",
Expand All @@ -340,6 +342,7 @@ const PATH_REMAP: &[(&str, &[&str])] = &[
"tests/rustdoc-ui",
"tests/ui",
"tests/ui-fulldeps",
// tidy-alphabetical-end
],
),
];
Expand Down
20 changes: 20 additions & 0 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ fn validate_path_remap() {
});
}

#[test]
fn check_missing_paths_for_x_test_tests() {
let build = Build::new(configure("test", &["A-A"], &["A-A"]));

let (_, tests_remap_paths) =
PATH_REMAP.iter().find(|(target_path, _)| *target_path == "tests").unwrap();

let tests_dir = fs::read_dir(build.src.join("tests")).unwrap();
for dir in tests_dir {
let path = dir.unwrap().path();

// Skip if not a test directory.
if path.ends_with("tests/auxiliary") || !path.is_dir() {
continue
}

assert!(tests_remap_paths.iter().any(|item| path.ends_with(*item)), "{} is missing in PATH_REMAP tests list.", path.display());
}
}

#[test]
fn test_exclude() {
let mut config = configure("test", &["A-A"], &["A-A"]);
Expand Down
2 changes: 1 addition & 1 deletion src/tools/miri/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ tex/*/out
perf.data
perf.data.old
flamegraph.svg
tests/extern-so/libtestlib.so
tests/native-lib/libtestlib.so
.auto-*
Loading
Loading