Commit Graph

15760 Commits

Author SHA1 Message Date
Matthias Krüger
e6b6d04b06
Rollup merge of #128499 - Konippi:refactor-backtrace-formatting, r=tgross35
chore: refactor backtrace formatting

Replace `write_str()` with the `writeln!()` macro, consolidating multiple write operations.
2024-08-01 18:43:42 +02:00
Matthias Krüger
ca73b8b7a5
Rollup merge of #128497 - Bryanskiy:fix-dropck-doc, r=lcnr
fix dropck documentation for `[T;0]` special-case

fixes https://github.com/rust-lang/rust/issues/110288.

r? ``@lcnr``
2024-08-01 18:43:41 +02:00
Matthias Krüger
683f2d3cb2
Rollup merge of #128433 - hermit-os:hermit-unsafe_op_in_unsafe_fn, r=joboet
fix(hermit): `deny(unsafe_op_in_unsafe_fn)`

Tracking issue: https://github.com/rust-lang/rust/issues/127747

r? workingjubilee

CC: ``@stlankes``
2024-08-01 18:43:39 +02:00
Konippi
45d35ba4fd chore: refactor backtrace formatting 2024-08-02 00:24:29 +09:00
Bryanskiy
c8a3cafc0f fix dropck documentation for [T;0] special-case 2024-08-01 17:44:14 +03:00
Martin Kröning
820ec720ff
fix(os/hermit): deny(unsafe_op_in_unsafe_fn)
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01 12:34:43 +02:00
Martin Kröning
4da966c30e
fix(pal/hermit): deny(unsafe_op_in_unsafe_fn)
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01 12:34:43 +02:00
Martin Kröning
b21af629ef
refactor(pal/hermit): make ENV a non-mutable static
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-08-01 12:34:43 +02:00
Matthias Krüger
0cda002610
Rollup merge of #128416 - maurer:remove-android-hack, r=tgross35
android: Remove libstd hacks for unsupported Android APIs

Our minimum supported API version is 21, remove hacks to support older Android APIs.

try-job: arm-android

r? tgross35
2024-08-01 08:33:27 +02:00
bors
e485266c67 Auto merge of #128461 - matthiaskrgr:rollup-3dpp11g, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #123813 (Add `REDUNDANT_IMPORTS` lint for new redundant import detection)
 - #126697 ([RFC] mbe: consider the `_` in 2024 an expression)
 - #127159 (match lowering: Hide `Candidate` from outside the lowering algorithm)
 - #128244 (Peel off explicit (or implicit) deref before suggesting clone on move error in borrowck, remove some hacks)
 - #128431 (Add myself as VxWorks target maintainer for reference)
 - #128438 (Add special-case for [T, 0] in dropck_outlives)
 - #128457 (Fix docs for OnceLock::get_mut_or_init)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-08-01 02:26:32 +00:00
Matthias Krüger
8377aae6a1
Rollup merge of #128162 - ChrisDenton:cleanup, r=joboet
Cleanup sys module to match house style

This moves a test file out of sys as it's just testing std types. Also cleans up some assorted bits including making the `use` statements match the house style.
2024-08-01 00:50:11 +02:00
Matthias Krüger
c1f2112600
Rollup merge of #127567 - joboet:once_wait, r=Amanieu
std: implement the `once_wait` feature

Tracking issue: #127527

This additionally adds a `wait_force` method to `Once` that doesn't panic on poison.

I also took the opportunity and cleaned up up the code of the queue-based implementation a bit.
2024-08-01 00:50:10 +02:00
Juniper Tyree
83fb140ec1
Fix docs for OnceLock::get_mut_or_init 2024-07-31 22:00:38 +03:00
joboet
1d49aad844
std: fix busy-waiting in Once::wait_force, add more tests 2024-07-31 17:44:10 +02:00
joboet
cf11f499b3
std: implement the once_wait feature 2024-07-31 17:42:20 +02:00
Chris Denton
e84a7d91b7
Remove unneeded pub(crate) 2024-07-31 13:45:14 +00:00
Matthias Krüger
5c63363284
Rollup merge of #128388 - beetrees:f16-f128-slightly-improve-windows-abi, r=tgross35
Match LLVM ABI in `extern "C"` functions for `f128` on Windows

As MSVC doesn't support `_Float128`, x86-64 Windows doesn't have a defined ABI for `f128`. Currently, Rust will pass and return `f128` indirectly for `extern "C"` functions. This is inconsistent with LLVM, which passes and returns `f128` in XMM registers, meaning that e.g. the ABI of `extern "C"` compiler builtins won't match. This PR fixes this discrepancy by making the x86-64 Windows `extern "C"` ABI pass `f128` directly through to LLVM, so that Rust will follow whatever LLVM does. This still leaves the difference between LLVM and GCC (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115054) but this PR is still an improvement as at least Rust is now consistent with it's primary codegen backend and compiler builtins from `compiler-builtins` will now work.

I've also fixed the x86-64 Windows `has_reliable_f16` match arm in `std` `build.rs` to refer to the correct target, and added an equivalent match arm to `has_reliable_f128` as the LLVM-GCC ABI difference affects both `f16` and `f128`.

Tracking issue: #116909

try-job: x86_64-msvc
try-job: x86_64-mingw
2024-07-31 15:36:31 +02:00
Matthias Krüger
22dbf88744
Rollup merge of #128387 - liigo:patch-14, r=tgross35
More detailed note to deprecate ONCE_INIT
2024-07-31 15:36:31 +02:00
Martin Kröning
127b469b7e
refactor(pal/hermit): use default impl of GlobalAlloc::alloc_zeroed
Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-31 13:31:41 +02:00
Martin Kröning
76b4a86b57
refactor(pal/hermit): return ! to satisfy rust-analyzer
This silences this rust-analyzer-specific error: `expected !, found ()`

Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
2024-07-31 13:31:41 +02:00
Matthew Maurer
7d7ad7b874 android: Remove libstd hacks for unsupported Android APIs
Our minimum supported API version is 21, remove hacks to support older
Android APIs.
2024-07-31 01:03:36 +00:00
Chris Denton
9169622027
Move Windows implementation of anon pipe 2024-07-30 19:23:52 +00:00
beetrees
fe6478cc53
Match LLVM ABI in extern "C" functions for f128 on Windows 2024-07-30 20:23:33 +01:00
Chris Denton
a75d2f9d38
Cleanup sys module to match house style 2024-07-30 19:22:54 +00:00
bors
f8060d282d Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68
Bump bootstrap compiler to new beta

https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-30 17:49:08 +00:00
Liigo Zhuang
918cdcc9c5
More detailed note to deprecate ONCE_INIT 2024-07-30 19:36:28 +08:00
bors
7e3a971870 Auto merge of #128378 - matthiaskrgr:rollup-i3qz9uo, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #127574 (elaborate unknowable goals)
 - #128141 (Set branch protection function attributes)
 - #128315 (Fix vita build of std and forbid unsafe in unsafe in the os/vita module)
 - #128339 ([rustdoc] Make the buttons remain when code example is clicked)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-30 05:50:05 +00:00
bors
710ce90fbe Auto merge of #128250 - Amanieu:select_unpredictable, r=nikic
Add `select_unpredictable` to force LLVM to use CMOV

Since https://reviews.llvm.org/D118118, LLVM will no longer turn CMOVs into branches if it comes from a `select` marked with an `unpredictable` metadata attribute.

This PR introduces `core::intrinsics::select_unpredictable` which emits such a `select` and uses it in the implementation of `binary_search_by`.
2024-07-30 03:22:27 +00:00
Matthias Krüger
f396a42ed6
Rollup merge of #128315 - zetanumbers:psvita-unsafe-in-unsafe, r=workingjubilee
Fix vita build of std and forbid unsafe in unsafe in the os/vita module

See #127747

r? `@workingjubilee`

`@pheki` `@nikarh`
2024-07-30 04:31:55 +02:00
bors
dba8e2d2c2 Auto merge of #128234 - jcsp:retain-empty-case, r=tgross35
Optimize empty case in Vec::retain

While profiling some code that happens to call Vec::retain() in a tight loop, I noticed more runtime than expected in retain, even in a bench case where the vector was always empty.  When I wrapped my call to retain in `if !myvec.is_empty()` I saw faster execution compared with doing retain on an empty vector.

On closer inspection, Vec::retain is doing set_len(0) on itself even when the vector is empty, and then resetting the length again in BackshiftOnDrop::drop.

Unscientific screengrab of a flamegraph illustrating how we end up spending time in set_len and drop:
![image](https://github.com/user-attachments/assets/ebc72ace-84a0-4432-9b6f-1b3c96d353ba)
2024-07-30 00:55:52 +00:00
George Bateman
23f46e5b99
Stabilize offset_of_nested 2024-07-29 17:50:12 +01:00
bors
56c698c711 Auto merge of #128334 - matthiaskrgr:rollup-nhxdt0c, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #128182 (handle no_std targets on std builds)
 - #128277 (miri: fix offset_from behavior on wildcard pointers)
 - #128304 (Isolate the diagnostic code that expects `thir::Pat` to be printable)
 - #128307 (Clean and enable `rustdoc::unescaped_backticks` for `core/alloc/std/test/proc_macro`)
 - #128322 (CI: move RFL job forward to v6.11-rc1)
 - #128333 (Miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-07-29 10:05:42 +00:00
Matthias Krüger
8f7af88b33
Rollup merge of #128307 - ojeda:unescaped_backticks, r=GuillaumeGomez
Clean and enable `rustdoc::unescaped_backticks` for `core/alloc/std/test/proc_macro`

I am not sure if the lint is supposed to be "ready enough" (since it is `allow` by default), but it does catch a couple issues in `core` (`alloc`, `std`, `test` and `proc_macro` are already clean), so I propose making it `warn` in all the crates rendered in the website.

Cc: `@GuillaumeGomez`
2024-07-29 11:42:35 +02:00
John Spray
6a6824a0ab Optimize empty case in Vec::retain 2024-07-29 09:40:51 +01:00
bors
80d8270d84 Auto merge of #125016 - nicholasbishop:bishop-cb-112, r=tgross35
Update compiler_builtins to 0.1.114

The `weak-intrinsics` feature was removed from compiler_builtins in https://github.com/rust-lang/compiler-builtins/pull/598, so dropped the `compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In https://github.com/rust-lang/compiler-builtins/pull/593, some builtins for f16/f128 were added. These don't work for all compiler backends, so add a `compiler-builtins-no-f16-f128` feature and disable it for cranelift and gcc.
2024-07-29 07:41:33 +00:00
Matthias Krüger
0c6d2fb3dc
Rollup merge of #128310 - kmicklas:btree-map-peek-next-docs, r=tgross35
Add missing periods on `BTreeMap` cursor `peek_next` docs

Tracking issue: https://github.com/rust-lang/rust/issues/107540
2024-07-29 07:11:16 +02:00
Matthias Krüger
d573743779
Rollup merge of #128055 - workingjubilee:deny-unsafe-ops-in-sys-personality-dwarf-eh, r=Amanieu
std: unsafe-wrap personality::dwarf::eh

Moves the forbiddance up a little. This is another largely whitespace diff, except for hoisting some variable declarations to allow enclosing the `unsafe {}` scope fully and make it clearer where the bounds of some temporaries are.
2024-07-29 07:11:15 +02:00
Matthias Krüger
1a9f91a43e
Rollup merge of #109174 - soerenmeier:cursor_fns, r=dtolnay
Replace `io::Cursor::{remaining_slice, is_empty}`

This is a late follow up to the concerns raised in https://github.com/rust-lang/rust/issues/86369.

https://github.com/rust-lang/rust/issues/86369#issuecomment-953096691
> This API seems focussed on the `Read` side of things. When `Seek`ing around and `Write`ing data, `is_empty` becomes confusing and `remaining_slice` is not very useful. When writing, the part of the slice before the cursor is much more interesting. Maybe we should have functions for both? Or a single function that returns both slices? (If we also have a `mut` version, a single function would be useful to allow mutable access to both sides at once.)

New feature name: `cursor_remaining` > `cursor_split`.
Added functions:
```rust
fn split(&self) -> (&[u8], &[u8]);
// fn before(&self) -> &[u8];
// fn after(&self) -> &[u8];
fn split_mut(&mut self) -> (&mut [u8], &mut [u8]);
// fn before_mut(&mut self) -> &mut [u8];
// fn after_mut(&mut self) -> &mut [u8];
```

A question was raised in https://github.com/rust-lang/rust/issues/86369#issuecomment-927124211 about whether to return a lifetime that would reflect the lifetime of the underlying bytes (`impl Cursor<&'a [u8]> { fn after(&self) -> &'a [u8] }`). The downside of doing this would be that it would not be possible to implement these functions generically over `T: AsRef<[u8]>`.

## Update
Based on the review, before* and after* methods where removed.
2024-07-29 07:11:13 +02:00
Nicholas Bishop
ecf2963baf Update compiler_builtins to 0.1.114
The `weak-intrinsics` feature was removed from compiler_builtins in
https://github.com/rust-lang/compiler-builtins/pull/598, so dropped the
`compiler-builtins-weak-intrinsics` feature from alloc/std/sysroot.

In https://github.com/rust-lang/compiler-builtins/pull/593, some
builtins for f16/f128 were added. These don't work for all compiler
backends, so add a `compiler-builtins-no-f16-f128` feature and disable
it for cranelift and gcc. Also disable it for LLVM targets that don't
support it.
2024-07-28 20:43:07 -04:00
Miguel Ojeda
dc815df1e1 Warn on rustdoc::unescaped_backticks for core/alloc/std/test/proc_macro
They are all clean now, so enable the lint to keep them clean going forward.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-07-29 00:58:45 +02:00
Miguel Ojeda
cf87203f48 Remove spurious backticks detected by rustdoc::unescaped_backticks
There are only 3 cases across the crates rendered in the website (`core`,
`alloc`, `std`, `proc_macro` and `test`), and they are all in `core`.

Clean them up, so that the lint can be enabled in the next commit.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2024-07-29 00:57:08 +02:00
Nicholas Nethercote
84ac80f192 Reformat use declarations.
The previous commit updated `rustfmt.toml` appropriately. This commit is
the outcome of running `x fmt --all` with the new formatting options.
2024-07-29 08:26:52 +10:00
Sören Meier
10da5553a8 Replace io::Cursor::{remaining_slice, is_empty} with io::Cursor::{split, split_mut} 2024-07-28 21:51:57 +02:00
Mark Rousskov
5eca36d27a step cfg(bootstrap) 2024-07-28 14:46:29 -04:00
Mark Rousskov
e8644f85b8 Update CURRENT_RUSTC_VERSION 2024-07-28 14:46:29 -04:00
Daria Sukhonina
0a5a84ee34 Add forbid(unsafe_op_in_unsafe_fn) 2024-07-28 21:10:59 +03:00
Guillaume Gomez
eeb76ccaf0
Rollup merge of #128240 - mbrubeck:patch-3, r=joboet
Add links from `assert_eq!` docs to `debug_assert_eq!`, etc.

This adds information and links from the docs for the following macros to their debug-only versions:

* `assert_eq!`
* `assert_ne!`
* `assert_matches!`

This matches the existing documentation for the `assert!` macro.
2024-07-28 20:07:46 +02:00
Guillaume Gomez
ee5956fd8a
Rollup merge of #128228 - slanterns:const_waker, r=dtolnay,oli-obk
Stabilize `const_waker`

Closes: https://github.com/rust-lang/rust/issues/102012.

For `local_waker` and `context_ext` related things, I just ~~moved them to dedicated feature gates and reused their own tracking issue (maybe it's better to open a new one later, but at least they should not be tracked under https://github.com/rust-lang/rust/issues/102012 from the beginning IMO.)~~ reused their own feature gates as suggested by ``@tgross35.``

``@rustbot`` label: +T-libs-api

r? libs-api
2024-07-28 20:07:46 +02:00
Guillaume Gomez
0e45047e81
Rollup merge of #128103 - folkertdev:unsigned-int-is-multiple-of, r=Amanieu
add `is_multiple_of` for unsigned integer types

tracking issue: https://github.com/rust-lang/rust/issues/128101

This adds the `.is_multiple_of` method on unsigned integers.

Returns `true` if `self` is an integer multiple of `rhs`, and false otherwise.

This function is equivalent to `self % rhs == 0`, except that it will not panic for `rhs == 0`. Instead, `0.is_multiple_of(0) == true`, and for any non-zero `n`, `n.is_multiple_of(0) == false`.
2024-07-28 20:07:45 +02:00
Guillaume Gomez
506a6317be
Rollup merge of #127765 - bitfield:fix_stdlib_doc_nits, r=dtolnay
Fix doc nits

Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo"), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits.
2024-07-28 20:07:44 +02:00