Commit graph

1357 commits

Author SHA1 Message Date
Dylan DPC
d783f399e5
Rollup merge of #84177 - ehuss:join_paths-err, r=kennytm
Fix join_paths error display.

On unix, the error from `join_paths` looked like this:

```
path segment contains separator `58`
```

This PR changes it to look like this:

```
path segment contains separator `:`
```
2021-04-15 01:27:53 +02:00
Dylan DPC
80ee7cbb37
Rollup merge of #82492 - CDirkx:sys_common_alloc, r=m-ou-se
Move `std::sys_common::alloc` to new module `std::sys::common`

6b56603e35/library/std/src/sys_common/mod.rs (L7-L13)

It was my impression that the goal for `std::sys` has changed from extracting it into a separate crate to making std work with features. However the fact remains that there is a lot of interdependence between `sys` and `sys_common`, this is because `sys_common` contains two types of code:

- abstractions over the different platform implementations in `std::sys` (for example [`std::sys_common::mutex`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/mutex.rs))
- code shared between platforms (for example [`std::sys_common::alloc`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/alloc.rs))

This PR attempts to address this by adding a new module `common` to `std::sys` which will contain code shared between platforms, `alloc.rs` in this case but more can be moved over in the future.
2021-04-15 01:27:52 +02:00
Christiaan Dirkx
cac0dd63b3 Update documentation 2021-04-14 14:03:00 +02:00
Christiaan Dirkx
905d23b65c Move std::sys_common::alloc to std::sys::common 2021-04-14 13:24:10 +02:00
Eric Huss
a8fbe2f22f Fix join_paths error display. 2021-04-13 14:20:49 -07:00
Dylan DPC
3d6a364e33
Rollup merge of #84084 - m-ou-se:stabilize-zero, r=scottmcm
Stabilize duration_zero.

FCP here: https://github.com/rust-lang/rust/issues/73544#issuecomment-817201305
2021-04-13 11:10:40 +02:00
bors
d4d7ebf142 Auto merge of #82992 - philippeitis:stabilize_bufreader_seek_relative, r=workingjubilee
Stabilize `bufreader_seek_relative`

This PR marks `BufReader::seek_relative` as stable - the associated issue, #31100, has passed the final comment period without any issues, and from what I understand, the only thing left to stabilize this is to submit a PR marking the method as stable.

Closes #31100.
2021-04-13 00:52:00 +00:00
bors
11d0528483 Auto merge of #82918 - Manishearth:edition-2015-warn, r=oli-obk
Turn old edition lint (anonymous-parameters) into warn-by-default on 2015

This makes `anonymous_parameters` <s>and `keyword_idents` </s>warn-by-default on the 2015 edition. I would also like to do this for `absolute_paths_not_starting_with_crate`, but I feel that case is slightly less clear-cut.

Note that this only affects code on the 2015 edition, such code is illegal in future editions anyway.

This was spurred by https://github.com/dtolnay/syn/issues/972: old edition syntax breaks tooling (like syn), and while the tooling should be free to find its balance on how much to support prior editions, it does seem like we should be nudging such code towards the newer edition, and we can do that by turning this Allow lint into a Warn.

In general, I feel like migration lints from an old edition should be made Warn after a year or so, and idiom lints for the new edition should be made Warn after a couple months.

cc `@m-ou-se,` this is for stuff from the 2015-2018 migration but you might be interested.
2021-04-12 22:26:15 +00:00
bors
d0695c9081 Auto merge of #83776 - jyn514:update-stdarch-docs, r=Amanieu
Update stdarch submodule (to before it switched to const generics)

https://github.com/rust-lang/rust/pull/83278#issuecomment-812389823: This unblocks #82539.

Major changes:
- More AVX-512 intrinsics.
- More ARM & AArch64 NEON intrinsics.
- Updated unstable WASM intrinsics to latest draft standards.
- std_detect is now a separate crate instead of a submodule of std.

I double-checked and the first use of const generics looks like 8d5017861e, which isn't included in this PR.

r? `@Amanieu`
2021-04-12 18:29:25 +00:00
Manish Goregaokar
664c3e71b8 Turn old edition lints (anonymous-parameters, keyword-idents) into warn-by-default on 2015 2021-04-12 09:45:59 -07:00
Mara Bos
d1e23b8af8 Stabilize duration_zero. 2021-04-12 16:32:56 +02:00
Joshua Nelson
1b0b7e95be Update stdarch submodule (to before it switched to const generics)
This also includes a cherry-pick of
ec1461905b
and https://github.com/rust-lang/stdarch/pull/1108 to fix a build
failure.

It also adds a re-export of various macros to the crate root of libstd -
previously they would show up automatically because std_detect was defined
in the same crate.
2021-04-12 09:39:04 -04:00
Dylan DPC
3ea5a9f301
Rollup merge of #84094 - tmiasko:remove-fixed-size-array, r=m-ou-se
Remove FixedSizeArray

Remove `FixedSizeArray` trait, it has been superseded by const generics.

Closes #27778.
2021-04-12 01:04:09 +02:00
Tomasz Miąsko
60780e438a Remove FixedSizeArray 2021-04-11 00:00:00 +00:00
Steve Klabnik
c2f4a5b9f9
clean up example on read_to_string
This is the same thing, but simpler.
2021-04-10 12:50:04 -05:00
Dylan DPC
445aa40153
Rollup merge of #83831 - AngelicosPhosphoros:issue-77583-inline-for-ip, r=m-ou-se
Add `#[inline]` to IpAddr methods

Add some inlines to trivial methods of IpAddr
Closes https://github.com/rust-lang/rust/issues/77583
2021-04-05 13:03:42 +02:00
bors
015d2bc3fe Auto merge of #83864 - Dylan-DPC:rollup-78an86n, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #80525 (wasm64 support)
 - #83019 (core: disable `ptr::swap_nonoverlapping_one`'s block optimization on SPIR-V.)
 - #83717 (rustdoc: Separate filter-empty-string out into its own function)
 - #83807 (Tests: Remove redundant `ignore-tidy-linelength` annotations)
 - #83815 (ptr::addr_of documentation improvements)
 - #83820 (Remove attribute `#[link_args]`)
 - #83841 (Allow clobbering unsupported registers in asm!)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-04-05 01:26:57 +00:00
Dylan DPC
3c2e4ff525
Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisa
Remove attribute `#[link_args]`

Closes https://github.com/rust-lang/rust/issues/29596

The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc.
Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
2021-04-05 00:24:33 +02:00
Mark Rousskov
b3a4f91b8d Bump cfgs 2021-04-04 14:57:05 -04:00
AngelicosPhosphoros
a3d0fa8008 Add #[inline] to IpAddr methods
Add some inlines to trivial methods of IpAddr
Closes https://github.com/rust-lang/rust/issues/77583
2021-04-04 02:42:56 +03:00
Vadim Petrochenkov
5839bff0ba Remove attribute #[link_args] 2021-04-03 21:25:53 +03:00
Yuki Okushi
961fa632d6
Rollup merge of #83780 - matklad:doc-error-message, r=JohnTitor
Document "standard" conventions for error messages

These are currently documented in the API guidelines:

https://rust-lang.github.io/api-guidelines/interoperability.html#error-types-are-meaningful-and-well-behaved-c-good-err

I think it makes sense to uplift this guideline (in a milder form) into
std docs. Printing and producing errors is something that even
non-expert users do frequently, so it is useful to give at least some
indication of what a typical error message looks like.
2021-04-04 00:19:37 +09:00
Yuki Okushi
3b40d2c1f3
Rollup merge of #82487 - CDirkx:const-socketaddr, r=m-ou-se
Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6`

The following methods are made unstable const under the `const_socketaddr` feature (https://github.com/rust-lang/rust/issues/82485):

```rust
// std::net

impl SocketAddr {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn is_ipv4(&self) -> bool;
    pub const fn is_ipv6(&self) -> bool;
}

impl SocketAddrV4 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
}

impl SocketAddrV6 {
    pub const fn ip(&self) -> IpAddr;
    pub const fn port(&self) -> u16;
    pub const fn flowinfo(&self) -> u32;
    pub const fn scope_id(&self) -> u32;
}
```

Note: `SocketAddrV4::ip` and `SocketAddrV6::ip` use pointer casting and depend on the unstable feature `const_raw_ptr_deref`
2021-04-04 00:19:30 +09:00
Dylan DPC
cb7133f693
Rollup merge of #83771 - asomers:stack_overflow_freebsd, r=dtolnay
Fix stack overflow detection on FreeBSD 11.1+

Beginning with FreeBSD 10.4 and 11.1, there is one guard page by
default.  And the stack autoresizes, so if Rust allocates its own guard
page, then FreeBSD's will simply move up one page.  The best solution is
to just use the OS's guard page.
2021-04-02 19:57:35 +02:00
Dylan DPC
48ebad58b2
Rollup merge of #83065 - CDirkx:win-alloc, r=dtolnay
Rework `std::sys::windows::alloc`

I came across https://github.com/rust-lang/rust/pull/76676#discussion_r488729990, which points out that there was unsound code in the Windows alloc code, creating a &mut to possibly uninitialized memory. I reworked the code so that that particular issue does not occur anymore, and started adding more documentation and safety comments.

Full list of changes:
 - moved and documented the relevant Windows Heap API functions
 - refactor `allocate_with_flags` to `allocate` (and remove the other helper functions), which now takes just a `bool` if the memory should be zeroed
 - add checks for if `GetProcessHeap` returned null
 - add a test that checks if the size and alignment of a `Header` are indeed <= `MIN_ALIGN`
 - add `#![deny(unsafe_op_in_unsafe_fn)]` and the necessary unsafe blocks with safety comments

I feel like I may have overdone the documenting, the unsoundness fix is the most important part; I could spit this PR up in separate parts.
2021-04-02 19:57:28 +02:00
Christiaan Dirkx
db1d003de1 Remove debug_assert 2021-04-02 17:50:23 +02:00
Christiaan Dirkx
c86e0985f9 Introduce get_process_heap and fix atomic ordering. 2021-04-02 17:37:52 +02:00
Yuki Okushi
417e6b1dd0
Rollup merge of #83740 - obi1kenobi:patch-1, r=joshtriplett
Fix comment typo in once.rs

I believe I came across a minor typo in a comment. I am not particularly familiar with this part of the codebase, but I have read the surrounding code as well as the referenced `park` and `unpark` functions, and I believe my proposed change is true to the intended meaning of the comment.

I intentionally tried to keep the change as minimal as possible. If I have the maintainers' permission, I'd also love to add a comma to improve readability as follows: `Luckily ``park`` comes with the guarantee that if it got an ``unpark`` just before on an unparked thread, it does not park.`
2021-04-02 21:28:23 +09:00
Aleksey Kladov
5547d92746 Document "standard" conventions for error messages
These are currently documented in the API guidelines:

https://rust-lang.github.io/api-guidelines/interoperability.html#error-types-are-meaningful-and-well-behaved-c-good-err

I think it makes sense to uplift this guideline (in a milder form) into
std docs. Printing and producing errors is something that even
non-expert users do frequently, so it is useful to give at least some
indication of what a typical error message looks like.
2021-04-02 15:11:49 +03:00
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
Alan Somers
ca14abbab1 Fix stack overflow detection on FreeBSD 11.1+
Beginning with FreeBSD 10.4 and 11.1, there is one guard page by
default.  And the stack autoresizes, so if Rust allocates its own guard
page, then FreeBSD's will simply move up one page.  The best solution is
to just use the OS's guard page.
2021-04-01 22:57:20 -06:00
Predrag Gruevski
2e4215cb72
Fix minor typo in once.rs 2021-04-01 00:52:02 -04: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