Commit graph

1354 commits

Author SHA1 Message Date
bors
5662d9343f Auto merge of #80965 - camelid:rename-doc-spotlight, r=jyn514
Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]`

Fixes #80936.

"spotlight" is not a very specific or self-explaining name.
Additionally, the dialog that it triggers is called "Notable traits".
So, "notable trait" is a better name.

* Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]`
* Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]`
* Update documentation
* Improve documentation

r? `@Manishearth`
2021-04-02 07:04:58 +00:00
Frank Steffahn
7509aa108c Apply suggestions from code review
More links, one more occurrence of “a OsString”

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2021-03-31 16:09:25 +02:00
Frank Steffahn
f5e7dbb20a Add a few missing links, fix a typo 2021-03-31 16:02:59 +02:00
Frank Steffahn
e7821e5475 Fix documentation of conversion from String to OsString 2021-03-31 16:02:52 +02:00
Dylan DPC
2aa1bf8984
Rollup merge of #83680 - ibraheemdev:patch-2, r=Dylan-DPC
Update for loop desugaring docs

It looks like the documentation for `for` loops was not updated to match the new de-sugaring process.
2021-03-31 01:14:49 +02:00
Dylan DPC
d51fc973e4
Rollup merge of #83678 - GuillaumeGomez:hack-Self-keyword-conflict, r=jyn514
Fix Self keyword doc URL conflict on case insensitive file systems (until definitely fixed on rustdoc)

This is just a hack to allow rustup to work on macOS and windows again to distribute std documentation (hopefully once https://github.com/rust-lang/rfcs/pull/3097 or an equivalent is merged).

Fixes https://github.com/rust-lang/rust/issues/80504. Prevents https://github.com/rust-lang/rust/issues/83154 and https://github.com/rust-lang/rustup/issues/2694 in future releases.

cc ``@kinnison``
r? ``@jyn514``
2021-03-31 01:14:48 +02:00
Dylan DPC
7391124154
Rollup merge of #80720 - steffahn:prettify_prelude_imports, r=camelid,jyn514
Make documentation of which items the prelude exports more readable.

I recently figured out that rustdoc allows link inside of inline code blocks as long as they’re delimited with `<code> </code>` instead of `` ` ` ``. I think this applies nicely in the listing of prelude exports [in the docs](https://doc.rust-lang.org/std/prelude/index.html). There, currently unformatted `::` and `{ , }` is used in order to mimick import syntax while attatching links to individual identifiers.

## Rendered Comparison
### Currently (light)
![Screenshot_20210105_155801](https://user-images.githubusercontent.com/3986214/103661510-1a87be80-4f6f-11eb-8360-1dfb23f732e8.png)

### After this PR (light)
![Screenshot_20210105_155811](https://user-images.githubusercontent.com/3986214/103661533-1f4c7280-4f6f-11eb-89d4-874793937824.png)

### Currently (dark)
![Screenshot_20210105_155824](https://user-images.githubusercontent.com/3986214/103661571-2a9f9e00-4f6f-11eb-95f9-e291b5570b41.png)

### After this PR (dark)
![Screenshot_20210105_155836](https://user-images.githubusercontent.com/3986214/103661592-2ffce880-4f6f-11eb-977a-82afcb07d331.png)

### Currently (ayu)
![Screenshot_20210105_155917](https://user-images.githubusercontent.com/3986214/103661619-39865080-4f6f-11eb-9ca1-9045a107cddd.png)

### After this PR (ayu)
![Screenshot_20210105_155923](https://user-images.githubusercontent.com/3986214/103661652-3db26e00-4f6f-11eb-82b7-378e38f0c41f.png)

_Edit:_ I just noticed, the “current” screenshots are from stable, so there are a few more differences in the pictures than the ones from just this PR.
2021-03-31 01:14:40 +02:00
bors
74874a690b Auto merge of #83652 - xu-cheng:ipv4-octal, r=sfackler
Disallow octal format in Ipv4 string

In its original specification, leading zero in Ipv4 string is interpreted
as octal literals. So a IP address 0127.0.0.1 actually means 87.0.0.1.

This confusion can lead to many security vulnerabilities. Therefore, in
[IETF RFC 6943], it suggests to disallow octal/hexadecimal format in Ipv4
string all together.

Existing implementation already disallows hexadecimal numbers. This commit
makes Parser reject octal numbers.

Fixes #83648.

[IETF RFC 6943]: https://tools.ietf.org/html/rfc6943#section-3.1.1
2021-03-30 19:34:23 +00:00
Ibraheem Ahmed
29fe5930a3
update for loop desugaring docs 2021-03-30 12:03:58 -04:00
Guillaume Gomez
f35e587db4 Fix Self keyword doc URL conflict on case insensitive file systems 2021-03-30 16:37:13 +02:00
bors
7b6fc5a3dd Auto merge of #83170 - joshtriplett:spawn-cleanup, r=kennytm
Simplify Command::spawn (no semantic change)

This minimizes the size of an unsafe block, and allows outdenting some
complex code.
2021-03-30 14:26:01 +00:00
Cheng XU
974192cd98
Disallow octal format in Ipv4 string
In its original specification, leading zero in Ipv4 string is interpreted
as octal literals. So a IP address 0127.0.0.1 actually means 87.0.0.1.

This confusion can lead to many security vulnerabilities. Therefore, in
[IETF RFC 6943], it suggests to disallow octal/hexadecimal format in Ipv4
string all together.

Existing implementation already disallows hexadecimal numbers. This commit
makes Parser reject octal numbers.

Fixes #83648.

[IETF RFC 6943]: https://tools.ietf.org/html/rfc6943#section-3.1.1
2021-03-30 10:24:23 +08:00
Dylan DPC
772582e19e
Rollup merge of #83374 - reyk:fix/bsd-ancillary, r=joshtriplett
unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDs

This adds support for CMSG handling on macOS and fixes it on OpenBSD and possibly other BSDs.

When traversing the CMSG list, the previous code had an exception for Android where the next element after the last pointer could point to the first pointer instead of NULL.  This is actually not specific to Android: the `libc::CMSG_NXTHDR` implementation for Linux and emscripten have a special case to return NULL when the length of the previous element is zero; most other implementations simply return the previous element plus a zero offset in this case.

This MR makes the check non-optional which fixes CMSG handling and a possible endless loop on such systems; tested with file descriptor passing on OpenBSD, Linux, and macOS.

This MR additionally adds `SocketAncillary::is_empty` because clippy is right that it should be added.

This belongs to the `feature(unix_socket_ancillary_data)` tracking issue:  https://github.com/rust-lang/rust/issues/76915

r? `@joshtriplett`
2021-03-30 00:32:21 +02:00
Josh Triplett
68dbdfb5bf Simplify Command::spawn (no semantic change)
This minimizes the size of an unsafe block, and allows outdenting some
complex code.
2021-03-29 13:37:24 -07:00
Frank Steffahn
761296bcb3 Change back prelude headline 2021-03-29 15:14:14 +02:00
klensy
a0ff4612f2 ffi::c_str smaller as_bytes 2021-03-29 15:32:25 +03:00
klensy
84542d22a7 ffi::c_str added tests for empty strings 2021-03-28 19:58:49 +03:00
Dylan DPC
7d6af6751c
Rollup merge of #83555 - m-ou-se:inline-io-error-new-const, r=jackh726
Add #[inline] to io::Error methods

Fixes #82812
2021-03-27 20:37:13 +01:00
Dylan DPC
aee7b9e7d6
Rollup merge of #83522 - pickfire:patch-6, r=JohnTitor
Improve fs error open_from unix

Consistency for #79399
Suggested by JohnTitor

r? `@JohnTitor`

Not user if the error is too long now, do we handle long errors well?
2021-03-27 20:37:11 +01:00
Dylan DPC
b2e254318d
Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se
Add function core::iter::zip

This makes it a little easier to `zip` iterators:

```rust
for (x, y) in zip(xs, ys) {}
// vs.
for (x, y) in xs.into_iter().zip(ys) {}
```

You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
`iter()`, respectively. This can also support arbitrary nesting, where
it's easier to see the item layout than with arbitrary `zip` chains:

```rust
for ((x, y), z) in zip(zip(xs, ys), zs) {}
for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
// vs.
for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
```

It may also format more nicely, especially when the first iterator is a
longer chain of methods -- for example:

```rust
    iter::zip(
        trait_ref.substs.types().skip(1),
        impl_trait_ref.substs.types().skip(1),
    )
    // vs.
    trait_ref
        .substs
        .types()
        .skip(1)
        .zip(impl_trait_ref.substs.types().skip(1))
```

This replaces the tuple-pair `IntoIterator` in #78204.
There is prior art for the utility of this in [`itertools::zip`].

[`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
2021-03-27 20:37:07 +01:00
Yuki Okushi
a800d7f63f
Rollup merge of #83561 - m-ou-se:lock-debug, r=jackh726
Improve Debug implementations of Mutex and RwLock.

This improves the Debug implementations of Mutex and RwLock.

They now show the poison flag and use debug_non_exhaustive. (See #67364.)
2021-03-28 01:33:21 +09:00
Yuki Okushi
8ad5f2143e
Rollup merge of #83560 - m-ou-se:io-chain-debug, r=sfackler
Derive Debug for io::Chain instead of manually implementing it.

This derives Debug for io::Chain instead of manually implementing it.

The manual implementation has the same bounds, so I don't think there's any reason for a manual implementation. The names used in the derive implementation are even nicer (`first`/`second`) than the manual implementation (`t`/`u`), and include the `done_first` field too.
2021-03-28 01:33:19 +09:00
Yuki Okushi
5dc29e189b
Rollup merge of #83559 - m-ou-se:rwlock-guard-debug-fix, r=jackh726
Fix Debug implementation for RwLock{Read,Write}Guard.

This would attempt to print the Debug representation of the lock that the guard has locked, which will try to lock again, fail, and just print `"<locked>"` unhelpfully.

After this change, this just prints the contents of the mutex, like the other smart pointers (and MutexGuard) do.

MutexGuard had this problem too: https://github.com/rust-lang/rust/issues/57702
2021-03-28 01:33:18 +09:00
Yuki Okushi
53cc8065a0
Rollup merge of #83558 - m-ou-se:use-finish-non-exhaustive, r=jackh726
Use DebugStruct::finish_non_exhaustive() in std.

See https://github.com/rust-lang/rust/issues/67364
2021-03-28 01:33:17 +09:00
Yuki Okushi
3f41fdd2eb
Rollup merge of #83462 - ijackson:exitstatus-message-wording, r=joshtriplett
ExitStatus: print "exit status: {}" rather than "exit code: {}" on unix

Proper Unix terminology is "exit status" (vs "wait status").  "exit
code" is imprecise on Unix and therefore unclear.  (As far as I can
tell, "exit code" is correct terminology on Windows.)

This new wording is unfortunately inconsistent with the identifier
names in the Rust stdlib.

It is the identifier names that are wrong, as discussed at length in eg
  https://doc.rust-lang.org/nightly/std/process/struct.ExitStatus.html
  https://doc.rust-lang.org/nightly/std/os/unix/process/trait.ExitStatusExt.html

Unfortunately for API stability reasons it would be a lot of work, and
a lot of disruption, to change the names in the stdlib (eg to rename
`std::process::ExitStatus` to `std::process::ChildStatus` or
something), but we should fix the message output.  Many (probably
most) readers of these messages about exit statuses will be users and
system administrators, not programmers, who won't even know that Rust
has this wrong terminology.

So I think the right thing is to fix the documentation (as I have
already done) and, now, the terminology in the implementation.

This is a user-visible change to the behaviour of all Rust programs
which run Unix subprocesses.  Hopefully no-one is matching against the
exit status string, except perhaps in tests.
2021-03-28 01:33:15 +09:00
Yuki Okushi
1f33a6a0da
Rollup merge of #79399 - pickfire:patch-3, r=JohnTitor
Use detailed and shorter fs error explaination

Includes suggestion from `@the8472` https://github.com/rust-lang/rust/issues/79390#issuecomment-733263336
2021-03-28 01:33:11 +09:00
Ivan Tham
6c6ef7317b Improve fs error open_from unix
Consistency for #79399
Suggested by JohnTitor

Improve fs error invaild input for sys_common

The text was duplicated from unix.
2021-03-27 21:23:48 +08:00
Ivan Tham
5495ce0874 Use detailed and shorter fs error explaination
Includes suggestion from the8472 https://github.com/rust-lang/rust/issues/79390#issuecomment-733263336

More detail error explanation in fs doc
2021-03-27 20:55:51 +08:00
Mara Bos
5402abc493 Improve Debug implementations of Mutex and RwLock.
They now show the poison flag and use debug_non_exhaustive.
2021-03-27 13:47:11 +01:00
Mara Bos
7c01e6c38a Derive Debug for io::Chain instead of manually implementing it.
The manual implementation has the same bounds, so I don't think there's
any reason for a manual implementation. The names used in the derive
implementation are even nicer (`first`/`second`) than the manual
implementation (`t`/`u`), and include the `done_first` field too.
2021-03-27 13:37:52 +01:00
Mara Bos
d73015397d Fix Debug implementation for RwLock{Read,Write}Guard.
This would attempt to print the Debug representation of the lock that
the guard has locked, which will try to lock again, fail, and just print
"<locked>" unhelpfully.

After this change, this just prints the contents of the mutex, like the
other smart pointers (and MutexGuard) do.
2021-03-27 13:33:52 +01:00
Mara Bos
2afa4cc958 Use DebugStruct::finish_non_exhaustive() in std. 2021-03-27 13:29:23 +01:00
Mara Bos
ee1b33c7ac Add #[inline] to io::Error methods. 2021-03-27 12:22:17 +01:00
bors
aef11409b4 Auto merge of #78618 - workingjubilee:ieee754-fmt, r=m-ou-se
Add IEEE 754 compliant fmt/parse of -0, infinity, NaN

This pull request improves the Rust float formatting/parsing libraries to comply with IEEE 754's formatting expectations around certain special values, namely signed zero, the infinities, and NaN. It also adds IEEE 754 compliance tests that, while less stringent in certain places than many of the existing flt2dec/dec2flt capability tests, are intended to serve as the beginning of a roadmap to future compliance with the standard. Some relevant documentation is also adjusted with clarifying remarks.

This PR follows from discussion in https://github.com/rust-lang/rfcs/issues/1074, and closes #24623.

The most controversial change here is likely to be that -0 is now printed as -0. Allow me to explain: While there appears to be community support for an opt-in toggle of printing floats as if they exist in the naively expected domain of numbers, i.e. not the extended reals (where floats live), IEEE 754-2019 is clear that a float converted to a string should be capable of being transformed into the original floating point bit-pattern when it satisfies certain conditions (namely, when it is an actual numeric value i.e. not a NaN and the original and destination float width are the same). -0 is given special attention here as a value that should have its sign preserved. In addition, the vast majority of other programming languages not only output `-0` but output `-0.0` here.

While IEEE 754 offers a broad leeway in how to handle producing what it calls a "decimal character sequence", it is clear that the operations a language provides should be capable of round tripping, and it is confusing to advertise the f32 and f64 types as binary32 and binary64 yet have the most basic way of producing a string and then reading it back into a floating point number be non-conformant with the standard. Further, existing documentation suggested that e.g. -0 would be printed with -0 regardless of the presence of the `+` fmt character, but it prints "+0" instead if given such (which was what led to the opening of #24623).

There are other parsing and formatting issues for floating point numbers which prevent Rust from complying with the standard, as well as other well-documented challenges on the arithmetic level, but I hope that this can be the beginning of motion towards solving those challenges.
2021-03-27 10:40:16 +00:00
Yuki Okushi
d340f63cca
Rollup merge of #83524 - faern:document-socketaddr-mem-layout, r=sfackler
Document that the SocketAddr memory representation is not stable

Intended to help out with #78802. Work has been put into finding and fixing code that assumes the memory layout of `SocketAddrV4` and `SocketAddrV6`. But it turns out there are cases where new code continues to make the same assumption ([example](96927dc2b7 (diff-917db3d8ca6f862ebf42726b23c72a12b35e584e497ebdb24e474348d7c6ffb6R610-R621))).

The memory layout of a type in `std` is never part of the public API. Unless explicitly stated I guess. But since that is invalidly relied upon by a considerable amount of code for these particular types, it might make sense to explicitly document this. This can be temporary. Once #78802 lands it does not make sense to rely on the layout any longer, and this documentation can also be removed.
2021-03-27 12:37:24 +09:00
Reyk Floeter
3d6bd87b24 unix: Fix feature(unix_socket_ancillary_data) on macos and other BSDs
This adds support for CMSG handling on macOS and fixes it on OpenBSD
and other BSDs.

When traversing the CMSG list, the previous code had an exception for
Android where the next element after the last pointer could point to
the first pointer instead of NULL.  This is actually not specific to
Android: the `libc::CMSG_NXTHDR` implementation for Linux and
emscripten have a special case to return NULL when the length of the
previous element is zero; most other implementations simply return the
previous element plus a zero offset in this case.

This MR additionally adds `SocketAncillary::is_empty` because clippy
is right that it should be added.
2021-03-26 21:12:22 +01:00
Linus Färnstrand
147316a094 Document that the SocketAddr memory representation is not stable 2021-03-26 19:44:06 +01:00
Josh Stone
3b1f5e3462 Use iter::zip in library/ 2021-03-26 09:32:29 -07:00
Dylan DPC
85d08e9afe
Rollup merge of #83463 - ijackson:exitstatusext-doc-grammar, r=kennytm
ExitStatusExt: Fix missing word in two docs messages

Looks like I missed the lack of these "and"s.
2021-03-26 02:34:42 +01:00
bors
6e17a5c5fd Auto merge of #83387 - cuviper:min-llvm-10, r=nagisa
Update the minimum external LLVM to 10

r? `@nikic`
2021-03-25 13:11:18 +00:00
Ian Jackson
88ca6c2219 ExitStatusExt: Fix missing word in two docs messages
Looks like I missed the lack of these "and"s.

Acked-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-25 10:48:27 +00:00
Ian Jackson
11e40ce240 ExitStatus: print "exit status: {}" rather than "exit code: {}"
Proper Unix terminology is "exit status" (vs "wait status").  "exit
code" is imprecise on Unix and therefore unclear.  (As far as I can
tell, "exit code" is correct terminology on Windows.)

This new wording is unfortunately inconsistent with the identifier
names in the Rust stdlib.

It is the identifier names that are wrong, as discussed at length in eg
  https://doc.rust-lang.org/nightly/std/process/struct.ExitStatus.html
  https://doc.rust-lang.org/nightly/std/os/unix/process/trait.ExitStatusExt.html

Unfortunately for API stability reasons it would be a lot of work, and
a lot of disruption, to change the names in the stdlib (eg to rename
`std::process::ExitStatus` to `std::process::ChildStatus` or
something), but we should fix the message output.  Many (probably
most) readers of these messages about exit statuses will be users and
system administrators, not programmers, who won't even know that Rust
has this wrong terminology.

So I think the right thing is to fix the documentation (as I have
already done) and, now, the terminology in the implementation.

This is a user-visible change to the behaviour of all Rust programs
which run Unix subprocesses.  Hopefully no-one is matching against the
exit status string, except perhaps in tests.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-03-25 10:27:53 +00:00
Dylan DPC
a42e62fa0a
Rollup merge of #83353 - m-ou-se:io-error-avoid-alloc, r=nagisa
Add internal io::Error::new_const to avoid allocations.

This makes it possible to have a io::Error containing a message with zero allocations, and uses that everywhere to avoid the *three* allocations involved in `io::Error::new(kind, "message")`.

The function signature isn't perfect, because it needs a reference to the `&str`. So for now, this is just a `pub(crate)` function. Later, we'll be able to use `fn new_const<MSG: &'static str>(kind: ErrorKind)` to make that a bit better. (Then we'll also be able to use some ZST trickery if that would result in more efficient code.)

See https://github.com/rust-lang/rust/issues/83352
2021-03-24 01:52:29 +01:00
Jubilee Young
e8dfbaca76 Rephrase -0.0 docs 2021-03-22 17:02:09 -07:00
Jubilee Young
6fdb8d8b36 Update signed fmt/-0f32 docs
"semantic equivalence" is too strong a phrasing here, which is why
actually explaining what kind of circumstances might produce a -0
was chosen instead.
2021-03-22 17:02:09 -07:00
Josh Stone
fcb37cb7d6 Fix asm! from AT&T to Intel syntax 2021-03-22 13:12:53 -07:00
bors
5d04957a4b Auto merge of #79278 - mark-i-m:stabilize-or-pattern, r=nikomatsakis
Stabilize or_patterns (RFC 2535, 2530, 2175)

closes #54883

This PR stabilizes the or_patterns feature in Rust 1.53.

This is blocked on the following (in order):
- [x] The crater run in https://github.com/rust-lang/rust/pull/78935#issuecomment-731564021
- [x] The resolution of the unresolved questions and a second crater run (https://github.com/rust-lang/rust/pull/78935#issuecomment-735412705)
    - It looks like we will need to pursue some sort of edition-based transition for `:pat`.
- [x] Nomination and discussion by T-lang
- [x] Implement new behavior for `:pat` based on consensus (https://github.com/rust-lang/rust/pull/80100).
- [ ] An FCP on stabilization

EDIT: Stabilization report is in https://github.com/rust-lang/rust/pull/79278#issuecomment-772815177
2021-03-22 19:48:27 +00:00
Josh Stone
7d872f538e Update the minimum external LLVM to 10 2021-03-22 11:33:43 -07:00
Dylan DPC
c66d66e8d1
Rollup merge of #82686 - CDirkx:unix-platform, r=m-ou-se
Move `std::sys::unix::platform` to `std::sys::unix::ext`

This moves the operating system dependent alias `platform` (`std::os::{linux, android, ...}`) from `std::sys::unix` to `std::sys::unix::ext` (a.k.a. `std::os::unix`), removing the need for compatibility code in `unix_ext` when documenting on another platform.

This is also a step in making it possible to properly move `std::sys::unix::ext` to `std::os::unix`, as ideally `std::sys` should not depend on the rest of `std`.
2021-03-22 02:20:28 +01:00
Dylan DPC
e9398bcc4d
Rollup merge of #80193 - zseri:stabilize-osstring-ascii, r=m-ou-se
stabilize `feature(osstring_ascii)`

This PR stabilizes `feature(osstring_ascii)`.

Fixes #70516.
2021-03-22 02:20:23 +01:00