Commit Graph

13773 Commits

Author SHA1 Message Date
Matthias Krüger
e13f454874
Rollup merge of #119590 - ChrisDenton:cfg-target-abi, r=Nilstrieb
Stabilize `cfg_target_abi`

This stabilizes the `cfg` option called `target_abi`:

```rust
#[cfg(target_abi = "eabihf")]
```

Tracking issue: #80970

fixes #78791
resolves #80970
2024-02-25 17:05:19 +01:00
bors
a2f3c0cf88 Auto merge of #117107 - zachs18:mapped-mutex-guard, r=Amanieu
Implement `MappedMutexGuard`, `MappedRwLockReadGuard`, and `MappedRwLockWriteGuard`.

ACP: https://github.com/rust-lang/libs-team/issues/260
Tracking issue: https://github.com/rust-lang/rust/issues/117108

<details> <summary> (Outdated) </summary>

`MutexState`/`RwLockState` structs

~~Having `sys::(Mutex|RwLock)` and `poison::Flag` as separate fields in the `Mutex`/`RwLock` would require `MappedMutexGuard`/`MappedRwLockWriteGuard` to hold an additional pointer, so I combined the two fields into a `MutexState`/`RwLockState` struct. This should not noticeably affect perf or layout, but requires an additional field projection when accessing the former `.inner` or `.poison` fields (now `.state.inner` and `.state.poison`).~~ If this is not desired, then `MappedMutexGuard`/`MappedRwLockWriteGuard` can instead hold separate pointers to the two fields.

</details>

The doc-comments are mostly copied from the existing `*Guard` doc-comments, with some parts from `lock_api::Mapped*Guard`'s doc-comments.

Unresolved question: Are more tests needed?
2024-02-25 05:59:54 +00:00
bors
e9f9594913 Auto merge of #121114 - Nilstrieb:no-inline!, r=saethlin
Add `#[rustc_no_mir_inline]` for standard library UB checks

should help with #121110 and also with #120848

Because the MIR inliner cannot know whether the checks are enabled or not, so inlining is an unnecessary compile time pessimization when debug assertions are disabled. LLVM knows whether they are enabled or not, so it can optimize accordingly without wasting time.

r? `@saethlin`
2024-02-25 03:47:31 +00:00
bors
2ae1bb6711 Auto merge of #121569 - matthiaskrgr:rollup-awglrax, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #121343 (Add examples for some methods on slices)
 - #121374 (match lowering: Split off `test_candidates` into several functions and improve comments)
 - #121474 (Ignore compiletest test directive migration commits)
 - #121515 (promotion: don't promote int::MIN / -1)
 - #121530 (Fix incorrect doc of ScopedJoinHandle::is_finished)
 - #121551 (Forbid use of `extern "C-unwind"` inside standard library)
 - #121556 (Use `addr_of!`)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-24 23:08:21 +00:00
Matthias Krüger
4c401531f5
Rollup merge of #121556 - GrigorenkoPV:addr_of, r=Nilstrieb
Use `addr_of!`

As per https://github.com/rust-lang/rust/pull/121303#discussion_r1500954662
2024-02-24 22:39:01 +01:00
Matthias Krüger
9975e848ff
Rollup merge of #121551 - nbdd0121:ffi_unwind, r=RalfJung
Forbid use of `extern "C-unwind"` inside standard library

Those libraries are build with `-C panic=unwind` and is expected to be linkable to `-C panic=abort` library. To ensure unsoundness compiler needs to prevent a `C-unwind` call to exist, as doing so may leak foreign exceptions into `-C panic=abort`.

r? ``@RalfJung``
2024-02-24 22:39:00 +01:00
Matthias Krüger
106e30ed41
Rollup merge of #121530 - wgslr:master, r=Mark-Simulacrum
Fix incorrect doc of ScopedJoinHandle::is_finished

Fixes the explanation how to use `is_finished` to achieve a non-blocking join. The updated version matches the documentation of the non-scoped JoinHandle::is_finished.
2024-02-24 22:39:00 +01:00
Matthias Krüger
ed75229a97
Rollup merge of #121343 - Takashiidobe:takashi/examples-for-slice, r=Mark-Simulacrum
Add examples for some methods on slices

Adds some examples to some methods on slice.

`is_empty` didn't have an example for an empty slice, even though `str` and the collections all have one, so I added that in.

`first_mut` and `last_mut` didn't have an example for what happens when the slice is empty, whereas `first` and `last` do, so I added that too.
2024-02-24 22:38:58 +01:00
Chris Denton
93ec0e6299
Stabilize cfg_target_abi 2024-02-24 17:52:03 -03:00
Nilstrieb
81d7069e34 Add #[rustc_no_mir_inline] for standard library UB checks
Co-authored-by: Ben Kimock <kimockb@gmail.com>
2024-02-24 21:19:41 +01:00
Gary Guo
f08e2d4137 Forbid use of extern "C-unwind" inside standard library
Those libraries are build with `-C panic=unwind` and is expected to
be linkable to `-C panic=abort` library. To ensure unsoundness
compiler needs to prevent a `C-unwind` call to exist, as doing so may leak
foreign exceptions into `-C panic=abort`.
2024-02-24 14:53:04 +00:00
Pavel Grigorenko
ff187a92d8
library: use addr_of! 2024-02-24 16:02:17 +03:00
Ralf Jung
55ee14005f update stdarch 2024-02-24 12:15:21 +01:00
zachs18
8aaa04b5c5
Apply suggestions from code review
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2024-02-23 20:18:04 -06:00
Wojciech Geisler
7234c9893d Fix incorrect doc of ScopedJoinHandle::is_finished
Fixes the explanation how to use is_finished to achieve a non-blocking
join. The updated version matches the documentation of the non-scoped
JoinHandle::is_finished.
2024-02-24 00:39:00 +02:00
bors
8f359beca4 Auto merge of #119536 - Jules-Bertholet:const-barrier, r=dtolnay
Make `Barrier::new()` const

I guess this was just missed in #97791?

`@rustbot` label T-libs-api -T-libs
2024-02-23 20:54:02 +00:00
bors
2dbd6233cc Auto merge of #121303 - GrigorenkoPV:static_mut_refs, r=oli-obk,RalfJung
Get rid of some `#![allow(static_mut_refs)]`
2024-02-23 18:52:47 +00:00
bors
21033f637e Auto merge of #121514 - matthiaskrgr:rollup-5f0vhv7, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #120742 (mark `min_exhaustive_patterns` as complete)
 - #121470 (Don't ICE on anonymous struct in enum variant)
 - #121492 (coverage: Rename `is_closure` to `is_hole`)
 - #121495 (remove repetitive words)
 - #121498 (Make QNX/NTO specific "timespec capping" public to crate::sys)
 - #121510 (lint-overflowing-ops: unify cases and remove redundancy)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-23 16:26:49 +00:00
Matthias Krüger
2e8177a208
Rollup merge of #121498 - flba-eb:make_timespec_capping_public, r=Nilstrieb
Make QNX/NTO specific "timespec capping" public to crate::sys

It is used in:

- `library/std/src/sys/locks/condvar/pthread.rs`
- `library/std/src/sys/pal/unix/thread_parking/pthread.rs`

This is probably required due to introduction of `sys/pal` and #121177

`@rustbot` label +O-neutrino
CC: `@jonathanpallant` `@japaric` `@gh-tr`
2024-02-23 17:02:05 +01:00
Pavel Grigorenko
58c8c0853f
Get rid of some #[allow(static_mut_refs)] 2024-02-23 18:02:25 +03:00
bors
b6a23b8537 Auto merge of #121454 - reitermarkus:generic-nonzero-library, r=dtolnay
Use generic `NonZero` everywhere in `library`.

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

Use generic `NonZero` everywhere (except stable examples).

r? `@dtolnay`
2024-02-23 14:27:33 +00:00
Florian Bartels
4f66783240 Make timespec capping public to crate::sys
It is used in:

- `library/std/src/sys/locks/condvar/pthread.rs`
- `library/std/src/sys/pal/unix/thread_parking/pthread.rs`
2024-02-23 11:43:27 +01:00
cui fliter
824d75c22e remove repetitive words
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-02-23 18:26:01 +08:00
bors
a28d221a4b Auto merge of #120730 - estebank:confusable-api, r=oli-obk
Provide suggestions through `rustc_confusables` annotations

Help with common API confusion, like asking for `push` when the data structure really has `append`.

```
error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope
  --> $DIR/rustc_confusables_std_cases.rs:17:7
   |
LL |     x.size();
   |       ^^^^
   |
help: you might have meant to use `len`
   |
LL |     x.len();
   |       ~~~
help: there is a method with a similar name
   |
LL |     x.resize();
   |       ~~~~~~
```

Fix #59450 (we can open subsequent tickets for specific cases).

Fix #108437:

```
error[E0599]: `Option<{integer}>` is not an iterator
   --> f101.rs:3:9
    |
3   |     opt.flat_map(|val| Some(val));
    |         ^^^^^^^^ `Option<{integer}>` is not an iterator
    |
   ::: /home/gh-estebank/rust/library/core/src/option.rs:571:1
    |
571 | pub enum Option<T> {
    | ------------------ doesn't satisfy `Option<{integer}>: Iterator`
    |
    = note: the following trait bounds were not satisfied:
            `Option<{integer}>: Iterator`
            which is required by `&mut Option<{integer}>: Iterator`
help: you might have meant to use `and_then`
    |
3   |     opt.and_then(|val| Some(val));
    |         ~~~~~~~~
```

On type error of method call arguments, look at confusables for suggestion. Fix #87212:

```
error[E0308]: mismatched types
    --> f101.rs:8:18
     |
8    |     stuff.append(Thing);
     |           ------ ^^^^^ expected `&mut Vec<Thing>`, found `Thing`
     |           |
     |           arguments to this method are incorrect
     |
     = note: expected mutable reference `&mut Vec<Thing>`
                           found struct `Thing`
note: method defined here
    --> /home/gh-estebank/rust/library/alloc/src/vec/mod.rs:2025:12
     |
2025 |     pub fn append(&mut self, other: &mut Self) {
     |            ^^^^^^
help: you might have meant to use `push`
     |
8    |     stuff.push(Thing);
     |           ~~~~
```
2024-02-23 00:42:56 +00:00
Esteban Küber
f566867ace Add flatmap/flat_map -> and_then suggestions 2024-02-22 18:05:28 +00:00
Esteban Küber
0e89465672 On type error of method call arguments, look at confusables for suggestion 2024-02-22 18:04:55 +00:00
Esteban Küber
e5b3c7ef14 Add rustc_confusables annotations to some stdlib APIs
Help with common API confusion, like asking for `push` when the data structure really has `append`.

```
error[E0599]: no method named `size` found for struct `Vec<{integer}>` in the current scope
  --> $DIR/rustc_confusables_std_cases.rs:17:7
   |
LL |     x.size();
   |       ^^^^
   |
help: you might have meant to use `len`
   |
LL |     x.len();
   |       ~~~
help: there is a method with a similar name
   |
LL |     x.resize();
   |       ~~~~~~
```

#59450
2024-02-22 18:04:55 +00:00
Matthias Krüger
e064bf639b
Rollup merge of #121439 - jrudolph:patch-1, r=bjorn3
Fix typo in metadata.rs doc comment
2024-02-22 18:09:55 +01:00
Markus Reiter
b74d8db9d2
Fix example. 2024-02-22 17:16:29 +01:00
Markus Reiter
0c474acdfa
Use generic NonZero everywhere else. 2024-02-22 15:17:34 +01:00
Markus Reiter
36d194f561
Use generic NonZero everywhere in alloc. 2024-02-22 15:17:34 +01:00
Markus Reiter
e0732e42d8
Use generic NonZero everywhere in std. 2024-02-22 15:17:33 +01:00
Markus Reiter
14ed426eec
Use generic NonZero everywhere in core. 2024-02-22 15:17:33 +01:00
bors
1bb3a9f67a Auto merge of #121309 - Nilstrieb:inline-all-the-fallbacks, r=oli-obk
Make intrinsic fallback bodies cross-crate inlineable

This change was prompted by the stage1 compiler spending 4% of its time when compiling the polymorphic-recursion MIR opt test in `unlikely`.

Intrinsic fallback bodies like `unlikely` should always be inlined, it's very silly if they are not. To do this, we enable the fallback bodies to be cross-crate inlineable. Not that this matters for our workloads since the compiler never actually _uses_ the "fallback bodies", it just uses whatever was cfg(bootstrap)ped, so I've also added `#[inline]` to those.

See the comments for more information.

r? oli-obk
2024-02-22 12:07:08 +00:00
Johannes Rudolph
c276af2373
Fix typo in metadata.rs doc comment 2024-02-22 09:30:03 +01:00
bors
026b3b8e95 Auto merge of #117174 - Ayush1325:uefi-stdio-improve, r=workingjubilee
Improve UEFI stdio

Fixed some things suggested in last PR: #116207

cc `@dvdhrm`
cc `@nicholasbishop`
2024-02-22 06:01:24 +00:00
bors
c1b478efd3 Auto merge of #121223 - RalfJung:simd-intrinsics, r=Amanieu
intrinsics::simd: add missing functions, avoid UB-triggering fast-math

Turns out stdarch declares a bunch more SIMD intrinsics that are still missing from libcore.
I hope I got the docs and in particular the safety requirements right for these "unordered" and "nanless" intrinsics.

Many of these are unused even in stdarch, but they are implemented in the codegen backend, so we may as well list them here.

r? `@Amanieu`
Cc `@calebzulawski` `@workingjubilee`
2024-02-22 04:02:31 +00:00
bors
c5f69bdd51 Auto merge of #118634 - Jules-Bertholet:box-allocator-static, r=Amanieu
Remove useless `'static` bounds on `Box` allocator

#79327 added `'static` bounds to the allocator parameter for various `Box` + `Pin` APIs to ensure soundness. But it was a bit overzealous, some of the bounds aren't actually needed.
2024-02-22 02:03:29 +00:00
Ralf Jung
07b6240947 remove simd_reduce_{min,max}_nanless 2024-02-21 20:50:47 +01:00
Ralf Jung
b58f647d54 rename ptr::invalid -> ptr::without_provenance
also introduce ptr::dangling matching NonNull::dangling
2024-02-21 20:15:52 +01:00
Ralf Jung
3dc631a61a make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all fast-math flags 2024-02-21 16:28:20 +01:00
Ralf Jung
25fe3cc69d intrinsics::simd: add missing functions 2024-02-21 16:26:32 +01:00
bors
1d447a9946 Auto merge of #121383 - Dylan-DPC:rollup-735p4u4, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #121208 (Convert `delayed_bug`s to `bug`s.)
 - #121288 (make rustc_expand translatable)
 - #121304 (Add docs for extension proc-macro)
 - #121328 (Make --verbose imply -Z write-long-types-to-disk=no)
 - #121338 (Downgrade ambiguous_wide_pointer_comparisons suggestions to MaybeIncorrect)
 - #121361 (diagnostic items for legacy numeric modules)
 - #121375 (Print proper relative path for descriptive name check)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-21 12:09:22 +00:00
bors
bb8b11e67d Auto merge of #120718 - saethlin:reasonable-fast-math, r=nnethercote
Add "algebraic" fast-math intrinsics, based on fast-math ops that cannot return poison

Setting all of LLVM's fast-math flags makes our fast-math intrinsics very dangerous, because some inputs are UB. This set of flags permits common algebraic transformations, but according to the [LangRef](https://llvm.org/docs/LangRef.html#fastmath), only the flags `nnan` (no nans) and `ninf` (no infs) can produce poison.

And this uses the algebraic float ops to fix https://github.com/rust-lang/rust/issues/120720

cc `@orlp`
2024-02-21 09:43:33 +00:00
Dylan DPC
860ad7c10b
Rollup merge of #121361 - pitaj:diag_items-legacy_numeric_constants, r=Nilstrieb
diagnostic items for legacy numeric modules

For https://github.com/rust-lang/rust-clippy/pull/12312

Missed these in #121272

r? `@Nilstrieb`
2024-02-21 08:55:58 +00:00
Peter Jaszkowiak
0195f21f72 diagnostic items for legacy numeric modules 2024-02-20 13:34:18 -07:00
Matthias Krüger
c03f61ba69
Rollup merge of #121352 - malobre:patch-1, r=Nilstrieb
docs: add missing "the" to `str::strip_prefix` doc

Fix #121348
2024-02-20 19:35:42 +01:00
Matthias Krüger
3099a7931a
Rollup merge of #121277 - reitermarkus:generic-nonzero-convert-num, r=dtolnay
Refactor trait implementations in `core::convert::num`.

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

Implement conversion traits using generic `NonZero` type, and refactor all macros to use a consistent format/order of parameters.

r? `@dtolnay`
2024-02-20 19:35:40 +01:00
Matthias Krüger
fc5f6f88e5
Rollup merge of #119203 - farnoy:simd-masked-intrinsic-docfix, r=RalfJung
Correct the simd_masked_{load,store} intrinsic docs

Explains the uniform pointer being used for these two operations and how elements are offset from it.
2024-02-20 19:35:39 +01:00
Ben Kimock
cc73b71e8e Add "algebraic" versions of the fast-math intrinsics 2024-02-20 12:39:03 -05:00