Commit Graph

18123 Commits

Author SHA1 Message Date
bors
f44efbf9e1 Auto merge of #137235 - matthiaskrgr:rollup-2kjua2t, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #135711 (Do not ICE on default_field_value const with lifetimes)
 - #136599 (librustdoc: more usages of `Joined::joined`)
 - #136876 (Locking documentation updates)
 - #137000 (Deeply normalize item bounds in new solver)
 - #137126 (fix docs for inherent str constructors)
 - #137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions)
 - #137191 (Update mdbook and move error_index_generator)
 - #137203 (Improve MIR modification)
 - #137206 (Make E0599 a structured error)
 - #137218 (misc `layout_of` cleanup)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-18 21:08:58 +00:00
Matthias Krüger
ac3b179c3b
Rollup merge of #137126 - m4rch3n1ng:fix-inherent-str-docs, r=Amanieu
fix docs for inherent str constructors

related to #131114

when implementing inherent str constructors in #136517, i forgot to change the docs, so the code examples still imported the `std::str` module and used the constructor from there, instead of using "itself" (the inherent constructor).
2025-02-18 18:40:52 +01:00
Matthias Krüger
5a942d67a6
Rollup merge of #136876 - joshtriplett:locking-might-not-be-advisory, r=Amanieu
Locking documentation updates

- Reword file lock documentation to clarify advisory vs mandatory. Remove the
  word "advisory", and make it more explicit that the lock may be advisory or
  mandatory depending on platform.

- Document that locking a file fails on Windows if the file is opened only for append
2025-02-18 18:40:50 +01:00
Urgau
b7c2da2231
Rollup merge of #137214 - cyrgani:clippy_diagnostic_items, r=compiler-errors
add last std diagnostic items for clippy

Part of https://github.com/rust-lang/rust-clippy/issues/5393.
Add diagnostic item attributes to the items in `std` and `core` where clippy currently uses hardcoded paths (https://github.com/rust-lang/rust-clippy/blob/master/clippy_utils/src/paths.rs).
2025-02-18 18:34:18 +01:00
Urgau
73e5abd175
Rollup merge of #137205 - thaliaarchi:remove-wasi-fileext-tell, r=alexcrichton
Remove `std::os::wasi::fs::FileExt::tell`

Following #137165 (Use `tell` for `<File as Seek>::stream_position`), `tell` is now directly exposed via `stream_position`, making `<File as FileExt>::tell` redundant. Remove it.

`std::os::wasi::fs::FileExt::tell` is currently unstable and tracked in https://github.com/rust-lang/rust/issues/71213.

``@rustbot`` ping wasi
2025-02-18 18:34:17 +01:00
Urgau
14fb84a5bb
Rollup merge of #137167 - martn3:reliable_f16_math-f16-erfc, r=tgross35
tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg

In #136324 the doctest for `f16::erf()` was gated with `reliable_f16_math`. Add the same gate on `f16::erfc()` to avoid:

    rust_out.71e2e529d20ea47d-cgu.0:\
    (.text._ZN8rust_out4main43_doctest_main_library_std_src_f16_rs_1321_017h485f3ffe6bf2a981E+0x38): \
    undefined reference to `__gnu_h2f_ieee'

on MIPS (and maybe other architectures).

r? tgross35
2025-02-18 18:34:15 +01:00
Urgau
d7fe4c0e92
Rollup merge of #136750 - kornelski:ub-bug, r=saethlin
Make ub_check message clear that it's not an assert

I've seen a user assume that their unsound code was *safe*, because ub_check prevented the program from performing the unsafe operation.

This PR makes the panic message clearer that ub_check is a bug detector, not run-time safety protection.
2025-02-18 18:34:13 +01:00
Josh Triplett
ec2034d53d Reorder "This lock may be advisory or mandatory." earlier in the lock docs 2025-02-18 17:31:10 +01:00
Josh Triplett
35674eff6f Clarify that locking on Windows also works for files opened with .read(true) 2025-02-18 17:26:33 +01:00
cyrgani
a72402a0f9 add last std diagnostic items for clippy 2025-02-18 10:54:37 +01:00
Thalia Archibald
d2f15971de Remove std::os::wasi::fs::FileExt::tell
Following #137165 (Use `tell` for `<File as Seek>::stream_position`),
`tell` is now directly exposed via `stream_position`, making
`<File as FileExt>::tell` redundant. Remove it.
2025-02-17 20:21:05 -08:00
Matthias Krüger
10018d8e10
Rollup merge of #137165 - thaliaarchi:file-tell, r=ChrisDenton
Use `tell` for `<File as Seek>::stream_position`

Some platforms have a more efficient way to get the current offset of the file than by seeking. For example, Wasi has `fd_tell` and SOLID has `SOLID_FS_Ftell`. Implement `<File as Seek>::stream_position()` in terms of those.

I do not use any APIs that were not already used in `std`. Although, the `libc` crate has [`ftell`](https://docs.rs/libc/latest/libc/fn.ftell.html), [`ftello`](https://docs.rs/libc/latest/libc/fn.ftello.html), and [`ftello64`](https://docs.rs/libc/latest/libc/fn.ftello64.html), I do not know platform coverage. It appears that Windows has no `tell`-like API.

I have checked that it builds on each relevant platform.
2025-02-17 17:06:10 +01:00
Thalia Archibald
7112474134 Use tell for <File as Seek>::stream_position 2025-02-17 05:25:14 -08:00
bors
2162e9d4b1 Auto merge of #137164 - matthiaskrgr:rollup-dj5826k, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #137095 (Replace some u64 hashes with Hash64)
 - #137100 (HIR analysis: Remove unnecessary abstraction over list of clauses)
 - #137105 (Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.)
 - #137120 (Enable `relative-path-include-bytes-132203` rustdoc-ui test on Windows)
 - #137125 (Re-add missing empty lines in the releases notes)
 - #137145 (use add-core-stubs / minicore for a few more tests)
 - #137149 (Remove SSE ABI from i586-pc-windows-msvc)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-17 11:18:33 +00:00
Martin Nordholts
f6485ff617 tests: Also gate f16::erfc() doctest with reliable_f16_math cfg
In 136324 the doctest for `f16::erf()` was gated with
`reliable_f16_math`. Add the same gate on `f16::erfc()` to
avoid:

    rust_out.71e2e529d20ea47d-cgu.0:\
    (.text._ZN8rust_out4main43_doctest_main_library_std_src_f16_rs_1321_017h485f3ffe6bf2a981E+0x38): \
    undefined reference to `__gnu_h2f_ieee'

on MIPS (and maybe other architectures).
2025-02-17 11:59:09 +01:00
Matthias Krüger
fae72a07dd
Rollup merge of #137105 - zachs18:cow-derefpure-restrict, r=Nadrieril
Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.

Fixes #136046

`feature(deref_patterns)` tracking issue: https://github.com/rust-lang/rust/issues/87121

`Cow<'_, T>` should only implement `DerefPure` if its `Deref` impl is pure, which requires `<T::Owned as Borrow<T>>::borrow`  to be pure. This PR restricts `impl DerefPure for Cow<'_, T>` to `T: Sized + Clone`, `T = [U: Clone]`, and `T = str` (for all of whom `<T::Owned as Borrow<T>>::borrow` is implemented in the stdlib and is pure).

cc ``@Nadrieril``

------

An alternate approach would be to introduce a new `unsafe trait BorrowPure<T>` analogous to `DerefPure`  that could be implemented for `T: Sized`, `&T`, `&mut T`, `String`, `Vec`, `Box`, `PathBuf`, `OsString`, etc. https://github.com/rust-lang/rust/compare/master...zachs18:borrow-pure-trait
2025-02-17 06:38:15 +01:00
Matthias Krüger
86f3d525e0
Rollup merge of #137101 - GrigorenkoPV:str-inherent-lint, r=Urgau
`invalid_from_utf8[_unchecked]`: also lint inherent methods

Addressing https://github.com/rust-lang/rust/issues/131114#issuecomment-2646663535

Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
2025-02-17 06:37:38 +01:00
Matthias Krüger
c04801dbb9
Rollup merge of #136844 - thaliaarchi:const-io-error, r=ChrisDenton
Use `const_error!` when possible

Replace usages of `io::Error::new(io::ErrorKind::Variant, "constant string")` with `io::const_error!(io::ErrorKind::Variant, "constant string")` to avoid allocations when possible. Additionally, fix `&&str` error messages in SGX and missing/misplaced trailing commas in `const_error!`.
2025-02-17 06:37:37 +01:00
Matthias Krüger
f82764f2d9
Rollup merge of #137114 - ChrisDenton:error, r=Noratrieb
Add an example for `std::error::Error`

There is currently no example provided for `std::error::Error` so let's fix that.
2025-02-16 17:14:06 +01:00
Matthias Krüger
53b4c7c631
Rollup merge of #136986 - ehuss:library-unsafe-fun, r=Noratrieb
Apply unsafe_op_in_unsafe_fn to the standard library

This applies unsafe_op_in_unsafe_fn to the standard library in preparation for updating to Rust 2024.

Closes https://github.com/rust-lang/rust/issues/127747 (I think?) cc ``@workingjubilee``
I have been testing a variety of targets, and I feel like they are all pretty much covered. I'll continue doing some testing async, but I don't expect to catch any more.
2025-02-16 17:14:03 +01:00
Pavel Grigorenko
f53d0f502d invalid_from_utf8[_unchecked]: also lint inherent methods 2025-02-16 16:34:51 +03:00
may
345c313def
fix docs for inherent str constructors 2025-02-16 12:02:06 +01:00
Chris Denton
f396a31075
Add an example for std::error::Error 2025-02-16 08:14:41 +00:00
Zachary S
0f220efb1a Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str. 2025-02-15 21:02:00 -06:00
Kornel
ca288273b4
Make ub_check message clear that it's not an assert 2025-02-16 00:56:09 +00:00
Michael Howell
4d551dd754 docs: fix broken intra-doc links that never worked 2025-02-15 12:21:38 -07:00
bors
8c07d140e0 Auto merge of #137065 - jhpratt:rollup-ree9mej, r=jhpratt
Rollup of 9 pull requests

Successful merges:

 - #135687 (re-export `FromCoroutine` from `core::iter`)
 - #135813 (CI: split i686-mingw job to three free runners)
 - #136749 (Implement Extend<AsciiChar> for String)
 - #136879 (Add safe new() to NotAllOnes)
 - #136978 (Windows: Update generated bindings)
 - #137028 (mir_build: Clarify some code for lowering `hir::PatExpr` to THIR)
 - #137029 (Remove unnecessary check code in unused_delims)
 - #137056 (made check_argument_compat public for use in miri)
 - #137062 (Forward all default methods for I/O impls)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-02-15 07:52:03 +00:00
Jacob Pratt
ba89ea8add
Rollup merge of #137062 - thaliaarchi:io-optional-methods/write, r=workingjubilee
Forward all default methods for I/O impls

Forward all default methods for `&mut T` and `Box<T>` to the inner `io::Read`, `io::Write`, `io::Seek`, and `io::BufRead` types.
2025-02-15 02:37:33 -05:00
Jacob Pratt
224be79129
Rollup merge of #136978 - ChrisDenton:windows-bindgen, r=Amanieu
Windows: Update generated bindings

Update to windows-bindgen 0.59.

This update is aimed at reducing churn in the future, but means a bit more churn now:

- `bindings.txt` no longer needs us to write the namespace for each item. This is good because it means in the future we won't need to change them if the namespace changes. However, there are a few where we still need to disambiguate due to duplicate items (this is a bug in the upstream metadata).
- The output in `windows-sys.rs` is now sorted. It was mostly sorted before but not intentionally. This should mean future changes are less noisy.

The actual code changes are minimal here. A few types are now `bool` instead of `BOOLEAN`, which is more convenient.
2025-02-15 02:37:30 -05:00
Jacob Pratt
1524b5319a
Rollup merge of #136879 - kornelski:non1, r=Noratrieb
Add safe new() to NotAllOnes

Replaces duplicated `unsafe` code with a single, easier to verify implementation.
2025-02-15 02:37:29 -05:00
Jacob Pratt
26be558650
Rollup merge of #136749 - mzeitlin11:extend-asciichar, r=scottmcm
Implement Extend<AsciiChar> for String

Implement `Extend<AsciiChar>` for `String` as suggested in https://github.com/rust-lang/rust/issues/110998#issuecomment-2590122968. Also implements `Extend<&AsciiChar>` since there's an analogous impl for `Extend<&char>`, but happy to remove if not thought useful.

r? `@scottmcm`
since you requested it, but no pressure to review!
2025-02-15 02:37:28 -05:00
Jacob Pratt
afbeefb684
Rollup merge of #135687 - joseluis:feat-reexport_from_coroutine, r=scottmcm
re-export `FromCoroutine` from `core::iter`

tracking issue: https://github.com/rust-lang/rust/issues/43122
fixes: #135686
2025-02-15 02:37:27 -05:00
Thalia Archibald
11c174006e Forward all default methods for I/O impls 2025-02-14 21:48:12 -08:00
bors
f77247ac59 Auto merge of #136324 - GrigorenkoPV:erf, r=tgross35
Implement `f{16,32,64,128}::{erf,erfc}` (`#![feature(float_erf)]`)

Tracking issue: #136321

try-job: x86_64-gnu-aux
2025-02-15 04:52:50 +00:00
Jubilee
922119b79c
Rollup merge of #136983 - ehuss:misc-2024-prep, r=tgross35
Prepare standard library for Rust 2024 migration

This includes a variety of commits preparing the standard library for migration to Rust 2024.

The actual migration is blocked on a few things, so I wanted to get this out of the way in a relatively digestable PR.
2025-02-14 14:05:24 -08:00
Jubilee
58e84ff2b5
Rollup merge of #134016 - zachs18:stable-const-str-split_at, r=Amanieu
Stabilize `const_is_char_boundary` and `const_str_split_at`.

Tracking issues: #131516, #131518

Stabilized const API:

```rs
// in `core`
impl str {
    // const_is_char_boundary feature
    const fn is_char_boundary(&self, index: usize) -> bool;

    // const_str_split_at feature, depends on const_is_char_boundary
    const fn split_at(&self, mid: usize) -> (&str, &str);
    const fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str);
    const fn split_at_checked(&self, mid: usize) -> Option<(&str, &str)>;
    const fn split_at_mut_checked(&mut self, mid: usize) -> Option<(&mut str, &mut str)>;
}
```

This will allow safely splitting string slices during const-eval.

Closes #131516, Closes #131518

This will need FCP.
r? libs-api

IIUC these do not use any new const language features (i.e. they are implementable manually on stable 1.83.0 using `unsafe`: [playground link](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=3679632cd1041084796241b7ac8edfbd)).

Cc ``@rust-lang/wg-const-eval`` (I don't know if I have the permissions for this ping; if not, someone else please ping wg-const-eval if it is necessary)
2025-02-14 14:05:22 -08:00
Eric Huss
80a7eb1c09 proc_macro: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
Eric Huss
4f4ea35a69 std: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
Eric Huss
d5f0aa49e7 Fix safety of windows uwp functions
These functions were changed to be safe in
https://github.com/rust-lang/rust/pull/127763, but this particular UWP
version was missed. Otherwise this causes unnecessary unsafe block
warnings/errors.
2025-02-14 07:36:17 -08:00
Eric Huss
0484d23465 unwind: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
Eric Huss
331911e699 panic_unwind: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
Eric Huss
e13928de93 panic_abort: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
Eric Huss
4e36f46464 core: Apply unsafe_op_in_unsafe_fn 2025-02-14 07:36:17 -08:00
Matthias Krüger
145e35a6e3
Rollup merge of #136976 - jedbrown:jed/doc-boxed-deferred-init, r=tgross35
alloc boxed: docs: use MaybeUninit::write instead of as_mut_ptr

In the deferred initialization pattern, the docs were needlessly going through `as_mut_ptr().write()` to initialize, which is unnecessary use of a pointer, needs to be inside an `unsafe` block, and may weaken alias analysis.
2025-02-14 16:23:33 +01:00
Matthias Krüger
b5fce2ab8e
Rollup merge of #136967 - DaniPopes:io-repeat-fill, r=joboet
Use `slice::fill` in `io::Repeat` implementation

Use the existing `fill` methods on slices instead of manually writing the fill loop.
2025-02-14 16:23:32 +01:00
Matthias Krüger
c21a76fde0
Rollup merge of #136886 - ehuss:remove-prelude-common, r=jhpratt
Remove the common prelude module

This fixes the issues described in https://github.com/rust-lang/rust/issues/136102. Primarily, this resolves some issues with how the documentation for the prelude is generated:

- It avoids showing "unstable" for macros in the prelude that are actually stable.
- Avoids duplication of some pages due to the previous lack of `doc(no_inline)`.
- Makes the different edition preludes consistent, and sets a pattern that can be used by future editions.

We may need to rearrange these modules in the future if we decide to remove anything from the prelude again. If we do, I think we should look into a different solution that avoids the documentation problems.

Closes https://github.com/rust-lang/rust/issues/136102
2025-02-14 16:23:30 +01:00
Matthias Krüger
678ff2a59b
Rollup merge of #136052 - no1wudi:fix, r=workingjubilee
Correct comment for FreeBSD and DragonFly BSD in unix/thread
2025-02-14 16:23:29 +01:00
Kornel
00964aa401
Add safe new to NotAllOnes 2025-02-14 12:00:13 +00:00
bors
d88ffcdb8b Auto merge of #136735 - scottmcm:transmute-nonnull, r=oli-obk
`transmute` should also assume non-null pointers

Previously it only did integer-ABI things, but this way it does data pointers too.  That gives more information in general to the backend, and allows slightly simplifying one of the helpers in slice iterators.
2025-02-14 09:06:17 +00:00
Jubilee
e961aac3c0
Rollup merge of #136992 - ehuss:update-backtrace, r=workingjubilee
Update backtrace

This updates the backtrace submodule.

6 commits in f8cc6ac9acc4e663ecd96f9bcf1ff4542636d1b9..9d2c34e7e63afe1e71c333b247065e3b7ba4d883
2025-01-04 03:37:47 +0100 to 2025-02-13 14:14:18 -0800
- Various cleanups: https://github.com/rust-lang/backtrace-rs/pull/673
- libunwind: Use builtin _Unwind_GetIP for NuttX on ARM platform: https://github.com/rust-lang/backtrace-rs/pull/692
- remove outdated docs part on Dbghelp::ensure_open: https://github.com/rust-lang/backtrace-rs/pull/696
- Cleanup Windows trace modules: https://github.com/rust-lang/backtrace-rs/pull/697
- Attempt to fix ARM32 Windows: https://github.com/rust-lang/backtrace-rs/pull/685
- Prepare backtrace for Rust 2024: https://github.com/rust-lang/backtrace-rs/pull/700
2025-02-13 21:37:53 -08:00