Commit Graph

11471 Commits

Author SHA1 Message Date
Igor Gutorov
001b081cc1 alloc: Allow comparing Boxs over different allocators 2023-06-18 06:19:35 +03:00
bors
371994e0d8 Auto merge of #112314 - ferrocene:pa-core-alloc-abort, r=bjorn3
Ignore `core`, `alloc` and `test` tests that require unwinding on `-C panic=abort`

Some of the tests for `core` and `alloc` require unwinding through their use of `catch_unwind`. These tests fail when testing using `-C panic=abort` (in my case through a target without unwinding support, and `-Z panic-abort-tests`), while they should be ignored as they don't indicate a failure.

This PR marks all of these tests with this attribute:

```rust
#[cfg_attr(not(panic = "unwind"), ignore = "test requires unwinding support")]
```

I'm not aware of a way to test this on rust-lang/rust's CI, as we don't test any target with `-C panic=abort`, but I tested this locally on a Ferrocene target and it does indeed make the test suite pass.
2023-06-13 19:03:27 +00:00
Pietro Albini
44556eed36
ignore core, alloc and test tests that require unwinding on panic=abort 2023-06-13 15:53:24 +02:00
bors
caeea3f0a2 Auto merge of #112575 - matthiaskrgr:rollup-7a8d7tg, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - #111885 (Don't ICE on unsized `extern "rust-call"` call)
 - #112558 (Fix typo in mod.rs)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-13 06:13:43 +00:00
Matthias Krüger
aee8e10a26
Rollup merge of #112558 - eltociear:patch-21, r=thomcc
Fix typo in mod.rs

assoicated -> associated
2023-06-13 07:02:28 +02:00
bors
de1ff0a8b5 Auto merge of #99339 - yanchith:binary-heap-ta, r=Amanieu
Make BinaryHeap parametric over Allocator

Tracking issue: #32838
Related: https://github.com/rust-lang/wg-allocators/issues/7

This parametrizes `BinaryHeap` with `A`, similarly to how other collections are parametrized.

A couple things I left out:

```
BinaryHeap::append

    Currently requires both structures to have the same allocator type. Could
    change, but depends on Vec::append, which has the same constraints.

impl<T: Ord> Default for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

impl<T: Ord> FromIterator<T> for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

impl<T: Ord, const N: usize> From<[T; N]> for BinaryHeap<T>

    Not parametrized, because there's nowhere to conjure the allocator from.

unsafe impl<I> AsVecIntoIter for IntoIter<I>

    AsVecIntoIter is not allocator aware, and I didn't dare change it without guidance. Is this something important?
```

I've seen very few tests for allocator_api in general, but I'd like to at least test this on some usage code in my projects before moving forward.

EDIT: Updated the list of impls and functions that are not affected by this. `BinaryHeap` no longer has a `SpecExtend` impl, and prior work made implementing `Extend` possible.
2023-06-13 03:23:12 +00:00
Ikko Eltociear Ashimine
69de7ca199
Fix typo in mod.rs
assoicated -> associated
2023-06-13 00:09:13 +09:00
bdbai
df08f56b08 Add comment for arm_shim in generate-windows-sys 2023-06-12 22:40:30 +08:00
bdbai
f7f25b0e2f Add windows_sys typedef for Win ARM32 2023-06-12 22:40:30 +08:00
Guillaume Gomez
7c5e41631d Revert "Fix intra-doc links from pointer appearing in windows HANDLE type alias"
This reverts commit 2ce7cd906b.
2023-06-12 11:18:28 +02:00
yanchith
e0e355dd25 Impl allocator function for iterators 2023-06-11 22:56:16 +02:00
yanchith
d9b6181d2f Remove explicit lifetimes 2023-06-11 22:42:50 +02:00
Matthias Krüger
0ff35f27b0
Rollup merge of #112497 - icecream17:patch-1, r=Mark-Simulacrum
abs_sub: fix typo 0[-:][+.]0
2023-06-11 01:57:28 +02:00
Matthias Krüger
e4f6b3d39e
Rollup merge of #112484 - bdbai:fix/uwpntdll, r=ChrisDenton
Fix ntdll linkage issues on Windows UWP platforms

See discussion: https://github.com/rust-lang/rust/issues/112265#issuecomment-1575479683

Static loading `ntdll` functions does not work for UWP programs, which will end up link errors complaining about missing symbols, or failure to pass the WACK tests. The breakage was introduced in #108262.

This PR basically reverts part of the changes in #108262 for UWP only, and fixes some lint suggestions.
2023-06-11 01:57:26 +02:00
icecream17
83d7826753
abs_sub: fix typo 0[-:][+.]0 2023-06-10 10:45:50 -05:00
bors
788c98df59 Auto merge of #111818 - Urgau:uplift_cmp_nan, r=cjgillot
Uplift `clippy::cmp_nan` lint

This PR aims at uplifting the `clippy::cmp_nan` lint into rustc.

## `invalid_nan_comparisons`

~~(deny-by-default)~~ (warn-by-default)

The `invalid_nan_comparisons` lint checks comparison with `f32::NAN` or `f64::NAN` as one of the operand.

### Example

```rust,compile_fail
let a = 2.3f32;
if a == f32::NAN {}
```

### Explanation

NaN does not compare meaningfully to anything – not even itself – so those comparisons are always false.

-----

Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler
2023-06-10 12:47:51 +00:00
bdbai
cd523f2f18 Keep uwp specific code in sync with windows-sys 2023-06-10 20:47:10 +08:00
bdbai
48e410e317 Lazy load ntdll functions on UWP 2023-06-10 16:34:20 +08:00
Urgau
3681285df7 Add diagnostic items for f32::NAN and f64::NAN 2023-06-09 17:46:33 +02:00
bors
397641f3bd Auto merge of #112465 - GuillaumeGomez:rollup-gyh5buc, r=GuillaumeGomez
Rollup of 3 pull requests

Successful merges:

 - #112260 (Improve document of `unsafe_code` lint)
 - #112429 ([rustdoc] List matching impls on type aliases)
 - #112442 (Deduplicate identical region constraints in new solver)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-06-09 15:37:22 +00:00
bors
d7ad9d9797 Auto merge of #111530 - Urgau:uplift_undropped_manually_drops, r=compiler-errors
Uplift `clippy::undropped_manually_drops` lint

This PR aims at uplifting the `clippy::undropped_manually_drops` lint.

## `undropped_manually_drops`

(warn-by-default)

The `undropped_manually_drops` lint check for calls to `std::mem::drop` with a value of `std::mem::ManuallyDrop` which doesn't drop.

### Example

```rust
struct S;
drop(std::mem::ManuallyDrop::new(S));
```

### Explanation

`ManuallyDrop` does not drop it's inner value so calling `std::mem::drop` will not drop the inner value of the `ManuallyDrop` either.

-----

Mostly followed the instructions for uplifting an clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

`@rustbot` label: +I-lang-nominated
r? compiler

-----

For Clippy:

changelog: Moves: Uplifted `clippy::undropped_manually_drops` into rustc
2023-06-09 12:44:23 +00:00
yanchith
4df4c0d00b Don't explicitly name Global 2023-06-09 12:19:17 +02:00
yanchith
767a7119a0 Pass tidy again 2023-06-09 12:02:25 +02:00
yanchith
208da513cc Add allocator function 2023-06-09 11:53:28 +02:00
yanchith
7a9f282528 Reallocatorize after merge 2023-06-09 11:48:11 +02:00
yanchith
cb5c011670 Merge branch 'master' into binary-heap-ta 2023-06-09 11:22:08 +02:00
Guillaume Gomez
2ce7cd906b Fix intra-doc links from pointer appearing in windows HANDLE type alias 2023-06-09 10:36:22 +02:00
Matthias Krüger
8747c0ebea
Rollup merge of #109953 - thomcc:thomcc/typeid128, r=WaffleLapkin
Use 128 bits for TypeId hash

Preliminary/Draft impl of https://github.com/rust-lang/compiler-team/issues/608

Prior art (probably incomplete list)
- https://github.com/rust-lang/rust/pull/75923
- https://github.com/rust-lang/rust/pull/95845
2023-06-08 12:36:17 +02:00
Urgau
d9d1c76ded Allow undropped_manually_drops for some tests 2023-06-08 11:41:34 +02:00
bors
80917360d3 Auto merge of #112292 - thomcc:tls-ohno, r=m-ou-se
Avoid unwind across `extern "C"` in `thread_local::fast_local`

This is a minimal fix for #112285, in case we want a simple patch that can be easily to backported if that's desirable.

*(Note: I have another broader cleanup which I've mostly omitted from here to avoid clutter, except for the `Cell` change, which isn't needed to fix UB, but simplifies safety comments).*

The only tier-1 target that this occurs on in a way that seems likely to cause problems in practice linux-gnu, although I believe some folks care about that platform somewhat 😉. I'm unsure how big of an issue this is. I've seen stuff like this behave quite badly, but there's a number of reasons to think this might actually be "fine in practice".

I've hedged my bets and assumed we'll backport this at least to beta but my feeling is that there's not enough evidence this is a problem worth backporting further than that.

### More details

This issue seems to have existed since `thread_local!`'s `const` init functionality was added. It occurs if you have a `const`-initialized thread local for a type that `needs_drop`, the drop panics, and you're on a target with support for static thread locals. In this case, we will end up defining an `extern "C"` function in the user crate rather than in libstd, and because the user crate will not have `#![feature(c_unwind)]` enabled, their panic will not be caught by an auto-inserted abort guard.

In practice, the actual situation where problems are likely[^ub] is somewhat narrower.

On most targets with static thread locals, we manage the TLS dtor list by hand (for reentrancy reasons among others). In these cases, while the users code may panic, we're calling it inside our own `extern "C"` (or `extern "system"`) function, which seems to (at least in practice) catch the panic and convert it to an abort.

However, on a few targets, most notably linux-gnu with recent glibc (but also fuchsia and redox), a tls dtor registration mechanism exists which we can actually use directly, [`__cxa_thread_atexit_impl`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys/unix/thread_local_dtor.rs#L26-L36).

This is the case that seems most likely to be a cause for concern, as now we're passing a function to the system library and panicking out of it in a case where there are may not be Rust frames above it on the call stack (since it's running thread shutdown), and even if there were, it may not be prepared to handle such unwinding. If that's the case, it'd be bad.

Is it? Dunno. The fact that it's a `__cxa_*` function makes me think they probably have considered that the callback could throw but I have no evidence here and it doesn't seem to be written down anywhere, so it's just a guess. (I would not be surprised if someone comes into this thread to tell me how definitely-bad-news it is).

That said, as I said, all this is actually UB! If this isn't a "technically UB but fine in practice", but all bets are off if this is the kind of thing we are telling LLVM about.

[^ub]: This is UB so take that with a grain of salt -- I'm absolutely making assumptions about how the UB will behave "in practice" here, which is almost certainly a mistake.
2023-06-08 04:44:08 +00:00
Thom Chiovoloni
b512004a4a
Fix typo
Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2023-06-07 21:27:51 -07:00
bors
10b7e468f3 Auto merge of #96875 - SabrinaJewson:noop-waker, r=m-ou-se
Add `task::Waker::noop`

I have found myself reimplementing this function many times when I need a `Context` but don't have a runtime or `futures` to hand.

Prior art: [`futures::task::noop_waker`](https://docs.rs/futures/0.3/futures/task/fn.noop_waker.html) and [`futures::task::noop_waker_ref`](https://docs.rs/futures/0.3/futures/task/fn.noop_waker_ref.html)

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

Unresolved questions:
1. Should we also add `RawWaker::noop()`? (I don't think so, I can't think of a use case for it)
2. Should we also add `Context::noop()`? Depending on the future direction `Context` goes a "noop context" might not even make sense in future.
3. Should it be an associated constant instead? That would allow for `let cx = &mut Context::from_waker(&Waker::NOOP);` to work on one line which is pretty nice. I don't really know what the guideline is here.

r? rust-lang/libs-api `@rustbot` label +T-libs-api -T-libs
2023-06-07 06:04:32 +00:00
bors
b3dd578767 Auto merge of #111819 - nikarh:vita-improved, r=Amanieu
Improved std support for ps vita target

Fixed a couple of things in std support for ps vita via Vita SDK newlib oss implementation:

- Added missing hardware features to target spec
- Compile in thumb by default (newlib is also compiled in thumb)
- Fixed fs calls. Vita newlib has a not-very-posix dirent. Also vita does not expose inodes, it's stubbed as 0 in stat, and I'm stubbing it here for dirent (because vita newlibs's dirent doesn't even have that field)
- Enabled signal handlers for panic unwinding
- Dropped static link requirement from the platform support md. Also, rearranged sections to better stick with the template.
2023-06-07 03:20:15 +00:00
Nikolay Arhipov
032857e7e4 Bumped libc version 2023-06-06 16:09:05 +03:00
Nikolay Arhipov
ac48d49ff8 Simplified bool to int conversion 2023-06-05 19:26:04 +03:00
Nikolay Arhipov
50117af409 Std support improvement for ps vita target 2023-06-05 19:14:09 +03:00
Guillaume Gomez
200d03acad
Rollup merge of #112263 - GrishaVar:remove-extend-element, r=scottmcm
Remove ExtendElement, ExtendWith, extend_with

Related to  #104624, broken up into two commits. The first removes wrapper trait ExtendWith and its only implementer struct ExtendElement. The second may have perf issues so may be reverted/removed if no alternate fix is found; it should be profiled.

r? `@scottmcm`
2023-06-05 17:02:51 +02:00
Thom Chiovoloni
70e1dc9967
Avoid unwind across extern "C" in thread_local::fast_local.rs 2023-06-04 14:54:28 -07:00
Thom Chiovoloni
9e5573a0d2
Use 128 bits for TypeId hash
- Switch TypeId to 128 bits
- Hack around the fact that tracing-subscriber dislikes how TypeId is hashed
- Remove lowering of type_id128 from rustc_codegen_llvm
- Remove unnecessary `type_id128` intrinsic (just change return type of `type_id`)
- Only hash the lower 64 bits of the TypeId
- Reword comment
2023-06-04 08:34:48 -07:00
Grisha Vartanyan
dd2bd03d0a Remove ExtendWith and ExtendElement 2023-06-04 15:55:34 +02:00
Matthias Krüger
cbc3e3f641
Rollup merge of #112172 - tshepang:patch-1, r=Mark-Simulacrum
doc: improve explanation
2023-06-04 13:21:27 +02:00
Matthias Krüger
7ee2505529
Rollup merge of #109093 - Dante-Broggi:patch-2, r=joshtriplett
add `#[doc(alias="flatmap")]` to `Option::and_then`

I keep forgetting that rust calls this `and_then` and trying to search for `flatmap`. `and_then`'s docs even mention "Some languages call this operation flatmap", but it doesn't show up as a result in the search at `https://doc.rust-lang.org/std/?search=flatmap`
2023-06-04 13:21:25 +02:00
Matthias Krüger
6e024ecab8
Rollup merge of #111702 - cgwalters:option-map-or-else-with-result, r=Mark-Simulacrum
Option::map_or_else: Show an example of integrating with Result

Moving this from https://github.com/rust-lang/libs-team/issues/59 where an API addition was rejected.  But I think it's valuable to add this example to the documentation at least.
2023-06-03 20:38:11 +02:00
bors
1e17cef9e2 Auto merge of #109432 - flba-eb:108594_forkspawn_exponential_backoff, r=workingjubilee
QNX Neutrino: exponential backoff when fork/spawn needs a retry

Fixes #108594: When retrying, sleep with an exponential duration. When sleep duration is lower than minimum possible sleeping time, yield instead (this will not be often due to the exponential increase of duration).

Minimum possible sleeping time is determined using `libc::clock_getres` but only when spawn/fork failed the first time in a request. This is cached using a LazyLock.

CC `@gh-tr`

r? `@workingjubilee`
`@rustbot` label +O-neutrino
2023-06-03 10:06:59 +00:00
Matthias Krüger
4435544c35
Rollup merge of #112206 - k0ur0x:typo, r=Nilstrieb
Fix typo in `std::cell` module docs
2023-06-02 18:12:47 +02:00
Matthias Krüger
a3b639ce43
Rollup merge of #111647 - klensy:cstr, r=oli-obk
use c literals in compiler and library

Use c literals #108801 in compiler and library

currently blocked on:
* <strike>rustfmt: don't know how to format c literals</strike> nope, nightly one works.
* <strike>bootstrap</strike>

r? `@ghost`
`@rustbot` blocked
2023-06-02 18:12:45 +02:00
Florian Bartels
716cc5ac93 Only determine clock res once; give up before sleeping more than 1 second 2023-06-02 17:52:14 +02:00
Florian Bartels
bdb475cf6c Retry to fork/spawn with exponential backoff 2023-06-02 16:12:21 +02:00
Kourosh
9df4572277
Fix typo in std::cell module docs 2023-06-02 15:30:40 +03:30
klensy
2f459f7f14 fix ptr cast 2023-06-02 11:26:34 +03:00