Commit graph

122502 commits

Author SHA1 Message Date
Dylan DPC
963a4805e3
Rollup merge of #73578 - RalfJung:ty-ctxt-at, r=jonas-schievink
Make is_freeze and is_copy_modulo_regions take TyCtxtAt

Make is_freeze and is_copy_modulo_regions take TyCtxtAt instead of separately taking TyCtxt and Span. This is consistent with is_sized.
2020-06-23 03:16:22 +02:00
Dylan DPC
4dfae775d3
Rollup merge of #73575 - dario23:typo-errorcodes-doc, r=matthewjasper
Fix typo in error_codes doc
2020-06-23 03:16:21 +02:00
Dylan DPC
5426586cc3
Rollup merge of #73495 - Lucretiel:wasi-io-impls, r=sfackler
Converted all platform-specific stdin/stdout/stderr implementations to use io:: traits

Currently, some of the platform-specific standard streams (`src/libstd/sys/*/stdio.rs`) manually implement parts of the `io::Write` interface directly as methods on the struct, rather than by actually implementing the trait. There doesn't seem to be any reason for this, other than an unused advantage of `fn write(&self, ...)` instead of `fn write(&mut self, ...)`.

Unfortunately, this means that those implementations don't have the default-implemented io methods, like `read_exact` and `write_all`. This caused #72705, which adds forwarding methods to the user-facing standard stream implementations, to fail to compile on those platforms.

This change converts *all* such standard stream structs to use the standard library traits. This change should not cause any breakages, because the changed types are not publicly exported, and in fact are only ever used in `src/libstd/io/stdio.rs`.
2020-06-23 03:16:19 +02:00
Dylan DPC
6276c135d1
Rollup merge of #71756 - carstenandrich:master, r=dtolnay
add Windows system error codes that should map to io::ErrorKind::TimedOut

closes #71646

**Disclaimer:** The author of this pull request has a negligible amount of experience (i.e., kinda zero) with the Windows API. This PR should _definitely_ be reviewed by someone familiar with the API and its error handling.

While porting POSIX software using serial ports to Windows, I found that for many Windows system error codes, an `io::Error` created via `io::Error::from_raw_os_error()` or `io::Error::last_os_error()` is not `io::ErrorKind::TimedOut`. For example, when a (non-overlapped) write to a COM port via [`WriteFile()`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-readfile) times out, [`GetLastError()`](https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-getlasterror) returns `ERROR_SEM_TIMEOUT` ([121](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-)). However, an `io::Error` created from this error code will have `io::ErrorKind::Other`.

Currently, only the error codes `ERROR_OPERATION_ABORTED` and `WSAETIMEDOUT` will instantiate `io::Error`s with kind `io::ErrorKind::TimedOut`.
This makes `io::Error::last_os_error()` unsuitable for error handling of syscalls that could time out, because timeouts can not be caught by matching the error's kind against `io::ErrorKind::TimedOut`.

Downloading the [list of Windows system error codes](https://gist.github.com/carstenandrich/c331d557520b8a0e7f44689ca257f805) and grepping anything that sounds like a timeout (`egrep -i "timed?.?(out|limit)"`), I've identified the following error codes that should also have `io::ErrorKind::TimedOut`, because they could be I/O-related:

Name | Code | Description
--- | --- | ---
`ERROR_SEM_TIMEOUT` | [121](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-) | The semaphore timeout period has expired.
`WAIT_TIMEOUT` | [258](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-) | The wait operation timed out.
`ERROR_DRIVER_CANCEL_TIMEOUT` | [594](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--500-999-) | The driver %hs failed to complete a cancelled I/O request in the allotted time.
`ERROR_COUNTER_TIMEOUT` | [1121](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299-) | A serial I/O operation completed because the timeout period expired. The IOCTL_SERIAL_XOFF_COUNTER did not reach zero.)
`ERROR_TIMEOUT` | [1460](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1300-1699-) | This operation returned because the timeout period expired.
`ERROR_CTX_MODEM_RESPONSE_TIMEOUT` | [7012](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--6000-8199-) | The modem did not respond to the command sent to it. Verify that the modem is properly cabled and powered on.
`ERROR_CTX_CLIENT_QUERY_TIMEOUT` | [7040](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--6000-8199-) | The client failed to respond to the server connect message.
`ERROR_DS_TIMELIMIT_EXCEEDED` | [8226](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--8200-8999-) | The time limit for this request was exceeded.
`DNS_ERROR_RECORD_TIMED_OUT` | [9705](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--9000-11999-) | DNS record timed out.
`ERROR_IPSEC_IKE_TIMED_OUT` | [13805](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-) | Negotiation timed out.

The following errors are also timeouts, but they don't seem to be directly related to I/O or network operations:

Name | Code | Description
--- | --- | ---
`ERROR_SERVICE_REQUEST_TIMEOUT` | [1053](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--1000-1299-) | The service did not respond to the start or control request in a timely fashion.
`ERROR_RESOURCE_CALL_TIMED_OUT` | [5910](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--4000-5999-) | The call to the cluster resource DLL timed out.
`FRS_ERR_SYSVOL_POPULATE_TIMEOUT` | [8014](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--6000-8199-) | The file replication service cannot populate the system volume because of an internal timeout. The event log may have more information.
`ERROR_RUNLEVEL_SWITCH_TIMEOUT` | [15402](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-) | The requested run level switch cannot be completed successfully since one or more services will not stop or restart within the specified timeout.
`ERROR_RUNLEVEL_SWITCH_AGENT_TIMEOUT` | [15403](https://docs.microsoft.com/en-us/windows/win32/debug/system-error-codes--12000-15999-) | A run level switch agent did not respond within the specified timeout.

Please note that `ERROR_SEM_TIMEOUT` is the only timeout error I have [seen in action](https://gist.github.com/carstenandrich/10b3962fa1abc9e50816b6460010900b). The remainder of the error codes listed above is based purely on reading documentation.

This pull request adds all of the errors listed in both tables, but I'm not sure whether adding all of them makes sense. Someone with actual Windows API experience should decide that.

I expect these changes to be fairly backwards compatible, because only the error's [`.kind()`](https://doc.rust-lang.org/std/io/struct.Error.html#method.kind) will change, but matching the error's code via [`.raw_os_error()`](https://doc.rust-lang.org/std/io/struct.Error.html#method.raw_os_error) will not be affected.
However, code expecting these errors to be `io::ErrorKind::Other` would break. Even though I personally do not think such an implementation would make sense, after all the docs say that `io::ErrorKind` is _intended to grow over time_, a residual risk remains, of course. I took the liberty to ammend the docstring of `io::ErrorKind::Other` with a remark that discourages matching against it.

As per the contributing guidelines I'm adding @steveklabnik due to the changed documentation. Also @retep998 might have some valuable insights on the error codes.

r? @steveklabnik
cc @retep998
cc @Mark-Simulacrum
2020-06-23 03:16:14 +02:00
bors
fa0f6a8dbf Auto merge of #5711 - flip1995:rustup, r=flip1995
Rustup

changelog: none
2020-06-23 00:27:02 +00:00
flip1995
51592f8587
Fix sync fallout 2020-06-23 02:23:27 +02:00
flip1995
018440c11e
Merge remote-tracking branch 'upstream/master' into rustup 2020-06-23 02:18:17 +02:00
bors
dcd470fe1b Auto merge of #73007 - yoshuawuyts:socketaddr-from-string-u16, r=sfackler
impl ToSocketAddrs for (String, u16)

This adds a convenience impl of `ToSocketAddrs for (String, u16)`. When authoring HTTP services it's common to take command line options for `host` and `port` and parse them into `String` and `u16` respectively. Consider the following program:
```rust
#[derive(Debug, StructOpt)]
struct Config {
    host: String,
    port: u16,
}

async fn main() -> io::Result<()> {
    let config = Config::from_args();
    let stream = TcpStream::connect((&*config.host, config.port))?; // &* is not ideal
    // ...
}
```

Networking is a pretty common starting point for people new to Rust, and seeing `&*` in basic examples can be confusing. Even as someone that has experience with networking in Rust I tend to forget that `String` can't be passed directly there. Instead with this patch we can omit the `&*` conversion and pass `host` directly:
```rust
#[derive(Debug, StructOpt)]
struct Config {
    host: String,
    port: u16,
}

async fn main() -> io::Result<()> {
    let config = Config::from_args();
    let stream = TcpStream::connect((config.host, config.port))?; // no more conversions!
    // ...
}
```

I think should be an easy and small ergonomics improvement for networking. Thanks!
2020-06-23 00:13:50 +00:00
Gary Guo
0a454e5398 Add UI test for issue 73592 2020-06-23 00:17:15 +01:00
Esteban Küber
3eb8eb9429 review comments 2020-06-22 16:05:31 -07:00
Rich Kadel
994d9d0327 Address remaining feedback items 2020-06-22 15:54:28 -07:00
Tshepang Lekhonkhobe
b65ea1bef1 place non-obvious defaults on a separate line
See https://github.com/rust-lang/rust/pull/73538#discussion_r443809593
for the motivation
2020-06-23 00:29:55 +02:00
Esteban Küber
f84b7e1b05 Provide context on E0308 involving fn items 2020-06-22 15:20:04 -07:00
Rich Kadel
f4a79385cf implemented query for coverage data
This commit adds a query that allows the CoverageData to be pulled from
a call on tcx, avoiding the need to change the
`codegen_intrinsic_call()` signature (no need to pass in the FunctionCx
or any additional arguments.

The commit does not change where/when the CoverageData is computed. It's
still done in the `pass`, and saved in the MIR `Body`.

See discussion (in progress) here:
https://github.com/rust-lang/rust/pull/73488#discussion_r443825646
2020-06-22 14:11:55 -07:00
bors
cbf356a1a5 Auto merge of #73594 - Aaron1011:revert/move-fn-self-msg, r=Manishearth
Revert PR #72389 - "Explain move errors that occur due to method calls involving `self"

r? @petrochenkov
2020-06-22 20:30:06 +00:00
flip1995
2792014ef4
Make AssocOp Copy 2020-06-22 21:01:49 +02:00
Niko Matsakis
d57689f9cd cite issue 73154 2020-06-22 18:51:08 +00:00
Niko Matsakis
6929013b85 fix subtle bug in NLL type checker
The bug was revealed by the behavior of the old-lub-glb-hr-noteq1.rs
test. The old-lub-glb-hr-noteq2 test shows the current 'order dependent'
behavior of coercions around higher-ranked functions, at least when
running with `-Zborrowck=mir`.

Also, run compare-mode=nll.
2020-06-22 18:51:08 +00:00
Niko Matsakis
c88a76e37b WIP bless test and compare-mode=nll 2020-06-22 18:51:07 +00:00
Niko Matsakis
93e29823a9 add new coherence tests and update the documentation 2020-06-22 18:51:07 +00:00
Niko Matsakis
be0d10f149 add new tests from MCP and the tracking issue 2020-06-22 18:51:07 +00:00
Niko Matsakis
3a68d56de3 remove leak_check from the outlives predicate evaluations 2020-06-22 18:51:07 +00:00
Niko Matsakis
6873a76f2c remove leak-check from project 2020-06-22 18:51:07 +00:00
Niko Matsakis
70cf33fcca remove snapshot calls from "match" operations during select
Motivation:

- we want to use leak-check sparingly, first off
- these calls were essentially the same as doing the check during subtyping
2020-06-22 18:51:05 +00:00
Aaron Hill
3ed96a6d63
Point at the call spawn when overflow occurs during monomorphization
This improves the output for issue #72577, but there's still more work
to be done.

Currently, an overflow error during monomorphization results in an error
that points at the function we were unable to monomorphize. However, we
don't point at the call that caused the monomorphization to happen. In
the overflow occurs in a large recursive function, it may be difficult
to determine where the issue is.

This commit tracks and `Span` information during collection of
`MonoItem`s, which is used when emitting an overflow error. `MonoItem`
itself is unchanged, so this only affects
`src/librustc_mir/monomorphize/collector.rs`
2020-06-22 14:35:42 -04:00
Aaron Hill
e11b873c70 Stop using old version of syn in rustc-workspace-hack
None of the tools seem to need syn 0.15.35, so we can just build syn
1.0.

This was causing an issue with clippy's `compile-test` program: since
multiple versions of `syn` would exist in the build directory, we would
non-deterministically pick one based on filesystem iteration order. If
the pre-1.0 version of `syn` was picked, a strange build error would
occur (see
https://github.com/rust-lang/rust/pull/73594#issuecomment-647671463)

To prevent this kind of issue from happening again, we now panic if we
find multiple versions of a crate in the build directly, instead of
silently picking the first version we find.
2020-06-22 13:29:39 -04:00
Aaron Hill
e2ab98df08
Stop using old version of syn in rustc-workspace-hack
None of the tools seem to need syn 0.15.35, so we can just build syn
1.0.

This was causing an issue with clippy's `compile-test` program: since
multiple versions of `syn` would exist in the build directory, we would
non-deterministically pick one based on filesystem iteration order. If
the pre-1.0 version of `syn` was picked, a strange build error would
occur (see
https://github.com/rust-lang/rust/pull/73594#issuecomment-647671463)

To prevent this kind of issue from happening again, we now panic if we
find multiple versions of a crate in the build directly, instead of
silently picking the first version we find.
2020-06-22 13:29:39 -04:00
Aaron Hill
d3feb8baaf
Re-enable Clippy tests 2020-06-22 12:46:29 -04:00
Aaron Hill
ad9972a20d
Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakis"
This reverts commit 372cb9b69c, reversing
changes made to 5c61a8dc34.
2020-06-22 12:46:29 -04:00
bors
6bb3dbfc6c Auto merge of #73415 - ehuss:update-cargo, r=ehuss
Update cargo

3 commits in 79c769c3d7b4c2cf6a93781575b7f592ef974255..089cbb80b73ba242efdcf5430e89f63fa3b5328d
2020-06-11 22:13:37 +0000 to 2020-06-15 14:38:34 +0000
- Support linker with -Zdoctest-xcompile. (rust-lang/cargo#8359)
- Fix doctests not running with --target=HOST. (rust-lang/cargo#8358)
- Allow passing a registry index url directly to `cargo install` (rust-lang/cargo#8344)
2020-06-22 16:38:21 +00:00
Charles Lew
ef24faf130 Refactor non_ascii_idents lints, exclude ascii pair for confusable_idents lint. 2020-06-23 00:06:14 +08:00
Niko Matsakis
1e00e1b6de upcasting traits requires only that things become more general
Revert the code that states that upcasting traits requires full
equality and change to require that the source type is a subtype of
the target type, as one would expect. As the comment states, this was
an old bug that we didn't want to fix yet as it interacted poorly with
the old leak-check. This fixes the old-lub-glb-object test, which was
previously reporting too many errors (i.e., in the previous commit).
2020-06-22 15:33:07 +00:00
Niko Matsakis
5a7a850753 move leak-check to during coherence, candidate eval
In particular, it no longer occurs during the subtyping check. This is
important for enabling lazy normalization, because the subtyping check
will be producing sub-obligations that could affect its results.

Consider an example like

    for<'a> fn(<&'a as Mirror>::Item) =
      fn(&'b u8)

where `<T as Mirror>::Item = T` for all `T`. We will wish to produce a
new subobligation like

    <'!1 as Mirror>::Item = &'b u8

This will, after being solved, ultimately yield a constraint that `'!1
= 'b` which will fail. But with the leak-check being performed on
subtyping, there is no opportunity to normalize `<'!1 as
Mirror>::Item` (unless we invoke that normalization directly from
within subtyping, and I would prefer that subtyping and unification
are distinct operations rather than part of the trait solving stack).

The reason to keep the leak check during coherence and trait
evaluation is partly for backwards compatibility. The coherence change
permits impls for `fn(T)` and `fn(&T)` to co-exist, and the trait
evaluation change means that we can distinguish those two cases
without ambiguity errors. It also avoids recreating #57639, where we
were incorrectly choosing a where clause that would have failed the
leak check over the impl which succeeds.

The other reason to keep the leak check in those places is that I
think it is actually close to the model we want. To the point, I think
the trait solver ought to have the job of "breaking down"
higher-ranked region obligation like ``!1: '2` into into region
obligations that operate on things in the root universe, at which
point they should be handed off to polonius. The leak check isn't
*really* doing that -- these obligations are still handed to the
region solver to process -- but if/when we do adopt that model, the
decision to pass/fail would be happening in roughly this part of the
code.

This change had somewhat more side-effects than I anticipated. It
seems like there are cases where the leak-check was not being enforced
during method proving and trait selection. I haven't quite tracked
this down but I think it ought to be documented, so that we know what
precisely we are committing to.

One surprising test was `issue-30786.rs`. The behavior there seems a
bit "fishy" to me, but the problem is not related to the leak check
change as far as I can tell, but more to do with the closure signature
inference code and perhaps the associated type projection, which
together seem to be conspiring to produce an unexpected
signature. Nonetheless, it is an example of where changing the
leak-check can have some unexpected consequences: we're now failing to
resolve a method earlier than we were, which suggests we might change
some method resolutions that would have been ambiguous to be
successful.

TODO:

* figure out remainig test failures
* add new coherence tests for the patterns we ARE disallowing
2020-06-22 15:33:05 +00:00
Tshepang Lekhonkhobe
e84552e5dc be more consistent with "defaults" placement 2020-06-22 17:07:42 +02:00
Niko Matsakis
f2cf994483 rewrite leak check to be based on universes
In the new leak check, instead of getting a list of placeholders to
track, we look for any placeholder that is part of a universe which
was created during the snapshot.

We are looking for the following error patterns:

* P1: P2, where P1 != P2
* P1: R, where R is in some universe that cannot name P1

This new leak check is more precise than before, in that it accepts
this patterns:

* R: P1, even if R cannot name P1, because R = 'static is a valid
sol'n
* R: P1, R: P2, as above

Note that this leak check, when running during subtyping, is less
efficient than before in some sense because it is going to check and
re-check all the universes created since the snapshot. We're going to
move when the leak check runs to try and correct that.
2020-06-22 14:33:44 +00:00
Alexis Bourget
3c46e36d39 Document the mut keyword 2020-06-22 16:27:23 +02:00
Niko Matsakis
4199b3ae26 Revert "modify leak-check to track only outgoing edges from placeholders"
This reverts commit 2e01db4b396a1e161f7a73933fff34bc9421dba0.
2020-06-22 14:05:00 +00:00
Niko Matsakis
bcc0a9c8eb modify leak-check to track only outgoing edges from placeholders
Also, update the affected tests. This seems strictly better but it is
actually more permissive than I initially intended. In particular it
accepts this

```
forall<'a, 'b> {
  exists<'intersection> {
    'a: 'intersection,
    'b: 'intersection,
  }
}
```

and I'm not sure I want to accept that. It implies that we have a
`'empty` in the new universe intoduced by the `forall`.
2020-06-22 14:05:00 +00:00
Alexis Bourget
9766a93163 Document the mod keyword 2020-06-22 15:36:09 +02:00
bors
62878c20e9 Auto merge of #73617 - Dylan-DPC:rollup-zugh80o, r=Dylan-DPC
Rollup of 6 pull requests

Successful merges:

 - #71660 (impl PartialEq<Vec<B>> for &[A], &mut [A])
 - #72623 (Prefer accessible paths in 'use' suggestions)
 - #73502 (Add E0765)
 - #73580 (deprecate wrapping_offset_from)
 - #73582 (Miri: replace many bug! by span_bug!)
 - #73585 (Do not send a notification for P-high stable regressions)

Failed merges:

 - #73581 (Create 0766 error code)

r? @ghost
2020-06-22 12:59:57 +00:00
Dylan DPC
c5e6f48544
Rollup merge of #73585 - LeSeulArtichaut:patch-3, r=Mark-Simulacrum
Do not send a notification for P-high stable regressions

This is kind of a hack to only match nightly and beta regressions, but not stable regressions. See my tests [on the playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=6ff8a809162118aa2951f2ff12400067).

r? @spastorino cc @Mark-Simulacrum
2020-06-22 14:53:56 +02:00
Dylan DPC
cb85f4bce0
Rollup merge of #73582 - RalfJung:miri-span-bug, r=oli-obk
Miri: replace many bug! by span_bug!

r? @oli-obk
2020-06-22 14:53:54 +02:00
Dylan DPC
35ecb26297
Rollup merge of #73580 - RalfJung:deprecate-wrapping-offset-from, r=Amanieu
deprecate wrapping_offset_from

As per https://github.com/rust-lang/rust/issues/41079#issuecomment-433140733 which seems like a consensus.

r? @Amanieu
2020-06-22 14:53:52 +02:00
Dylan DPC
d22b80dc0c
Rollup merge of #73502 - GuillaumeGomez:add-e0764, r=estebank
Add E0765
2020-06-22 14:53:50 +02:00
Dylan DPC
fdd241f5b3
Rollup merge of #72623 - da-x:use-suggest-public-path, r=petrochenkov
Prefer accessible paths in 'use' suggestions

This PR addresses issue https://github.com/rust-lang/rust/issues/26454, where `use` suggestions are made for paths that don't work. For example:

```rust
mod foo {
    mod bar {
        struct X;
    }
}

fn main() { X; } // suggests `use foo::bar::X;`
```
2020-06-22 14:53:48 +02:00
Dylan DPC
8da1dd0215
Rollup merge of #71660 - sollyucko:master, r=dtolnay
impl PartialEq<Vec<B>> for &[A], &mut [A]

https://github.com/rust-lang/rfcs/issues/2917
2020-06-22 14:53:46 +02:00
Ivan Tham
314e621198 Liballoc minor hash import tweak 2020-06-22 20:52:02 +08:00
Bastian Kauschke
932237b101
fix intrinsics::needs_drop docs 2020-06-22 14:42:26 +02:00
Guillaume Gomez
c474317747 Clean up E0699 explanation 2020-06-22 11:50:55 +02:00
David Wood
b60ec47a06
bootstrap: no config.toml exists regression
This commit fixes a regression introduced in #73317 where an oversight
meant that `config.toml` was assumed to exist.

Signed-off-by: David Wood <david@davidtw.co>
2020-06-22 10:02:00 +01:00