Commit graph

2712 commits

Author SHA1 Message Date
Matthias Krüger 5d904c17f6
Rollup merge of #92709 - joshtriplett:file-options-docs, r=Mark-Simulacrum
Improve documentation for File::options to give a more likely example

`File::options().read(true).open(...)` is equivalent to just
`File::open`. Change the example to set the `append` flag instead, and
then change the filename to something more likely to be written in
append mode.
2022-01-12 07:12:12 +01:00
Konrad Borowski 7e6d97bc39 Inline std::os::unix::ffi::OsStringExt methods 2022-01-11 19:33:46 +01:00
Miguel Ojeda 8680a44c0f Partially stabilize maybe_uninit_extra
This covers:

    impl<T> MaybeUninit<T> {
        pub unsafe fn assume_init_read(&self) -> T { ... }
        pub unsafe fn assume_init_drop(&mut self) { ... }
    }

It does not cover the const-ness of `write` under
`const_maybe_uninit_write` nor the const-ness of
`assume_init_read` (this commit adds
`const_maybe_uninit_assume_init_read` for that).

FCP: https://github.com/rust-lang/rust/issues/63567#issuecomment-958590287.

Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-01-11 17:01:13 +01:00
bors 2e2c86eba2 Auto merge of #92070 - rukai:replace_vec_into_iter_with_array_into_iter, r=Mark-Simulacrum
Replace usages of vec![].into_iter with [].into_iter

`[].into_iter` is idiomatic over `vec![].into_iter` because its simpler and faster (unless the vec is optimized away in which case it would be the same)

So we should change all the implementation, documentation and tests to use it.

I skipped:
* `src/tools` - Those are copied in from upstream
* `src/test/ui` - Hard to tell if `vec![].into_iter` was used intentionally or not here and not much benefit to changing it.
*  any case where `vec![].into_iter` was used because we specifically needed a `Vec::IntoIter<T>`
*  any case where it looked like we were intentionally using `vec![].into_iter` to test it.
2022-01-11 14:23:24 +00:00
Josh Triplett c91ad5d0f2 Improve documentation for File::options to give a more likely example
`File::options().read(true).open(...)` is equivalent to just
`File::open`. Change the example to set the `append` flag instead, and
then change the filename to something more likely to be written in
append mode.
2022-01-10 17:35:17 -05:00
david-perez 5786bbddc6 Eliminate "boxed" wording in std::error::Error documentation
In commit 29403ee, documentation for the methods on `std::any::Any` was
modified so that they referred to the concrete value behind the trait
object as the "inner" value. This is a more accurate wording than
"boxed": while putting trait objects inside boxes is arguably the most
common use, they can also be placed behind other pointer types like
`&mut` or `std::sync::Arc`.

This commit does the same documentation changes for `std::error::Error`.
2022-01-10 23:18:34 +01:00
bors 89b9f7b284 Auto merge of #92719 - matthiaskrgr:rollup-tc7oqys, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92248 (Normalize struct tail type when checking Pointee trait)
 - #92357 (Fix invalid removal of newlines from doc comments)
 - #92602 (Make source links look cleaner)
 - #92636 (Normalize generator-local types with unevaluated constants)
 - #92693 (Release notes: add `Result::unwrap_{,err_}unchecked`)
 - #92702 (Clean up lang_items::extract)
 - #92717 (update miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-10 11:53:15 +00:00
Yaroslav Dynnikov 2ae616af30
Fix doc formatting for time.rs
The doc states that instants are not steady, but the word "not" wasn't highlighted in bold.
2022-01-10 14:22:45 +03:00
Matthias Krüger a4ac4fae41
Rollup merge of #92602 - jsha:source-link-2, r=GuillaumeGomez
Make source links look cleaner

Change from syntaxy-looking [src] to the plain word "source".

Change the syntaxy-looking `[-]` at the top of the page to say "collapse".

Reduce opacity of rightside content.

Part of #59851

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/source-link-2/std/string/struct.String.html

[Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/display.20of.20source.20link).
2022-01-10 11:03:06 +01:00
Lamb 3a77bb86ff Compute most of Public/Exported access level in rustc_resolve
Mak DefId to AccessLevel map in resolve for export

hir_id to accesslevel in resolve and applied in privacy
using local def id
removing tracing probes
making function not recursive and adding comments

Move most of Exported/Public res to rustc_resolve

moving public/export res to resolve

fix missing stability attributes in core, std and alloc

move code to access_levels.rs

return for some kinds instead of going through them

Export correctness, macro changes, comments

add comment for import binding

add comment for import binding

renmae to access level visitor, remove comments, move fn as closure, remove new_key

fmt

fix rebase

fix rebase

fmt

fmt

fix: move macro def to rustc_resolve

fix: reachable AccessLevel for enum variants

fmt

fix: missing stability attributes for other architectures

allow unreachable pub in rustfmt

fix: missing impl access level + renaming export to reexport

Missing impl access level was found thanks to a test in clippy
2022-01-09 21:33:14 +00:00
Ibraheem Ahmed 1e53a905ba
export tcp::IntoIncoming 2022-01-08 23:48:50 -05:00
Lucas Kent 08829853d3 eplace usages of vec![].into_iter with [].into_iter 2022-01-09 14:09:25 +11:00
Jacob Hoffman-Andrews 962c0a4ee5 Make source links look cleaner
Change from syntaxy-looking [src] to the plain word "source".
2022-01-08 09:49:41 -05:00
Eric Huss 10010685a9
Rollup merge of #92632 - yoshuawuyts:stabilize-available-parallelism, r=joshtriplett
Implement stabilization of `#[feature(available_parallelism)]`

Stabilized in https://github.com/rust-lang/rust/issues/74479#issuecomment-984379800. Closes https://github.com/rust-lang/rust/issues/74479. Thanks!

cc/ ``@rust-lang/libs-api``
2022-01-07 20:21:01 -08:00
Badel2 0c58586c9c Add safety comments to panic::(set/take/update)_hook 2022-01-08 00:57:59 +01:00
Badel2 8ef3ce866e Change panic::update_hook to simplify usage
And to remove possibility of panics while changing the panic handler,
because that resulted in a double panic.
2022-01-08 00:57:59 +01:00
Jane Lusby 72cb1bd06d silence tidy errors 2022-01-07 13:59:27 -08:00
Ian Douglas Scott a02639dc09 Implement TryFrom<char> for u8
Previously suggested in https://github.com/rust-lang/rfcs/issues/2854.

It makes sense to have this since `char` implements `From<u8>`. Likewise
`u32`, `u64`, and `u128` (since #79502) implement `From<char>`.
2022-01-07 12:28:47 -08:00
Badel2 8bdf5c3de6 Implement panic::update_hook 2022-01-07 17:28:20 +01:00
Yoshua Wuyts 3632f41c78 Stabilize #[feature(available_parallelism)] 2022-01-07 01:07:10 +01:00
Alex Macleod 7ea03db04a Add diagnostic items for macros 2022-01-06 14:59:33 +00:00
Matthias Krüger 2647ce2165
Rollup merge of #92288 - yescallop:patch-1, r=m-ou-se
Fix a pair of mistyped test cases in `std::net::ip`

These two test cases are not consistent with their comments, which I believe is unintended.
2022-01-06 12:01:00 +01:00
bors f1ce0e6a00 Auto merge of #92587 - matthiaskrgr:rollup-qnwa8qx, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #92092 (Drop guards in slice sorting derive src pointers from &mut T, which is invalidated by interior mutation in comparison)
 - #92388 (Fix a minor mistake in `String::try_reserve_exact` examples)
 - #92442 (Add negative `impl` for `Ord`, `PartialOrd` on `LocalDefId`)
 - #92483 (Stabilize `result_cloned` and `result_copied`)
 - #92574 (Add RISC-V detection macro and more architecture instructions)
 - #92575 (ast: Always keep a `NodeId` in `ast::Crate`)
 - #92583 (⬆️ rust-analyzer)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-01-05 15:28:36 +00:00
Mara Bos 4cb73704e2
Mention *scoped* thread in panic message.
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2022-01-05 11:17:11 +00:00
Mara Bos aa9c0881ef Note the invariance over 'env in Scope<'env>. 2022-01-05 12:14:32 +01:00
Mara Bos 5bd5781823 Fix missing .load() in Scope's Debug impl. 2022-01-05 12:14:32 +01:00
Mara Bos a9efbaf3a5 Rename n_running_threads to num_running_threads. 2022-01-05 12:14:32 +01:00
Matthias Krüger 42a3acfdb1
Rollup merge of #92517 - ChrisDenton:explicit-path, r=dtolnay
Explicitly pass `PATH` to the Windows exe resolver

This allows for testing different `PATH`s without using the actual environment.
2022-01-05 11:26:07 +01:00
luojia65 06f4453027 Add is_riscv_feature_detected!; modify impl of hint::spin_loop
Update library/core/src/hint.rs

Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>

Remove redundant config gate
2022-01-05 15:44:52 +08:00
Mara Bos 5b5746f081
Fix typo in Scope::spawn docs.
Co-authored-by: deltragon <m@dafert.at>
2022-01-04 18:43:23 +00:00
Mara Bos c429ade760 Fix typo in is_running() docs.
Co-authored-by: Mattias Buelens <649348+MattiasBuelens@users.noreply.github.com>
2022-01-04 18:40:00 +01:00
Mara Bos 09e6665aba Fix typo in documentation. 2022-01-04 17:05:26 +01:00
Mara Bos 2c8cc70ea0
Use > rather than == for overflow check in scoped threads.
Co-authored-by: Jacob Lifshay <programmerjake@gmail.com>
2022-01-04 15:58:29 +00:00
Mara Bos c5cb2def06 Fix variance of thread::Scope. 2022-01-04 16:57:16 +01:00
Matthias Krüger b2d6ff4b6e
Rollup merge of #92525 - zohnannor:patch-1, r=camelid
intra-doc: Make `Receiver::into_iter` into a clickable link

The documentation on `std::sync::mpsc::Iter` and `std::sync::mpsc::TryIter` provides links to the corresponding `Receiver` methods, unlike `std::sync::mpsc::IntoIter` does.

This was left out in c59b188aae
Related to #29377
2022-01-04 16:34:19 +01:00
Matthias Krüger 4e4e1ec931
Rollup merge of #92456 - danielhenrymantilla:patch-1, r=petrochenkov
Make the documentation of builtin macro attributes accessible

`use ::std::prelude::v1::derive;` compiles on stable, so, AFAIK, there is no reason to have it be `#[doc(hidden)]`.

  - What it currently looks like for things such as `#[test]`, `#[derive]`, `#[global_allocator]`: https://doc.rust-lang.org/1.57.0/core/prelude/v1/index.html#:~:text=Experimental-,pub,-use%20crate%3A%3Amacros%3A%3Abuiltin%3A%3Aglobal_allocator

    <img width="767" alt="Screen Shot 2021-12-31 at 17 49 46" src="https://user-images.githubusercontent.com/9920355/147832999-cbd747a6-4607-4df6-8e57-c1675dcbc1c3.png">

    and in `::std` they're just straight `hidden`.

    <img width="452" alt="Screen Shot 2021-12-31 at 17 53 18" src="https://user-images.githubusercontent.com/9920355/147833105-c5ff8cd1-9e4d-4d2b-9621-b36aa3cfcb28.png">

  - Here is how it looks like with this PR (assuming the `Rustc{De,En}codable` ones are not reverted):

    <img width="778" alt="Screen Shot 2021-12-31 at 17 50 55" src="https://user-images.githubusercontent.com/9920355/147833034-84286342-dbf7-4e6e-9062-f39cd6c286a4.png">

    <img width="291" alt="Screen Shot 2021-12-31 at 17 52 54" src="https://user-images.githubusercontent.com/9920355/147833109-c92ed55c-51c6-40a2-9205-f834d1e349c0.png">

 Since this involves doc people to chime in, and since `jyn` is on vacation, I'll cc `@GuillaumeGomez` and tag the `rustdoc` team as well
2022-01-04 16:34:16 +01:00
Matthias Krüger 50a66b75dc
Rollup merge of #91754 - Patrick-Poitras:rm-4byte-minimum-stdio-windows, r=Mark-Simulacrum
Modifications to `std::io::Stdin` on Windows so that there is no longer a 4-byte buffer minimum in read().

This is an attempted fix of issue #91722, where a too-small buffer was passed to the read function of stdio on Windows. This caused an error to be returned when `read_to_end` or `read_to_string` were called. Both delegate to `std::io::default_read_to_end`, which creates a buffer that is of length >0, and forwards it to `std::io::Stdin::read()`. The latter method returns an error if the length of the buffer is less than 4, as there might not be enough space to allocate a UTF-16 character. This creates a problem when the buffer length is in `0 < N < 4`, causing the bug.

The current modification creates an internal buffer, much like the one used for the write functions

I'd also like to acknowledge the help of ``@agausmann`` and ``@hkratz`` in detecting and isolating the bug, and for suggestions that made the fix possible.

Couple disclaimers:

- Firstly, I didn't know where to put code to replicate the bug found in the issue. It would probably be wise to add that case to the testing suite, but I'm afraid that I don't know _where_ that test should be added.
- Secondly, the code is fairly fundamental to IO operations, so my fears are that this may cause some undesired side effects ~or performance loss in benchmarks.~ The testing suite runs on my computer, and it does fix the issue noted in #91722.
- Thirdly, I left the "surrogate" field in the Stdin struct, but from a cursory glance, it seems to be serving the same purpose for other functions. Perhaps merging the two would be appropriate.

Finally, this is my first pull request to the rust language, and as such some things may be weird/unidiomatic/plain out bad. If there are any obvious improvements I could do to the code, or any other suggestions, I would appreciate them.

Edit: Closes #91722
2022-01-04 16:34:14 +01:00
Mara Bos 4300bea0c2 Formatting. 2022-01-04 16:32:39 +01:00
Mara Bos f5217792ed Simplify panicking mechanism of thread::scope.
It now panic!()s on its own, rather than resume_unwind'ing the panic
payload from the thread. Using resume_unwind skips the panic_handler,
meaning that the main thread would never have a panic handler run, which
can get confusing.
2022-01-04 16:10:14 +01:00
Mara Bos da33da161b Add documentation for scoped threads. 2022-01-04 16:09:53 +01:00
Mara Bos cc699e1b62 Add ScopedJoinHandle::is_running(). 2022-01-04 15:15:41 +01:00
Mara Bos 0e24ad537b Implement RFC 3151: Scoped threads. 2022-01-04 14:51:39 +01:00
Mara Bos a45b3ac183 Simpilfy thread::JoinInner. 2022-01-04 14:08:44 +01:00
Daniel Henry-Mantilla f20ccc0748 Make the documentation of builtin macro attributes accessible
- Do not `#[doc(hidden)]` the `#[derive]` macro attribute

  - Add a link to the reference section to `derive`'s inherent docs

  - Do the same for `#[test]` and `#[global_allocator]`

  - Fix `GlobalAlloc` link (why is it on `core` and not `alloc`?)

  - Try `no_inline`-ing the `std` reexports from `core`

  - Revert "Try `no_inline`-ing the `std` reexports from `core`"

  - Address PR review

  - Also document the unstable macros
2022-01-03 20:43:16 +01:00
zohnannor ca3f9048a1
Make Receiver::into_iter into a clickable link
The documentation on `std::sync::mpsc::Iter` and `std::sync::mpsc::TryIter` provides links to the corresponding `Receiver` methods, unlike `std::sync::mpsc::IntoIter` does.

This was left out in c59b188aae
Related to #29377
2022-01-03 20:17:57 +03:00
Chris Denton 4145877731
Explicitly pass PATH to the Windows exe resolver 2022-01-03 12:55:42 +00:00
Xuanwo edae82e5e4
std: Implement try_reserve and try_reserve_exact on PathBuf
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-01-03 17:35:38 +08:00
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
AngelicosPhosphoros 4b62a77e4d Little improves in CString new when creating from slice
Old code already contain optimization for cases with `&str` and `&[u8]` args. This commit adds a specialization for `&mut[u8]` too.

Also, I added usage of old slice in search for zero bytes instead of new buffer because it produce better code for Windows on LTO builds. For other platforms, this wouldn't cause any difference because it calls `libc` anyway.

Inlined `_new` method into spec trait to reduce amount of code generated to `CString::new` callers.
2021-12-27 12:26:30 +03: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
Scallop Ye e3ad30962e
Fix a pair of mistyped test cases in std::net::ip 2021-12-26 16:41:32 +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
Jane Lusby 5b3902fc65 attempt to make Report usable with Box dyn Error and fn main 2021-12-16 16:08:30 -08:00
Jane Lusby 9be1cc9b61 more docs improvements 2021-12-16 15:34:12 -08:00
Jane Lusby 078b112d94 add a panicking example 2021-12-16 14:22:35 -08:00
Jane Lusby 4420cc33d6 Update report output and fix examples 2021-12-16 14:06:28 -08: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
Ayrton c12f7efd01 Bump compiler-builtins to 0.1.66
Adds intrinsics for truncdfsf2 and truncdfsf2vsp on ARM.
2021-12-15 21:00:06 -05:00
PFPoitras d49d1d4499 Modifications to buffer UTF-16 internally so that there is no longer a 4-byte buffer minimum. Include suggestions from @agausmann and @Mark-Simulacrum. 2021-12-15 18:35:29 -04: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
Jane Lusby 1386a15529 Update std::error::Report based on feedback 2021-12-14 13:56:49 -08: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
bors 3b263ceb5c Auto merge of #81156 - DrMeepster:read_buf, r=joshtriplett
Implement most of RFC 2930, providing the ReadBuf abstraction

This replaces the `Initializer` abstraction for permitting reading into uninitialized buffers, closing #42788.

This leaves several APIs described in the RFC out of scope for the initial implementation:

* read_buf_vectored
* `ReadBufs`

Closes #42788, by removing the relevant APIs.
2021-12-09 10:11:55 +00:00
Matthias Krüger 856eefece9
Rollup merge of #89999 - talagrand:GetTempPath2, r=m-ou-se
Update std::env::temp_dir to use GetTempPath2 on Windows when available.

As a security measure, Windows 11 introduces a new temporary directory API, GetTempPath2.
When the calling process is running as SYSTEM, a separate temporary directory
will be returned inaccessible to non-SYSTEM processes. For non-SYSTEM processes
the behavior will be the same as before.

This can help mitigate against attacks such as this one:
https://medium.com/csis-techblog/cve-2020-1088-yet-another-arbitrary-delete-eop-a00b97d8c3e2

Compatibility risk: Software which relies on temporary files to communicate between SYSTEM and non-SYSTEM
processes may be affected by this change. In many cases, such patterns may be vulnerable to the very
attacks the new API was introduced to harden against.
I'm unclear on the Rust project's tolerance for such change-of-behavior in the standard library. If anything,
this PR is meant to raise awareness of the issue and hopefully start the conversation.

How tested: Taking the example code from the documentation and running it through psexec (from SysInternals) on
Win10 and Win11.
On Win10:
C:\test>psexec -s C:\test\main.exe
<...>
Temporary directory: C:\WINDOWS\TEMP\

On Win11:
C:\test>psexec -s C:\test\main.exe
<...>
Temporary directory: C:\Windows\SystemTemp\
2021-12-09 05:08:31 +01:00
Matthias Krüger 3fc5bd7abc
Rollup merge of #87599 - Smittyvb:concat_bytes, r=Mark-Simulacrum
Implement concat_bytes!

This implements the unstable `concat_bytes!` macro, which has tracking issue #87555. It can be used like:
```rust
#![feature(concat_bytes)]

fn main() {
    assert_eq!(concat_bytes!(), &[]);
    assert_eq!(concat_bytes!(b'A', b"BC", [68, b'E', 70]), b"ABCDEF");
}
```
If strings or characters are used where byte strings or byte characters are required, it suggests adding a `b` prefix. If a number is used outside of an array it suggests arrayifying it. If a boolean is used it suggests replacing it with the numeric value of that number. Doubly nested arrays of bytes are disallowed.
2021-12-09 05:08:30 +01:00
Matthias Krüger bb8a4ab6ae
Rollup merge of #91467 - ChrisDenton:confusing-os-string, r=Mark-Simulacrum
Emphasise that an OsStr[ing] is not necessarily a platform string

Fixes #53261

Since that issue was filed, #56141 added a further clarification to the `OsString` docs. However the ffi docs may still leave the impression that an `OsStr` is in the platform native form. This PR aims to further emphasise that an `OsStr` is not necessarily a platform string.
2021-12-08 11:08:58 +01:00
David Tolnay 4e8b91a920
Work around Clippy false positive on as c_char 2021-12-07 22:33:31 -08:00
DrMeepster cd23799ba5
correct typo
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-12-07 22:09:14 -08:00
David Tolnay db5a2ae6a4
Define c_char using cfg_if rather than repeating 40-line cfg 2021-12-07 13:40:25 -08:00
Smitty eb56693a37 Implement concat_bytes!
The tracking issue for this is #87555.
2021-12-06 21:05:13 -05:00
bors 87dce6e8df Auto merge of #91284 - t6:freebsd-riscv64, r=Amanieu
Add support for riscv64gc-unknown-freebsd

For https://doc.rust-lang.org/nightly/rustc/target-tier-policy.html#tier-3-target-policy:

* A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

For all Rust targets on FreeBSD, it's [rust@FreeBSD.org](mailto:rust@FreeBSD.org).

* Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

Done.

* Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.

Done

* Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

Done.

* The target must not introduce license incompatibilities.

Done.

* Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).

Fine with me.

* The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.

Done.

* If the target supports building host tools (such as rustc or cargo), those host tools must not depend on proprietary (non-FOSS) libraries, other than ordinary runtime libraries supplied by the platform and commonly used by other binaries built for the target. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.

Done.

* Targets should not require proprietary (non-FOSS) components to link a functional binary or library.

Done.

* "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.

Fine with me.

* Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

Ok.

* This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.

Ok.

* Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

std is implemented.

* The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running tests (even if they do not pass), the documentation must explain how to run tests for the target, using emulation if possible or dedicated hardware if necessary.

Building is possible the same way as other Rust on FreeBSD targets.

* Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Ok.

* Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.

Ok.

* Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

Ok.

* In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.

Ok.
2021-12-06 03:51:05 +00:00
David Carlier e68887e67c socket ancillary data implementation for dragonflybsd. 2021-12-05 13:36:06 +00:00
bors 1597728ef5 Auto merge of #88611 - m-ou-se:array-into-iter-new-deprecate, r=joshtriplett
Deprecate array::IntoIter::new.
2021-12-05 12:53:01 +00:00
Matthias Krüger 23012b5200
Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-se
std: Stabilize the `thread_local_const_init` feature

This commit is intended to follow the stabilization disposition of the
FCP that has now finished in #84223. This stabilizes the ability to flag
thread local initializers as `const` expressions which enables the macro
to generate more efficient code for accessing it, notably removing
runtime checks for initialization.

More information can also be found in #84223 as well as the tests where
the feature usage was removed in this PR.

Closes #84223
2021-12-05 00:38:00 +01:00
Matthias Krüger b97f375ea2
Rollup merge of #89642 - devnexen:macos_getenv_chng, r=m-ou-se
environ on macos uses directly libc which has the correct signature.
2021-12-05 00:37:55 +01:00
Mara Bos eb3fc45c87 Update docs. 2021-12-04 19:40:33 +01:00
Mara Bos 1acb44f03c Use IntoIterator for array impl everywhere. 2021-12-04 19:40:33 +01:00
Matthias Krüger aa6f2d9a79
Rollup merge of #91474 - rtzoeller:dfly_set_errno, r=cuviper
suppress warning about set_errno being unused on DragonFly

Other targets allow this function to be unused, DragonFly just misses out due to providing a specialization.

This fixes a build error for DragonFly.
2021-12-03 06:24:18 +01:00
Matthias Krüger 25474ed731
Rollup merge of #91453 - ChrisDenton:doc-win-tls-dtors, r=dtolnay
Document Windows TLS drop behaviour

The way Windows TLS destructors are run has some "interesting" properties. They should be documented.

Fixes #74875
2021-12-03 06:24:16 +01:00
Joseph T Lyons 72a6974e45 Make HashMaps mutable again 2021-12-03 00:14:55 -05:00
Ryan Zoeller 0fdb109795 suppress warning about set_errno being unused on DragonFly
Other targets allow this function to be unused, DragonFly just
misses out due to providing a specialization.
2021-12-02 16:16:27 -06:00
Matthias Krüger 6e5f4c2f1b
Rollup merge of #91464 - ChrisDenton:doc-path-case-sensitivity, r=joshtriplett
Document file path case sensitivity

This describes the current behaviour of the standard library's pure path methods.

Fixes #66260.
2021-12-02 22:16:18 +01:00
Matthias Krüger 2ec0f841b4
Rollup merge of #91460 - ChrisDenton:doc-last-os-error, r=joshtriplett
Document how `last_os_error` should be used

It should be made clear that the state of the last OS error could change if another function call is made before the call to `Error::last_os_error()`.

Fixes: #53155
2021-12-02 22:16:16 +01:00
Chris Denton 49aa5baf36
Emphasise that an OsStr[ing] is not necessarily a platform string 2021-12-02 21:02:56 +00:00
Chris Denton d8832425fc
Document file path case sensitivity 2021-12-02 19:48:10 +00:00
Chris Denton 6df44a389c
Document how last_os_error should be used 2021-12-02 17:53:57 +00:00
Joseph T Lyons 80a308df32 Use HashMap::from() instead of using HashMap::new() with HashMap::insert() 2021-12-02 12:26:47 -05:00
Matthias Krüger d96ce3ea8e
Rollup merge of #91394 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump stage0 compiler

r? `@pietroalbini` (or anyone else)
2021-12-02 15:52:03 +01:00
Chris Denton 7a145250c6
Document Windows TLS drop behaviour 2021-12-02 14:17:58 +00:00
Matthias Krüger bc929f9404
Rollup merge of #91340 - cr1901:no-atomic, r=Mark-Simulacrum
Bump compiler_builtins to 0.1.55 to bring in fixes for targets lackin…

…g atomic support.

This fixes a "Cannot select" LLVM error when compiling `compiler_builtins` for targets lacking atomics, like MSP430. Se https://github.com/rust-lang/compiler-builtins/issues/441 for more info. This PR is a more general version of #91248.
2021-11-30 23:43:31 +01:00
Mark Rousskov b221c877e8 Apply cfg-bootstrap switch 2021-11-30 10:51:42 -05:00
Alex Crichton a0c959750a std: Stabilize the thread_local_const_init feature
This commit is intended to follow the stabilization disposition of the
FCP that has now finished in #84223. This stabilizes the ability to flag
thread local initializers as `const` expressions which enables the macro
to generate more efficient code for accessing it, notably removing
runtime checks for initialization.

More information can also be found in #84223 as well as the tests where
the feature usage was removed in this PR.

Closes #84223
2021-11-29 07:23:46 -08:00
Matthias Krüger 80277dcc4f
Rollup merge of #91049 - dimo414:patch-1, r=kennytm
Add a caveat to std::os::windows::fs::symlink_file

This is similar to the note on [Python's `os.symlink()`](https://docs.python.org/3/library/os.html#os.symlink). Some additional notes in https://github.com/dimo414/bkt/issues/3.
2021-11-29 10:41:33 +01:00
William D. Jones e500eb6950 Bump compiler_builtins to 0.1.55 to bring in fixes for targets lacking atomic support. 2021-11-28 23:01:03 -05:00
Jubilee Young 9a04ae4997 Update libc to 0.2.108
Changelog:
https://github.com/rust-lang/libc/releases/tag/0.2.107
https://github.com/rust-lang/libc/releases/tag/0.2.108
Primarily intended to pull in fd331f65f214ea75b6210b415b5fd8650be15c73
This should help with https://github.com/rust-lang/rust/pull/90044
2021-11-27 16:13:04 -08:00
bors 686e313a9a Auto merge of #91288 - matthiaskrgr:rollup-yp5h41r, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #83791 (Weaken guarantee around advancing underlying iterators in zip)
 - #90995 (Document non-guarantees for Hash)
 - #91057 (Expand `available_parallelism` docs in anticipation of cgroup quota support)
 - #91062 (rustdoc: Consolidate static-file replacement mechanism)
 - #91208 (Account for incorrect `where T::Assoc = Ty` bound)
 - #91266 (Use non-generic inner function for pointer formatting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-27 14:29:12 +00:00
Matthias Krüger 8fb58e5ece
Rollup merge of #91057 - the8472:clarify-parallelism-steady-state, r=dtolnay
Expand `available_parallelism` docs in anticipation of cgroup quota support

The "fixed" in "fixed steady state limits" means to exclude load-dependent resource prioritization
that would calculate to 100% of capacity on an idle system and less capacity on a loaded system.

Additionally I also exclude "system load" since it would be silly to try to identify
other, perhaps higher priority, processes hogging some CPU cores that aren't explicitly excluded
by masks/quotas/whatever.
2021-11-27 11:46:42 +01:00
bors 0881b3abe4 Auto merge of #90846 - cuviper:weak, r=dtolnay
Refactor weak symbols in std::sys::unix

This makes a few changes to the weak symbol macros in `sys::unix`:

- `dlsym!` is added to keep the functionality for runtime `dlsym`
  lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't
  want to show up in ELF symbol tables.
- `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime
  behavior is just a simple null check. This is also used by `syscall!`.
  - On non-ELF targets (macos/ios) where that linkage is not known to
    behave, `weak!` is just an alias to `dlsym!` for the old behavior.
- `raw_syscall!` is added to always call `libc::syscall` on linux and
  android, for cases like `clone3` that have no known libc wrapper.

The new `weak!` linkage does mean that you'll get versioned symbols if
you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`.
This might seem problematic, but old non-weak symbols can tie the build
to new versions too, like `dlsym@GLIBC_2.34` from their recent library
unification. If you build with an old glibc like `dist-x86_64-linux`
does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may
be resolved based on the runtime glibc.

I also found a few functions that don't need to be weak anymore:

- Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as
  these were added in API 12, and our baseline is API 14.
- Linux can directly use `splice`, added way back in glibc 2.5 and
  similarly old musl. Android only added it in API 21 though.
2021-11-27 07:58:00 +00:00
Tobias Kortkamp 47474f1055
Add riscv64gc-unknown-freebsd 2021-11-27 07:24:18 +01:00
Matthias Krüger a92f867bf1
Rollup merge of #91248 - alessandrod:compiler-builtins-bump-bpf, r=Mark-Simulacrum
Bump compiler-builtins to 0.1.53

Fixes a LLVM crash with the bpf targets, see https://github.com/rust-lang/compiler-builtins/pull/440
2021-11-26 22:41:42 +01:00
Matthias Krüger fdc305d58d
Rollup merge of #91176 - hermitcore:spin, r=kennytm
If the thread does not get the lock in the short term, yield the CPU

Reduces on [RustyHermit](https://github.com/hermitcore/rusty-hermit) the amount of wasted processor cycles
2021-11-26 16:02:24 +01:00
Alessandro Decina 1cf37189bc Bump compiler-builtins to 0.1.53
Fixes a LLVM crash with the bpf targets
2021-11-26 10:33:32 +00:00
Guillaume Gomez a81f3610ea
Rollup merge of #91151 - name1e5s:chore/process_test, r=m-ou-se
Fix test in std::process on android

closes #10380
2021-11-24 22:56:38 +01:00
Guillaume Gomez a6a1d7ca29
Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelid
Create rustdoc_internals feature gate

As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag.

This is pretty much what it would look like (needs to update the tests too).

The tracking issue is https://github.com/rust-lang/rust/issues/90418.

What do you think ``@rust-lang/rustdoc`` ?
2021-11-24 22:56:37 +01:00
Guillaume Gomez 1e6ced3532 Create rustdoc_internals feature gate 2021-11-24 21:57:18 +01:00
Stefan Lankes 6911af9d06
Improving the readability
Co-authored-by: kennytm <kennytm@gmail.com>
2021-11-24 21:12:56 +01:00
Stefan Lankes 644b445428 If the thread does not get the lock in the short term, yield the CPU
Reduces the amount of wasted processor cycles
2021-11-24 15:59:28 +01:00
Georg Brandl b490ccc227 kernel_copy: avoid panic on unexpected OS error
According to documentation, the listed errnos should only occur
if the `copy_file_range` call cannot be made at all, so the
assert be correct.  However, since in practice file system
drivers (incl. FUSE etc.) can return any errno they want, we
should not panic here.

Fixes #91152
2021-11-23 11:10:49 +01:00
name1e5s 08a500ffc9 fix test in std::process on android 2021-11-23 13:57:22 +08:00
bors 883a241c08 Auto merge of #91101 - birkenfeld:io_error_docs, r=Mark-Simulacrum
Mention std::io::Error::from(ErrorKind) in Error::new() docs

This conversion is not very discoverable for the cases
where an error is required without extra payload.
2021-11-22 13:56:51 +00:00
bors cebd2dda1d Auto merge of #90352 - camsteffen:for-loop-desugar, r=oli-obk
Simplify `for` loop desugar

Basically two intermediate bindings are inlined. I could have left one intermediate binding in place as this would simplify some diagnostic logic, but I think the difference in that regard would be negligible, so it is better to have a minimal HIR.

For checking that the pattern is irrefutable, I added a special case when the `match` is found to be non-exhaustive.

The reordering of the arms is purely stylistic. I don't *think* there are any perf implications.

```diff
  match IntoIterator::into_iter($head) {
      mut iter => {
          $label: loop {
-             let mut __next;
              match Iterator::next(&mut iter) {
-                 Some(val) => __next = val,
                  None => break,
+                 Some($pat) => $block,
              }
-             let $pat = __next;
-             $block
          }
      }
  }
```
2021-11-21 21:20:20 +00:00
Eduardo Sánchez Muñoz 23637e20cd libcore: assume the input of next_code_point and next_code_point_reverse is UTF-8-like
The functions are now `unsafe` and they use `Option::unwrap_unchecked` instead of `unwrap_or_0`

`unwrap_or_0` was added in 42357d772b. I guess `unwrap_unchecked` was not available back then.

Given this example:

```rust
pub fn first_char(s: &str) -> Option<char> {
    s.chars().next()
}
```

Previously, the following assembly was produced:

```asm
_ZN7example10first_char17ha056ddea6bafad1cE:
	.cfi_startproc
	test	rsi, rsi
	je	.LBB0_1
	movzx	edx, byte ptr [rdi]
	test	dl, dl
	js	.LBB0_3
	mov	eax, edx
	ret
.LBB0_1:
	mov	eax, 1114112
	ret
.LBB0_3:
	lea	r8, [rdi + rsi]
	xor	eax, eax
	mov	r9, r8
	cmp	rsi, 1
	je	.LBB0_5
	movzx	eax, byte ptr [rdi + 1]
	add	rdi, 2
	and	eax, 63
	mov	r9, rdi
.LBB0_5:
	mov	ecx, edx
	and	ecx, 31
	cmp	dl, -33
	jbe	.LBB0_6
	cmp	r9, r8
	je	.LBB0_9
	movzx	esi, byte ptr [r9]
	add	r9, 1
	and	esi, 63
	shl	eax, 6
	or	eax, esi
	cmp	dl, -16
	jb	.LBB0_12
.LBB0_13:
	cmp	r9, r8
	je	.LBB0_14
	movzx	edx, byte ptr [r9]
	and	edx, 63
	jmp	.LBB0_16
.LBB0_6:
	shl	ecx, 6
	or	eax, ecx
	ret
.LBB0_9:
	xor	esi, esi
	mov	r9, r8
	shl	eax, 6
	or	eax, esi
	cmp	dl, -16
	jae	.LBB0_13
.LBB0_12:
	shl	ecx, 12
	or	eax, ecx
	ret
.LBB0_14:
	xor	edx, edx
.LBB0_16:
	and	ecx, 7
	shl	ecx, 18
	shl	eax, 6
	or	eax, ecx
	or	eax, edx
	ret
```

After this change, the assembly is reduced to:

```asm
_ZN7example10first_char17h4318683472f884ccE:
	.cfi_startproc
	test	rsi, rsi
	je	.LBB0_1
	movzx	ecx, byte ptr [rdi]
	test	cl, cl
	js	.LBB0_3
	mov	eax, ecx
	ret
.LBB0_1:
	mov	eax, 1114112
	ret
.LBB0_3:
	mov	eax, ecx
	and	eax, 31
	movzx	esi, byte ptr [rdi + 1]
	and	esi, 63
	cmp	cl, -33
	jbe	.LBB0_4
	movzx	edx, byte ptr [rdi + 2]
	shl	esi, 6
	and	edx, 63
	or	edx, esi
	cmp	cl, -16
	jb	.LBB0_7
	movzx	ecx, byte ptr [rdi + 3]
	and	eax, 7
	shl	eax, 18
	shl	edx, 6
	and	ecx, 63
	or	ecx, edx
	or	eax, ecx
	ret
.LBB0_4:
	shl	eax, 6
	or	eax, esi
	ret
.LBB0_7:
	shl	eax, 12
	or	eax, edx
	ret
```
2021-11-21 17:05:55 +01:00
Cameron Steffen 9c83f8c4d1 Simplify for loop desugar 2021-11-21 08:15:21 -06:00
Matthias Krüger 789d168e13
Rollup merge of #91008 - Urgau:float-minimum-maximum, r=scottmcm
Adds IEEE 754-2019 minimun and maximum functions for f32/f64

IEEE 754-2019 removed the `minNum` (`min` in Rust) and `maxNum` (`max` in Rust) operations in favor of the newly created `minimum` and `maximum` operations due to their [non-associativity](https://grouper.ieee.org/groups/msc/ANSI_IEEE-Std-754-2019/background/minNum_maxNum_Removal_Demotion_v3.pdf) that cannot be fix in a backwards compatible manner. This PR adds `fN::{minimun,maximum}` functions following the new rules.

### IEEE 754-2019 Rules

> **minimum(x, y)** is x if x < y, y if y < x, and a quiet NaN if either operand is a NaN, according to 6.2.
For this operation, −0 compares less than +0. Otherwise (i.e., when x = y and signs are the same)
it is either x or y.

> **maximum(x, y)** is x if x > y, y if y > x, and a quiet NaN if either operand is a NaN, according to 6.2.
For this operation, +0 compares greater than −0. Otherwise (i.e., when x = y and signs are the
same) it is either x or y.

"IEEE Standard for Floating-Point Arithmetic," in IEEE Std 754-2019 (Revision of IEEE 754-2008) , vol., no., pp.1-84, 22 July 2019, doi: 10.1109/IEEESTD.2019.8766229.

### Implementation

This implementation is inspired by the one in [`glibc` ](90f0ac10a7/math/s_fminimum_template.c) (it self derived from the C2X draft) expect that:
 - it doesn't use `copysign` because it's not available in `core` and also because `copysign` is unnecessary (we only want to check the sign, no need to create a new float)
 - it also prefer `other > self` instead of `self < other` like IEEE 754-2019 does

I originally tried to implement them [using intrinsics](1d8aa13bc3) but LLVM [error out](https://godbolt.org/z/7sMrxW49a) when trying to lower them to machine intructions, GCC doesn't yet have built-ins for them, only cranelift support them nativelly (as it doesn't support the nativelly the old sementics).

Helps with https://github.com/rust-lang/rust/issues/83984
2021-11-21 09:55:13 +01:00
Georg Brandl 289eb786d4 Mention std::io::Error::from(ErrorKind) in Error::new() docs
This conversion is not very discoverable for the cases
where an error is required without extra payload.
2021-11-21 09:00:13 +01:00
Michael Diamond 9c3b0d81ef Add a caveat to std::os::windows::fs::symlink_file
This is similar to the note on [Python's `os.symlink()`](https://docs.python.org/3/library/os.html#os.symlink). Some additional notes in https://github.com/dimo414/bkt/issues/3.
2021-11-20 12:28:43 -08:00
bors 2885c47482 Auto merge of #87704 - ChrisDenton:win-resolve-exe, r=yaahc
Windows: Resolve `process::Command` program without using the current directory

Currently `std::process::Command` searches many directories for the executable to run, including the current directory. This has lead to a [CVE for `ripgrep`](https://cve.circl.lu/cve/CVE-2021-3013) but presumably other command line utilities could be similarly vulnerable if they run commands. This was [discussed on the internals forum](https://internals.rust-lang.org/t/std-command-resolve-to-avoid-security-issues-on-windows/14800). Also discussed was [which directories should be searched](https://internals.rust-lang.org/t/windows-where-should-command-new-look-for-executables/15015).

EDIT: This PR originally removed all implicit paths. They've now been added back as laid out in the rest of this comment.

## Old Search Strategy

The old search strategy is [documented here][1]. Additionally Rust adds searching the child's paths (see also #37519). So the full list of paths that were searched was:

1. The directories that are listed in the child's `PATH` environment variable.
2. The directory from which the application loaded.
3. The current directory for the parent process.
4. The 32-bit Windows system directory.
5. The 16-bit Windows system directory.
6. The Windows directory.
7. The directories that are listed in the PATH environment variable.

## New Search Strategy

The new strategy removes the current directory from the searched paths.

1. The directories that are listed in the child's PATH environment variable.
2. The directory from which the application loaded.
3. The 32-bit Windows system directory.
4. The Windows directory.
5. The directories that are listed in the parent's PATH environment variable.

Note that it also removes the 16-bit system directory, mostly because there isn't a function to get it. I do not anticipate this being an issue in modern Windows.

## Impact

Removing the current directory should fix CVE's like the one linked above. However, it's possible some Windows users of affected Rust CLI applications have come to expect the old behaviour.

This change could also affect small Windows-only script-like programs that assumed the current directory would be used. The user would need to use `.\file.exe` instead of the bare application name.

This PR could break tests, especially those that test the exact output of error messages (e.g. Cargo) as this does change the error messages is some cases.

[1]: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa#parameters
2021-11-20 18:23:11 +00:00
Loïc BRANSTETT a8ee0e9c2c Implement IEEE 754-2019 minimun and maximum functions for f32/f64 2021-11-20 10:14:03 +01:00
Matthias Krüger 97bd45b373
Rollup merge of #88361 - WaffleLapkin:patch-2, r=jyn514
Makes docs for references a little less confusing

- Make clear that the `Pointer` trait is related to formatting
- Make clear that the `Pointer` trait is implemented for references (previously it was confusing to first see that it's implemented and then see it in "expect")
- Make clear that `&T` (shared reference) implements `Send` (if `T: Send + Sync`)
2021-11-20 01:09:37 +01:00
The8472 39b98e8c1a Expand available_parallelism docs in anticipation of cgroup quotas
The "fixed" in "fixed steady state limits" means to exclude load-dependent resource prioritization
that would calculate to 100% of capacity on an idle system and less capacity on a loaded system.

Additionally I also exclude "system load" since it would be silly to try to identify
other, perhaps higher priority, processes hogging some CPU cores that aren't explicitly excluded
by masks/quotas/whatever.
2021-11-19 22:52:09 +01:00
Maybe Waffle cdb0c29a9c Remove unnecessary doc links 2021-11-19 19:13:53 +03:00
Yuki Okushi f62984fca9
Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-se
windows: Return the "Not Found" error when a path is empty

Fixes #90940
2021-11-19 13:06:35 +09:00
bors 548c1088ef Auto merge of #90774 - alexcrichton:tweak-const, r=m-ou-se
std: Tweak expansion of thread-local const

This commit tweaks the expansion of `thread_local!` when combined with a
`const { ... }` value to help ensure that the rules which apply to
`const { ... }` blocks will be the same as when they're stabilized.
Previously with this invocation:

    thread_local!(static NAME: Type = const { init_expr });

this would generate (on supporting platforms):

    #[thread_local]
    static NAME: Type = init_expr;

instead the macro now expands to:

    const INIT_EXPR: Type = init_expr;
    #[thread_local]
    static NAME: Type = INIT_EXPR;

with the hope that because `init_expr` is defined as a `const` item then
it's not accidentally allowing more behavior than if it were put into a
`static`. For example on the stabilization issue [this example][ex] now
gives the same error both ways.

[ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-18 23:54:14 +00:00
bors b6f580acc0 Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplett
std: Get the standard library compiling for wasm64

This commit goes through and updates various `#[cfg]` as appropriate to
get the wasm64-unknown-unknown target behaving similarly to the
wasm32-unknown-unknown target. Most of this is just updating various
conditions for `target_arch = "wasm32"` to also account for `target_arch
= "wasm64"` where appropriate. This commit also lists `wasm64` as an
allow-listed architecture to not have the `restricted_std` feature
enabled, enabling experimentation with `-Z build-std` externally.

The main goal of this commit is to enable playing around with
`wasm64-unknown-unknown` externally via `-Z build-std` in a way that's
similar to the `wasm32-unknown-unknown` target. These targets are
effectively the same and only differ in their pointer size, but wasm64
is much newer and has much less ecosystem/library support so it'll still
take time to get wasm64 fully-fledged.
2021-11-18 17:19:27 +00:00
Yuki Okushi ddc1d58ca8
windows: Return the "Not Found" error when a path is empty 2021-11-17 03:11:14 +09:00
Yuki Okushi 96cfc9e73a
Rollup merge of #90835 - sunfishcode:sunfishcode/wasi-char-device, r=alexcrichton
Rename WASI's `is_character_device` to `is_char_device`.

Rename WASI's `FileTypeExt::is_character_device` to
`FileTypeExt::is_char_device`, for consistency with the Unix
`FileTypeExt::is_char_device`.

Also, add a `FileTypeExt::is_socket` function, for consistency with the
Unix `FileTypeExt::is_socket` function.

r? `@alexcrichton`
2021-11-16 09:14:19 +09:00
Yuki Okushi aaac528b80
Rollup merge of #90790 - tamaroning:fix-lib-std-test, r=Mark-Simulacrum
Fix standard library test with read_link

closes #90669
resolve this issue by comparing between Paths instead of strs
2021-11-16 09:14:17 +09:00
Yuki Okushi c44455af1d
Rollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahc
Implement `Termination` for `Result<Infallible, E>`

As noted in #43301, `Result<!, E>` is not usable on stable.
2021-11-16 09:14:15 +09:00
Yuki Okushi 73ec27d359
Rollup merge of #85766 - workingjubilee:file-options, r=yaahc
Stabilize File::options()

Renames File::with_options to File::options, per consensus in
rust-lang/rust#65439, and stabilizes it.
2021-11-16 09:14:14 +09:00
bors c8e94975a6 Auto merge of #90596 - the8472:path-hash-opt, r=Mark-Simulacrum
Optimize Eq and Hash for Path/PathBuf

```
# new

test path::tests::bench_hash_path_long                            ... bench:          86 ns/iter (+/- 1)
test path::tests::bench_hash_path_short                           ... bench:          13 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:         197 ns/iter (+/- 6)
test path::tests::bench_path_hashset_miss                         ... bench:          94 ns/iter (+/- 4)

# old

test path::tests::bench_hash_path_long                            ... bench:         192 ns/iter (+/- 2)
test path::tests::bench_hash_path_short                           ... bench:          33 ns/iter (+/- 1)
test path::tests::bench_path_hashset                              ... bench:       1,121 ns/iter (+/- 24)
test path::tests::bench_path_hashset_miss                         ... bench:         273 ns/iter (+/- 6)
```
2021-11-14 15:18:26 +00:00
bors d212d902ae Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obk
Stabilize `const_raw_ptr_deref` for `*const T`

This stabilizes dereferencing immutable raw pointers in const contexts.
It does not stabilize `*mut T` dereferencing. This is behind the
same feature gate as mutable references.

closes https://github.com/rust-lang/rust/issues/51911
2021-11-13 17:10:15 +00:00
bors 032dfe4360 Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrum
pub use core::simd;

A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust, `std::arch` offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completely `unsafe` to use.  `core::simd` offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available.

`core::simd` is enabled by the `#![portable_simd]` nightly feature tracked in https://github.com/rust-lang/rust/issues/86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests **are** introduced via the documentation, but these use deterministic asserts.

There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out.

The major types are
- `core::simd::Simd<T, N>`
- `core::simd::Mask<T, N>`

There is also the `LaneCount` struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.
2021-11-13 02:17:20 +00:00
Jubilee Young 39cb863253 Expose portable-simd as core::simd
This enables programmers to use a safe alternative to the current
`extern "platform-intrinsics"` API for writing portable SIMD code.
This is `#![feature(portable_simd)]` as tracked in #86656
2021-11-12 16:58:39 -08:00
Josh Stone 5ff6ac4287 Refactor weak symbols in std::sys::unix
This makes a few changes to the weak symbol macros in `sys::unix`:

- `dlsym!` is added to keep the functionality for runtime `dlsym`
  lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't
  want to show up in ELF symbol tables.
- `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime
  behavior is just a simple null check. This is also used by `syscall!`.
  - On non-ELF targets (macos/ios) where that linkage is not known to
    behave, `weak!` is just an alias to `dlsym!` for the old behavior.
- `raw_syscall!` is added to always call `libc::syscall` on linux and
  android, for cases like `clone3` that have no known libc wrapper.

The new `weak!` linkage does mean that you'll get versioned symbols if
you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`.
This might seem problematic, but old non-weak symbols can tie the build
to new versions too, like `dlsym@GLIBC_2.34` from their recent library
unification. If you build with an old glibc like `dist-x86_64-linux`
does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may
be resolved based on the runtime glibc.

I also found a few functions that don't need to be weak anymore:

- Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as
  these were added in API 12, and our baseline is API 14.
- Linux can directly use `splice`, added way back in glibc 2.5 and
  similarly old musl. Android only added it in API 21 though.
2021-11-12 15:25:16 -08:00
Matthias Krüger 160602b485
Rollup merge of #90704 - ijackson:exitstatus-comments, r=joshtriplett
Unix ExitStatus comments and a tiny docs fix

Some nits left over from #88300
2021-11-12 19:17:31 +01:00
Dan Gohman 2d46d1bec9 Rename WASI's is_character_device to is_char_device.
Rename WASI's `FileTypeExt::is_character_device` to
`FileTypeExt::is_char_device`, for consistency with the Unix
`FileTypeExt::is_char_device`.

Also, add a `FileTypeExt::is_socket` function, for consistency with the
Unix `FileTypeExt::is_socket` function.
2021-11-12 09:25:32 -08:00
The8472 c1ea7bdc87 Prefix can be case-insensitive, delegate to its Hash impl instead of trying to hash the raw bytes
This should have 0 performance overhead on unix since Prefix is always None.
2021-11-11 21:44:12 +01:00
Ian Jackson fe39fb3149 process::ExitStatus: Discuss exit vs _exit in a comment.
As discussed here
 https://github.com/rust-lang/rust/pull/88300#issuecomment-936097710

I felt this was the best place to put this (rather than next to
ExitStatusExt).  After all, it's a property of the ExitStatus type on
Unix.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11 17:48:51 +00:00
Ian Jackson d1df4715ec unix::ExitStatus: Add comment saying that it's a wait status
With cross-reference.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11 17:48:51 +00:00
Ian Jackson 79e52b3f1e unix::ExitStatusExt: Correct reference to _exit system call
As discussed here
 https://github.com/rust-lang/rust/pull/88300#issuecomment-936085371

exit is (conventionally) a library function, with _exit being the
actual system call.

I have checked the other references and they say "if the process
terminated by calling `exti`".  I think despite the slight
imprecision (strictly, it should read iff ... `_exit`), this is
clearer.  Anyone who knows about the distinction between `exit` and
`_exit` will not be confused.

`_exit` is the correct traditional name for the system call, despite
Linux calling it `exit_group` or `exit`:
  https://www.freebsd.org/cgi/man.cgi?query=_exit&sektion=2&n=1

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11 17:48:03 +00:00
bors d71ba74f0d Auto merge of #88798 - sunfishcode:sunfishcode/windows-null-handles, r=joshtriplett
Fix assertion failures in `OwnedHandle` with `windows_subsystem`.

As discussed in #88576, raw handle values in Windows can be null, such
as in `windows_subsystem` mode, or when consoles are detached from a
process. So, don't use `NonNull` to hold them, don't assert that they're
not null, and remove `OwnedHandle`'s `repr(transparent)`. Introduce a
new `HandleOrNull` type, similar to `HandleOrInvalid`, to cover the FFI
use case.

r? `@joshtriplett`
2021-11-11 12:07:53 +00:00
tamaron 181716a16c compare between Path instead of str 2021-11-11 11:40:34 +09:00
bors 8e0293137f Auto merge of #90784 - matthiaskrgr:rollup-car8g12, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - #89930 (Only use `clone3` when needed for pidfd)
 - #90736 (adjust documented inline-asm register constraints)
 - #90783 (Update Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-11-10 23:13:06 +00:00
Matthias Krüger a09115f3b4
Rollup merge of #89930 - cuviper:avoid-clone3, r=joshtriplett
Only use `clone3` when needed for pidfd

In #89522 we learned that `clone3` is interacting poorly with Gentoo's
`sandbox` tool. We only need that for the unstable pidfd extensions, so
otherwise avoid that and use a normal `fork`.

This is a re-application of beta #89924, now that we're aware that we need
more than just a temporary release fix. I also reverted 12fbabd27f, as
that was just fallout from using `clone3` instead of `fork`.

r? `@Mark-Simulacrum`
cc `@joshtriplett`
2021-11-10 23:04:25 +01:00
Alex Crichton 1ac5d7dcde std: Tweak expansion of thread-local const
This commit tweaks the expansion of `thread_local!` when combined with a
`const { ... }` value to help ensure that the rules which apply to
`const { ... }` blocks will be the same as when they're stabilized.
Previously with this invocation:

    thread_local!(static NAME: Type = const { init_expr });

this would generate (on supporting platforms):

    #[thread_local]
    static NAME: Type = init_expr;

instead the macro now expands to:

    const INIT_EXPR: Type = init_expr;
    #[thread_local]
    static NAME: Type = INIT_EXPR;

with the hope that because `init_expr` is defined as a `const` item then
it's not accidentally allowing more behavior than if it were put into a
`static`. For example on the stabilization issue [this example][ex] now
gives the same error both ways.

[ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-10 11:07:43 -08:00
Alex Crichton e4b3496618 Update stdarch/dlmalloc
Ensure that they compile with the now-a-feature-is-required logic.
2021-11-10 08:35:43 -08:00
Alex Crichton b5c3f4c5d8 Update dlmalloc for libstd
This pulls in a fix for wasm64 to work correctly with this dlmalloc
2021-11-10 08:35:43 -08:00
Alex Crichton 88f1bf73ee Update stdarch/compiler_builtins
Brings in some fixes and better support for the wasm64 target.
2021-11-10 08:35:42 -08:00
Alex Crichton caa9e4a2d0 Review comments 2021-11-10 08:35:42 -08:00
Alex Crichton 971638824f Use target_family = "wasm" 2021-11-10 08:35:42 -08:00
Alex Crichton 7f3ffbc8c2 std: Get the standard library compiling for wasm64
This commit goes through and updates various `#[cfg]` as appropriate to
get the wasm64-unknown-unknown target behaving similarly to the
wasm32-unknown-unknown target. Most of this is just updating various
conditions for `target_arch = "wasm32"` to also account for `target_arch
= "wasm64"` where appropriate. This commit also lists `wasm64` as an
allow-listed architecture to not have the `restricted_std` feature
enabled, enabling experimentation with `-Z build-std` externally.

The main goal of this commit is to enable playing around with
`wasm64-unknown-unknown` externally via `-Z build-std` in a way that's
similar to the `wasm32-unknown-unknown` target. These targets are
effectively the same and only differ in their pointer size, but wasm64
is much newer and has much less ecosystem/library support so it'll still
take time to get wasm64 fully-fledged.
2021-11-10 08:35:42 -08:00
Joseph Roitman 7b40448a6f Fix collection entry API documentation. 2021-11-10 12:37:18 +02:00
Matthias Krüger e7375016eb
Rollup merge of #90751 - ehuss:update-books, r=ehuss
Update books

## nomicon

1 commits in 358e6a61d5f4f0496d0a81e70cdcd25d05307342..c6b4bf831e9a40aec34f53067d20634839a6778b
2021-10-20 11:23:12 -0700 to 2021-11-09 02:30:56 +0900
- Replace some use of variant with covariant (rust-lang/nomicon#322)

## book

11 commits in fd9299792852c9a368cb236748781852f75cdac6..5c5dbc5b196c9564422b3193264f3288d2a051ce
2021-10-22 21:59:46 -0400 to 2021-11-09 19:30:43 -0500
- Fix constants link.
- Fix updated anchor
- Propagate edits to chapter 2 back
- Edits to nostarch's chapter 3 edits
- ch 3 from nostarch
- Fix Cargo.toml snippet about custom derive macros
- Snapshot of chapter 9 for nostarch
- Create tmp/src for converting quotes, not sure why this broke but ok
- Update question mark to better explain where it can be used
- Clarify sentence about Results in functions that don't return Result. Fixes rust-lang/book#2912.
- Merge pull request rust-lang/book#2913 from covariant/patch-1

## rust-by-example

2 commits in 27f1ff5e440ef78828b68ab882b98e1b10d9af32..e9d45342d7a6c1def4731f1782d87ea317ba30c3
2021-10-13 08:04:40 -0300 to 2021-11-02 13:33:03 -0500
- Enums: Linked-List Needs Re-Wording (rust-lang/rust-by-example#1469)
- fix: Use the point as top left corner for `square` (rust-lang/rust-by-example#1471)

## rustc-dev-guide

13 commits in b06008731af0f7d07cd0614e820c8276dfed1c18..196ef69aa68f2cef44f37566ee7db37daf00301b
2021-10-21 15:13:09 -0500 to 2021-11-07 07:48:47 -0600
- Fix typo: [upv.rs_mentioned] -&gt; [upvars_mentioned]
- Add note to emphasize replacing TARGET_TRIPLE (rust-lang/rustc-dev-guide#1250)
- Remove some legacy test suites.
- tiny capitalization fix
- Fix date
- Update some date-check comments
- Ensure date-check cron job is using latest stable Rust
- enhance subtree docs, link to clippy docs
- Edit introduction to bootstrapping
- Some minor adjustments to the diagnostic documentation
- Edit "About this guide" for semantic line feeds
- Fix `rustc_mir` related links (rust-lang/rustc-dev-guide#1228)
- Add documentation for LLVM CFI support

## edition-guide

3 commits in 7c0088ca744d293a5f4b1e2ac378e7c23d30fe55..27f4a84d3852e9416cae5861254fa53a825c56bd
2021-10-05 13:28:05 +0200 to 2021-11-08 10:13:20 -0500
- Add a missing period (rust-lang/edition-guide#271)
- Fix syntax error in code example (rust-lang/edition-guide#270)
- Fixed an example error of prelude.md (rust-lang/edition-guide#269)
2021-11-10 06:02:56 +01:00
Matthias Krüger ebd15290a2
Rollup merge of #90748 - cuviper:track-setgroups, r=dtolnay
Add a real tracking issue for `CommandExt::groups`

The `unstable` attribute referenced the closed RFE #38527, so I filed tracking issue #90747.
2021-11-10 06:02:55 +01:00
Eric Huss 9be22db5e1 Update books 2021-11-09 19:11:01 -08:00
Josh Stone c0fbadaba3 Add a real tracking issue for CommandExt::groups 2021-11-09 17:28:56 -08:00