Commit graph

2424 commits

Author SHA1 Message Date
bors 7b13c628a2 Auto merge of #92482 - matthiaskrgr:rollup-uso1zi0, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #84083 (Clarify the guarantees that ThreadId does and doesn't make.)
 - #91593 (Remove unnecessary bounds for some Hash{Map,Set} methods)
 - #92297 (Reduce compile time of rustbuild)
 - #92332 (Add test for where clause order)
 - #92438 (Enforce formatting for rustc_codegen_cranelift)
 - #92463 (Remove pronunciation guide from Vec<T>)
 - #92468 (Emit an error for `--cfg=)`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-02 00:20:04 +00:00
Matthias Krüger 5137f7c9db
Rollup merge of #91593 - upsuper-forks:hashmap-set-methods-bound, r=dtolnay
Remove unnecessary bounds for some Hash{Map,Set} methods

This PR moves `HashMap::{into_keys,into_values,retain}` and `HashSet::retain` from `impl` blocks with `K: Eq + Hash, S: BuildHasher` into the blocks without them. It doesn't seem to me there is any reason these methods need to be bounded by that. This change brings `HashMap::{into_keys,into_values}` on par with `HashMap::{keys,values,values_mut}` which are not bounded either.
2022-01-01 22:49:48 +01:00
Matthias Krüger 30ec1f0384
Rollup merge of #84083 - ltratt:threadid_doc_tweak, r=dtolnay
Clarify the guarantees that ThreadId does and doesn't make.

The existing documentation does not spell out whether `ThreadId`s are unique during the lifetime of a thread or of a process. I had to examine the source code to realise (pleasingly!) that they're unique for the lifetime of a process. That seems worth documenting clearly, as it's a strong guarantee.

Examining the way `ThreadId`s are created also made me realise that the `as_u64` method on `ThreadId` could be a trap for the unwary on those platforms where the platform's notion of a thread identifier is also a 64 bit integer (particularly if they happen to use a similar identifier scheme to `ThreadId`). I therefore think it's worth being even clearer that there's no relationship between the two.
2022-01-01 22:49:47 +01:00
bors dd3ac41495 Auto merge of #92396 - xfix:remove-commandenv-apply, r=Mark-Simulacrum
Remove CommandEnv::apply

It's not being used and uses unsound set_var and remove_var functions. This is an internal function that isn't exported (even with `process_internals` feature), so this shouldn't break anything.

Also see #92365. Note that this isn't the only use of those methods in standard library, so that particular pull request will need more changes than just this to work (in particular, `test_capture_env_at_spawn` is using `set_var` and `remove_var`).
2022-01-01 20:45:37 +00:00
Josh Triplett 0d55bd1100 Make tidy check for magic numbers that spell things
Remove existing problematic cases.
2021-12-31 21:13:07 -08:00
David Tolnay d29941e724
Remove needless allocation from example code of OsString 2021-12-30 12:45:02 -08:00
David Tolnay 1f62c24d5a
Fix some copy/paste hysteresis in OsString try_reserve docs
It appears `find_max_slow` comes from the BinaryHeap docs, where the
try_reserve example is a slow implementation of find_max. It has no
relevance to this code in OsString though.
2021-12-30 12:41:26 -08:00
Konrad Borowski 14fc9dcbba Remove CommandEnv::apply
It's not being used and uses unsound set_var and remove_var
functions.
2021-12-29 10:07:44 +01:00
Xuanwo b07ae1c4d5
Address comments
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-29 14:02:20 +08:00
Xuanwo 9166428be1
Update library/std/src/ffi/os_str.rs
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2021-12-29 13:49:39 +08:00
Xuanwo 27b92c9f98
Implement support in wtf8
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-28 11:53:14 +08:00
Xuanwo 013fbc6187
Fix windows build
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-28 11:40:58 +08:00
Xuanwo c40ac57efb
Add try_reserve for OsString
Signed-off-by: Xuanwo <github@xuanwo.io>
2021-12-28 11:28:05 +08:00
Hiroshi Kori 7a3a668bc9 fix typo: intialized -> initialized 2021-12-26 18:37:11 -08:00
Hiroshi Kori 7ddad349b1 fix typo: the use f.pad -> then use f.pad 2021-12-26 17:44:53 -08:00
Laurence Tratt d66a9e16ba Language tweak. 2021-12-25 15:18:55 +00:00
Matthias Krüger 40c6720620
Rollup merge of #90625 - Milo123459:ref-unwind-safe, r=dtolnay
Add `UnwindSafe` to `Once`

Fixes #43469
2021-12-23 17:48:29 +01:00
Matthias Krüger 3afed8fc70
Rollup merge of #92208 - ChrisDenton:win-bat-cmd, r=dtolnay
Quote bat script command line

Fixes #91991

[`CreateProcessW`](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw#parameters) should only be used to run exe files but it does have some (undocumented) special handling for files with `.bat` and `.cmd` extensions. Essentially those magic extensions will cause the parameters to be automatically rewritten. Example pseudo Rust code (note that `CreateProcess` starts with an optional application name followed by the application arguments):
```rust
// These arguments...
CreateProcess(None, `@"foo.bat` "hello world""`@,` ...);
// ...are rewritten as
CreateProcess(Some(r"C:\Windows\System32\cmd.exe"), `@""foo.bat` "hello world"""`@,` ...);
```

However, when setting the first parameter (the application name) as we now do, it will omit the extra level of quotes around the arguments:

```rust
// These arguments...
CreateProcess(Some("foo.bat"), `@"foo.bat` "hello world""`@,` ...);
// ...are rewritten as
CreateProcess(Some(r"C:\Windows\System32\cmd.exe"), `@"foo.bat` "hello world""`@,` ...);
```

This means the arguments won't be passed to the script as intended.

Note that running batch files this way is undocumented but people have relied on this so we probably shouldn't break it.
2021-12-23 00:28:56 +01:00
Matthias Krüger 12e4907728
Rollup merge of #92139 - dtolnay:backtrace, r=m-ou-se
Change Backtrace::enabled atomic from SeqCst to Relaxed

This atomic is not synchronizing anything outside of its own value, so we don't need the `Acquire`/`Release` guarantee that all memory operations prior to the store are visible after the subsequent load, nor the `SeqCst` guarantee of all threads seeing all of the sequentially consistent operations in the same order.

Using `Relaxed` reduces the overhead of `Backtrace::capture()` in the case that backtraces are not enabled.

## Benchmark

```rust
#![feature(backtrace)]

use std::backtrace::Backtrace;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::thread;
use std::time::Instant;

fn main() {
    let begin = Instant::now();
    let mut threads = Vec::new();
    for _ in 0..64 {
        threads.push(thread::spawn(|| {
            for _ in 0..10_000_000 {
                let _ = Backtrace::capture();
                static LOL: AtomicUsize = AtomicUsize::new(0);
                LOL.store(1, Ordering::Release);
            }
        }));
    }
    for thread in threads {
        let _ = thread.join();
    }
    println!("{:?}", begin.elapsed());
}
```

**Before:**&ensp;6.73 seconds
**After:**&ensp;5.18 seconds
2021-12-23 00:28:54 +01:00
Matthias Krüger 554ad50fa2
Rollup merge of #92117 - solid-rs:fix-kmc-solid-read-buf, r=yaahc
kmc-solid: Add `std::sys::solid::fs::File::read_buf`

This PR adds `std::sys::solid::fs::File::read_buf` to catch up with the changes introduced by #81156 and fix the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets..
2021-12-23 00:28:53 +01:00
Chris Denton 615604f0c7
Fix tests 2021-12-22 18:31:36 +00:00
Matthias Krüger 55b494445a
Rollup merge of #92129 - RalfJung:join-handle-docs, r=jyn514
JoinHandle docs: add missing 'the'
2021-12-21 08:33:42 +01:00
Matthias Krüger 3009dd7c5a
Rollup merge of #90345 - passcod:entry-insert, r=dtolnay
Stabilise entry_insert

This stabilises `HashMap:Entry::insert_entry` etc. Tracking issue #65225. It will need an FCP.

This was implemented in #64656 two years ago.

This PR includes the rename and change discussed in https://github.com/rust-lang/rust/issues/65225#issuecomment-910652430, happy to split if needed.
2021-12-21 08:33:37 +01:00
Tomoaki Kawada 874514c7b4 kmc-solid: Add std::sys::solid::fs::File::read_buf
Catching up with commit 3b263ceb5c
2021-12-21 11:18:35 +09:00
David Tolnay a2fd84a125
Bump insert_entry stabilization to Rust 1.59 2021-12-20 13:14:06 -08:00
David Tolnay 984b10da16
Change Backtrace::enabled atomic from SeqCst to Relaxed 2021-12-20 12:34:10 -08:00
David Tolnay 91161ed110
impl RefUnwindSafe for Once 2021-12-20 11:49:47 -08:00
Ralf Jung fbceb7ac3b JoinHandle docs: add missing 'the' 2021-12-20 18:30:29 +01:00
Matthias Krüger efbefb673d
Rollup merge of #92030 - rukai:stdlib2021, r=m-ou-se
Update stdlib to the 2021 edition

progress towards https://github.com/rust-lang/rust/issues/88638

I couldnt find a way to run the 2018 style panic tests against 2018 so I just deleted them, maybe theres a way to do it that I missed though?
2021-12-18 10:26:40 +01:00
Matthias Krüger e69acdaae4
Rollup merge of #92025 - devnexen:revert-91553-anc_data_dfbsd, r=kennytm
Revert "socket ancillary data implementation for dragonflybsd."

Reverts rust-lang/rust#91553
2021-12-18 10:26:39 +01:00
Lucas Kent b656384d83 Update stdlib to the 2021 edition 2021-12-18 00:21:53 +11:00
David CARLIER 78a3078c3f
Revert "socket ancillary data implementation for dragonflybsd." 2021-12-16 21:32:53 +00:00
Chris Denton de764a7ccb
Quote bat script command line 2021-12-16 17:22:32 +00:00
Matthias Krüger b742594f4a
Rollup merge of #91947 - ibraheemdev:io-error-other, r=joshtriplett
Add `io::Error::other`

This PR adds a small utility constructor, `io::Error::other`, a shorthand for `io::Error::new(io::ErrorKind::Other, err)`, something I find myself writing often.

For some concrete stats, a quick search on [grep.app](https://grep.app) shows that more than half of the uses of `io::Error::new` use `ErrorKind::Other`:
```
Error::new\((?:std::)?(?:io::)?ErrorKind:: => 3,898 results
Error::new\((?:std::)?(?:io::)?ErrorKind::Other => 2,186 results
```
2021-12-16 17:23:10 +01:00
Matthias Krüger 99f4458a8c
Rollup merge of #91916 - steffahn:fix-typos, r=dtolnay
Fix a bunch of typos

I hope that none of these files is not supposed to be modified.

FYI, I opened separate PRs for typos in submodules, in the respective repositories
* https://github.com/rust-lang/stdarch/pull/1267
* https://github.com/rust-lang/backtrace-rs/pull/455
2021-12-15 10:57:02 +01:00
Ibraheem Ahmed 85f786cc9c add io::Error::other constructor 2021-12-14 20:00:59 -05:00
Matthias Krüger 4e7497bda0
Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcm
Stabilize `iter::zip`

Hello all!

As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue.

As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been
used in many places across the rust compiler and standard library since March without any issues.

For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-15 01:28:08 +01:00
PFPoitras 304ede6bcc Stabilize iter::zip. 2021-12-14 18:50:31 -04:00
bors 2f4da6243f Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplett
Stabilize asm! and global_asm!

Tracking issue: #72016

It's been almost 2 years since the original [RFC](https://github.com/rust-lang/rfcs/pull/2850) was posted and we're finally ready to stabilize this feature!

The main changes in this PR are:
- Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228.
- Stabilizing the `asm` and `global_asm` features.
- Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](https://github.com/rust-lang/reference/pull/1105) and [rust by example](https://github.com/rust-lang/rust-by-example/pull/1483).
  - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example.
- Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`.
- Updating `stdarch` and `compiler-builtins`.
- Updating all the tests.

r? `@joshtriplett`
2021-12-14 21:15:22 +00:00
Frank Steffahn a957cefda6 Fix a bunch of typos 2021-12-14 16:40:43 +01:00
Konrad Borowski 23e4aeb140 Stabilize const_cstr_unchecked 2021-12-13 08:43:19 +01:00
Amanieu d'Antras 1c48025685 Address review feedback 2021-12-12 11:26:59 +00:00
Amanieu d'Antras 44a3a66ee8 Stabilize asm! and global_asm!
They are also removed from the prelude as per the decision in
https://github.com/rust-lang/rust/issues/87228.

stdarch and compiler-builtins are updated to work with the new, stable
asm! and global_asm! macros.
2021-12-12 11:20:03 +00:00
Matthias Krüger bb23d82e6f
Rollup merge of #91782 - maxwase:is_symlink_since_attribute, r=jyn514
Correct since attribute for `is_symlink` feature

Follow-up from [89677](https://github.com/rust-lang/rust/pull/89677)
2021-12-11 16:02:50 +01:00
Maxwase 8fafb77af9 Correct since attribute for feature 2021-12-11 13:47:20 +03:00
Xidorn Quan fb1e031685 Remove unnecessary bounds for some Hash{Map,Set} methods 2021-12-11 21:07:41 +11:00
Matthias Krüger 5da73311be
Rollup merge of #91553 - devnexen:anc_data_dfbsd, r=yaahc
socket ancillary data implementation for dragonflybsd.
2021-12-11 08:22:33 +01:00
bors c185610ebc Auto merge of #91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #91668 (Remove the match on `ErrorKind::Other`)
 - #91678 (Add tests fixed by #90023)
 - #91679 (Move core/stream/stream/mod.rs to core/stream/stream.rs)
 - #91681 (fix typo in `intrinsics::raw_eq` docs)
 - #91686 (Fix `Vec::reserve_exact` documentation)
 - #91697 (Delete Utf8Lossy::from_str)
 - #91706 (Add unstable book entries for parts of asm that are not being stabilized)
 - #91709 (Replace iterator-based set construction by *Set::From<[T; N]>)
 - #91716 (Improve x.py logging and defaults a bit more)
 - #91747 (Add pierwill to .mailmap)
 - #91755 (Fix since attribute for const_linked_list_new feature)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-12-11 03:52:12 +00:00
Matthias Krüger 5510803fe9
Rollup merge of #91482 - JosephTLyons:update-HashMap-and-BTreeMap-documentation, r=yaahc
Update documentation to use `from()` to initialize `HashMap`s and `BTreeMap`s

As of Rust 1.56, `HashMap` and `BTreeMap` both have associated `from()` functions.  I think using these in the documentation cleans things up a bit.  It allows us to remove some of the `mut`s and avoids the Initialize-Then-Modify anti-pattern.
2021-12-10 22:40:33 +01:00
Júnior Bassani cebd9494bd
Replace iterator-based set construction by *Set::From<[T; N]> 2021-12-09 11:56:19 -03:00