Commit Graph

7629 Commits

Author SHA1 Message Date
bors
4dd8b420c0 Auto merge of #96521 - petrochenkov:docrules, r=notriddle,GuillaumeGomez
rustdoc: Resolve doc links referring to `macro_rules` items

cc https://github.com/rust-lang/rust/issues/81633

UPD: the fallback to considering *all* `macro_rules` in the crate for unresolved names is not removed in this PR, it will be removed separately and will be run through crater.
2022-05-01 20:28:10 +00:00
bors
508e0584e3 Auto merge of #96376 - scottmcm:do-yeet, r=oli-obk
Add `do yeet` expressions to allow experimentation in nightly

Two main goals for this:
- Ensure that trait restructuring in https://github.com/rust-lang/rust/issues/84277#issuecomment-1066120333 doesn't accidentally close us off from the possibility of doing this in future, as sketched in https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#possibilities-for-yeet
- Experiment with the *existence* of syntax for this, to be able to weight the syntax-vs-library tradeoffs better than we can right now.  Notably the syntax (with `do`) and name in this PR are not intended as candidates for stabilization, but they make a good v0 PR for adding this with minimal impact to compiler maintenance or priming one possible name choice over another.

r? `@oli-obk`
The lang `second` for doing this: https://github.com/rust-lang/lang-team/issues/160#issuecomment-1107896716

Tracking issues
- Lang, https://github.com/rust-lang/rust/issues/96373
- Libs-api, https://github.com/rust-lang/rust/issues/96374
2022-05-01 13:10:21 +00:00
bors
f75d884046 Auto merge of #96078 - udoprog:refcounted-str-to-u8, r=dtolnay
Implement str to [u8] conversion for refcounted containers

This seems motivated to complete the APIs for shared containers since we already have similar allocation-free conversions for strings like `From<Box<[u8]>> for Box<str>`.

Insta-stable since it's a new trait impl?
2022-05-01 06:41:59 +00:00
David Tolnay
100006bec9
Bump shared_from_str to Rust 1.62.0 2022-04-30 23:40:35 -07:00
bors
61469b682c Auto merge of #96490 - dtolnay:writetmpbackport, r=Mark-Simulacrum
Make [e]println macros eagerly drop temporaries (for backport)

This PR extracts the subset of #96455 which is only the parts necessary for fixing the 1.61-beta regressions in #96434.

My larger PR #96455 contains a few other changes relative to the pre-#94868 behavior; those are not necessary to backport into 1.61.

argument position | before #94868 | after #94868 | after this PR
--- |:---:|:---:|:---:
`write!($tmp, "…", …)` | 😡 | 😡 | 😡
`write!(…, "…", $tmp)` | 😡 | 😡 | 😡
`writeln!($tmp, "…", …)` | 😡 | 😡 | 😡
`writeln!(…, "…", $tmp)` | 😡 | 😡 | 😡
`print!("…", $tmp)` | 😡 | 😡 | 😡
`println!("…", $tmp)` | 😺 | 😡 | 😺
`eprint!("…", $tmp)` | 😡 | 😡 | 😡
`eprintln!("…", $tmp)` | 😺 | 😡 | 😺
`panic!("…", $tmp)` | 😺 | 😺 | 😺
2022-05-01 03:18:53 +00:00
bors
bf611439e3 Auto merge of #95362 - scottmcm:calloc-arrays, r=Mark-Simulacrum
Support arrays of zeros in Vec's __rust_alloc_zeroed optimization

I happened to notice in https://users.rust-lang.org/t/any-advantage-of-box-u64-16-16-16-over-vec-u64/73500/3?u=scottmcm that the calloc optimization wasn't applying to vectors-of-arrays, so here's the easy fix for that.
2022-05-01 00:50:46 +00:00
Scott McMurray
e094ee5f10 Add do yeet expressions to allow experimentation in nightly
Using an obviously-placeholder syntax.  An RFC would still be needed before this could have any chance at stabilization, and it might be removed at any point.

But I'd really like to have it in nightly at least to ensure it works well with try_trait_v2, especially as we refactor the traits.
2022-04-30 17:40:27 -07:00
Vadim Petrochenkov
6083db7c4e Fix some links in the standard library 2022-05-01 00:02:34 +03:00
bors
579d26876d Auto merge of #96348 - overdrivenpotato:inline-location, r=the8472
Inline core::panic::Location methods

This avoids the overhead of a function call when used.
2022-04-30 16:33:12 +00:00
bors
f1d8a7d662 Auto merge of #96489 - shepmaster:revert-vec-from-array-ref, r=yaahc
Revert "impl From<&[T; N]> and From<&mut [T; N]> for Vec<T>"

This reverts commit 5dd702763a.
2022-04-29 14:39:14 +00:00
Dylan DPC
cd5dc49379
Rollup merge of #96492 - joshtriplett:revert-std-ffi-re-export, r=yaahc
Revert "Re-export core::ffi types from std::ffi"

This reverts commit 9aed829fe6.

Fixes https://github.com/rust-lang/rust/issues/96435 , a regression
in crates doing `use std::ffi::*;` and `use std::os::raw::*;`.

We can re-add this re-export once the `core::ffi` types
are stable, and thus the `std::os::raw` types can become re-exports as
well, which will avoid the conflict. (Type aliases to the same type
still conflict, but re-exports of the same type don't.)
2022-04-29 11:23:14 +02:00
Dylan DPC
db1ec25224
Rollup merge of #96481 - aDotInTheVoid:hashmap-docs-monospace, r=joshtriplett
HashMap doc: Don't use monospace font for 'Entry Api'
2022-04-29 11:23:13 +02:00
bors
ddb7fbe843 Auto merge of #96441 - ChrisDenton:sync-pipes, r=m-ou-se
Windows: Make stdin pipes synchronous

Stdin pipes do not need to be used asynchronously within the standard library. This is a first step in making pipes mostly synchronous.

r? `@m-ou-se`
2022-04-29 03:06:45 +00:00
bors
baaa3b6829 Auto merge of #96393 - joboet:pthread_parker, r=thomcc
std: directly use pthread in UNIX parker implementation

`Mutex` and `Condvar` are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore we should use the `pthread` synchronization primitives directly. Also, we can avoid allocating the mutex and condition variable because the `Parker` struct is being placed in an `Arc` anyways.

This basically is just a copy of the current `Mutex` and `Condvar` code, which will however be removed (again, see #93740). An alternative implementation could be to use dedicated private `OsMutex` and `OsCondvar` types, but all the other platforms supported by std actually have their own thread parking primitives.

I used `Pin` to guarantee a stable address for the `Parker` struct, while the current implementation does not, rather using extra unsafe declaration. Since the thread struct is shared anyways, I assumed this would not add too much clutter while being clearer.
2022-04-28 21:58:08 +00:00
Dylan DPC
2c1d58b8cc
Rollup merge of #96480 - user-simon:patch-1, r=Dylan-DPC
Fixed grammatical error in example comment

Added missing "we" in sentence.
2022-04-28 20:13:03 +02:00
Dylan DPC
0cbf3b2b30
Rollup merge of #96433 - petrochenkov:delim, r=nnethercote
rustc_ast: Harmonize delimiter naming with `proc_macro::Delimiter`

Compiler cannot reuse `proc_macro::Delimiter` directly due to extra impls, but can at least use the same naming.

After this PR the only difference between these two enums is that `proc_macro::Delimiter::None` is turned into `token::Delimiter::Invisible`.
It's my mistake that the invisible delimiter is called `None` on stable, during the stabilization I audited the naming and wrote the docs, but missed the fact that the `None` naming gives a wrong and confusing impression about what this thing is.

cc https://github.com/rust-lang/rust/pull/96421
r? ``@nnethercote``
2022-04-28 20:13:02 +02:00
joboet
550273361d
std: simplify UNIX parker timeouts 2022-04-28 12:31:19 +02:00
bors
3bfeffd55b Auto merge of #95904 - paolobarbolini:vecdeque-specextend, r=the8472
Add VecDeque::extend from vec::IntoIter and slice::Iter specializations

Inspired from the [`Vec` `SpecExtend` implementation](027a232755/library/alloc/src/vec/spec_extend.rs), but without the specialization for `TrustedLen` which I'll look into in the future.

Should help #95632 and https://github.com/KillingSpark/zstd-rs/pull/17

## Benchmarks

Before

```
test vec_deque::bench_extend_bytes    ... bench:         862 ns/iter (+/- 10)
test vec_deque::bench_extend_vec      ... bench:         883 ns/iter (+/- 19)
```

After

```
test vec_deque::bench_extend_bytes    ... bench:           8 ns/iter (+/- 0)
test vec_deque::bench_extend_vec      ... bench:          24 ns/iter (+/- 1)

```
2022-04-28 09:27:21 +00:00
Vadim Petrochenkov
2733ec1be3 rustc_ast: Harmonize delimiter naming with proc_macro::Delimiter 2022-04-28 10:04:29 +03:00
Paolo Barbolini
c126f7fc8b Add VecDeque::extend from vec::IntoIter and slice::Iter specializations 2022-04-28 06:13:54 +02:00
Dylan DPC
6f6fe3e651
Rollup merge of #96466 - compiler-errors:error-collect-array, r=davidtwco
Better error messages when collecting into `[T; n]`

Fixes #96461
2022-04-28 02:40:35 +02:00
Dylan DPC
c4dd0d3bb7
Rollup merge of #96397 - AronParker:issue-96368-fix, r=dtolnay
Make EncodeWide implement FusedIterator

[`EncodeUtf16`](https://doc.rust-lang.org/std/str/struct.EncodeUtf16.html) and [`EncodeWide`](https://doc.rust-lang.org/std/os/windows/ffi/struct.EncodeWide.html) currently serve similar purposes: They convert from UTF-8 to UTF-16 and WTF-8 to WTF-16, respectively. `EncodeUtf16` wraps a &str, whereas `EncodeWide` wraps an &OsStr.

When Iteration has concluded, these iterators wrap an empty slice, which will forever yield `None` values. Hence, `EncodeUtf16` rightfully implements `FusedIterator`. However, `EncodeWide` in contrast does not, even though it serves an almost identical purpose.

This PR attempts to fix that issue. I consider this change minor and non-controversial, hence why I have not added a RFC/FCP. Please let me know if the stability attribute is wrong or contains a wrong version number. Thanks in advance.

Fixes https://github.com/rust-lang/rust/issues/96368
2022-04-28 02:40:33 +02:00
Josh Triplett
07ea143f96 Revert "Re-export core::ffi types from std::ffi"
This reverts commit 9aed829fe6.

Fixes https://github.com/rust-lang/rust/issues/96435 , a regression
in crates doing `use std::ffi::*;` and `use std::os::raw::*;`.

We can re-add this re-export once the `core::ffi` types
are stable, and thus the `std::os::raw` types can become re-exports as
well, which will avoid the conflict. (Type aliases to the same type
still conflict, but re-exports of the same type don't.)
2022-04-27 14:01:04 -07:00
Josh Triplett
42d96bb2f6 Remove use of reverted std::ffi::c_char 2022-04-27 14:01:04 -07:00
David Tolnay
3a8f81aac9
Make [e]println macros eagerly drop temporaries (for backport) 2022-04-27 13:22:41 -07:00
Jake Goulding
762bb1f506 Revert "impl From<&[T; N]> and From<&mut [T; N]> for Vec<T>"
This reverts commit 5dd702763a.
2022-04-27 15:56:29 -04:00
Paolo Barbolini
84b8898d63 Add VecDeque::extend benchmark 2022-04-27 21:10:20 +02:00
Nixon Enraght-Moony
d34f8d269a HashMap doc: Don't use monospace font for 'Entry Api' 2022-04-27 17:59:29 +01:00
Simon
332f326334
Fixed grammatical error in example comment 2022-04-27 17:27:02 +02:00
Chris Denton
1e7c15634d
Note the importance of using sync pipes 2022-04-27 13:56:59 +01:00
Michael Goulet
83d701e569 Better error messages when collecting into [T; n] 2022-04-26 21:37:10 -07:00
bors
bb85bcaca9 Auto merge of #96195 - sunfishcode:sunfishcode/handle-or-error-type, r=joshtriplett
Define a dedicated error type for `HandleOrNull` and `HandleOrInvalid`.

Define `NullHandleError` and `InvalidHandleError` types, that implement std::error::Error, and use them as the error types in `HandleOrNull` and `HandleOrInvalid`,

This addresses [this concern](https://github.com/rust-lang/rust/issues/87074#issuecomment-1080031167).

This is the same as #95387.

r? `@joshtriplett`
2022-04-27 03:42:59 +00:00
Chris Denton
949b978ec9
Windows: Make stdin pipes synchronous
Stdin pipes do not need to be used asynchronously within the standard library.
2022-04-26 16:31:27 +01:00
Chris Denton
b89b056742
Add set_inheritable for Windows Handles 2022-04-26 15:56:26 +01:00
Guillaume Gomez
223f107b48
Rollup merge of #96415 - ehuss:git-io, r=bjorn3
Remove references to git.io

The git.io service is shutting down soon (see https://github.blog/changelog/2022-04-25-git-io-deprecation/). This removes the references of those short links with the actual destination.
2022-04-26 13:22:31 +02:00
Guillaume Gomez
2b8bf0d530
Rollup merge of #95949 - SoniEx2:patch-5, r=m-ou-se
Implement Default for AssertUnwindSafe

Trait impls are still insta-stable yeah...?
2022-04-26 13:22:27 +02:00
Guillaume Gomez
eaf8beb3f3
Rollup merge of #94022 - jongiddy:cow-into-owned-docs, r=Dylan-DPC
Clarify that `Cow::into_owned` returns owned data

Two sections of the `Cow::into_owned` docs imply that `into_owned` returns a `Cow`. Clarify that it returns the underlying owned object, either cloned or extracted from the `Cow`.
2022-04-26 13:22:26 +02:00
Eric Huss
159b95d5bb Remove references to git.io 2022-04-25 17:05:58 -07:00
Dylan DPC
93db30aa7f
Rollup merge of #96149 - est31:remove_unused_macro_matchers, r=petrochenkov
Remove unused macro rules

Removes rules of internal macros that weren't triggered.
2022-04-26 01:21:20 +02:00
Dylan DPC
51b86848ff
Rollup merge of #90312 - r00ster91:search, r=Dylan-DPC
Fix some confusing wording and improve slice-search-related docs

This adds more links between `contains` and `binary_search` because I do think they have some relevant connections. If your (big) slice happens to be sorted and you know it, surely you should be using `[3; 100].binary_search(&5).is_ok()` over `[3; 100].contains(&5)`?
This also fixes the confusing "searches this sorted X" wording which just sounds really weird because it doesn't know whether it's actually sorted. It should be but it may not be. The new wording should make it clearer that you will probably want to sort it and in the same sentence it also mentions the related function `contains`.
Similarly, this mentions `binary_search` on `contains`' docs.
This also fixes some other minor stuff and inconsistencies.
2022-04-26 01:21:20 +02:00
Aron Parker
fc6af819c4 Make EncodeWide implement FusedIterator 2022-04-25 18:38:47 +02:00
joboet
54daf496e2
std: directly use pthread in UNIX parker implementation
Mutex and Condvar are being replaced by more efficient implementations, which need thread parking themselves (see #93740). Therefore use the pthread synchronization primitives directly. Also, avoid allocating because the Parker struct is being placed in an Arc anyways.
2022-04-25 15:19:50 +02:00
bors
756ffb8d0b Auto merge of #95246 - ChrisDenton:command-args, r=joshtriplett
Windows Command: Don't run batch files using verbatim paths

Fixes #95178

Note that the first commit does some minor refactoring (moving command line argument building to args.rs). The actual changes are in the second.
2022-04-25 07:28:09 +00:00
Matthias Krüger
b7e67a6ad9
Rollup merge of #96107 - Gumichocopengin8:test/vec-deque, r=Mark-Simulacrum
[test] Add test cases for untested functions for VecDeque

Added test cases of the following functions
- get
- get_mut
- swap
- reserve_exact
- try_reserve_exact
- try_reserve
- contains
- rotate_left
- rotate_right
- binary_search
- binary_search_by
- binary_search_by_key
2022-04-25 00:11:00 +02:00
bors
18f314e702 Auto merge of #94609 - esp-rs:esp-idf-stat-type-fixes, r=Mark-Simulacrum
espidf: fix stat

Marking as draft as currently dependant on [a libc fix](https://github.com/rust-lang/libc/pull/2708) and release.
2022-04-24 19:16:20 +00:00
Keita Nonaka
a40cd2aa8b test: add test cases for VecDeque 2022-04-24 11:43:07 -07:00
Marko Mijalkovic
92a584177d Inline core::panic::Location methods 2022-04-23 14:41:47 -04:00
bors
6b4563bf93 Auto merge of #90602 - mbartlett21:const-intoiterator, r=oli-obk
Unstably constify `impl<I: Iterator> IntoIterator for I`

This constifies the default `IntoIterator` implementation under the `const_intoiterator_identity` feature.

Tracking Issue: #90603
2022-04-23 15:41:45 +00:00
bors
1e9aa8a96b Auto merge of #95971 - workingjubilee:no-weird-fp-in-const, r=oli-obk
No "weird" floats in const fn {from,to}_bits

I suspect this code is subtly incorrect and that we don't even e.g. use x87-style floats in CTFE, so I don't have to guard against that case. A future PR will be hopefully removing them from concern entirely, anyways. But at the moment I wanted to get this rolling because small questions like that one seem best answered by review.

r? `@oli-obk`
cc `@eddyb` `@thomcc`
2022-04-23 13:00:54 +00:00
bors
64c5deb0e3 Auto merge of #96314 - AronParker:issue-96297-fix, r=thomcc
Reduce allocations for path conversions on Windows

Previously, UTF-8 to UTF-16 Path conversions on Windows unnecessarily allocate twice, as described in #96297. This commit fixes that issue.
2022-04-23 04:17:50 +00:00