Commit graph

2016 commits

Author SHA1 Message Date
Sören Meier
626bab5a7c Remove unstable Cursor::remaining 2021-07-02 16:23:44 +02:00
Thomas Versteeg
d3bf89b302
Fix double import in wasm thread
The `unsupported` type is imported two times, as `super::unsupported` and as `crate::sys::unsupported`, throwing an error. Remove `super::unsupported` in favor of the other.
2021-07-02 09:37:00 +00:00
Konrad Borowski
18715c0753 Remove & from Command::args calls in documentation
Now that arrays implement `IntoIterator`, using
`&` is no longer necessary. This makes examples
easier to understand.
2021-07-02 11:14:42 +02:00
bors
f9fa13f705 Auto merge of #85746 - m-ou-se:io-error-other, r=joshtriplett
Redefine `ErrorKind::Other` and stop using it in std.

This implements the idea I shared yesterday in the libs meeting when we were discussing how to handle adding new `ErrorKind`s to the standard library: This redefines `Other` to be for *user defined errors only*, and changes all uses of `Other` in the standard library to a `#[doc(hidden)]` and permanently `#[unstable]` `ErrorKind` that users can not match on. This ensures that adding `ErrorKind`s at a later point in time is not a breaking change, since the user couldn't match on these errors anyway. This way, we use the `#[non_exhaustive]` property of the enum in a more effective way.

Open questions:
- How do we check this change doesn't cause too much breakage? Will a crate run help and be enough?
- How do we ensure we don't accidentally start using `Other` again in the standard library? We don't have a `pub(not crate)` or `#[deprecated(in this crate only)]`.

cc https://github.com/rust-lang/rust/pull/79965

cc `@rust-lang/libs` `@ijackson`

r? `@dtolnay`
2021-07-02 09:01:42 +00:00
Taylor Yu
b3db5cd46c add owned locked stdio handles
Add stderr_locked, stdin_locked, and stdout_locked free functions
to obtain owned locked stdio handles in a single step. Also add
into_lock methods to consume a stdio handle and return an owned
lock. These methods will make it easier to use locked stdio
handles without having to deal with lifetime problems or keeping
bindings to the unlocked handles around.
2021-07-01 20:55:46 -05:00
Aris Merchant
6d34a2e007 Stabilize Seek::rewind 2021-07-01 15:08:20 -07:00
Yuki Okushi
3ec8e6c5fd
Rollup merge of #86783 - mark-i-m:mutex-drop-unsized, r=Xanewok
Move Mutex::unlock to T: ?Sized

r? ``@mbrubeck``

cc https://github.com/rust-lang/rust/issues/81872
2021-07-02 06:20:33 +09:00
Janik Rabe
2dd69aaafc Document iteration order of retain functions
For `HashSet` and `HashMap`, this simply copies the comment from
`BinaryHeap::retain`.

For `BTreeSet` and `BTreeMap`, this adds an additional guarantee that
wasn't previously documented. I think that because these data structures
are inherently ordered and other functions guarantee ordered iteration,
it makes sense to provide this guarantee for `retain` as well.
2021-07-01 22:15:13 +01:00
Mark Mansi
057bc91399 Move Mutex::unlock to T: ?Sized 2021-07-01 12:04:41 -05:00
bstrie
2db05230d3 impl From<[(K, V); N]> for std::collections 2021-06-30 17:28:17 -04:00
Amanieu d'Antras
e2536bb271 Remove "length" doc aliases 2021-06-30 20:28:51 +01:00
Amanieu d'Antras
fc2705d707 Remove "delete" doc aliases 2021-06-30 20:28:51 +01:00
Ian Jackson
a7e88e0dad impl Default, Copy, Clone for std::io::Sink and Empty
The omission of Sink: Default is causing me a slight inconvenience in
a test harness.  There seems little reason for this and Empty not to
be Clone and Copy too.

I have made all three of these insta-stable, because:

AIUI Copycan only be derived, and I was not able to find any
examples of how to unstably derive it.  I think it is probably not
possible.

I hunted through the git history for precedent and found

  79b8ad84c8
  Implement `Copy` for `IoSlice`
  https://github.com/rust-lang/rust/pull/69403

which was also insta-stable.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-30 11:58:25 +01:00
Roxane Fruytier
06afafd492 Use diagnostic items to check for Send, UnwindSafe and RefUnwindSafe traits 2021-06-29 17:47:57 -04:00
Roxane Fruytier
3e569dd2df Remove lang items Send, UnwindSafe and RefUnwindSafe 2021-06-29 17:47:57 -04:00
Mark Rousskov
06661ba759 Update to new bootstrap compiler 2021-06-28 11:30:49 -04:00
bors
17ea490310 Auto merge of #82624 - ojeda:rwlock-example-deadlock, r=JohnTitor
RWLock: Add deadlock example

Suggested in https://github.com/rust-lang/rust/pull/82596 but it was a bit too late.

`@matklad` `@azdavis` `@sfackler`
2021-06-28 09:58:06 +00:00
bors
481971978f Auto merge of #86586 - Smittyvb:https-everywhere, r=petrochenkov
Use HTTPS links where possible

While looking at #86583, I wondered how many other (insecure) HTTP links were in `rustc`. This changes most other `http` links to `https`. While most of the links are in comments or documentation, there are a few other HTTP links that are used by CI that are changed to HTTPS.

Notes:
- I didn't change any to or in licences
- Some links don't support HTTPS :(
- Some `http` links were dead, in those cases I upgraded them to their new places (all of which used HTTPS)
2021-06-26 08:24:31 +00:00
bors
6830052c7b Auto merge of #86637 - ehuss:spellings, r=dtolnay
Fix a few misspellings.
2021-06-26 05:09:27 +00:00
Eric Huss
6235e6f93f Fix a few misspellings. 2021-06-25 13:18:56 -07:00
Mara Bos
cc90733008 Restore original ordering of ErrorKind::Other. 2021-06-25 19:04:08 +00:00
Yoshua Wuyts
9f579968cd Add Integer::{log,log2,log10} variants 2021-06-25 18:52:46 +02:00
Yuki Okushi
9e4649995f
Rollup merge of #86592 - jhpratt:non_exhaustive, r=JohnTitor
Use `#[non_exhaustive]` where appropriate

Due to the std/alloc split, it is not possible to make `alloc::collections::TryReserveError::AllocError` non-exhaustive without having an unstable, doc-hidden method to construct (which negates the benefits from `#[non_exhaustive]`).

`@rustbot` label +C-cleanup +T-libs +S-waiting-on-review
2021-06-26 00:42:12 +09:00
bors
cbeda5cbeb Auto merge of #86467 - ChrisDenton:win-env-clear, r=JohnTitor
Windows: Fix `Command::env_clear` so it works if no variables are set

Previously, it would error unless at least one new environment variable was added. The missing null presumably meant that Windows was reading random memory in that case.

See: [CreateProcessW](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw) (scroll down to `lpEnvironment`). Essentially the environment block is a null terminated list of null terminated strings and an empty list is `\0\0` and not `\0`.

EDIT: Oh, [CreateEnvironmentBlock](https://docs.microsoft.com/en-gb/windows/win32/api/userenv/nf-userenv-createenvironmentblock) states this much more explicitly.

Fixes #31259
2021-06-24 17:37:29 +00:00
Chris Denton
16145a9952
Test that env_clear works on Windows 2021-06-24 09:32:24 +01:00
Jacob Pratt
3f14f4b3ce
Use #[non_exhaustive] where appropriate
Due to the std/alloc split, it is not possible to make
`alloc::collections::TryReserveError::AllocError` non-exhaustive without
having an unstable, doc-hidden method to construct (which negates the
benefits from `#[non_exhaustive]`.
2021-06-24 04:16:11 -04:00
Michael Hall
1e759bef91 make docs clearer about how hidden files are dealt with 2021-06-24 14:26:10 +10:00
Michael Hall
fcb1ebf194 change return signature for split_file_at_dot 2021-06-24 13:45:56 +10:00
Smitty
bdfcb88e8b Use HTTPS links where possible 2021-06-23 16:26:46 -04:00
bors
75ed34223a Auto merge of #84910 - eopb:stabilize_int_error_matching, r=yaahc
stabilize `int_error_matching`

closes #22639

> It has been over half a year since https://github.com/rust-lang/rust/pull/77640#pullrequestreview-511263516, and the indexing question is rejected in https://github.com/rust-lang/rust/pull/79728#pullrequestreview-633030341, so I guess we can submit another stabilization attempt? 😉

_Originally posted by `@kennytm` in https://github.com/rust-lang/rust/issues/22639#issuecomment-831738266_
2021-06-22 09:30:15 +00:00
Ethan Brierley
52a6885c50 postpone stabilizaton by one release 2021-06-22 10:20:56 +01:00
bors
2c04f0bb17 Auto merge of #86527 - JohnTitor:rollup-cbu78g4, r=JohnTitor
Rollup of 11 pull requests

Successful merges:

 - #85054 (Revert SGX inline asm syntax)
 - #85182 (Move `available_concurrency` implementation to `sys`)
 - #86037 (Add `io::Cursor::{remaining, remaining_slice, is_empty}`)
 - #86114 (Reopen #79692 (Format symbols under shared frames))
 - #86297 (Allow to pass arguments to rustdoc-gui tool)
 - #86334 (Resolve type aliases to the type they point to in intra-doc links)
 - #86367 (Fix comment about rustc_inherit_overflow_checks in abs().)
 - #86381 (Add regression test for issue #39161)
 - #86387 (Remove `#[allow(unused_lifetimes)]` which is now unnecessary)
 - #86398 (Add regression test for issue #54685)
 - #86493 (Say "this enum variant takes"/"this struct takes" instead of "this function takes")

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-06-22 01:14:31 +00:00
Yuki Okushi
7ee6b8bc43
Rollup merge of #86114 - JDuchniewicz:feat/panic-frame-fmt, r=yaahc
Reopen #79692 (Format symbols under shared frames)

Reopening #79692.
2021-06-22 07:37:47 +09:00
Yuki Okushi
4463b08652
Rollup merge of #86037 - soerenmeier:cursor_remaining, r=yaahc
Add `io::Cursor::{remaining, remaining_slice, is_empty}`

Tracking issue: #86369

I came across an inconvenience when answering the following [Stack Overflow](https://stackoverflow.com/questions/67831170) question.
To get the remaining slice you have to call `buff.fill_buf().unwrap()`. Which in my opinion doesn't really tell you what is returned (in the context of Cursor). To improve readability and convenience when using Cursor i propose adding the method `remaining`.

The next thing i found inconvenient (unnecessary long) was detecting if the cursor reached the end. There are a few ways this can be achieved right now:
- `buff.fill_buf().unwrap().is_empty()`
- `buff.position() >= buff.get_ref().len()`
- `buff.bytes().next().is_none()`

Which all seem a bit unintuitive, hidden in trait documentations or just a bit long for such a simple task.
Therefor i propose another method called `is_empty`, maybe with another name, since this one may leave room for interpretation on what really is empty (the underlying slice, the remaining slice or maybe the position).

Since it seemed easier to create this PR instead of an RFC i did that, if an RFC is wanted, i can close this PR and write an RFC first.
2021-06-22 07:37:46 +09:00
Yuki Okushi
7f1a4a287f
Rollup merge of #85182 - CDirkx:available_concurrency, r=JohnTitor
Move `available_concurrency` implementation to `sys`

This splits out the platform-specific implementation of `available_concurrency` to the corresponding platforms under `sys`. No changes are made to the implementation.

Tidy didn't lint against this code being originally added outside of `sys` because of a bug (see #84677), this PR also reverts the exclusion that was introduced in that bugfix.

Tracking issue of `available_concurrency`: #74479
2021-06-22 07:37:46 +09:00
Yuki Okushi
d6e344d45d
Rollup merge of #85054 - jethrogb:jb/sgx-inline-asm, r=Amanieu
Revert SGX inline asm syntax

This was erroneously changed in #83387
2021-06-22 07:37:42 +09:00
bors
4573a4a879 Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3
Add MIR pass to lower call to `core::slice::len` into `Len` operand

During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator.

It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how.

Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
2021-06-21 22:24:13 +00:00
Christiaan Dirkx
059008f033 Merge sys_common::bytestring into os_str_bytes 2021-06-21 12:57:14 +02:00
Christiaan Dirkx
888418a079 Use Unsupported on platforms where available_concurrency is not implemented. 2021-06-21 11:31:07 +02:00
Christiaan Dirkx
9063edaf3b Move available_concurrency implementation to sys 2021-06-21 11:01:46 +02:00
bors
dd941450fb Auto merge of #84967 - CDirkx:os_str_ext, r=m-ou-se
Move `OsStringExt` and `OsStrExt` to `std::os`

Moves the `OsStringExt` and `OsStrExt` traits and implementations from `sys_common` to `os`. `sys_common` is for abstractions over `sys` and shouldn't really contain publicly exported items.

This does introduce some duplication: the traits and implementations are now duplicated in `unix`, `wasi`, `hermit`, and `sgx`. However, I would argue that this duplication is no different to how something like `MetadataExt` is duplicated in `linux`, `vxworkx`, `redox`, `solaris` etc. The duplication also matches the fact that the traits on different platforms are technically distinct types: any platform is free to add it's own extra methods to the extension trait.
2021-06-20 16:42:13 +00:00
Ian Jackson
333d42de2c ErrorKind: Add missing full stops
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-20 17:16:24 +01:00
Ian Jackson
f00975ea7d ErrorKind::FilesystemLoop: Generalise dscription
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-20 17:05:18 +01:00
Alex Vlasov
aa53928ed7 Squashed implementation of the pass 2021-06-20 16:09:42 +02:00
Christiaan Dirkx
ad7b8975e0 Add comment to std::os::unix::ffi::os_str explaining that the module is reused on other platforms. 2021-06-20 12:06:19 +02:00
Christiaan Dirkx
835561ac5b Make os_str_bytes::{Buf, Slice} pub and repr(transparent) 2021-06-20 11:55:26 +02:00
Christiaan Dirkx
1a96d2272e Move OsStringExt and OsStrExt to std::os 2021-06-20 11:55:01 +02:00
bors
192920c22b Auto merge of #86463 - fee1-dead:fixed-encode_wide, r=m-ou-se
Account for self.extra in size_hint for EncodeWide

Fixes #86414.
2021-06-20 02:18:51 +00:00
bors
6b354a1382 Auto merge of #86034 - nagisa:nagisa/rt-soundness, r=m-ou-se
Change entry point to 🛡️ against 💥 💥-payloads

Guard against panic payloads panicking within entrypoints, where it is
UB to do so.

Note that there are a number of tradeoffs to consider. For instance, I
considered guarding against accidental panics inside the `rt::init` and
`rt::cleanup` code as well, as it is not all that obvious these may not
panic, but doing so would mean that we initialize certain thread-local
slots unconditionally, which has its own problems.

Fixes #86030
r? `@m-ou-se`
2021-06-19 17:05:08 +00:00
Christiaan Dirkx
a26237e634 Remove Ipv4Addr::is_ietf_protocol_assignment 2021-06-19 15:03:02 +02:00
Simonas Kazlauskas
9c9a0da132 Change entry point to 🛡️ against 💥 💥-payloads
Guard against panic payloads panicking within entrypoints, where it is
UB to do so.

Note that there are a number of implementation approaches to consider.
Some simpler, some more complicated. This particular solution is nice in
that it also guards against accidental implementation issues in
various pieces of runtime code, something we cannot prevent statically
right now.

Fixes #86030
2021-06-19 11:46:56 +03:00
Chris Denton
365a3586a9
Windows: Fix Command::env_clear so it works
Previously, it would error unless at least one new environment variable was added.
2021-06-19 09:46:34 +01:00
bors
39260f6d49 Auto merge of #86426 - hi-rustin:rustin-patch-lint-warn, r=Aaron1011
Lint for unused borrows as part of UNUSED_MUST_USE

close https://github.com/rust-lang/rust/issues/76264

base on https://github.com/rust-lang/rust/pull/76894

r? `@RalfJung`
2021-06-19 08:41:58 +00:00
Deadbeef
15cdb28f5b Account for self.extra in size_hint for EncodeWide 2021-06-19 12:59:22 +08:00
bors
ce1d5611a2 Auto merge of #85815 - YuhanLiin:buf-read-data-left, r=m-ou-se
Add has_data_left() to BufRead

This is a continuation of #40747 and also addresses #40745. The problem with the previous PR was that it had "eof" in its method name. This PR uses a more descriptive method name, but I'm open to changing it.
2021-06-18 20:11:51 +00:00
Ian Jackson
c8bddf3bd1 ErrorKind::NotSeekable: Fix reference to File::open()
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 19:40:31 +01:00
Ian Jackson
622a45d1b8 ErrorKind: Windows: Fix tidy
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 19:30:55 +01:00
Ian Jackson
58d0cec678 ErrorKind: Windows: Fix botched rebase
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 19:18:10 +01:00
Ian Jackson
1ec9454403 ErrorKind: Provide many more ErrorKinds, motivated by Unix errnos
Rationale for the mappings etc. is extensively discussed in the MR
  https://github.com/rust-lang/rust/pull/79965

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 18:51:53 +01:00
Ian Jackson
655053ed91 Windows error codes: Add two missing ones
For some reason these aren't in the mingw list.

We'll need them shortly.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 18:51:53 +01:00
Ian Jackson
8a4b1e4c0b Windows error codes: Add very very many from mingw
Dump mingw-64's error codes into our source tree.

I have verified with these runes:

  $ f=library/std/src/sys/windows/c/errors.rs
  $ diff -ub <(git-cat-file blob HEAD~:$f | sort) <(cat $f | perl -pe 's/WSABASEERR \+ (\d+)/10000 + $1/e' |sort) |grep ^- |less

that this does not change any existing values.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 18:51:53 +01:00
Ian Jackson
9580f3336b Windows error codes: Move to a separate module
We're going to add many more of these.

This commit is pure code motion, plus the necessary administrivia, as
I have veried with the following runes:

  $ git-diff HEAD~ | grep '^+' |sort >plus
  $ git-diff HEAD~ | grep '^-' | perl -pe 's/^-/+/' |sort >min
  $ diff -ub min plus |less

The output is precisely the expected `mod` and `use` directives.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 18:51:47 +01:00
Ian Jackson
e7fb1a71cd windows errors: Change type name for ERROR_SHARING_VIOLATION
DWORD is a type alias for u32, so this makes no difference.
But this entry is anomalous and in my forthcoming commits I am going
to import many errors wholesale, and I spotted that my wholesale
import didn't match what was here.

CC: Chris Denton <christophersdenton@gmail.com>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 18:51:47 +01:00
Ian Jackson
2a38dfbe04 ErrorKind: Fix a spurious space
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 18:46:50 +01:00
bors
88ba8ad730 Auto merge of #85747 - maxwase:path-symlinks-methods, r=m-ou-se
Path methods — symlinks improvement

This PR adds symlink method for the `Path`.

Tracking issue: #85748
For the discussion you can see [internals topic](https://internals.rust-lang.org/t/path-methods-symlinks-improvement/14776)

P.S.
I'm not fully sure about `stable` attribute, correct me if I'm wrong.
2021-06-18 17:13:19 +00:00
Ian Jackson
d59d52e455 ErrorKind: Reformat the mapping table (windows)
use ErrorKind::*;

I don't feel confident enough about Windows things to reorder this
alphabetically

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 17:53:19 +01:00
Ian Jackson
5513faa512 ErrorKind: Reformat the mapping table (unix)
* Sort the single matches alphabetically.
* use ErrorKind::*;

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 17:45:04 +01:00
Ian Jackson
f092501737 ErrorKind: Reformat the error string table
* Sort alphabetically.
* use ErrorKind::*;

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18 17:43:08 +01:00
Max Wase
01435fc83a no_run and ignore doc attributes 2021-06-18 14:17:21 +03:00
hi-rustin
88abd7d81d Lint for unused borrows as part of UNUSED_MUST_USE 2021-06-18 15:09:40 +08:00
YuhanLiin
99939c44c3 Update tracking issue 2021-06-17 23:17:16 -04:00
Mara Bos
a5dce6c99a
Rollup merge of #86357 - de-vri-es:simplify-repeated-cfg-ifs, r=m-ou-se
Rely on libc for correct integer types in os/unix/net/ancillary.rs.

This PR is a small maintainability improvement. It simplifies `unix/net/ancillary.rs` in `std` by removing the `cfg_ifs` for casting to the correct integer type, and just rely on libc to define the struct correctly.
2021-06-17 23:41:00 +02:00
Mara Bos
b7dd942e15
Rollup merge of #86202 - a1phyr:spec_io_bytes_size_hint, r=m-ou-se
Specialize `io::Bytes::size_hint` for more types

Improve the result of `<io::Bytes as Iterator>::size_hint` for some readers. I did not manage to specialize `SizeHint` for `io::Cursor`

Side question: would it be interesting for `io::Read` to have an optional `size_hint` method ?
2021-06-17 23:40:58 +02:00
Mara Bos
fcac478966
Rollup merge of #85925 - clarfonthey:lerp, r=m-ou-se
Linear interpolation

#71016 is a previous attempt at implementation that was closed by the author. I decided to reuse the feature request issue (#71015) as a tracking issue. A member of the rust-lang org will have to edit the original post to be formatted correctly as I am not the issue's original author.

The common name `lerp` is used because it is the term used by most code in a wide variety of contexts; it also happens to be the recently chosen name of the function that was added to C++20.

To ensure symmetry as a method, this breaks the usual ordering of the method from `lerp(a, b, t)` to `t.lerp(a, b)`. This makes the most sense to me personally, and there will definitely be discussion before stabilisation anyway.

Implementing lerp "correctly" is very dififcult even though it's a very common building-block used in all sorts of applications. A good prior reading is [this proposal](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0811r2.html#linear-interpolation) for the C++20 lerp which talks about the various guarantees, which I've simplified down to:

1. Exactness: `(0.0).lerp(start, end) == start` and `(1.0).lerp(start, end) == end`
2. Consistency: `anything.lerp(x, x) == x`
3. Monotonicity: once you go up don't go down

Fun story: the version provided in that proposal, from what I understand, isn't actually monotonic.

I messed around with a *lot* of different lerp implementations because I kind of got a bit obsessed and I ultimately landed on one that uses the fused `mul_add` instruction. Floating-point lerp lore is hard to come by, so, just trust me when I say that this ticks all the boxes. I'm only 90% certain that it's monotonic, but I'm sure that people who care deeply about this will be there to discuss before stabilisation.

The main reason for using `mul_add` is that, in general, it ticks more boxes with fewer branches to be "correct." Although it will be slower on architectures without the fused `mul_add`, that's becoming more and more rare and I have a feeling that most people who will find themselves needing `lerp` will also have an efficient `mul_add` instruction available.
2021-06-17 23:40:57 +02:00
Maarten de Vries
259bf5f47a Rely on libc for correct integer types in os/unix/net/ancillary.rs. 2021-06-17 15:56:47 +02:00
Yuki Okushi
31ee68067e
Rollup merge of #85802 - Thomasdezeeuw:ioslice-advance, r=m-ou-se
Rename IoSlice(Mut)::advance to advance_slice and add IoSlice(Mut)::advance

Also changes the signature of `advance_slice` to accept a `&mut &mut [IoSlice]`, not returning anything. This will better match the `IoSlice::advance` function.

Updates https://github.com/rust-lang/rust/issues/62726.
2021-06-17 21:56:41 +09:00
Mara Bos
5e7a8c6eb1
Fix typos in code examples. 2021-06-17 12:13:06 +02:00
Chris Denton
a200c01e4f
Document how Windows compares environment variables 2021-06-17 07:15:33 +01:00
Sören Meier
664bde0770 rename remaining to remaining_slice and add a new remaining 2021-06-17 02:14:53 +02:00
Yuki Okushi
0d14acad7e
Rollup merge of #86141 - amorison:link-ref-in-doc-dyn-keyword, r=kennytm
Link reference in `dyn` keyword documentation

The "read more" sentence formatted "object safety" as inline code
instead of providing a link to more information.  This PR adds a link
to the Reference about this matter, as well as the page regarding trait
objects.

---

We could also put these links in the very first line (instead of the link to the
Book) and in the first paragraph which mentions the "object safe" requirement.
Personally, I think it's good to keep the link to the Book up-front as it's more
accessible than the Reference.
2021-06-17 05:54:55 +09:00
Sören Meier
212e91a356
Update tracking issue 2021-06-16 17:25:47 +02:00
bors
9fef8d91b4 Auto merge of #86179 - the8472:revere-path-cmp, r=kennytm
optimize Eq implementation for paths

Filesystems generally have a tree-ish structure which means paths are more likely to share a prefix than a suffix. Absolute paths are especially prone to share long prefixes.

quick benchmark consisting of a search through through a vec containing the absolute paths of all (1850) files in `compiler/`:

```
# old
test path::tests::bench_path_cmp                                  ... bench:     227,407 ns/iter (+/- 2,162)

# new
test path::tests::bench_path_cmp                                  ... bench:      64,976 ns/iter (+/- 1,142)
```
2021-06-16 15:18:19 +00:00
bors
d192c80d22 Auto merge of #85820 - CDirkx:is_unicast_site_local, r=joshtriplett
Remove `Ipv6Addr::is_unicast_site_local`

Removes the unstable method `Ipv6Addr::is_unicast_site_local`, see also #85604 where I have tried to summarize related discussion so far.

Unicast site-local addresses (`fec0::/10`) were deprecated in [IETF RFC #3879](https://datatracker.ietf.org/doc/html/rfc3879), see also [RFC #4291 Section 2.5.7](https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.7). Any new implementation must no longer support the special behaviour of site-local addresses. This is mentioned in the docs of `is_unicast_site_local` and already implemented in `is_unicast_global`, which considers addresses in `fec0::/10` to have global scope, thus overlapping with `is_unicast_site_local`.

Given that RFC #3879 was published in 2004, long before Rust existed, and it is specified that any new implementation must no longer support the special behaviour of site-local addresses, I don't see how a user would ever have a need for `is_unicast_site_local`. It is also confusing that currently both `is_unicast_site_local` and `is_unicast_global` can be `true` for an address, but an address can actually only have a single scope. The deprecating RFC mentions that Site-Local scope was confusing to work with and that the classification of an address as either Link-Local or Global better matches the mental model of users.

There has been earlier discussion of removing `is_unicast_site_local` (https://github.com/rust-lang/rust/pull/60145#issuecomment-485970669) which decided against it, but that had the incorrect assumption that the method was already stable; it is not. (This confusion arose from the placement of the unstable attribute on the entire module, instead of on individual methods, resolved in #85672)

r? `@joshtriplett` as reviewer of all the related PRs
2021-06-16 01:46:08 +00:00
Christiaan Dirkx
1f2480b9d4 Document IPv4-mapped and IPv4-compatible addresses. 2021-06-15 20:10:25 +02:00
Mara Bos
a0d11a4fab Rename ErrorKind::Unknown to Uncategorized. 2021-06-15 14:30:13 +02:00
Mara Bos
82d3ef199f Fix copy-paste error in sys/hermit error message. 2021-06-15 14:22:56 +02:00
Mara Bos
0b37bb2bc2 Redefine ErrorKind::Other and stop using it in std. 2021-06-15 14:22:49 +02:00
Yuki Okushi
74cc63a7a5
Rollup merge of #86314 - Veykril:patch-2, r=JohnTitor
Remove trailing triple backticks in `mut_keyword` docs
2021-06-15 17:40:17 +09:00
Yuki Okushi
891ceab0ea
Rollup merge of #86294 - m-ou-se:edition-prelude-modules, r=joshtriplett
Stabilize {std, core}::prelude::rust_*.

This stabilizes the `{core, std}::prelude::{rust_2015, rust_2018, rust_2021}` modules.

The usage of these modules as the prelude in those editions was already stabilized. This just stabilizes the modules themselves, making it possible for a user to explicitly refer to them.

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

FCP on the RFC that included this finished here: https://github.com/rust-lang/rfcs/pull/3114#issuecomment-840577395
2021-06-15 17:40:14 +09:00
Yuki Okushi
3f4d6d73a9
Rollup merge of #85792 - mjptree:refactor-windows-sockets, r=JohnTitor
Refactor windows sockets impl methods

No behavioural changes, but a bit tidier visual flow.
2021-06-15 17:40:09 +09:00
Yuki Okushi
1e14d397db
Rollup merge of #82179 - mbartlett21:patch-5, r=joshtriplett
Add functions `Duration::try_from_secs_{f32, f64}`

These functions allow constructing a Duration from a floating point value that could be out of range without panicking.

Tracking issue: #83400
2021-06-15 17:40:03 +09:00
Yuki Okushi
2d2f1a5e88
Rollup merge of #80269 - pickfire:patch-4, r=joshtriplett
Explain non-dropped sender recv in docs

Original senders that are still hanging around could cause
Receiver::recv to not block since this is a potential footgun
for beginners, clarify more on this in the docs for readers to
be aware about it.

Maybe it would be better to show an example of the pattern where `drop(tx)` is used when it is being cloned multiple times? Although I have seen it in quite a few articles but I am surprised that this part is not very clear with the current words without careful reading.

> If the corresponding Sender has disconnected, or it disconnects while this call is blocking, this call will wake up and return Err to indicate that no more messages can ever be received on this channel. However, since channels are buffered, messages sent before the disconnect will still be properly received.

Some words there may seemed similar if I carefully read and relate it but if I am new, I probably does not know "drop" makes it "disconnected". So I mention the words "drop" and "alive" to make it more relatable to lifetime.
2021-06-15 17:39:58 +09:00
Michael Hall
a889529e98 add explicit hidden file name tests 2021-06-15 14:47:23 +10:00
Michael Hall
7465192c7d simplify logic for split_file_at_dot 2021-06-15 14:09:11 +10:00
Lukas Wirth
7cd750f16f
Update keyword_docs.rs 2021-06-15 00:22:03 +02:00
Mara Bos
65c1d35973 Stabilize {std, core}::prelude::rust_*. 2021-06-14 14:44:50 +00:00
mbartlett21
c2c1ca071f Add functions Duration::try_from_secs_{f32, f64}
This also adds the error type used, `FromSecsError` and its `impl`s.
2021-06-14 12:16:13 +00:00
Ethan Brierley
85b06e9c01 run tidy 2021-06-14 09:58:41 +01:00
Ethan Brierley
b59f7d9662 stabilize int_error_matching 2021-06-14 09:58:32 +01:00
Yuki Okushi
7fa1308db1
Stabilize maybe_uninit_ref 2021-06-14 05:08:03 +09:00
ltdk
525d76026f Change tracking issue 2021-06-13 14:04:43 -04:00
ltdk
d8e247e38c More lerp tests, altering lerp docs 2021-06-13 14:00:15 -04:00
Ivan Tham
0f3c7d18fb Explain non-dropped sender recv in docs
Original senders that are still hanging around could cause
Receiver::recv to not block since this is a potential footgun
for beginners, clarify more on this in the docs for readers to
be aware about it.

Fix minor tidbits in sender recv doc

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>

Add example for unbounded receive loops in doc

Show the drop(tx) pattern, based on tokio docs
https://tokio-rs.github.io/tokio/doc/tokio/sync/index.html

Fix example code for drop sender recv

Fix wording in sender docs

Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-06-12 14:56:46 +08:00
Benoît du Garreau
2cbd5d1df5 Specialize io::Bytes::size_hint for more types 2021-06-10 19:16:55 +02:00
Yuki Okushi
ceed619194
Rollup merge of #86051 - erer1243:update_move_keyword_docs, r=Mark-Simulacrum
Updated code examples and wording in move keyword documentation

Had a conversation with someone on the Rust Discord who was confused by the move keyword documentation. Some of the wording is odd sounding ("owned by value" - what else can something be owned by?). Also, some of the examples used Copy types when demonstrating move, leading to variables still being accessible in the outer scope after the move, contradicting the examples' comments.

I changed the move keyword documentation a bit, removing that odd wording and changing all the examples to use non-Copy types
2021-06-10 11:02:13 +09:00
Yuki Okushi
578eb6d65f
Rollup merge of #84687 - a1phyr:improve_rwlock, r=m-ou-se
Multiple improvements to RwLocks

This PR replicates #77147, #77380 and #84650 on RWLocks :
- Split `sys_common::RWLock` in `StaticRWLock` and `MovableRWLock`
- Unbox rwlocks on some platforms (Windows, Wasm and unsupported)
- Simplify `RwLock::into_inner`

Notes to reviewers :
- For each target, I copied `MovableMutex` to guess if `MovableRWLock` should be boxed.
- ~A comment says that `StaticMutex` is not re-entrant, I don't understand why and I don't know whether it applies to `StaticRWLock`.~

r? `@m-ou-se`
2021-06-10 11:02:10 +09:00
The8472
53d71c181e optimize Eq implementation for paths
Filesystems generally have a tree-ish structure which means
paths are more likely to share a prefix than a suffix. Absolute paths
are especially prone to share long prefixes.
2021-06-09 23:11:07 +02:00
Christiaan Dirkx
ed0557ec2c Remove is_unicast_site_local 2021-06-09 09:41:29 +02:00
Yuki Okushi
c961a0fc88
Rollup merge of #86121 - nickshiling:forwarding_impl_for_seek_trait_stream_position, r=dtolnay
Forwarding implementation for Seek trait's stream_position method

Forwarding implementations for `Seek` trait's `stream_position` were missed when it was stabilized in `1.51.0`
2021-06-09 12:04:05 +09:00
Yuki Okushi
3bc8221558
Rollup merge of #85791 - CDirkx:is_unicast, r=joshtriplett
Add `Ipv6Addr::is_unicast`

Adds an unstable utility method `Ipv6Addr::is_unicast` under the feature flag `ip` (tracking issue: #27709).

Added for completeness with the other unicast methods (see also https://github.com/rust-lang/rust/issues/85604#issuecomment-848220455) and opposite of `is_multicast`.
2021-06-09 12:04:01 +09:00
Yuki Okushi
e6763c966c
Rollup merge of #85676 - CDirkx:ip-style, r=JohnTitor
Fix documentation style inconsistencies for IP addresses

Pulled out of #85655 as it is unrelated. Fixes some inconsistencies in the docs for IP addresses:
- Currently some addresses are backticked, some are not, this PR backticks everything consistently. (looks better imo)
- Lowercase hex-literals are used when writing addresses.
2021-06-09 12:03:54 +09:00
Adrien Morison
7728476239 Link reference in dyn keyword documentation
The "read more" sentence formatted "object safety" as inline code
instead of providing a link to more information.  This PR adds a link
to the Reference about this matter, as well as the page regarding trait
objects.
2021-06-08 16:49:57 +01:00
myshylin
ed8a775b71 Forwarding implementation for Seek trait's stream_position method 2021-06-07 19:21:22 -04:00
Ashley Mannix
8423a19f66 make both panic display formats collapse frames 2021-06-07 21:18:55 +02:00
Ashley Mannix
5fb298664c format symbols under shared frames 2021-06-07 21:18:54 +02:00
ltdk
0865acd22b A few lerp tests 2021-06-06 22:42:53 -04:00
Reagan McFarland
eb3fd6d208 Default panic message should print Box<dyn Any>
Prior to this patch, the default panic message (resulting from calling
`panic_any(42);` for example), would print the following error message:

```
thread 'main' panicked at 'Box<Any>', ...
```

However, this should be `Box<dyn Any>` instead.
2021-06-06 16:21:47 -04:00
Max Wase
f3c1db311c
Update doc library/std/src/path.rs
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-06-06 22:42:29 +03:00
erer1243
67f4f3baec Updated code examples and wording 2021-06-05 23:44:21 -04:00
Guillaume Gomez
9c7ebc15a6
Rollup merge of #85974 - GuillaumeGomez:td-align, r=jsha
td align attribute

This is a follow-up of #85972. I have put this one on its own because it changes the display:

![Screenshot from 2021-06-03 21-49-11](https://user-images.githubusercontent.com/3050060/120703622-d533d280-c4b5-11eb-9519-ea1131a40bee.png)

Without align:

![Screenshot from 2021-06-03 21-49-15](https://user-images.githubusercontent.com/3050060/120703623-d5cc6900-c4b5-11eb-95f9-878d3915c7fb.png)

I also opened an issue about it: raphlinus/pulldown-cmark#533. However, I'm not sure if this is the right course of action... Should we instead ignore the warning?

r? ``@jsha``
2021-06-05 19:41:44 +02:00
Guillaume Gomez
114aff58fd
Rollup merge of #85760 - ChrisDenton:path-doc-platform-specific, r=m-ou-se
Possible errors when accessing file metadata are platform specific

In particular the `is_dir`, `is_file` and `exists` functions suggests that querying a file requires querying the directory. On Windows this is not normally true.

r? `@m-ou-se`
2021-06-05 19:41:43 +02:00
Guillaume Gomez
6dfde9a857
Rollup merge of #85710 - fee1-dead:document-path, r=m-ou-se
Document `From` impls in path.rs
2021-06-05 19:41:42 +02:00
Sören Meier
08d44c2cc3 Implement Cursor::{remaining, is_empty} 2021-06-05 19:02:38 +02:00
Thomas de Zeeuw
fd14c52075 Rename IoSlice(Mut)::advance_slice to advance_slices 2021-06-05 13:06:10 +02:00
Yuki Okushi
01b0e6e645
Rollup merge of #84942 - jyn514:channel-replace, r=Manishearth
rustdoc: link to stable/beta docs consistently in documentation

This is an alternative to https://github.com/rust-lang/rust/pull/84941 which fixes the problem consistently by linking to stable/beta for *all* items, not just for primitives.

 ## User-facing changes

- Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as).
- Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels).
- Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links.

Note that "links" includes both intra-doc links and rustdoc's own
automatically generated hyperlinks.

 ## Implementation changes

- Update the testsuite to allow linking to /beta and /1.52.1 in docs
- Use an html_root_url for the standard library that's dependent on the channel

  This avoids linking to nightly docs on stable.

- Update rustdoc to use channel-dependent links for primitives from an
  unknown crate

- Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync
- Include doc.rust-lang.org in the channel

cc Mark-Simulacrum - I know [you were dubious about this in the past](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs/near/231223124), but I'm not quite sure why? I see this as "just a bugfix", I don't know why rustdoc should unconditionally link to nightly.
cc dtolnay who commented in https://github.com/rust-lang/rust/issues/30693:

>  I would welcome a PR to solve this permanently if anyone has ideas for how. I don't believe we need an RFC.

Fixes https://github.com/rust-lang/rust/issues/30693 (note that issue is marked as feature-accepted, although I don't see where it was discussed).
2021-06-05 06:13:37 +09:00
Joshua Nelson
7411a9e7cc rustdoc: link to stable/beta docs consistently in documentation
## User-facing changes

- Intra-doc links to primitives that currently go to rust-lang.org/nightly/std/primitive.x.html will start going to channel that rustdoc was built with. Nightly will continue going to /nightly; Beta will link to /beta; stable compilers will link to /1.52.1 (or whatever version they were built as).
- Cross-crate links from std to core currently go to /nightly unconditionally. They will start going to /1.52.0 on stable channels (but remain the same on nightly channels).
- Intra-crate links from std to std (or core to core) currently go to the same URL they are hosted at; they will continue to do so. Notably, this is different from everything else because it can preserve the distinction between /stable and /1.52.0 by using relative links.

Note that "links" includes both intra-doc links and rustdoc's own
automatically generated hyperlinks.

 ## Implementation changes

- Update the testsuite to allow linking to /beta and /1.52.1 in docs
- Use an html_root_url for the standard library that's dependent on the channel

  This avoids linking to nightly docs on stable.

- Update rustdoc to use channel-dependent links for primitives from an
  unknown crate

- Set DOC_RUST_LANG_ORG_CHANNEL from bootstrap to ensure it's in sync
- Include doc.rust-lang.org in the channel
2021-06-04 14:18:21 -04:00
bors
efc4e377bf Auto merge of #85806 - ATiltedTree:android-ndk-beta, r=petrochenkov
Support Android ndk versions `r23-beta3` and up

Since android ndk version `r23-beta3`, `libgcc` has been replaced with `libunwind`. This moves the linking of `libgcc`/`libunwind` into the `unwind` crate where we check if the system compiler can find `libunwind` and fall back to `libgcc` if needed.
2021-06-04 16:48:50 +00:00
Guillaume Gomez
38ec87c188 Fix invalid align attribute generation on <td> elements 2021-06-04 10:10:13 +02:00
ltdk
f310d0e500 Add lerp method 2021-06-01 23:09:46 -04:00
bors
c4f186f0ea Auto merge of #85687 - m-ou-se:new-prelude, r=yaahc
New prelude

RFC: rust-lang/rfcs#3114
Tracking issue: https://github.com/rust-lang/rust/issues/85684
2021-06-02 02:36:44 +00:00
Tilmann Meyer
965997b369
Support Android ndk versions r23-beta3 and up
Since android ndk version `r23-beta3`, `libgcc` has been replaced with
`libunwind`. This moves the linking of `libgcc`/`libunwind` into the
`unwind` crate where we check if the system compiler can find
`libunwind` and fall back to `libgcc` if needed.
2021-06-01 21:37:50 +02:00
Tilmann Meyer
971a3f15f0
Update compiler_builtins to 0.1.44 2021-06-01 21:32:29 +02:00
Benoît du Garreau
ac470e9585 Multiple improvements to RwLocks
- Split `sys_common::RWLock` between `StaticRWLock` and `MovableRWLock`
- Unbox `RwLock` on some platforms (Windows, Wasm and unsupported)
- Simplify `RwLock::into_inner`
2021-06-01 09:07:55 +02:00
Christiaan Dirkx
187b415450 Use is_unicast instead of `!is_multicast 2021-05-31 09:57:43 +02:00
Christiaan Dirkx
7f27b29fd4 Add Ipv6Addr::is_unicast 2021-05-31 09:57:05 +02:00
Christiaan Dirkx
c1f0c15382 Remove is_unicast_link_local_strict 2021-05-30 00:32:17 +02:00
YuhanLiin
e76929ff98 Add has_data_left() to BufRead 2021-05-29 17:47:51 -04:00
Thomas de Zeeuw
49e25b5ef2 Add IoSlice(Mut)::advance
Advance the internal cursor of a single slice.
2021-05-29 10:18:19 +02:00
Thomas de Zeeuw
3803c090f8 Rename IoSlice(Mut)::advance to advance_slice
To make way for a new IoSlice(Mut)::advance function that advances a
single slice.

Also changes the signature to accept a `&mut &mut [IoSlice]`, not
returning anything. This will better match the future IoSlice::advance
function.
2021-05-29 10:08:00 +02:00
Michael
78d3d3790a Refactor windows sockets impl methods 2021-05-28 20:32:42 +01:00
bors
18135ec85b Auto merge of #85745 - veber-alex:panic_any, r=m-ou-se
Add #[track_caller] to panic_any

Report the panic location from the user code.

```rust
use std::panic;
use std::panic::panic_any;

fn main() {
    panic::set_hook(Box::new(|panic_info| {
        if let Some(location) = panic_info.location() {
            println!(
                "panic occurred in file '{}' at line {}",
                location.file(),
                location.line(),
            );
        } else {
            println!("panic occurred but can't get location information...");
        }
    }));

    panic_any(42);
}
````

Before:
`panic occurred in file '/rustc/ff2c947c00f867b9f012e28ba88cecfbe556f904/library/std/src/panic.rs' at line 59`

After:
`panic occurred in file 'src/main.rs' at line 17`
2021-05-28 06:08:58 +00:00
Chris Denton
536d98238c
Possible errors when reading file metadata are platform specific
In particular the `is_dir`, `is_file` and `exists` functions says that querying a file requires querying the directory. On Windows this is not normally true.
2021-05-27 22:06:56 +01:00
Max Wase
a0958df56f Review fixes + doc-features 2021-05-27 18:02:21 +03:00
Deadbeef
2967626150
Document From impls in path.rs 2021-05-27 13:50:28 +00:00
Max Wase
2d88c52ab7 Tracking issue add. 2021-05-27 16:11:54 +03:00
Max Wase
89c0f50b09 Fix is_symlink() method for Path using added is_symlink() method for Metadata 2021-05-27 16:04:08 +03:00
Max Wase
e1cf38fa89 Add is_symlink() method for Path. 2021-05-27 15:20:36 +03:00
Alex Veber
ef13f27bc7 Add #[track_caller] to panic_any 2021-05-27 14:19:47 +03:00
Albert Ford
3cafe2a43f
Rename opensbd to openbsd 2021-05-26 23:17:13 -07:00
Dylan DPC
955e0f42fc
Rollup merge of #85719 - elichai:cstring-into_inner-inline, r=m-ou-se
Add inline attr to CString::into_inner so it can optimize out NonNull checks

It seems that currently if you convert any of the standard library's container to a pointer and then to a NonNull pointer, all will optimize out the NULL check except `CString`(https://godbolt.org/z/YPKW9G5xn),
because for some reason `CString::into_inner` isn't inlined even though it's a private function that should compile into a simple `mov` instruction.

Adding a simple `#[inline]` attribute solves this, code example:
```rust
use std::ffi::CString;
use std::ptr::NonNull;

pub fn cstring_nonull(mut n: CString) -> NonNull<i8> {
    NonNull::new(CString::into_raw(n)).unwrap()
}
```

assembly before:
```asm
__ZN3wat14cstring_nonull17h371c755bcad76294E:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	callq	__ZN3std3ffi5c_str7CString10into_inner17h28ece07b276e2878E
	testq	%rax, %rax
	je	LBB0_2
	popq	%rbp
	retq
LBB0_2:
	leaq	l___unnamed_1(%rip), %rdi
	leaq	l___unnamed_2(%rip), %rdx
	movl	$43, %esi
	callq	__ZN4core9panicking5panic17h92a83fa9085a8f73E
	.cfi_endproc

	.section	__TEXT,__const
l___unnamed_1:
	.ascii	"called `Option::unwrap()` on a `None` value"

l___unnamed_3:
	.ascii	"wat.rs"

	.section	__DATA,__const
	.p2align	3
l___unnamed_2:
	.quad	l___unnamed_3
	.asciz	"\006\000\000\000\000\000\000\000\006\000\000\000(\000\000"
```

Assembly after:
```asm
__ZN3wat14cstring_nonull17h9645eb9341fb25d7E:
	.cfi_startproc
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	movq	%rdi, %rax
	popq	%rbp
	retq
	.cfi_endproc
```

(Related discussion on zulip: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/NonNull.20From.3CBox.3CT.3E.3E)
2021-05-27 03:02:11 +02:00
Elichai Turkel
45099e6cf6 Add inline attr to private CString::into_inner 2021-05-26 13:12:54 +03:00
Yuki Okushi
7caf93fa1b
Rollup merge of #85672 - CDirkx:ip, r=Mark-Simulacrum
Move stability attribute for items under the `ip` feature

The `#[unstable]` attribute for items under the `ip` feature is currently located on the `std::net::ip` module itself. This is unusual, and less readable. This has sidetracked discussion about these items numerous times (https://github.com/rust-lang/rust/pull/60145#issuecomment-498016572, https://github.com/rust-lang/rust/pull/76098#discussion_r530463543, https://github.com/rust-lang/rust/pull/76098#discussion_r558067755, https://github.com/rust-lang/rust/pull/75019#discussion_r467464300, https://github.com/rust-lang/rust/pull/75019#issuecomment-672888727) and lead to incorrect assumptions about which items are actually stable (https://github.com/rust-lang/rust/pull/60145#issuecomment-485970669, https://github.com/rust-lang/rust/pull/76098#discussion_r530444275).

This PR moves the attribute from the module to the items themselves.
2021-05-26 13:31:07 +09:00
Yuki Okushi
ae6a1a7043
Rollup merge of #85529 - tlyu:trylock-errors, r=JohnTitor
doc: clarify Mutex::try_lock, etc. errors

Clarify error returns from Mutex::try_lock, RwLock::try_read,
RwLock::try_write to make it more obvious that both poisoning
and the lock being already locked are possible errors.
2021-05-26 13:30:58 +09:00
Mara Bos
e37ef7a842 Add tracking issue for edition-specific preludes. 2021-05-25 19:58:39 +02:00
Christiaan Dirkx
7234141f95 Fix documentation style inconsistencies 2021-05-25 16:42:21 +02:00
Christiaan Dirkx
87cf2d4726 Move stability attribute for methods under the ip feature from the module to the methods themselves 2021-05-25 15:57:27 +02:00
bors
a7890c7952 Auto merge of #84985 - pietroalbini:bootstrap-1.54, r=Mark-Simulacrum
Bump bootstrap compiler to beta 1.53.0

This PR bumps the bootstrap compiler to version 1.53.0 beta, as part of our usual release process (this was supposed to be Wednesday's step, but creating the beta release took longer than expected).

The PR also includes the "Bootstrap: skip rustdoc fingerprint for building docs" commit, see the reasoning [on Zulip](https://zulip-archive.rust-lang.org/241545trelease/88450153betabootstrap.html).

r? `@Mark-Simulacrum`
2021-05-25 05:48:00 +00:00
Guillaume Gomez
2a8eeafa9d
Rollup merge of #85271 - th1000s:master, r=JohnTitor
Fix indentation in move keyword documentation

See (at the time of writing) the second example code block with `create_fn()` at https://doc.rust-lang.org/std/keyword.move.html
2021-05-24 18:53:29 +02:00
Pietro Albini
9e22b844dd remove cfg(bootstrap) 2021-05-24 11:07:48 -04:00
Taylor Yu
0e4f8cb661 minor rewording after review
Use "the `WouldBlock` error" instead of "the error `WouldBlock`", etc.
2021-05-24 09:24:35 -05:00
bors
6e92fb4098 Auto merge of #85490 - CDirkx:fix-vxworks, r=dtolnay
Fix `vxworks`

Some PRs made the `vxworks` target not build anymore. This PR fixes that:

- #82973: copy `ExitStatusError` implementation from `unix`.
- #84716: no `libc::chroot` available on `vxworks`, so for now don't implement `os::unix::fs::chroot`.
2021-05-23 05:40:18 +00:00
Dylan DPC
4430aab045
Rollup merge of #85334 - r00ster91:patch-8, r=dtolnay
Add doc aliases to `unit`

I think it makes sense for `unit` to have the same doc aliases as `tuple` does.
2021-05-23 03:23:41 +02:00
Dylan DPC
b1e0d5fda5
Rollup merge of #85288 - Geal:clarify-std-io-read, r=dtolnay
add an example to explain std::io::Read::read returning 0 in some cases

I have always found the explanation about `Read::read` returning 0 to indicate EOF but not indefinitely, so here's more info using Linux as example. I can also add example code if necessary
2021-05-23 03:23:37 +02:00
Dylan DPC
d5fa533ab0
Rollup merge of #84758 - ChrisDenton:dllimport, r=dtolnay
MSVC: Avoid using jmp stubs for dll function imports

Windows import libraries contain two symbols for every function: `__imp_FunctionName` and `FunctionName` (where `FunctionName` is the name of the function to be imported).

`__imp_FunctionName` contains the address of the imported function. This will be filled in by the Windows executable loader at runtime. `FunctionName` contains a jmp stub that simply jumps to the address given by `__imp_FunctionName`. E.g. it's a function that solely contains a single jmp instruction:

```asm
jmp __imp_FunctionName
```

When using an external DLL function in Rust, by default the linker will link to FunctionName, causing a bit of indirection at runtime. In Microsoft's C++ it's possible to instead tell it to insert calls to the address in `__imp_FunctionName` by using the  `__declspec(dllimport)` attribute. In Rust it's possible to get effectively the same behaviour using the `#[link]` attribute on `extern` blocks.

----

The second commit also merges multiple `extern` blocks into one block. This is because otherwise Rust will currently create duplicate linker arguments for each block. In this case having duplicates shouldn't matter much other than the noise when displaying the linker command.
2021-05-23 03:23:34 +02:00
Aaron Rennow
bc45e474a0 Add std::os::unix::fs::DirEntryExt2::file_name_ref(&self) -> &OsStr
DirEntryExt2 is a new trait with the same purpose as DirEntryExt,
but sealed
2021-05-21 21:53:03 -04:00
bors
f36b137074 Auto merge of #85060 - ChrisDenton:win-file-exists, r=yaahc
Windows implementation of feature `path_try_exists`

Draft of a Windows implementation of `try_exists` (#83186).

The first commit reorganizes the code so I would be interested to get some feedback on if this is a good idea or not. It moves the `Path::try_exists` function to `fs::exists`. leaving the former as a wrapper for the latter. This makes it easier to provide platform specific implementations and matches the `fs::metadata` function.

The other commit implements a Windows specific variant of `exists`. I'm still figuring out my approach so this is very much a first draft. Eventually this will need some more eyes from knowledgable Windows people.
2021-05-21 05:47:24 +00:00
Taylor Yu
e5873660fc doc: clarify Mutex::try_lock, etc. errors
Clarify error returns from Mutex::try_lock, RwLock::try_read,
RwLock::try_write to make it more obvious that both poisoning
and the lock being already locked are possible errors.
2021-05-20 17:36:48 -05:00
bors
40d2302047 Auto merge of #85521 - alexcrichton:less-tls-inline, r=Mark-Simulacrum
std: Don't inline TLS accessor on MinGW

This is causing [issues] on Cargo's own CI for MinGW and given the
original investigation there's no reason that MinGW should work when
MSVC doesn't, this this tweaks the MSVC exception to being a Windows exception.

[issues]: https://github.com/rust-lang/cargo/runs/2626676503?check_suite_focus=true#step:9:2453
2021-05-20 21:11:19 +00:00
Alex Crichton
75df635cb8 std: Don't inline TLS accessor on MinGW
This is causing [issues] on Cargo's own CI for MinGW and given the
original investigation there's no reason that MinGW should work when
MSVC doesn't, this this tweaks the MSVC exception to being a Windows exception.

[issues]: https://github.com/rust-lang/cargo/runs/2626676503?check_suite_focus=true#step:9:2453
2021-05-20 12:45:05 -07:00
Guillaume Gomez
0d3bee8be0
Rollup merge of #85275 - CDirkx:memchr, r=m-ou-se
Move `std::memchr` to `sys_common`

`std::memchr` is a thin abstraction over the different `memchr` implementations in `sys`, along with documentation and tests. The module is only used internally by `std`, nothing is exported externally. Code like this is exactly what the `sys_common` module is for, so this PR moves it there.
2021-05-20 17:56:46 +02:00
bors
8a57820bca Auto merge of #84665 - adamgemmell:aarch64-features, r=Amanieu
Update list of allowed aarch64 features

I recently added these features to std_detect for aarch64 linux, pending [review](https://github.com/rust-lang/stdarch/pull/1146).

I have commented any features not supported by LLVM 9, the current minimum version for Rust. Some (PAuth at least) were renamed between 9 & 12 and I've left them disabled. TME, however, is not in LLVM 9 but I've left it enabled.

See https://github.com/rust-lang/stdarch/issues/993
2021-05-20 13:07:35 +00:00
bors
35bab923c8 Auto merge of #85486 - RalfJung:rollup-4ibcxuu, r=RalfJung
Rollup of 8 pull requests

Successful merges:

 - #84717 (impl FromStr for proc_macro::Literal)
 - #85169 (Add method-toggle to <details> for methods)
 - #85287 (Expose `Concurrent` (private type in public i'face))
 - #85315 (adding time complexity for partition_in_place iter method)
 - #85439 (Add diagnostic item to `CStr`)
 - #85464 (Fix UB in documented example for `ptr::swap`)
 - #85470 (Fix invalid CSS rules for a:hover)
 - #85472 (CTFE Machine: do not expose Allocation)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-20 07:39:24 +00:00
bors
5ab0f37087 Auto merge of #84697 - CDirkx:util, r=m-ou-se
Introduce `sys_common::rt::rtprintpanic!` to replace `sys_common::util` functionality

This PR introduces a new macro `rtprintpanic!`, similar to `sys_common::util::dumb_print` and uses that macro to replace all `sys_common::util` functionality.
2021-05-20 04:58:13 +00:00
Christiaan Dirkx
03e90b7f7e Not implement os::unix::fs::chroot for vxworks 2021-05-20 01:37:57 +02:00
Christiaan Dirkx
63791233ff Add ExitStatusError for vxworks 2021-05-20 01:34:06 +02:00
Chris Denton
86dbc063ab
Windows implementation of fs::try_exists 2021-05-19 23:55:33 +01:00
Chris Denton
2c2c1593ac
Move the implementation of Path::exists to sys_common::fs so platforms can specialize it
Windows implementation of `fs::try_exists`
2021-05-19 23:54:56 +01:00
Chris Denton
8345538fec
Windows Command environment variables are case-preserving
But comparing is case-insensitive.
2021-05-19 23:34:15 +01:00
Ralf Jung
1207b7fa0b
Rollup merge of #85439 - mgacek8:add_diagnostic_item_to_CStr_type, r=davidtwco
Add diagnostic item to `CStr`

Required for clippy issue: https://github.com/rust-lang/rust-clippy/issues/7145
2021-05-20 00:19:07 +02:00
bors
3bcaeb0bf9 Auto merge of #84876 - alexcrichton:inline-thread-locals-cross-crate, r=Mark-Simulacrum
std: Attempt again to inline thread-local-init across crates

Issue #25088 has been part of `thread_local!` for quite some time now.
Historical attempts have been made to add `#[inline]` to `__getit`
in #43931, #50252, and #59720, but these attempts ended up not landing
at the time due to segfaults on Windows.

In the interim though with `const`-initialized thread locals AFAIK this
is the only remaining bug which is why you might want to use
`#[thread_local]` over `thread_local!`. As a result I figured it was
time to resubmit this and see how it fares on CI and if I can help
debugging any issues that crop up.

Closes #25088
2021-05-19 15:59:46 +00:00
Adam Gemmell
d3737a6607 Remove test for crypto feature ahead of its removal 2021-05-19 16:13:52 +01:00
Christiaan Dirkx
4ff5ab5296 Rename rterr to rtprintpanic 2021-05-19 15:52:09 +02:00
Christiaan Dirkx
6145051eee Replace sys_common::util::dumb_print with rterr! 2021-05-19 15:05:35 +02:00
Christiaan Dirkx
236705f3c3 Replace sys_common::util::report_overflow with rterr! 2021-05-19 15:01:52 +02:00
Christiaan Dirkx
b987f74f05 Remove sys_common::util::abort 2021-05-19 15:01:50 +02:00
Christiaan Dirkx
5b0908587e Introduce sys_common::rt::rterr! 2021-05-19 15:01:47 +02:00
bors
9f8012e3aa Auto merge of #85458 - jackh726:rollup-zvvybmt, r=jackh726
Rollup of 8 pull requests

Successful merges:

 - #83366 (Stabilize extended_key_value_attributes)
 - #83767 (Fix v0 symbol mangling bug)
 - #84883 (compiletest: "fix" FileCheck with --allow-unused-prefixes)
 - #85274 (Only pass --[no-]gc-sections if linker is GNU ld.)
 - #85297 (bootstrap: build cargo only if requested in tools)
 - #85396 (rustdoc: restore header sizes)
 - #85425 (Fix must_use on `Option::is_none`)
 - #85438 (Fix escape handling)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-19 04:44:09 +00:00
Jack Huey
3c99dcd82d
Rollup merge of #83366 - jyn514:stabilize-key-value-attrs, r=petrochenkov
Stabilize extended_key_value_attributes

Closes https://github.com/rust-lang/rust/issues/44732. Closes https://github.com/rust-lang/rust/issues/78835. Closes https://github.com/rust-lang/rust/issues/82768 (by making it irrelevant).

 # Stabilization report

 ## Summary

This stabilizes using macro expansion in key-value attributes, like so:

 ```rust
 #[doc = include_str!("my_doc.md")]
 struct S;

 #[path = concat!(env!("OUT_DIR"), "/generated.rs")]
 mod m;
 ```

See Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455)
for alternatives that were considered and rejected ("why accept no more and no less?")

This has been available on nightly since 1.50 with no major issues.

## Notes

### Accepted syntax

The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`).  Note that decorators and the like may be able to observe other expression forms.

### Expansion ordering

Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input.

There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work).

## Test cases

 - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs
 - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs

The feature has also been dogfooded extensively in the compiler and
standard library:

- https://github.com/rust-lang/rust/pull/83329
- https://github.com/rust-lang/rust/pull/83230
- https://github.com/rust-lang/rust/pull/82641
- https://github.com/rust-lang/rust/pull/80534

## Implementation history

- Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412
- Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121
- Preliminary work to restrict expansion that would conflict with this
feature: https://github.com/rust-lang/rust/pull/77271
- Initial implementation: https://github.com/rust-lang/rust/pull/78837
- Fix for an ICE: https://github.com/rust-lang/rust/pull/80563

## Unresolved Questions

~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~

 ## Additional Information

 There are two workarounds that have a similar effect for `#[doc]`
attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons:

```rust
macro_rules! forward_inner_docs {
    ($e:expr => $i:item) => {
        #[doc = $e]
        $i
    };
}

forward_inner_docs!(include_str!("lib.rs") => struct S {});
```

This also works for other attributes (like `#[path = concat!(...)]`).
The other is to use `doc(include)`:

```rust
 #![feature(external_doc)]
 #[doc(include = "lib.rs")]
 struct S {}
```

The first works, but is non-trivial for people to discover, and
difficult to read and maintain. The second is a strange special-case for
a particular use of the macro. This generalizes it to work for any use
case, not just including files.

I plan to remove `doc(include)` when this is stabilized
(https://github.com/rust-lang/rust/pull/82539). The `forward_inner_docs`
workaround will still compile without warnings, but I expect it to be
used less once it's no longer necessary.
2021-05-18 22:35:54 -04:00
bors
3d31363338 Auto merge of #85176 - a1phyr:impl_clone_from, r=yaahc
Override `clone_from` for some types

Override `clone_from` method of the `Clone` trait for:
- `cell::RefCell`
- `cmp::Reverse`
- `io::Cursor`
- `mem::ManuallyDrop`

This can bring performance improvements.
2021-05-19 02:17:41 +00:00
Alex Crichton
641d3b09f4 std: Attempt again to inline thread-local-init across crates
Issue #25088 has been part of `thread_local!` for quite some time now.
Historical attempts have been made to add `#[inline]` to `__getit`
in #43931, #50252, and #59720, but these attempts ended up not landing
at the time due to segfaults on Windows.

In the interim though with `const`-initialized thread locals AFAIK this
is the only remaining bug which is why you might want to use
`#[thread_local]` over `thread_local!`. As a result I figured it was
time to resubmit this and see how it fares on CI and if I can help
debugging any issues that crop up.

Closes #25088
2021-05-18 11:22:04 -07:00
Jorge Ferreira
d13745d99b
fix typo 2021-05-18 17:05:40 +01:00
Mateusz Gacek
d730cc6646 Add diagnostic item to CStr 2021-05-18 15:45:30 +02:00
bors
25a277f03d Auto merge of #82973 - ijackson:exitstatuserror, r=yaahc
Provide ExitStatusError

Closes #73125

In MR #81452 "Add #[must_use] to [...] process::ExitStatus" we concluded that the existing arrangements in are too awkward so adding that `#[must_use]` is blocked on improving the ergonomics.

I wrote a mini-RFC-style discusion of the approach in https://github.com/rust-lang/rust/issues/73125#issuecomment-771092741
2021-05-18 08:01:32 +00:00
Joshua Nelson
e48b6b4599 Stabilize extended_key_value_attributes
# Stabilization report

 ## Summary

This stabilizes using macro expansion in key-value attributes, like so:

 ```rust
 #[doc = include_str!("my_doc.md")]
 struct S;

 #[path = concat!(env!("OUT_DIR"), "/generated.rs")]
 mod m;
 ```

See the changes to the reference for details on what macros are allowed;
see Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455)
for alternatives that were considered and rejected ("why accept no more
and no less?")

This has been available on nightly since 1.50 with no major issues.

 ## Notes

 ### Accepted syntax

The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`).  Note that decorators and the like may be able to observe other expression forms.

 ### Expansion ordering

Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input.

There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work).

 ## Test cases

 - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs
 - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs

The feature has also been dogfooded extensively in the compiler and
standard library:

- https://github.com/rust-lang/rust/pull/83329
- https://github.com/rust-lang/rust/pull/83230
- https://github.com/rust-lang/rust/pull/82641
- https://github.com/rust-lang/rust/pull/80534

 ## Implementation history

- Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412
- Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121
- Preliminary work to restrict expansion that would conflict with this
feature: https://github.com/rust-lang/rust/pull/77271
- Initial implementation: https://github.com/rust-lang/rust/pull/78837
- Fix for an ICE: https://github.com/rust-lang/rust/pull/80563

 ## Unresolved Questions

~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~

 ## Additional Information

 There are two workarounds that have a similar effect for `#[doc]`
attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons:

```rust
macro_rules! forward_inner_docs {
    ($e:expr => $i:item) => {
        #[doc = $e]
        $i
    };
}

forward_inner_docs!(include_str!("lib.rs") => struct S {});
```

This also works for other attributes (like `#[path = concat!(...)]`).
The other is to use `doc(include)`:

```rust
 #![feature(external_doc)]
 #[doc(include = "lib.rs")]
 struct S {}
```

The first works, but is non-trivial for people to discover, and
difficult to read and maintain. The second is a strange special-case for
a particular use of the macro. This generalizes it to work for any use
case, not just including files.

I plan to remove `doc(include)` when this is stabilized. The
`forward_inner_docs` workaround will still compile without warnings, but
I expect it to be used less once it's no longer necessary.
2021-05-18 01:01:36 -04:00
Ralf Jung
360db9c384
Rollup merge of #85409 - CDirkx:cfg_redox, r=nagisa
Simplify `cfg(any(unix, target_os="redox"))` in example to just `cfg(unix)`

Update example for `OsString` that handled `redox` seperately from `unix`: Redox has been completely integrated under `target_family="unix"`, so `cfg(unix)` implies `target_os="redox"`

35dbef2350/compiler/rustc_target/src/spec/redox_base.rs (L26)
2021-05-17 18:52:13 +02:00
Ralf Jung
8a1403af1e
Rollup merge of #85302 - r00ster91:patch-7, r=joshtriplett
Expand WASI abbreviation in docs

I was pretty sure this was related to something for WebAssembly but wasn't 100% sure so I checked but even on these top-level docs I couldn't find the abbreviation expanded. I'm normally used to Rust docs being detailed and explanatory and writing abbreviations like this out in full at least once so I thought it was worth the change. Feel free to close this if it's too much.
2021-05-17 18:52:04 +02:00
Christiaan Dirkx
383642714a Simplify cfg(any(unix, target_os="redox")) to just cfg(unix) 2021-05-17 13:49:14 +02:00
bors
d565c74887 Auto merge of #81858 - ijackson:fork-no-unwind, r=m-ou-se
Do not allocate or unwind after fork

### Objective scenarios

 * Make (simple) panics safe in `Command::pre_exec_hook`, including most `panic!` calls, `Option::unwrap`, and array bounds check failures.
 * Make it possible to `libc::fork` and then safely panic in the child (needed for the above, but this requirement means exposing the new raw hook API which the `Command` implementation needs).
 * In singlethreaded programs, where panic in `pre_exec_hook` is already memory-safe, prevent the double-unwinding malfunction #79740.

I think we want to make panic after fork safe even though the post-fork child environment is only experienced by users of `unsafe`, beause the subset of Rust in which any panic is UB is really far too hazardous and unnatural.

#### Approach

 * Provide a way for a program to, at runtime, switch to having panics abort.  This makes it possible to panic without making *any* heap allocations, which is needed because on some platforms malloc is UB in a child forked from a multithreaded program (see https://github.com/rust-lang/rust/pull/80263#issuecomment-774272370, and maybe also the SuS [spec](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html)).
 * Make that change in the child spawned by `Command`.
 * Document the rules comprehensively enough that a programmer has a fighting chance of writing correct code.
 * Test that this all works as expected (and in particular, that there aren't any heap allocations we missed)

Fixes #79740

#### Rejected (or previously attempted) approaches

 * Change the panic machinery to be able to unwind without allocating, at least when the payload and message are both `'static`.  This seems like it would be even more subtle.  Also that is a potentially-hot path which I don't want to mess with.
 * Change the existing panic hook mechanism to not convert the message to a `String` before calling the hook.  This would be a surprising change for existing code and would not be detected by the type system.
 * Provide a `raw_panic_hook` function to intercept panics in a way that doesn't allocate.  (That was an earlier version of this MR.)

### History

This MR could be considered a v2 of #80263.  Thanks to everyone who commented there.  In particular, thanks to `@m-ou-se,` `@Mark-Simulacrum` and `@hyd-dev.`  (Tagging you since I think you might be interested in this new MR.)  Compared to #80263, this MR has very substantial changes and additions.

Additionally, I have recently (2021-04-20) completely revised this series following very helpful comments from `@m-ou-se.`

r? `@m-ou-se`
2021-05-15 22:27:09 +00:00
r00ster
10c43c3980
Add doc aliases to unit 2021-05-15 17:31:32 +02:00
Guillaume Gomez
5a8619b435
Rollup merge of #85221 - ijackson:dbg-doc-re-tests, r=joshtriplett
dbg macro: Discuss use in tests, and slightly clarify

As discussed in a tangent in #82778.

I chose to use [semantic newlines](https://rhodesmill.org/brandon/2012/one-sentence-per-line/) in the source text but I don't mind reformatting it.
2021-05-15 13:29:50 +02:00
Guillaume Gomez
c4f81c12ea
Rollup merge of #85207 - andrewhalle:typo-rootseparator, r=kennytm
Fix typo in comment

missing space in "rootseparator"
2021-05-15 13:29:48 +02:00
r00ster
4f66337df2
Expand WASI abbreviation in docs 2021-05-14 22:03:00 +02:00
Geoffroy Couprie
95ccdb11da add an example to explain std::io::Read::read returning 0 in some cases
the example focuses on Linux, but that should be enough to explain how
the behaviour can change
2021-05-14 18:06:31 +02:00
Christiaan Dirkx
5353c5c3fb Move std::memchr to sys_common 2021-05-14 03:54:46 +02:00
Amanieu d'Antras
d9cf2ce28f Update compiler_builtins to 0.1.43 2021-05-13 22:32:44 +01:00
Amanieu d'Antras
5918ee4317 Add support for const operands and options to global_asm!
On x86, the default syntax is also switched to Intel to match asm!
2021-05-13 22:31:57 +01:00
Thomas Otto
95920d15b9 Fix indentation in move keyword documentation 2021-05-13 23:01:38 +02:00
Ian Jackson
6369637a19 Tolerate SIGTRAP for panic abort after panic::always_abort
Some platforma (eg ARM64) apparently generate SIGTRAP for panic abort!

See eg
  https://github.com/rust-lang/rust/pull/81858#issuecomment-840702765

This is probably a bug, but we don't want to entangle this MR with it.
When it's fixed, this commit should be reverted.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-13 18:42:52 +01:00
Ian Jackson
b36a3162fe
Change "etc." to "and similar"
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-05-13 15:02:02 +01:00
bors
28e2b29b89 Auto merge of #84730 - sexxi-goose:rox-auto-trait, r=nikomatsakis
Add auto traits and clone trait migrations for RFC2229

This PR
- renames the existent RFC2229 migration `disjoint_capture_drop_reorder` to `disjoint_capture_migration`
- add additional migrations for auto traits and clone trait

Closes rust-lang/project-rfc-2229#29
Closes rust-lang/project-rfc-2229#28

r? `@nikomatsakis`
2021-05-12 13:33:32 +00:00
Ian Jackson
a173518ceb dbg macro: Discuss use in tests, and slightly clarify
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12 12:09:53 +01:00
Ian Jackson
26c782b8e7 ExitStatusError: Remove mentions in stable docs
We should revert this commit when this is stabilised.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12 11:12:20 +01:00
Ian Jackson
46871539e4 impl crate::error::Error for ExitStatusError
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12 11:12:20 +01:00
Ian Jackson
bb4ef68639 ExitStatusError: Be more verbose in Display impl
Co-authored-by: Jane Lusby <jlusby@yaah.dev>
2021-05-12 11:12:19 +01:00
Ian Jackson
8832b0a81c Fix typo in doc
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-05-12 11:12:19 +01:00
Ian Jackson
60a4d9612d unix: impl ExitStatusExt for ExitStatusError
It is unergnomic to have to say things like
   bad.into_status().signal()

Implementing `ExitStatusExt` for `ExitStatusError` fixes this.
Unfortunately it does mean making a previously-infallible method
capable of panicing, although of course the existing impl remains
infallible.

The alternative would be a whole new `ExitStatusErrorExt` trait.

`<ExitStatus as ExitStatusExt>::into_raw()` is not particularly
ergonomic to call because of the often-required type annotation.
See for example the code in the test case in
  library/std/src/sys/unix/process/process_unix/tests.rs

Perhaps we should provide equivalent free functions for `ExitStatus`
and `ExitStatusExt` in std::os::unix::process and maybe deprecate this
trait method.  But I think that is for the future.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12 11:12:19 +01:00
Ian Jackson
e893089ea0 Provide ExitStatusError
Closes #73125

This is in pursuance of
  Issue #73127 Consider adding #[must_use] to std::process::ExitStatus

In
  MR #81452 Add #[must_use] to [...] process::ExitStatus
we concluded that the existing arrangements in are too awkward
so adding that #[must_use] is blocked on improving the ergonomics.

I wrote a mini-RFC-style discusion of the approach in
  https://github.com/rust-lang/rust/issues/73125#issuecomment-771092741

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12 11:12:19 +01:00
Andrew Halle
3c06f00985 Fix typo in comment
missing space in "rootseparator"
2021-05-11 18:13:01 -07:00
Yuki Okushi
6ec4f91610
Rollup merge of #85136 - shirshak55:master, r=dtolnay
Change param name (k to key and v to value) in std::env module

1. When I was reading code the ide displayed `k` and `v`, so I
thought it would be better to show key and value?

2. I noticed var method already uses `key` instead of `k` so it
is more consistent to use `key` instead of `k`?

Thanks
2021-05-12 07:18:02 +09:00
Roxane
564b4de626 use the correct attributes and add helper function 2021-05-11 14:01:33 -04:00
Benoît du Garreau
9332ac3bfc Override clone_from for some types 2021-05-11 13:00:34 +02:00
bors
506e75cbf8 Auto merge of #85109 - RalfJung:remove-const_fn, r=oli-obk
remove const_fn feature gate

Fixes https://github.com/rust-lang/rust/issues/84510
r? `@oli-obk`
2021-05-11 10:25:14 +00:00
bors
fe62c6e295 Auto merge of #80300 - LeSeulArtichaut:80275-doc-inline, r=Manishearth
Emit errors/warns on some wrong uses of rustdoc attributes

This PR adds a few diagnostics:
- error if conflicting `#[doc(inline)]`/`#[doc(no_inline)]` are found
- introduce the `invalid_doc_attributes` lint (warn-by-default) which triggers:
  - if a crate-level attribute is used on a non-`crate` item
  - if `#[doc(inline)]`/`#[doc(no_inline)]` is used on a non-`use` item

The code could probably be improved but I wanted to get feedback first. Also, some of those changes could be considered breaking changes, so I don't know what the procedure would be? ~~And finally, for the warnings, they are currently hard warnings, maybe it would be better to introduce a lint?~~ (EDIT: introduced the `invalid_doc_attributes` lint)

Closes #80275.
r? `@jyn514`
2021-05-11 05:03:18 +00:00
Michael Hall
b1d84f721e add missing windows tests 2021-05-11 11:41:37 +10:00
Michael Hall
3e2206a29a add file_prefix method 2021-05-11 10:29:57 +10:00
LeSeulArtichaut
804ab9f78e Remove an invalid #[doc(inline)] 2021-05-11 00:03:44 +02:00
Ian Jackson
7ae852e349 io::Seek: Set tracking issue
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 13:55:31 +01:00
Ian Jackson
3113b6bd69
Fix typo in doc
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-10 13:50:56 +01:00
Ian Jackson
c3ca148ac0 io::Seek: Provide rewind()
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 13:03:49 +01:00
Ian Jackson
74e0e45f3c io::Seek: Mention that seeking can fail due to buffer flush fail
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 12:57:19 +01:00
shirshak55
0778e8dcb8 change k to key and v to v in std::env mod 2021-05-10 19:31:09 +08:00
Ian Jackson
b50c1bbb0e windows: provide NonZeroDWORD
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10 11:18:08 +01:00
Ralf Jung
bafc51e01a remove const_fn feature gate 2021-05-09 14:29:31 +02:00
Jethro Beekman
5bbf8cf331 Revert SGX inline asm syntax
This was erroneously changed in #83387
2021-05-07 23:49:24 +02:00
Ian Jackson
8220f2f212 panic/fork test: Do not run on emscripten
fork fails there.  The failure message is confusing: so c.status()
returns an Err, the closure panics, and the test thinks the panic was
propagated from inside the child.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07 16:51:13 +01:00
Dylan DPC
62b68f9688
Rollup merge of #85030 - jethrogb:jb/sgx-rearrange-files, r=nagisa
Rearrange SGX split module files

In #75979 several inlined modules were split out into multiple files.
This PR keeps the multiple files but moves a few things around to
organize things in a coherent way.
2021-05-07 16:19:24 +02:00
Dylan DPC
73d3544fb9
Rollup merge of #85029 - jethrogb:jb/sgx-movable-mutex, r=m-ou-se
SGX mutex is movable

r? ``@m-ou-se``
2021-05-07 16:19:23 +02:00
Dylan DPC
8f0b1863d0
Rollup merge of #84655 - CDirkx:wasm, r=m-ou-se
Cleanup of `wasm`

Some more cleanup of `sys`, this time `wasm`

- Reuse `unsupported::args` (functionally equivalent implementation, just an empty iterator).
- Split out `atomics` implementation of `wasm::thread`, the non-`atomics` implementation is reused from `unsupported`.
- Move all of the `atomics` code to a separate directory `wasm/atomics`.

````@rustbot```` label: +T-libs-impl
r? ````@m-ou-se````
2021-05-07 16:19:20 +02:00
Jethro Beekman
bfa84842e5 Rearrange SGX split module files
In #75979 several inlined modules were split out into multiple files.
This PR keeps the multiple files but moves a few things around to
organize things in a coherent way.
2021-05-07 13:55:03 +02:00
Jethro Beekman
30b82e0f96 SGX mutex is movable 2021-05-07 13:21:38 +02:00
Ian Jackson
a17eab7bed panic ui test: Provide comprehensive test for panic after fork
This tests that we can indeed safely panic after fork, both
a raw libc::fork and in a Command pre_exec hook.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07 11:17:44 +01:00
Ian Jackson
f8015061c8 panic tests: Command: Test that we do not unwind past fork
This is safe (does not involve heap allocation) but we don't yet have
a test to ensure that stays true.  That will come in a moment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07 11:17:44 +01:00
Ian Jackson
9283cdca36 unix process: pre_exec: Discuss panic safety
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07 11:17:44 +01:00
Ian Jackson
820123a949 panic/fork: Command: Do not unwind after fork() in child
Unwinding after fork() in the child is UB on some platforms, because
on those (including musl) malloc can be UB in the child of a
multithreaded program, and unwinding must box for the payload.

Even if it's safe, unwinding past fork() in the child causes whatever
traps the unwind to return twice.  This is very strange and clearly
not desirable.  With the default behaviour of the thread library, this
can even result in a panic in the child being transformed into zero
exit status (ie, success) as seen in the parent!

Fixes #79740.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-07 11:17:44 +01:00
Ian Jackson
3cba120ba4 std panicking: ALWAYS_ABORT: use Relaxed memory ordering
As per
  https://github.com/rust-lang/rust/pull/81858#discussion_r626507810

Suggested-by: Mara Bos <m-ou.se@m-ou.se>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-07 11:17:44 +01:00
Ian Jackson
1b1bf24636 std panicking: Provide panic::always_abort
We must change the atomic read on panic entry to `Acquire`, to pick up
a possible an `always_panic` on another thread.

We add `count` to the names of panic_count::get and ::is_zaero,
because now there is another reason why panic ought to maybe abort.
Renaming these ensures that we have checked every call site to ensure
that they don't need further adjustment.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07 11:17:44 +01:00
Ian Jackson
a9f43a2a8f std panicking: Make decrease() return ()
Nothing uses the return value.  This will make the next changes
easier.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-07 11:17:44 +01:00
Dylan DPC
b30e428689
Rollup merge of #84409 - mzohreva:mz/tls-dtors-before-join, r=jethrogb
Ensure TLS destructors run before thread joins in SGX

The excellent test is from ```@jethrogb```

For context see: https://github.com/rust-lang/rust/pull/83416#discussion_r617282907
2021-05-07 00:38:33 +02:00
bors
676ee14729 Auto merge of #79930 - tgnottingham:bufwriter_performance, r=m-ou-se
Optimize BufWriter
2021-05-06 20:04:32 +00:00
Roxane
9afea614bf Add additional migrations to handle auto-traits and clone traits
Combine all 2229 migrations under one flag name
2021-05-06 14:17:59 -04:00
Mohsen Zohrevandi
2acd62d7c3 join_orders_after_tls_destructors: ensure thread 2 is launched before thread 1 enters TLS destructors 2021-05-06 09:36:26 -07:00
Dylan DPC
2ed0134cfa
Rollup merge of #84712 - joshtriplett:simplify-chdir, r=yaahc
Simplify chdir implementation and minimize unsafe block
2021-05-06 13:30:55 +02:00
Dylan DPC
6a6c644016
Rollup merge of #84328 - Folyd:stablize_map_into_keys_values, r=m-ou-se
Stablize {HashMap,BTreeMap}::into_{keys,values}

I would propose to stabilize `{HashMap,BTreeMap}::into_{keys,values}`( aka. `map_into_keys_values`).

Closes #75294.
2021-05-06 13:30:54 +02:00
Chris Denton
fc40aa059b
Use the proper import library names 2021-05-06 04:04:19 +01:00
Chris Denton
25712afd94
Add #[link] attributes to dll imports
This avoids using jmp stubs when calling functions exported from a dll.
2021-05-06 02:41:51 +01:00
bors
bacf770f29 Auto merge of #84956 - RalfJung:rollup-m70mx2n, r=RalfJung
Rollup of 11 pull requests

Successful merges:

 - #83553 (Update `ptr` docs with regards to `ptr::addr_of!`)
 - #84183 (Update RELEASES.md for 1.52.0)
 - #84709 (Add doc alias for `chdir` to `std::env::set_current_dir`)
 - #84803 (Reduce duplication in `impl_dep_tracking_hash` macros)
 - #84808 (Account for unsatisfied bounds in E0599)
 - #84843 (use else if in std library )
 - #84865 (rustbuild: Pass a `threads` flag that works to windows-gnu lld)
 - #84878 (Clarify documentation for `[T]::contains`)
 - #84882 (platform-support: Center the contents of the `std` and `host` columns)
 - #84903 (Remove `rustc_middle::mir::interpret::CheckInAllocMsg::NullPointerTest`)
 - #84913 (Do not ICE on invalid const param)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-05-05 17:45:41 +00:00
Ralf Jung
4c4b3e81df
Rollup merge of #84709 - joshtriplett:doc-alias-chdir, r=dtolnay
Add doc alias for `chdir` to `std::env::set_current_dir`

Searching for `chdir` in the Rust documentation produces no useful
results.

I wrote some code recently that called `libc::chdir` and manually
handled errors, because I didn't realize that the safe
`std::env::set_current_dir` existed. I searched for `chdir` and
`change_dir` and `change_directory` (the latter two based on the
precedent of unabbreviating set by `create_dir`), and I also read
through `std::fs` expecting to potentially find it there. Given that
none of those led to `std::env::set_current_dir`, I think that provides
sufficient justification to add this specific alias.
2021-05-05 17:52:20 +02:00
Ralf Jung
722bebf163
Rollup merge of #83553 - jfrimmel:addr-of, r=m-ou-se
Update `ptr` docs with regards to `ptr::addr_of!`

This updates the documentation since `ptr::addr_of!` and `ptr::addr_of_mut!` are now stable. One might remove the distinction between the sections `# On packed structs` and `# Examples`, as the old section on packed structs was primarily to prevent users of doing undefined behavior, which is not necessary anymore.

Technically there is now wrong/outdated documentation on stable, but I don't think this is worth a point release 😉

Fixes #83509.

``````````@rustbot`````````` modify labels: T-doc
2021-05-05 17:52:18 +02:00
Mara Bos
b6f3dbb65d Bump map_into_keys_values stable version to 1.54.0. 2021-05-05 16:40:06 +02:00
bors
342db70ae4 Auto merge of #84200 - CDirkx:os, r=m-ou-se
Move all `sys::ext` modules to `os`

This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`.

Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around https://github.com/rust-analyzer/rust-analyzer/issues/6038.

`@rustbot` label: +T-libs-impl
2021-05-05 14:15:19 +00:00
Julian Frimmel
389333a21c Update ptr docs with regards to ptr::addr_of!
This updates the documentation since `ptr::addr_of!` and
`ptr::addr_of_mut!` are now stable. One might remove the distinction
between the sections `# On packed structs` and `# Examples`, as the old
section on packed structs was primarily to prevent users of doing unde-
fined behavior, which is not necessary anymore.
There is also a new section in "how to obtain a pointer", which referen-
ces the `ptr::addr_of!` macros.

This commit contains squashed commits from code review.

Co-authored-by: Joshua Nelson <joshua@yottadb.com>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
Co-authored-by: Soveu <marx.tomasz@gmail.com>
Co-authored-by: Ralf Jung <post@ralfj.de>
2021-05-03 23:14:17 +02:00
Christiaan Dirkx
0caa20ee5d Allow documenting on hermit 2021-05-03 16:56:22 +02:00
Christiaan Dirkx
a0ca3f94f0 Rework os to avoid using cfg_if! with public items 2021-05-03 16:56:22 +02:00
Christiaan Dirkx
e098d2730a Move std::sys::sgx::ext to std::os::fortanix_sgx 2021-05-03 16:56:21 +02:00
Christiaan Dirkx
3edba7a806 Move std::sys::wasi::ext to std::os::wasi 2021-05-03 16:56:21 +02:00
Christiaan Dirkx
a808fd44a3 Move std::sys::unix::ext to std::os::unix 2021-05-03 16:56:21 +02:00
Christiaan Dirkx
ffc20e48de Move std::sys::windows::ext to std::os::windows 2021-05-03 16:56:20 +02:00
Christiaan Dirkx
7024bfffbd Move std::sys::hermit::ext to std::os::hermit 2021-05-03 16:56:20 +02:00
Christiaan Dirkx
0e2cd33db8 Cleanup std::os 2021-05-03 16:56:20 +02:00
Guillaume Gomez
2604440d8a
Rollup merge of #84856 - kornelski:enomem, r=JohnTitor
Correct stability of ErrorKind::OutOfMemory

Fix for #84744
2021-05-03 15:08:10 +02:00
Guillaume Gomez
dd5fc8edb8
Rollup merge of #84835 - wcampbell0x2a:add-issue-34202-link, r=m-ou-se
Add link to Issue #34202 in udp docs
2021-05-03 15:08:02 +02:00
Kornel
2247d46b11 Correct stability of ErrorKind::OutOfMemory 2021-05-03 10:28:19 +01:00
bors
2428cc4816 Auto merge of #84842 - blkerby:null_lowercase, r=joshtriplett
Replace 'NULL' with 'null'

This replaces occurrences of "NULL" with "null" in docs, comments, and compiler error/lint messages. This is for the sake of consistency, as the lowercase "null" is already the dominant form in Rust. The all-caps NULL looks like the C macro (or SQL keyword), which seems out of place in a Rust context, given that NULL does not exist in the Rust language or standard library (instead having [`ptr::null()`](https://doc.rust-lang.org/stable/std/ptr/fn.null.html)).
2021-05-03 05:41:23 +00:00
Brent Kerby
6679f5ceb1 Change 'NULL' to 'null' 2021-05-02 17:46:00 -06:00
wcampbell
e4250a014e
Add link to Issue #34202 in udp docs
Signed-off-by: wcampbell <wcampbell1995@gmail.com>
2021-05-02 19:13:41 -04:00
Kornel
19568f9a83 Use ErrorKind::OutOfMemory in unix, windows, and wasi 2021-05-02 11:40:32 +01:00
Kornel
541c8d898e Add ErrorKind::OutOfMemory 2021-05-02 11:40:31 +01:00
bors
603a42ec54 Auto merge of #84658 - Amanieu:reserved_regs, r=petrochenkov
Be stricter about rejecting LLVM reserved registers in asm!

LLVM will silently produce incorrect code if these registers are used as operands.

cc `@rust-lang/wg-inline-asm`
2021-05-01 13:01:24 +00:00
Amanieu d'Antras
ea310d9253 Reserve x18 on AArch64 and un-reserve x16 2021-05-01 13:25:56 +01:00
Amanieu d'Antras
09cfb248e7 Avoid using rbx in SGX inline assembly since it is reserved 2021-04-30 18:27:12 +01:00
bors
7506228e2e Auto merge of #84716 - joshtriplett:chroot, r=dtolnay
Add std::os::unix::fs::chroot to change the root directory of the current process

This is a straightforward wrapper that uses the existing helpers for C
string handling and errno handling.

Having this available is convenient for UNIX utility programs written in
Rust, and avoids having to call the unsafe `libc::chroot` directly and
handle errors manually, in a program that may otherwise be entirely safe
code.
2021-04-30 12:19:37 +00:00
bors
49920bc581 Auto merge of #84522 - CDirkx:cmath, r=yaahc
Reuse `sys::unix::cmath` on other platforms

Reuse `sys::unix::cmath` on all non-`windows` platforms.

`unix` is chosen as the canonical location instead of `unsupported` or `common` because `unsupported` doesn't make sense semantically and `common` is reserved for code that is supported on all platforms. Also `unix` is already the home of some non-`windows` code that is technically not exclusive to `unix` like `unix::path`.
2021-04-30 09:52:32 +00:00
Josh Triplett
ffb874ac90 Add std::os::unix::fs::chroot to change the root directory of the current process
This is a straightforward wrapper that uses the existing helpers for C
string handling and errno handling.

Having this available is convenient for UNIX utility programs written in
Rust, and avoids having to call the unsafe `libc::chroot` directly and
handle errors manually, in a program that may otherwise be entirely safe
code.
2021-04-30 00:11:03 -07:00
Jack Huey
6e50ac8a34
Rollup merge of #84692 - r00ster91:var-var_os-vars, r=joshtriplett
Link between std::env::{var, var_os} and std::env::{vars, vars_os}

In #84551 I linked between `std::env::{args, args_os}` and this PR does the same but for `std::env::{var, var_os}` and `std::env::{vars, vars_os}`. Now all of `std::env::{var, var_os, vars, vars_os, args, args_os}` should each mention their `_os` or non-`_os` equivalent in the docs so that you can easily navigate between them.
2021-04-29 19:27:25 -04:00
Jack Huey
e720df672d
Rollup merge of #84590 - est31:array_into_iter, r=nikomatsakis
Point out that behavior might be switched on 2015 and 2018 too one day

Reword documentation to make it clear that behaviour can be switched on older editions too, one day in the future. It doesn't *have* to be switched, but I think it's good to have it as an option and re-evaluate it a few months/years down the line when e.g. the crates that showed up in crater were broken by different changes in the language already.

cc #25725, #65819, #66145, #84147 , and https://github.com/rust-lang/rust/issues/84133#issuecomment-818005314
2021-04-29 19:27:21 -04:00
Josh Triplett
8a2e67e0d0 Simplify chdir implementation and minimize unsafe block 2021-04-29 13:11:20 -07:00
Josh Triplett
c185f08e46 Add doc alias for chdir to std::env::set_current_dir
Searching for `chdir` in the Rust documentation produces no useful
results.
2021-04-29 12:41:23 -07:00
Mohsen Zohrevandi
8a0a4b1493 Use atomics in join_orders_after_tls_destructors test
std::sync::mpsc uses thread locals and depending on the order TLS dtors
are run `rx.recv()` can panic when used in a TLS dtor.
2021-04-29 08:51:18 -07:00
r00ster91
d0c0b8a4a3 Link between std::env::{var, var_os} and std::env::{vars, vars_os} 2021-04-29 13:15:49 +02:00
est31
a3523363db Ignore doctests in bootstrap
On bootstrap the IntoIterator trait is not implemented
yet for arrays.
2021-04-29 12:39:23 +02:00
Jack Huey
ccd04a5281
Rollup merge of #84663 - CDirkx:dropguard, r=Mark-Simulacrum
Remove `DropGuard` in `sys::windows::process` and use `StaticMutex` instead

`StaticMutex` is a mutex that when locked provides a guard that unlocks the mutex again when dropped, thus provides the exact same functionality as `DropGuard`. `StaticMutex` is used in more places, and is thus preferred over an ad-hoc construct like `DropGuard`.

````@rustbot```` label: +T-libs-impl
2021-04-28 22:59:31 -04:00
bors
50ca3ac24f Auto merge of #84615 - a1phyr:clone_from_pathbuf_osstring, r=Mark-Simulacrum
Override `clone_from` method for PathBuf and OsString

This was not the case before because `#[derive(Clone)]` do not do it.
2021-04-28 23:25:23 +00:00
bors
da43ee8d82 Auto merge of #84650 - a1phyr:simplify_mutex_into_inner, r=m-ou-se
Simplify `Mutex::into_inner`

Thanks to #77147, `Mutex` do not implement `Drop` directly, so the old unsafe implementation of `into_inner` is not relevant anymore.
2021-04-28 18:08:01 +00:00
Christiaan Dirkx
1ac632627b Remove DropGuard in sys::windows::process and use StaticMutex instead 2021-04-28 19:11:57 +02:00
Christiaan Dirkx
cf79c06575 Fix missing import in unsupported::args 2021-04-28 16:16:01 +02:00
Christiaan Dirkx
45bc1930ca Reuse unsupported::args on wasm 2021-04-28 16:14:03 +02:00
Christiaan Dirkx
fab8410801 Move wasm atomics code to wasm/atomics 2021-04-28 16:14:01 +02:00
Christiaan Dirkx
52fa9daa64 Rework wasm::thread to thread_atomics 2021-04-28 15:51:14 +02:00
Christiaan Dirkx
26fb1e373b Reuse unix::cmath 2021-04-28 14:25:04 +02:00
Benoît du Garreau
0b7b121c29 Simplify Mutex::into_inner 2021-04-28 13:56:23 +02:00