Commit Graph

10876 Commits

Author SHA1 Message Date
Yuki Okushi ed5e2ddeed
Rollup merge of #109883 - skaunov:patch-1, r=thomcc
Add links to <cell.rs>

`UnsafeCell` page could benefit too from having links to these most popular structs in the module.
2023-04-04 05:52:34 +09:00
bors 1767585509 Auto merge of #109756 - cr1901:msp-shift, r=Mark-Simulacrum
Update compiler-builtins to 0.1.91 to bring in msp430 shift primitive…

… fixes.

This fixes unsoundness on MSP430 where `compiler-builtins` and LLVM didn't agree on the width of the shift amount argument of the shifting primitives (4 bytes vs 2 bytes). See https://github.com/rust-lang/compiler-builtins/pull/522 for more details.
2023-04-03 13:09:08 +00:00
bors f13ccefb5b Auto merge of #108448 - ishitatsuyuki:binary-heap, r=Mark-Simulacrum
binary_heap: Optimize Extend implementation.

This PR makes the `Extend` implementation for `BinaryHeap` no longer rely on specialization, so that it always use the bulk rebuild optimization that was previously only available for the `Vec` specialization.
2023-04-03 10:30:20 +00:00
Matthias Krüger f2f5efce9c
Rollup merge of #109722 - hermitcore:read, r=Mark-Simulacrum
Implement read_buf for RustHermit

In principle, this PR extends rust-lang/rust#108326 for RustyHermit.
2023-04-03 08:58:53 +02:00
Sergey Kaunov abc61d23de
Add links to <cell.rs>
`UnsafeCell` page could benefit too from having links to these most popular structs in the module.
2023-04-03 09:18:14 +03:00
bors 11cd4ff34d Auto merge of #109852 - Nilstrieb:rollup-g3mgxxw, r=Nilstrieb
Rollup of 4 pull requests

Successful merges:

 - #109839 (Improve grammar of Iterator.partition_in_place)
 - #109840 (Fix typo in std/src/os/fd/owned.rs)
 - #109844 (a couple clippy::complexity fixes)
 - #109846 (more clippy::complexity fixes (iter_kv_map, map_flatten, nonminimal_bool))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-02 09:39:41 +00:00
Nilstrieb 099f3469a9
Rollup merge of #109840 - taiki-e:typo, r=ChrisDenton
Fix typo in std/src/os/fd/owned.rs
2023-04-02 10:08:34 +02:00
Nilstrieb a38bdd4439
Rollup merge of #109839 - sartak:iter-grammar, r=scottmcm
Improve grammar of Iterator.partition_in_place

This is my first PR against Rust, please let me know if there's anything I should be providing here! I didn't find any instructions specific to documentation grammar in the [std-dev guide](https://std-dev-guide.rust-lang.org/documentation/summary.html).
2023-04-02 10:08:33 +02:00
bors 637d7fdb23 Auto merge of #109701 - Amanieu:binaryheap_retain, r=ChrisDenton
Stabilize `binary_heap_retain`

FCP finished in tracking issue: #71503
2023-04-02 07:04:01 +00:00
bors 0599b6b931 Auto merge of #109483 - joboet:optimize_lazycell, r=Mark-Simulacrum
Optimize `LazyCell` size

`LazyCell` can only store either the initializing function or the data it produces, so it does not need to reserve the space for both. Similar to #107329, but uses an `enum` instead of a `union`.
2023-04-01 20:11:49 +00:00
Taiki Endo 455a9601da Fix typo in std/src/os/fd/owned.rs 2023-04-02 02:14:37 +09:00
Shawn M Moore ec71feb984 Improve grammar of Iterator.partition_in_place
b9535c0b7d Auto merge of #109801 - aliemjay:test-implied-normalization, r=petrochenkov
2023-04-01 13:01:00 -04:00
Guillaume Gomez 6c93c63771
Rollup merge of #109443 - GuillaumeGomez:doc-primitive-hard-error, r=notriddle
Move `doc(primitive)` future incompat warning to `invalid_doc_attributes`

Fixes #88070.

It's been a while since this was turned into a "future incompatible lint" so I think we can now turn it into a hard error without problem.

r? `@jyn514`
2023-03-31 22:32:49 +02:00
bors 22a7a19f93 Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obk
Insert alignment checks for pointer dereferences when debug assertions are enabled

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

- [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit)
- [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue!
- [x] Implement a more helpful panic message like slice bounds checking.

r? `@oli-obk`
2023-03-31 08:50:35 +00:00
Matthias Krüger ec276c7e67
Rollup merge of #109793 - lukas-code:negative-impl-comment, r=scottmcm
add comment to `impl !Error for &str`

I saw this impl in the [standard library docs](https://doc.rust-lang.org/nightly/core/error/trait.Error.html#impl-Error-for-%26str) and wondered why it's needed. This commit adds a comment to explain its existence.
2023-03-31 08:03:15 +02:00
Matthias Krüger 0708fbf5cb
Rollup merge of #109784 - beetrees:riscv32-time64, r=cuviper
Refactor glibc time64 support, riscv32 always has 64-bit `time_t`

Refactor existing support for 64-bit `time_t` on 32-bit glibc platforms, as riscv32 `time_t` is 64-bit by default. Split out of #109773.
2023-03-31 08:03:15 +02:00
Matthias Krüger 41369b734d
Rollup merge of #109598 - veera-sivarajan:improve-wording, r=thomcc
Improve documentation for str::replace() and str::replacen()

Currently, to know what the function will return when the pattern doesn't match, the docs require the reader to understand the implementation detail and mentally evaluate or run the example code. It is not immediately clear.

This PR makes it more explicit so the reader can quickly find the information.
2023-03-31 08:03:14 +02:00
Guillaume Gomez 364e961417 Replace doc(primitive) with rustc_doc_primitive 2023-03-30 22:56:52 +02:00
Lukas Markeffsky bdb0c7f427 add comment to `impl !Error for &str` 2023-03-30 22:19:28 +02:00
beetrees 8d1bf505ff
Refactor glibc time64 support, riscv32 always has 64-bit `time_t` 2023-03-30 19:43:47 +01:00
joboet af080bf04b
fix typo and adjust comment
Co-authored-by: Ralf Jung <post@ralfj.de>
2023-03-30 14:49:43 +02:00
joboet 97d49fcf60
core: use `pointer::write` to cleanup `LazyCell` initialization 2023-03-30 14:49:43 +02:00
joboet c7f9739bad
core: improve code documentation for `LazyCell` 2023-03-30 14:49:43 +02:00
joboet f015e6fe49
core: optimize `LazyCell` size 2023-03-30 14:49:42 +02:00
bors 516a6d3202 Auto merge of #109769 - JohnTitor:rollup-7n2bnpg, r=JohnTitor
Rollup of 7 pull requests

Successful merges:

 - #106985 (Enhanced doucmentation of binary search methods for `slice` and `VecDeque` for unsorted instances)
 - #109509 (compiletest: Don't allow tests with overlapping prefix names)
 - #109719 (RELEASES: Add "Only support Android NDK 25 or newer" to 1.68.0)
 - #109748 (Don't ICE on `DiscriminantKind` projection in new solver)
 - #109749 (Canonicalize float var as float in new solver)
 - #109761 (Drop binutils on powerpc-unknown-freebsd)
 - #109766 (Fix title for openharmony.md)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-30 12:44:25 +00:00
Yuki Okushi d6f27401f1
Rollup merge of #106985 - jofas:106746-fix, r=ChrisDenton
Enhanced doucmentation of binary search methods for `slice` and `VecDeque` for unsorted instances

Fixes #106746. Issue #106746 raises the concern that the binary search methods for slices and deques aren't explicit enough about the fact that they are only applicable to sorted slices/deques. I changed the explanation for these methods. I took the relatively harsh description of the behaviour of binary search on unsorted collections ("unspecified and meaningless") from the description of the [`partition_point`](https://doc.rust-lang.org/std/primitive.slice.html#method.partition_point) method:

> If this slice is not partitioned, the returned result is unspecified and meaningless, as this method performs a kind of binary search.
2023-03-30 21:06:59 +09:00
bors 8a7ca936e6 Auto merge of #105587 - tgross35:once-cell-min, r=m-ou-se
Partial stabilization of `once_cell`

This PR aims to stabilize a portion of the `once_cell` feature:

- `core::cell::OnceCell`
- `std::cell::OnceCell` (re-export of the above)
- `std::sync::OnceLock`

This will leave `LazyCell` and `LazyLock` unstabilized, which have been moved to the `lazy_cell` feature flag.

Tracking issue: https://github.com/rust-lang/rust/issues/74465 (does not fully close, but it may make sense to move to a new issue)

Future steps for separate PRs:
- ~~Add `#[inline]` to many methods~~ #105651
- Update cranelift usage of the `once_cell` crate
- Update rust-analyzer usage of the `once_cell` crate
- Update error messages discussing once_cell

## To be stabilized API summary

```rust
// core::cell (in core/cell/once.rs)

pub struct OnceCell<T> { .. }

impl<T> OnceCell<T> {
    pub const fn new() -> OnceCell<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceCell<T>;
impl<T: Debug> Debug for OnceCell<T>
impl<T> Default for OnceCell<T>;
impl<T> From<T> for OnceCell<T>;
impl<T: PartialEq> PartialEq for OnceCell<T>;
impl<T: Eq> Eq for OnceCell<T>;
```

```rust
// std::sync (in std/sync/once_lock.rs)

impl<T> OnceLock<T> {
    pub const fn new() -> OnceLock<T>;
    pub fn get(&self) -> Option<&T>;
    pub fn get_mut(&mut self) -> Option<&mut T>;
    pub fn set(&self, value: T) -> Result<(), T>;
    pub fn get_or_init<F>(&self, f: F) -> &T where F: FnOnce() -> T;
    pub fn into_inner(self) -> Option<T>;
    pub fn take(&mut self) -> Option<T>;
}

impl<T: Clone> Clone for OnceLock<T>;
impl<T: Debug> Debug for OnceLock<T>;
impl<T> Default for OnceLock<T>;
impl<#[may_dangle] T> Drop for OnceLock<T>;
impl<T> From<T> for OnceLock<T>;
impl<T: PartialEq> PartialEq for OnceLock<T>
impl<T: Eq> Eq for OnceLock<T>;
impl<T: RefUnwindSafe + UnwindSafe> RefUnwindSafe for OnceLock<T>;
unsafe impl<T: Send> Send for OnceLock<T>;
unsafe impl<T: Sync + Send> Sync for OnceLock<T>;
impl<T: UnwindSafe> UnwindSafe for OnceLock<T>;
```

No longer planned as part of this PR, and moved to the `rust_cell_try` feature gate:

```rust
impl<T> OnceCell<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}

impl<T> OnceLock<T> {
    pub fn get_or_try_init<F, E>(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result<T, E>;
}
```

I am new to this process so would appreciate mentorship wherever needed.
2023-03-30 10:12:23 +00:00
jofas b085007313 removed deprecated markdown links from documentation 2023-03-30 10:20:57 +02:00
William D. Jones 01f49b350d Update compiler-builtins to 0.1.91 to bring in msp430 shift primitive fixes. 2023-03-30 00:39:49 -04:00
bors 10338571cf Auto merge of #107221 - kleisauke:getentropy-emscripten, r=ChrisDenton
Use `getentropy()` instead of `/dev/urandom` on Emscripten

`/dev/urandom` is usually available on Emscripten, except when using
the special `NODERAWFS` filesystem backend, which replaces all normal
filesystem access with direct Node.js operations.

Since this filesystem backend directly access the filesystem on the
OS, it is not recommended to depend on `/dev/urandom`, especially
when trying to run the Wasm binary on OSes that are not Unix-based.

This can be considered a non-functional change, since Emscripten
implements `/dev/urandom` in the same way as `getentropy()` when not
linking with `-sNODERAWFS`.
2023-03-30 00:25:41 +00:00
Mara Bos 9b5122976e Em dashes are cooler than hyphens. 2023-03-29 18:04:44 -04:00
Trevor Gross d1b28b75d2 Documentation updates to better share the purpose of OnceCell/OnceLock 2023-03-29 18:04:44 -04:00
Trevor Gross dc4ba57566 Stabilize a portion of 'once_cell'
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29 18:04:44 -04:00
Matthias Krüger c62bb46fb3
Rollup merge of #109693 - workingjubilee:maybe-unconstify-alloc, r=fee1-dead
Remove ~const from alloc

There is currently an effort underway to stop using `~const Trait`, temporarily, so as to refactor the logic underlying const traits with relative ease. This means it has to go from the standard library, as well.

I have taken the initial step of just removing these impls from alloc, as removing them from core is a much more tangled task. In addition, all of these implementations are one more-or-less logically-connected group, so reverting their deconstification as a group seems like it will also be sensible.

r? `@fee1-dead`
2023-03-29 21:19:50 +02:00
Matthias Krüger 57f1d114cd
Rollup merge of #107387 - joboet:hermit_random, r=ChrisDenton
Use random `HashMap` keys on Hermit

Initializing the keys with random data provided by the libOS avoids HashDOS attacks and similar issues.

CC `@stlankes`
2023-03-29 21:19:47 +02:00
bors f98598c6cd Auto merge of #108089 - Zoxc:windows-tls, r=bjorn3
Support TLS access into dylibs on Windows

This allows access to `#[thread_local]`  in upstream dylibs on Windows by introducing a MIR shim to return the address of the thread local. Accesses that go into an upstream dylib will call the MIR shim to get the address of it.

`convert_tls_rvalues` is introduced in `rustc_codegen_ssa` which rewrites MIR TLS accesses to dummy calls which are replaced with calls to the MIR shims when the dummy calls are lowered to backend calls.

A new `dll_tls_export` target option enables this behavior with a `false` value which is set for Windows platforms.

This fixes https://github.com/rust-lang/rust/issues/84933.
2023-03-29 16:20:37 +00:00
Stefan Lankes a9aaf3fedb Implement read_buf for RustHermit
In principle, this PR extends rust-lang/rust#108326 for RustyHermit.

Signed-off-by: Stefan Lankes <slankes@eonerc.rwth-aachen.de>
2023-03-29 15:29:36 +02:00
jofas 37ed3cebbc enhanced documentation of binary search methods for slice and VecDeque for unsorted instances 2023-03-29 11:14:23 +02:00
joboet f6bde0352b
std: use `cvt` to handle errors from `read_entropy` on Hermit 2023-03-29 10:52:48 +02:00
bors f346fb0bc6 Auto merge of #108792 - Amanieu:ohos, r=petrochenkov
Add OpenHarmony targets

- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`

Compiler team MCP: https://github.com/rust-lang/compiler-team/issues/568
2023-03-29 07:16:16 +00:00
John Kåre Alsaker 3019a341f3 Use #[inline] on Windows for thread local access 2023-03-29 08:55:25 +02:00
bors cdbbce0a9e Auto merge of #108095 - soc:drop-contains, r=Amanieu
Drop unstable `Option::contains`, `Result::contains`, `Result::contains_err`

This is a proposal to drop the three functions `Option::contains`, `Result::contains` and `Result::contains_err`.

The discovery of `Option::is_some_with`/`Result::is_ok_with`/`Result::is_err_with` in https://github.com/rust-lang/rust/pull/93051 obviates the need for these methods (non-stabilization tracked in https://github.com/rust-lang/rust/issues/62358).

An additional benefit of change is that it avoids spurious error messages in IDEs, when `contains` is supplied by a third-party library:
![option-result-unstable](https://user-images.githubusercontent.com/42493/219127961-13cb559e-6ee8-4449-8dc9-d28d07270ad5.png)
2023-03-28 23:20:30 +00:00
Jubilee Young e34ad76363 Remove ~const from alloc 2023-03-28 10:37:16 -07:00
Amanieu d'Antras c972a4269c Stabilize `binary_heap_retain`
FCP finished in tracking issue: #71503
2023-03-28 17:29:21 +01:00
bors 478cbb42b7 Auto merge of #109692 - Nilstrieb:rollup-hq65rps, r=Nilstrieb
Rollup of 8 pull requests

Successful merges:

 - #91793 (socket ancillary data implementation for FreeBSD (from 13 and above).)
 - #92284 (Change advance(_back)_by to return the remainder instead of the number of processed elements)
 - #102472 (stop special-casing `'static` in evaluation)
 - #108480 (Use Rayon's TLV directly)
 - #109321 (Erase impl regions when checking for impossible to eagerly monomorphize items)
 - #109470 (Correctly substitute GAT's type used in `normalize_param_env` in `check_type_bounds`)
 - #109562 (Update ar_archive_writer to 0.1.3)
 - #109629 (remove obsolete `givens` from regionck)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-28 15:18:16 +00:00
Amanieu d'Antras e3968be331 Add OpenHarmony targets
- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`
2023-03-28 16:01:13 +01:00
bors bf57e8ada6 Auto merge of #108080 - oli-obk:FnPtr-trait, r=lcnr
Add a builtin `FnPtr` trait that is implemented for all function pointers

r? `@ghost`

Rebased version of https://github.com/rust-lang/rust/pull/99531 (plus adjustments mentioned in the PR).

If perf is happy with this version, I would like to land it, even if the diagnostics fix in 9df8e1befb5031a5bf9d8dfe25170620642d3c59 only works for `FnPtr` specifically, and does not generally improve blanket impls.
2023-03-28 12:50:01 +00:00
nils 0883848882
Rollup merge of #92284 - the8472:simplify-advance-by, r=scottmcm
Change advance(_back)_by to return the remainder instead of the number of processed elements

When advance_by can't advance the iterator by the number of requested elements it now returns the amount by which it couldn't be advanced instead of the amount by which it did.

This simplifies adapters like chain, flatten or cycle because the remainder doesn't have to be calculated as the difference between requested steps and completed steps anymore.

Additionally switching from `Result<(), usize>` to `Result<(), NonZeroUsize>` reduces the size of the result and makes converting from/to a usize representing the number of remaining steps cheap.
2023-03-28 12:51:11 +02:00
nils 857b631616
Rollup merge of #91793 - devnexen:anc_data_fbsd, r=ChrisDenton
socket ancillary data implementation for FreeBSD (from 13 and above).

introducing new build config as well.
2023-03-28 12:51:10 +02:00
Matthias Krüger a69496002c
Rollup merge of #109687 - joshtriplett:document-windows-isterminal-heuristics, r=BurntSushi
Document the heuristics IsTerminal uses on Windows

Suggested by `@BurntSushi.`
2023-03-28 07:01:12 +02:00