Commit Graph

153439 Commits

Author SHA1 Message Date
Dan Gohman 18a9f4628a Don't encourage migration until io_safety is stablized. 2021-08-19 12:02:40 -07:00
Dan Gohman 1dbd6d60f0 Factor out Unix and WASI fd code into a common module. 2021-08-19 12:02:40 -07:00
Dan Gohman 71dab738ac Synchronize minor differences between Unix and WASI implementations. 2021-08-19 12:02:40 -07:00
Dan Gohman 907f00be30 Add more comments about the `INVALID_HANDLE_VALUE` situation. 2021-08-19 12:02:40 -07:00
Dan Gohman ab08639e59 Add comments about impls for File, TcpStream, ChildStdin, etc. 2021-08-19 12:02:40 -07:00
Dan Gohman 68964a7d68 Fix copypasta of "Unix" within the WASI directory. 2021-08-19 12:02:40 -07:00
Dan Gohman 1b35f7405a Reword the description of dup2/dup3. 2021-08-19 12:02:40 -07:00
Dan Gohman 6d7211738d Add Safety comments to the `As*` for `Owned*` implementations. 2021-08-19 12:02:40 -07:00
Dan Gohman 6486f89cbc Add Owned*, Borrowed*, and As* to the preludes. 2021-08-19 12:02:39 -07:00
Dan Gohman 0cb69dec57 Rename `OwnedFd`'s private field to match it's debug output. 2021-08-19 12:02:39 -07:00
Dan Gohman 45b5de3376 Delete a spurious empty comment line. 2021-08-19 12:02:39 -07:00
Dan Gohman 926344a80f Add a comment about how `OwnedHandle` should not be used with registry handles. 2021-08-19 12:02:39 -07:00
Dan Gohman 31f7bf8271 Add a comment about `OptionFileHandle`. 2021-08-19 12:02:39 -07:00
Dan Gohman 6b4dbdbf47 Be more precise about `mmap` and undefined behavior.
`mmap` doesn't *always* cause undefined behavior; it depends on the
details of how you use it.
2021-08-19 12:02:39 -07:00
Dan Gohman 1f8a450cdd Add a test to ensure that RawFd is the size we assume it is. 2021-08-19 12:02:39 -07:00
Dan Gohman 1c6bf04edb Update library/std/src/os/windows/io/socket.rs
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-08-19 12:02:39 -07:00
Dan Gohman a23ca7ceb1 Update library/std/src/os/windows/io/handle.rs
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-08-19 12:02:39 -07:00
Dan Gohman 3a38511ab3 Update library/std/src/os/unix/io/fd.rs
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-08-19 12:02:39 -07:00
Dan Gohman d15418586c I/O safety.
Introduce `OwnedFd` and `BorrowedFd`, and the `AsFd` trait, and
implementations of `AsFd`, `From<OwnedFd>` and `From<T> for OwnedFd`
for relevant types, along with Windows counterparts for handles and
sockets.

Tracking issue:
 - <https://github.com/rust-lang/rust/issues/87074>

RFC:
 - <https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md>
2021-08-19 12:02:39 -07:00
Ellen ab61e722ee regression tests 2021-08-19 19:47:38 +01:00
Ellen 696c88d69c canonicalize const equate predicates 2021-08-19 19:47:38 +01:00
Charles Lew c22dfab215 Add assertion to ensure the query doesn't get called before type infererence is done. 2021-08-20 02:37:00 +08:00
Guillaume Gomez 1095bb1eb2
Rollup merge of #88159 - spastorino:fix-unused-generic-param-test, r=oli-obk
Use a trait instead of the now disallowed missing trait there

To properly test the unused generic parameter and just that we need to use a trait in the tait. Missing the trait there is already tested and is not what we meant to test here.

r? `@oli-obk`
2021-08-19 19:30:12 +02:00
Guillaume Gomez bcc3b4ef62
Rollup merge of #88153 - hkmatsumoto:mailmap, r=Mark-Simulacrum
Update .mailmap
2021-08-19 19:30:11 +02:00
Guillaume Gomez 01b0a8dce7
Rollup merge of #88146 - BoxyUwU:tests-cec-incr-comp, r=oli-obk
Add tests for some `feature(const_evaluatable_checked)` incr comp issues

Closes #77650
Closes #79251

#79251 didn't seem to be ICEing anymore so added regression tests for that aswell

r? `@oli-obk`
2021-08-19 19:30:10 +02:00
Guillaume Gomez 10165f8af9
Rollup merge of #88093 - Kobzol:rustdoc-wrap-code-in-code-tag, r=GuillaumeGomez
[rustdoc] Wrap code blocks in <code> tag

This PR modifies Rustdoc output so that fenced code snippets, items and whole file source codes are wrapped in `<pre><code>` instead of just `<pre>`. This should improve the semantic meaning of the generated content.

I'm not sure what to do about `render_attributes_in_pre` and `render_attributes_in_code`. These functions were clearly expected to be used for things inside `<pre>` or `<code>`, and since I added `<code>` in this PR, some of them will be used in a different context than before. However, it seems to me that even before they were not consistent. For example, `item_constant` used `render_attributes_in_code` for its attributes, however there was no `<code>` used for constants before this PR...

Should I create some `rustdoc-gui` tests? For example to check that all `<pre>` tags have a `<code>` child?

Fixes: https://github.com/rust-lang/rust/issues/88020
2021-08-19 19:30:09 +02:00
Guillaume Gomez 09d56a749c
Rollup merge of #88050 - Aaron1011:filename-hash-stable, r=michaelwoerister
Remove `HashStable` impls for `FileName` and `RealFileName`

These impls were unused, and incorrectly hashed the local
(non-remapped) path for `RealFileName::Remapped` (which would
break reproducible builds if these impls were used).
2021-08-19 19:30:07 +02:00
Guillaume Gomez 8b9a4c3c4b
Rollup merge of #88034 - petrochenkov:localevel2, r=wesleywiser
rustc_privacy: Replace `HirId`s and `DefId`s with `LocalDefId`s where possible

Follow up to https://github.com/rust-lang/rust/pull/87568
2021-08-19 19:30:06 +02:00
Guillaume Gomez 6ce8a371bd
Rollup merge of #87874 - schneems:schneems/tcpstream-iterator-type, r=Mark-Simulacrum
Add TcpStream type to TcpListener::incoming docs

## Context

While going through the "The Rust Programming Language" book (Klabnik & Nichols), the TCP server example directs us to use TcpListener::incoming. I was curious how I could pass this value to a function (before reading ahead in the book), so I looked up the docs to determine the signature.

When I opened the docs, I found https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming, which didn't mention TcpStream anywhere in the example.

Eventually, I clicked on https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.accept in the docs (after clicking a few other locations first), and was able to surmise that the value contained TcpStream.

## Opportunity

While this type is mentioned several times in this doc, I feel that someone should be able to fully use the results of the TcpListner::incoming iterator based solely on the docs of just this method.

## Implementation

I took the code from the top-level TcpListener https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming and blended it with the existing docs for TcpListener::incoming https://doc.rust-lang.org/std/net/struct.TcpListener.html#method.incoming.

It does make the example a little longer, and it also introduces a little duplication. It also gives the reader the type signatures they need to move on to the next step.

## Additional considerations

I noticed that in this doc, `handle_connection` and `handle_client` are both used to accept a TcpStream in the docs on this page. I want to standardize on one function name convention, so readers don't accidentally think two different concepts are being referenced. I didn't want to cram do too much in one PR, I can update this PR to make that change, or I could send another PR (if you would like).

First attempted contribution to Rust (and I'm also still very new, hence reading through the rust book for the first time)! Would you please let me know what you think?
2021-08-19 19:30:05 +02:00
Guillaume Gomez def6393a8b
Rollup merge of #86123 - Aaron1011:query-span, r=cjgillot
Preserve more spans in internal `rustc_queries!` macro

We now preserve the span of the various query modifiers, and
use the span of the query's name for the commas that we
generate to separate the modifiers. This makes debugging issues with the
internal query macro infrastructure much nicer - previously, we
would get errors messages pointing at the entire call site
(the `rustc_queries!` invocation), which isn't very useful.

This should have no effect when compilation succeeds.

A concrete example of an error message produced after this changed:

```
error: local ambiguity: multiple parsing options: built-in NTs tt ('modifiers') or 1 other option.
    --> /home/aaron/repos/rust/compiler/rustc_middle/src/query/mod.rs:23:11
     |
12   | / rustc_queries! {
13   | |     query trigger_delay_span_bug(key: DefId) -> () {
14   | |         desc { "trigger a delay span bug" }
15   | |     }
...    |
23   | |     query hir_crate(key: ()) -> &'tcx Crate<'tcx> {
     | |           ^^^^^^^^^
...    |
1715 | |     }
1716 | | }
     | |_- in this expansion of `rustc_query_append!`
     |
    ::: compiler/rustc_query_impl/src/lib.rs:51:1
     |
51   |   rustc_query_append! { [define_queries!][<'tcx>] }
     |   ------------------------------------------------- in this macro invocation
```

The particular bug shown in this error message will be fixed
in a separate PR.
2021-08-19 19:30:04 +02:00
bors 7960030d69 Auto merge of #88151 - alexcrichton:update-backtrace, r=Mark-Simulacrum
Update the backtrace crate in libstd

This commit updates the backtrace crate in libstd now that dependencies
have been updated to use `memchr` from the standard library as well.
This is mostly just making sure deps are up-to-date and have all the
latest-and-greatest fixes and such.

Closes rust-lang/backtrace-rs#432
2021-08-19 17:20:59 +00:00
Augie Fackler c4e6185385 PassWrapper: adapt for LLVM 14 changes
These API changes appear to have all taken place in
https://reviews.llvm.org/D105007, which moved HWAddressSanitizerPass and
AddressSanitizerPass to only accept their options type as a ctor
argument instead of the sequence of bools etc. This required a couple of
parameter additions, which I made match the default prior to the
mentioned upstream LLVM change.

This patch restores rustc to building (though not quite passing all
tests, I've mailed other patches for those issues) against LLVM HEAD.
2021-08-19 12:44:54 -04:00
bors 2451f42c1d Auto merge of #88124 - tmiasko:start-block-critical-edge, r=oli-obk
Split critical edge targeting the start block

Fixes #88043.
2021-08-19 14:35:16 +00:00
Alex Crichton 4a3e73643a Update the backtrace crate in libstd
This commit updates the backtrace crate in libstd now that dependencies
have been updated to use `memchr` from the standard library as well.
This is mostly just making sure deps are up-to-date and have all the
latest-and-greatest fixes and such.

Closes rust-lang/backtrace-rs#432
2021-08-19 07:31:49 -07:00
Santiago Pastorino df8a64327c
Use a trait instead of the now disallowed missing trait there 2021-08-19 10:48:20 -03:00
bors 20e92344bc Auto merge of #88023 - devnexen:fbsd_arm64, r=nagisa
freebsd arm64 add supported sanitizers.
2021-08-19 11:54:27 +00:00
Hirochika Matsumoto 8b4e7a4792 Update .mailmap 2021-08-19 18:44:43 +09:00
bors a9ab2e5539 Auto merge of #88002 - hermitcore:unbox-mutex, r=dtolnay
Unbox mutexes, condvars and rwlocks on hermit

[RustyHermit](https://github.com/hermitcore/rusty-hermit) provides now movable synchronization primitives and we are able to unbox mutexes and condvars.
2021-08-19 09:08:11 +00:00
Jakub Beránek ccd550ee56
[rustdoc] Wrap code blocks in <code> tag 2021-08-19 10:30:08 +02:00
bors 4968a8bbd1 Auto merge of #87986 - Aaron1011:incr-double-panic, r=estebank
Prevent double panic when handling incremental fingerprint mismatch

When an incremental fingerprint mismatch occurs, we debug-print
our `DepNode` and query result. Unfortunately, the debug printing
process may cause us to run additional queries, which can result
in a re-entrant fingerprint mismatch error.

To avoid a double panic, this commit adds a thread-local variable
to detect re-entrant calls.
2021-08-19 06:27:17 +00:00
Joshua Nelson 18f0f242e1 Give precedence to `html_root_url` over `--extern-html-root-url` by default, but add a way to opt-in to the previous behavior
## What is an HTML root url?

It tells rustdoc where it should link when documentation for a crate is
not available locally; for example, when a crate is a dependency of a
crate documented with `cargo doc --no-deps`.

 ## What is the difference between `html_root_url` and `--extern-html-root-url`?

Both of these tell rustdoc what the HTML root should be set to.
`doc(html_root_url)` is set by the crate author, while
`--extern-html-root-url` is set by the person documenting the crate.
These are often different. For example, docs.rs uses
`--extern-html-root-url https://docs.rs/crate-name/version` to ensure
all crates have documentation, even if `html_root_url` is not set.
Conversely, crates such as Rocket set `doc(html_root_url =
"https://api.rocket.rs")`, because they prefer users to view the
documentation on their own site.

Crates also set `html_root_url` to ensure they have
documentation when building locally when offline. This is unfortunate to
require, because it's more work from the library author. It also makes
it impossible to distinguish between crates that want to be viewed on a
different site (e.g. Rocket) and crates that just want documentation to
be visible offline at all (e.g. Tokio). I have authored a separate
change to the API guidelines to no longer recommend doing this:
https://github.com/rust-lang/api-guidelines/pull/230.

 ## Why change the default?

In the past, docs.rs has been the main user of `--extern-html-root-url`.
However, it's useful for other projects as well. In particular, Cargo
wants to pass it by default when running `--no-deps`
(https://github.com/rust-lang/cargo/issues/8296).

Unfortunately, for these other use cases, the priority order is
inverted. They want to give *precedence* to the URL the crate picks, and
only fall back to the `--extern-html-root` if no `html_root_url` is
present. That allows passing `--extern-html-root` unconditionally,
without having to parse the source code to see what attributes are
present.

For docs.rs, however, we still want to keep the old behavior, so that
all links on docs.rs stay on the site.
2021-08-19 05:11:22 +00:00
bors ad1eaffc7e Auto merge of #88143 - GuillaumeGomez:rollup-sgh318f, r=GuillaumeGomez
Rollup of 10 pull requests

Successful merges:

 - #87818 (Fix anchors display in rustdoc)
 - #87983 (Use more accurate spans when proposing adding lifetime to item)
 - #88012 (Change WASI's `RawFd` from `u32` to `c_int` (`i32`).)
 - #88031 (Make `BuildHasher` object safe)
 - #88036 (Fix dead code warning when inline const is used in pattern)
 - #88082 (Take into account jobs number for rustdoc GUI tests)
 - #88109 (Fix environment variable getter docs)
 - #88111 (Add background-color on clickable definitions in source code)
 - #88129 (Fix dataflow graphviz bug, make dataflow graphviz modules public)
 - #88136 (Move private_unused.rs test to impl-trait)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-19 03:45:50 +00:00
bors 6d300391ed Auto merge of #87818 - GuillaumeGomez:anchors-display-rustdoc, r=camelid
Fix anchors display in rustdoc

Fixes https://github.com/rust-lang/rust/issues/87611 (it simplifies the positioning and fix the background).

![Screenshot from 2021-08-06 16-47-03](https://user-images.githubusercontent.com/3050060/128531105-61d1c21f-4a4d-4d68-aedf-9bfe0332f8ae.png)
![Screenshot from 2021-08-06 16-47-10](https://user-images.githubusercontent.com/3050060/128531109-b2ea8065-10b0-4400-9507-322122e42e78.png)
![Screenshot from 2021-08-06 16-47-14](https://user-images.githubusercontent.com/3050060/128531111-8a17cbdb-29e8-4baa-a0d6-81aa4f6ac6ed.png)

r? `@camelid`
2021-08-19 01:05:03 +00:00
Vadim Petrochenkov 1fdea560d2 rustc_privacy: Replace `HirId`s and `DefId`s with `LocalDefId`s where possible 2021-08-19 00:01:12 +03:00
Ellen 0d9ea42579 add tests 2021-08-18 21:15:33 +01:00
Guillaume Gomez 9bbb57c6ab
Rollup merge of #88136 - spastorino:fix-test-directory, r=oli-obk
Move private_unused.rs test to impl-trait

This test was added to fix this issue #55124 which is about impl traits but not related with type alias impl traits.

r? `@oli-obk`

`@bors` rollup=always
2021-08-18 19:55:06 +02:00
Guillaume Gomez e2271cd422
Rollup merge of #88129 - willcrichton:expose-graphviz-modules, r=ecstatic-morse
Fix dataflow graphviz bug, make dataflow graphviz modules public

I'm working on a rustc plugin that uses the dataflow framework for MIR analysis. I've found the graphviz utilities extremely helpful for debugging. However, I had to fork the compiler to expose them since they're currently private. I would appreciate if they could be made public so I can build against a nightly instead of a custom fork. Specifically, this PR:

* Makes public the `rustc_mir::dataflow::framework::graphviz` module.
* Makes public the `rustc_mir::util::pretty::write_mir_fn` function.

Here's a concrete example of how I'm using the graphviz module: 97b843b8b0/src/slicing/mod.rs (L186-L203)

Additionally, this PR fixes a small bug in the diff code that incorrectly shows the updated object as the old object.

r? `@ecstatic-morse`
2021-08-18 19:55:04 +02:00
Guillaume Gomez 75c6a9190d
Rollup merge of #88111 - GuillaumeGomez:background-color-jump-to-def, r=jhpratt
Add background-color on clickable definitions in source code

Someone suggested to add a decoration on clickable elements in the source code pages:

![Screenshot from 2021-08-17 14-49-39](https://user-images.githubusercontent.com/3050060/129728911-def74f9e-50e2-40d2-b512-e23f1b3d0409.png)
![Screenshot from 2021-08-17 14-49-47](https://user-images.githubusercontent.com/3050060/129728925-14aec500-82ff-4336-955a-4173c769deeb.png)
![Screenshot from 2021-08-17 14-49-52](https://user-images.githubusercontent.com/3050060/129728927-a8a89d7a-e837-4ff5-b094-35be23629d14.png)

The idea is to not disturb the reading while telling the reader "you can click on this one", which is why it's not a text decoration.

What do you think `@rust-lang/rustdoc` ?

r? `@Nemo157`
2021-08-18 19:55:03 +02:00
Guillaume Gomez fbaa4a2a17
Rollup merge of #88109 - inquisitivecrystal:env-docs, r=m-ou-se
Fix environment variable getter docs

`@RalfJung` pointed out a number of errors and suboptimal choices I made in my documentation for #86183. This PR should (hopefully) fix the problems they've identified.
2021-08-18 19:55:02 +02:00
Guillaume Gomez fe025a71a1
Rollup merge of #88082 - GuillaumeGomez:rustdoc-gui-jobs-opt, r=dns2utf8
Take into account jobs number for rustdoc GUI tests

Fixes #88054.

r? `@Mark-Simulacrum`
2021-08-18 19:55:00 +02:00