]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoUpdate books
Eric Huss [Wed, 24 Jun 2020 00:56:33 +0000 (17:56 -0700)]
Update books

4 years agoTweak binop errors
Esteban Küber [Wed, 24 Jun 2020 00:32:06 +0000 (17:32 -0700)]
Tweak binop errors

* Suggest potentially missing binop trait bound (fix #73416)
* Use structured suggestion for dereference in binop

4 years agoFix ptr doc warnings.
Eric Huss [Tue, 23 Jun 2020 23:25:01 +0000 (16:25 -0700)]
Fix ptr doc warnings.

4 years agoAuto merge of #73669 - Manishearth:rollup-0n4u7vq, r=Manishearth
bors [Tue, 23 Jun 2020 21:33:22 +0000 (21:33 +0000)]
Auto merge of #73669 - Manishearth:rollup-0n4u7vq, r=Manishearth

Rollup of 11 pull requests

Successful merges:

 - #72780 (Enforce doc alias check)
 - #72876 (Mention that BTreeMap::new() doesn't allocate)
 - #73244 (Check for assignments between non-conflicting generator saved locals)
 - #73488 (code coverage foundation for hash and num_counters)
 - #73523 (Fix -Z unpretty=everybody_loops)
 - #73587 (Move remaining `NodeId` APIs from `Definitions` to `Resolver`)
 - #73601 (Point at the call span when overflow occurs during monomorphization)
 - #73613 (The const propagator cannot trace references.)
 - #73614 (fix `intrinsics::needs_drop` docs)
 - #73630 (Provide context on E0308 involving fn items)
 - #73665 (rustc: Modernize wasm checks for atomics)

Failed merges:

r? @ghost

4 years agoRollup merge of #73665 - alexcrichton:update-wasm-atomics-feature, r=davidtwco
Manish Goregaokar [Tue, 23 Jun 2020 20:10:19 +0000 (13:10 -0700)]
Rollup merge of #73665 - alexcrichton:update-wasm-atomics-feature, r=davidtwco

rustc: Modernize wasm checks for atomics

This commit modernizes how rustc checks for whether the `atomics`
feature is enabled for the wasm target. The `sess.target_features` set
is consulted instead of fiddling around with dealing with various
aspects of LLVM and that syntax.

4 years agoRollup merge of #73630 - estebank:fn-item-e0308, r=davidtwco
Manish Goregaokar [Tue, 23 Jun 2020 20:10:17 +0000 (13:10 -0700)]
Rollup merge of #73630 - estebank:fn-item-e0308, r=davidtwco

Provide context on E0308 involving fn items

Fix #73487.

4 years agoRollup merge of #73614 - lcnr:patch-4, r=Dylan-DPC
Manish Goregaokar [Tue, 23 Jun 2020 20:10:15 +0000 (13:10 -0700)]
Rollup merge of #73614 - lcnr:patch-4, r=Dylan-DPC

fix `intrinsics::needs_drop` docs

4 years agoRollup merge of #73613 - oli-obk:const_prop_miscompile, r=wesleywiser
Manish Goregaokar [Tue, 23 Jun 2020 20:10:13 +0000 (13:10 -0700)]
Rollup merge of #73613 - oli-obk:const_prop_miscompile, r=wesleywiser

The const propagator cannot trace references.

Thus we avoid propagation of a local the moment we encounter references to it.

fixes #73609

cc @RalfJung

r? @wesleywiser

4 years agoRollup merge of #73601 - Aaron1011:fix/better-mono-overflow-err, r=ecstatic-morse
Manish Goregaokar [Tue, 23 Jun 2020 20:10:11 +0000 (13:10 -0700)]
Rollup merge of #73601 - Aaron1011:fix/better-mono-overflow-err, r=ecstatic-morse

Point at the call span 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`

4 years agoRollup merge of #73587 - marmeladema:hir-id-ification-final, r=petrochenkov
Manish Goregaokar [Tue, 23 Jun 2020 20:10:09 +0000 (13:10 -0700)]
Rollup merge of #73587 - marmeladema:hir-id-ification-final, r=petrochenkov

Move remaining `NodeId` APIs from `Definitions` to `Resolver`

Implements https://github.com/rust-lang/rust/pull/73291#issuecomment-643515557

TL;DR: it moves all fields that are only needed during name resolution passes into the `Resolver` and keep the rest in `Definitions`. This effectively enforces that all references to `NodeId`s are gone once HIR lowering is completed.

After this, the only remaining work for #50928 should be to adjust the dev guide.

r? @petrochenkov

4 years agoRollup merge of #73523 - jyn514:everybody_loops, r=ecstatic-morse
Manish Goregaokar [Tue, 23 Jun 2020 20:10:07 +0000 (13:10 -0700)]
Rollup merge of #73523 - jyn514:everybody_loops, r=ecstatic-morse

Fix -Z unpretty=everybody_loops

It turns out that this has not been working for who knows how long.
Previously:

```
pub fn h() { 1 + 2; }
```

After this change:

```
pub fn h() { loop { } }
```

This only affected the pass when run with the command line
pretty-printing option, so rustdoc was still replacing bodies with
`loop {}`.

4 years agoRollup merge of #73488 - richkadel:llvm-coverage-map-gen, r=tmandry
Manish Goregaokar [Tue, 23 Jun 2020 20:10:05 +0000 (13:10 -0700)]
Rollup merge of #73488 - richkadel:llvm-coverage-map-gen, r=tmandry

code coverage foundation for hash and num_counters

This PR is the next iteration after PR #73011 (which is still waiting on bors to merge).

@wesleywiser - PTAL
r? @tmandry

(FYI, I'm also working on injecting the coverage maps, in another branch, while waiting for these to merge.)

Thanks!

4 years agoRollup merge of #73244 - ecstatic-morse:validate-generator-mir, r=tmandry
Manish Goregaokar [Tue, 23 Jun 2020 20:10:03 +0000 (13:10 -0700)]
Rollup merge of #73244 - ecstatic-morse:validate-generator-mir, r=tmandry

Check for assignments between non-conflicting generator saved locals

This is to prevent future changes to the generator transform from reintroducing the problem that caused #73137. Namely, a store between two generator saved locals whose storage does not conflict.

My ultimate goal is to introduce a modified version of #71956 that handles this case properly.

r? @tmandry

4 years agoRollup merge of #72876 - TrolledWoods:patch-2, r=Dylan-DPC
Manish Goregaokar [Tue, 23 Jun 2020 20:10:01 +0000 (13:10 -0700)]
Rollup merge of #72876 - TrolledWoods:patch-2, r=Dylan-DPC

Mention that BTreeMap::new() doesn't allocate

I think it would be nice to mention this, so you don't have to dig through the src to look at the definition of new().

4 years agoRollup merge of #72780 - GuillaumeGomez:enforce-doc-alias-check, r=ollie27
Manish Goregaokar [Tue, 23 Jun 2020 20:09:59 +0000 (13:09 -0700)]
Rollup merge of #72780 - GuillaumeGomez:enforce-doc-alias-check, r=ollie27

Enforce doc alias check

Part of #50146.

r? @ollie27

4 years agoreview comments: wording and style
Esteban Küber [Tue, 23 Jun 2020 20:01:24 +0000 (13:01 -0700)]
review comments: wording and style

4 years agoReview fixes
Dan Aloni [Tue, 23 Jun 2020 19:25:23 +0000 (22:25 +0300)]
Review fixes

4 years agoUpdate map.rs
Nikodem Rabuliński [Tue, 23 Jun 2020 18:06:44 +0000 (20:06 +0200)]
Update map.rs

4 years agoAuto merge of #73644 - ollie27:rustdoc_alias_filter, r=GuillaumeGomez
bors [Tue, 23 Jun 2020 17:30:54 +0000 (17:30 +0000)]
Auto merge of #73644 - ollie27:rustdoc_alias_filter, r=GuillaumeGomez

rustdoc: Fix doc aliases with crate filtering

Fix a crash when searching for an alias contained in the currently selected filter crate.

Also remove alias search results for crates that should be filtered out.

The test suite needed to be fixed to actually take into account the crate filtering and check that there are no results when none are expected.

Needs to be backported to beta to fix the `std` docs.

Fixes #73620

r? @GuillaumeGomez

4 years agorustc: Modernize wasm checks for atomics
Alex Crichton [Tue, 23 Jun 2020 16:41:56 +0000 (09:41 -0700)]
rustc: Modernize wasm checks for atomics

This commit modernizes how rustc checks for whether the `atomics`
feature is enabled for the wasm target. The `sess.target_features` set
is consulted instead of fiddling around with dealing with various
aspects of LLVM and that syntax.

4 years agoRecord span of `const` kw in GenericParamKind
Ayaz Hafiz [Sun, 21 Jun 2020 22:49:56 +0000 (15:49 -0700)]
Record span of `const` kw in GenericParamKind

Context: this is needed to fix https://github.com/rust-lang/rustfmt/issues/4263,
which currently records the span of a const generic param incorrectly
because the location of the `const` kw is not known.

I am not sure how to add tests for this; any guidance in how to do so
would be appreciated :slightly_smiling_face:

4 years agoMerge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup
flip1995 [Tue, 23 Jun 2020 15:05:22 +0000 (17:05 +0200)]
Merge commit 'c2c07fa9d095931eb5684a42942a7b573a0c5238' into clippyup

4 years agoAuto merge of #5740 - lzutao:unused-unused, r=flip1995
bors [Tue, 23 Jun 2020 14:34:18 +0000 (14:34 +0000)]
Auto merge of #5740 - lzutao:unused-unused, r=flip1995

Remove unused allowed unused attributes

changelog: none

4 years agoAuto merge of #5738 - mikerite:loops-20200623-2, r=matthiaskrgr
bors [Tue, 23 Jun 2020 14:05:45 +0000 (14:05 +0000)]
Auto merge of #5738 - mikerite:loops-20200623-2, r=matthiaskrgr

Improve end of expression check in for loop lints

changelog: none

4 years agoRemove unused allowed unused attributes
Lzu Tao [Tue, 23 Jun 2020 13:59:35 +0000 (20:59 +0700)]
Remove unused allowed unused attributes

4 years agoAuto merge of #5735 - lzutao:issue-temp, r=flip1995
bors [Tue, 23 Jun 2020 13:40:02 +0000 (13:40 +0000)]
Auto merge of #5735 - lzutao:issue-temp, r=flip1995

Add more specific GitHub issue templates

changelog: Make it easier to create feature request and bug reports with issue templates.

4 years agoAuto merge of #5741 - flip1995:rollup-8chbwhy, r=flip1995
bors [Tue, 23 Jun 2020 12:52:46 +0000 (12:52 +0000)]
Auto merge of #5741 - flip1995:rollup-8chbwhy, r=flip1995

Rollup of 9 pull requests

Successful merges:

 - #5178 (clippy-driver: pass all args to rustc if --rustc is present)
 - #5705 (Downgrade unnested_or_patterns to pedantic)
 - #5709 (Fix ICE in consts::binop)
 - #5710 (typo)
 - #5712 (Remove `bar` from blacklisted names)
 - #5713 (Use lints in Clippy that are enabled in rustc bootstrap)
 - #5716 (Fix typo in wildcard_imports)
 - #5724 (redundant_pattern_matching: avoid non-`const fn` calls in const contexts)
 - #5726 (Fix typo)

Failed merges:

r? @ghost

changelog: rollup

4 years agoRollup merge of #5726 - sozysozbot:patch-1, r=flip1995
Philipp Krones [Tue, 23 Jun 2020 12:39:50 +0000 (14:39 +0200)]
Rollup merge of #5726 - sozysozbot:patch-1, r=flip1995

Fix typo

changelog: extending it's lifetime -> extending its lifetime

4 years agoRollup merge of #5724 - ebroto:5697_const_result_option, r=Manishearth
Philipp Krones [Tue, 23 Jun 2020 12:39:49 +0000 (14:39 +0200)]
Rollup merge of #5724 - ebroto:5697_const_result_option, r=Manishearth

redundant_pattern_matching: avoid non-`const fn` calls in const contexts

changelog: Avoid suggesting non-`const fn` calls in const contexts in [`redundant_pattern_matching`]

Fixes #5697

4 years agoRollup merge of #5716 - bugadani:patch-1, r=matthiaskrgr
Philipp Krones [Tue, 23 Jun 2020 12:39:48 +0000 (14:39 +0200)]
Rollup merge of #5716 - bugadani:patch-1, r=matthiaskrgr

Fix typo in wildcard_imports

changelog: none

4 years agoRollup merge of #5713 - flip1995:more_lints, r=Manishearth
Philipp Krones [Tue, 23 Jun 2020 12:39:47 +0000 (14:39 +0200)]
Rollup merge of #5713 - flip1995:more_lints, r=Manishearth

Use lints in Clippy that are enabled in rustc bootstrap

cc https://github.com/rust-lang/rust/pull/73297#discussion_r439747061

changelog: none

4 years agoRollup merge of #5712 - ijijn:master, r=flip1995
Philipp Krones [Tue, 23 Jun 2020 12:39:45 +0000 (14:39 +0200)]
Rollup merge of #5712 - ijijn:master, r=flip1995

Remove `bar` from blacklisted names

changelog: Remove `bar` from blacklisted names
fixes #5225

4 years agoRollup merge of #5710 - lcnr:patch-1, r=flip1995
Philipp Krones [Tue, 23 Jun 2020 12:39:44 +0000 (14:39 +0200)]
Rollup merge of #5710 - lcnr:patch-1, r=flip1995

typo

changelog: none

4 years agoRollup merge of #5709 - ebroto:5389_ice, r=Manishearth
Philipp Krones [Tue, 23 Jun 2020 12:39:43 +0000 (14:39 +0200)]
Rollup merge of #5709 - ebroto:5389_ice, r=Manishearth

Fix ICE in consts::binop

changelog: Fix ICE in `consts::binop`

Fixes #5389

4 years agoRollup merge of #5705 - dtolnay:orpat, r=flip1995
Philipp Krones [Tue, 23 Jun 2020 12:39:42 +0000 (14:39 +0200)]
Rollup merge of #5705 - dtolnay:orpat, r=flip1995

Downgrade unnested_or_patterns to pedantic

Even with #5704 fixed, I don't believe it is a safe bet that if someone is using or-patterns anywhere in a codebase then they want to use it as much as possible in the whole codebase. I think it would be reasonable to reevaluate after the feature is stable. I feel that a warn-by-default lint suggesting use of an unstable feature, even if already being used in one place, is questionable.

changelog: Remove unnested_or_patterns from default set of enabled lints

4 years agoRollup merge of #5178 - matthiaskrgr:rustc_arg_pass, r=flip1995
Philipp Krones [Tue, 23 Jun 2020 12:39:40 +0000 (14:39 +0200)]
Rollup merge of #5178 - matthiaskrgr:rustc_arg_pass, r=flip1995

clippy-driver: pass all args to rustc if --rustc is present

changelog: clippy-driver: pass all args to rustc if --rustc is present

4 years agoFix fallout
flip1995 [Sat, 13 Jun 2020 16:22:49 +0000 (18:22 +0200)]
Fix fallout

4 years agoUse lints in Clippy that are enabled in rustc bootstrap
flip1995 [Sat, 13 Jun 2020 16:22:38 +0000 (18:22 +0200)]
Use lints in Clippy that are enabled in rustc bootstrap

4 years agoAuto merge of #5739 - flip1995:rustup, r=flip1995
bors [Tue, 23 Jun 2020 12:04:08 +0000 (12:04 +0000)]
Auto merge of #5739 - flip1995:rustup, r=flip1995

Rustup

changelog: none

r? @ghost

4 years agoAdd re-exports to use suggestions
Dan Aloni [Sun, 21 Jun 2020 16:31:49 +0000 (19:31 +0300)]
Add re-exports to use suggestions

In the following example, an inaccessible path is suggested via
`use foo::bar::X;` whereas an accessible public exported path can
be suggested instead.

```
mod foo {
    mod bar {
        pub struct X;
    }
    pub use self::bar::X;
}

fn main() { X; }
```

This fixes the issue.

4 years agoAdd test for issue-69840
Yuki Okushi [Tue, 23 Jun 2020 08:52:51 +0000 (17:52 +0900)]
Add test for issue-69840

4 years agoAdd test for issue-59435
Yuki Okushi [Tue, 23 Jun 2020 08:52:42 +0000 (17:52 +0900)]
Add test for issue-59435

4 years agoAdd test for issue-51506
Yuki Okushi [Tue, 23 Jun 2020 08:52:26 +0000 (17:52 +0900)]
Add test for issue-51506

4 years agoAdd test for issue-44861
Yuki Okushi [Tue, 23 Jun 2020 08:52:01 +0000 (17:52 +0900)]
Add test for issue-44861

4 years agorustdoc: Fix doc aliases with crate filtering
Oliver Middleton [Tue, 23 Jun 2020 08:18:51 +0000 (09:18 +0100)]
rustdoc: Fix doc aliases with crate filtering

Fix a crash when searching for an alias contained in the currently selected filter crate.

Also remove alias search results for crates that should be filtered out.

The test suite needed to be fixed to actually take into account the crate filtering and check that there are no results when none are expected.

4 years agoThe const propagator cannot trace references.
Oliver Scherer [Mon, 22 Jun 2020 12:03:18 +0000 (14:03 +0200)]
The const propagator cannot trace references.

Thus we avoid propagation of a local the moment we encounter references to it.

4 years agoAuto merge of #73643 - Manishearth:rollup-68dr8fz, r=Manishearth
bors [Tue, 23 Jun 2020 07:50:51 +0000 (07:50 +0000)]
Auto merge of #73643 - Manishearth:rollup-68dr8fz, r=Manishearth

Rollup of 9 pull requests

Successful merges:

 - #72271 (Improve compiler error message for wrong generic parameter order)
 - #72493 ( move leak-check to during coherence, candidate eval)
 - #73398 (A way forward for pointer equality in const eval)
 - #73472 (Clean up E0689 explanation)
 - #73496 (Account for multiple impl/dyn Trait in return type when suggesting `'_`)
 - #73515 (Add second message for LiveDrop errors)
 - #73567 (Clarify --extern documentation.)
 - #73572 (Fix typos in doc comments)
 - #73590 (bootstrap: no `config.toml` exists regression)

Failed merges:

r? @ghost

4 years agoAdd more specific GitHub issue templates
Lzu Tao [Tue, 23 Jun 2020 07:27:11 +0000 (14:27 +0700)]
Add more specific GitHub issue templates

Apply suggestions from code review

Co-authored-by: Philipp Krones <hello@philkrones.com>
4 years agoRollup merge of #73590 - davidtwco:bootstrap-fix-config-env-var, r=Mark-Simulacrum
Manish Goregaokar [Tue, 23 Jun 2020 07:34:06 +0000 (00:34 -0700)]
Rollup merge of #73590 - davidtwco:bootstrap-fix-config-env-var, r=Mark-Simulacrum

bootstrap: no `config.toml` exists regression

Fixes #73574.

This PR fixes a regression introduced in #73317 where an oversight meant that `config.toml` was assumed to exist.

4 years agoRollup merge of #73572 - JOE1994:patch-4, r=jonas-schievink
Manish Goregaokar [Tue, 23 Jun 2020 07:34:05 +0000 (00:34 -0700)]
Rollup merge of #73572 - JOE1994:patch-4, r=jonas-schievink

Fix typos in doc comments

Hello 🦀 ,

This commit fixes typos in the doc comments of 'librustc_mir/monomorphize/collector.rs'

Thank you for reviewing this PR 👍

4 years agoRollup merge of #73567 - adetaylor:extern-doc-fix, r=dtolnay
Manish Goregaokar [Tue, 23 Jun 2020 07:34:03 +0000 (00:34 -0700)]
Rollup merge of #73567 - adetaylor:extern-doc-fix, r=dtolnay

Clarify --extern documentation.

Fixes #64731, #73531.

See also https://github.com/rust-lang/rust/issues/64402#issuecomment-530852886

4 years agoRollup merge of #73515 - christianpoveda:livedrop-diagnostics, r=oli-obk
Manish Goregaokar [Tue, 23 Jun 2020 07:34:00 +0000 (00:34 -0700)]
Rollup merge of #73515 - christianpoveda:livedrop-diagnostics, r=oli-obk

Add second message for LiveDrop errors

This is an attempt to fix https://github.com/rust-lang/rust/issues/72907 by adding a second message to the `LiveDrop` diagnostics. Changing from this
```
error[E0493]: destructors cannot be evaluated at compile-time
 --> src/lib.rs:7:9
  |
7 |     let mut always_returned = None;
  |         ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors

error: aborting due to previous error
```
to this
```
error[E0493]: destructors cannot be evaluated at compile-time
  --> foo.rs:6:9
   |
6  |     let mut always_returned = None;
   |         ^^^^^^^^^^^^^^^^^^^ constants cannot evaluate destructors
...
10 |         always_returned = never_returned;
   |         --------------- value is dropped here

error: aborting due to previous error
```
r? @RalfJung @ecstatic-morse

4 years agoRollup merge of #73496 - estebank:opaque-missing-lts-in-fn-3, r=nikomatsakis
Manish Goregaokar [Tue, 23 Jun 2020 07:33:58 +0000 (00:33 -0700)]
Rollup merge of #73496 - estebank:opaque-missing-lts-in-fn-3, r=nikomatsakis

Account for multiple impl/dyn Trait in return type when suggesting `'_`

Make `impl` and `dyn` Trait lifetime suggestions a bit more resilient.

Follow up to #72804.

r? @nikomatsakis

4 years agoRollup merge of #73472 - GuillaumeGomez:cleanup-e0689, r=Dylan-DPC
Manish Goregaokar [Tue, 23 Jun 2020 07:33:56 +0000 (00:33 -0700)]
Rollup merge of #73472 - GuillaumeGomez:cleanup-e0689, r=Dylan-DPC

Clean up E0689 explanation

r? @Dylan-DPC

4 years agoRollup merge of #73398 - oli-obk:const_raw_ptr_cmp, r=varkor,RalfJung,nagisa
Manish Goregaokar [Tue, 23 Jun 2020 07:33:54 +0000 (00:33 -0700)]
Rollup merge of #73398 - oli-obk:const_raw_ptr_cmp, r=varkor,RalfJung,nagisa

A way forward for pointer equality in const eval

r? @varkor on the first commit and @RalfJung on the second commit

cc #53020

4 years agoRollup merge of #72493 - nikomatsakis:move-leak-check, r=matthewjasper
Manish Goregaokar [Tue, 23 Jun 2020 07:33:52 +0000 (00:33 -0700)]
Rollup merge of #72493 - nikomatsakis:move-leak-check, r=matthewjasper

 move leak-check to during coherence, candidate eval

Implementation of MCP https://github.com/rust-lang/compiler-team/issues/295.

I'd like to do a crater run on this.

Note to @rust-lang/lang: This PR is a breaking change (bugfix). It causes tests like the following to go from a future-compatibility warning #56105 to a hard error:

```rust
trait Trait {}
impl Trait for for<'a, 'b> fn(&'a u32, &'b u32) {}
impl Trait for for<'c> fn(&'c u32, &'c u32) {} // now rejected, used to warn
```

I am not aware of any instances of this code in the wild, but that is why we are doing a crater run. The reason for this change is that those two types are, in fact, the same type, and hence the two impls are overlapping.

There will still be impls that trigger #56105 after this lands, however -- I hope that we will eventually just accept those impls without warning, for the most part. One example of such an impl is this pattern, which is used by wasm-bindgen and other crates as well:

```rust
trait Trait {}
impl<T> Trait for fn(&T) { }
impl<T> Trait for fn(T) { } // still accepted, but warns
```

4 years agoRollup merge of #72271 - rakshith-ravi:master, r=varkor
Manish Goregaokar [Tue, 23 Jun 2020 07:33:46 +0000 (00:33 -0700)]
Rollup merge of #72271 - rakshith-ravi:master, r=varkor

Improve compiler error message for wrong generic parameter order

- Added optional "help" parameter that shows a help message on the compiler error if required.
- Added a simple ordered parameter as a sample help.

@varkor will make more changes as required. Let me know if I'm heading in the right direction.

Fixes #68437

r? @varkor

4 years agoUpdated query for num_counters to compute from max index
Rich Kadel [Tue, 23 Jun 2020 06:31:41 +0000 (23:31 -0700)]
Updated query for num_counters to compute from max index

Also added FIXME comments to note the possible need to accommodate
counter increment calls in source-based functions that differ from the
function context of the caller instance (e.g., inline functions).

4 years agoImprove end of expression check in for loop lints
Michael Wright [Thu, 11 Jun 2020 18:25:14 +0000 (20:25 +0200)]
Improve end of expression check in for loop lints

The code should to check that the current expression _is_ the end
expression; not that it's equal to it. The equality check seems very
wasteful in terms of performance.

4 years agoAuto merge of #5695 - esamudera:lint_mem_uninitialized, r=phansch,oli-obk
bors [Tue, 23 Jun 2020 05:14:21 +0000 (05:14 +0000)]
Auto merge of #5695 - esamudera:lint_mem_uninitialized, r=phansch,oli-obk

New lint: suggest `ptr::read` instead of `mem::replace(..., uninitialized())`

resolves: #5575

changelog: improvements to `MEM_REPLACE_WITH_UNINIT`:
- add a new test case in `tests/ui/repl_uninit.rs` to cover the case of replacing with `mem::MaybeUninit::uninit().assume_init()`.
- modify the existing `MEM_REPLACE_WITH_UNINIT` when replacing with `mem::uninitialized` to suggest using `ptr::read` instead.
- lint with `MEM_REPLACE_WITH_UNINIT` when replacing with `mem::MaybeUninit::uninit().assume_init()`

4 years agoAuto merge of #73635 - Dylan-DPC:rollup-b4wbp42, r=Dylan-DPC
bors [Tue, 23 Jun 2020 04:03:28 +0000 (04:03 +0000)]
Auto merge of #73635 - Dylan-DPC:rollup-b4wbp42, r=Dylan-DPC

Rollup of 7 pull requests

Successful merges:

 - #71756 (add Windows system error codes that should map to io::ErrorKind::TimedOut)
 - #73495 (Converted all platform-specific stdin/stdout/stderr implementations to use io:: traits)
 - #73575 (Fix typo in error_codes doc)
 - #73578 (Make is_freeze and is_copy_modulo_regions take TyCtxtAt)
 - #73586 (switch_ty is redundant)
 - #73600 (Fix spurious 'value moved here in previous iteration of loop' messages)
 - #73610 (Clean up E0699 explanation)

Failed merges:

r? @ghost

4 years agoChange heuristic for determining range literal
Ayaz Hafiz [Tue, 23 Jun 2020 03:52:44 +0000 (20:52 -0700)]
Change heuristic for determining range literal

Currently, rustc uses a heuristic to determine if a range expression is
not a literal based on whether the expression looks like a function call
or struct initialization. This fails for range literals whose
lower/upper bounds are the results of function calls. A possibly-better
heuristic is to check if the expression contains `..`, required in range
literals.

Of course, this is also not perfect; for example, if the range
expression is a struct which includes some text with `..` this will
fail, but in general I believe it is a better heuristic.

A better alternative altogether is to add the `QPath::LangItem` enum
variant suggested in #60607. I would be happy to do this as a precursor
to this patch if someone is able to provide general suggestions on how
usages of `QPath` need to be changed later in the compiler with the
`LangItem` variant.

Closes #73553

4 years agoRemove unused crate imports in 2018 edition crates
yuqio [Tue, 23 Jun 2020 03:01:20 +0000 (05:01 +0200)]
Remove unused crate imports in 2018 edition crates

4 years agousing "mir_body" (vs "body") in InstrumentCoverage
Rich Kadel [Tue, 23 Jun 2020 02:30:52 +0000 (19:30 -0700)]
using "mir_body" (vs "body") in InstrumentCoverage

The mod uses both MIR bodies and HIR bodies, so I'm trying to maintain
consistency with these names.

4 years agoPR no longer requires u32 impl TypeFoldable
Rich Kadel [Tue, 23 Jun 2020 02:27:48 +0000 (19:27 -0700)]
PR no longer requires u32 impl TypeFoldable

4 years agomoves coverage data computation from pass to query
Rich Kadel [Tue, 23 Jun 2020 02:21:56 +0000 (19:21 -0700)]
moves coverage data computation from pass to query

4 years agoRollup merge of #73610 - GuillaumeGomez:cleanup-e0699, r=Dylan-DPC
Dylan DPC [Tue, 23 Jun 2020 01:16:28 +0000 (03:16 +0200)]
Rollup merge of #73610 - GuillaumeGomez:cleanup-e0699, r=Dylan-DPC

Clean up E0699 explanation

r? @Dylan-DPC

4 years agoRollup merge of #73600 - Aaron1011:fix/move-in-macro, r=ecstatic-morse
Dylan DPC [Tue, 23 Jun 2020 01:16:26 +0000 (03:16 +0200)]
Rollup merge of #73600 - Aaron1011:fix/move-in-macro, r=ecstatic-morse

Fix spurious 'value moved here in previous iteration of loop' messages

Fixes #46099

Previously, we would check the 'move' and 'use' spans to see if we
should emit this message. However, this can give false positives when
macros are involved, since two distinct expressions may end up with the
same span.

Instead, we check the actual MIR `Location`, which eliminates false
positives.

4 years agoRollup merge of #73586 - RalfJung:switch-ty, r=oli-obk
Dylan DPC [Tue, 23 Jun 2020 01:16:24 +0000 (03:16 +0200)]
Rollup merge of #73586 - RalfJung:switch-ty, r=oli-obk

switch_ty is redundant

This field is redundant, but we cannot remove it currently as pretty-printing relies on it (and it does not have access to `mir::Body` to compute the type itself).

Cc @oli-obk @matthewjasper @jonas-schievink

4 years agoRollup merge of #73578 - RalfJung:ty-ctxt-at, r=jonas-schievink
Dylan DPC [Tue, 23 Jun 2020 01:16:22 +0000 (03:16 +0200)]
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.

4 years agoRollup merge of #73578 - RalfJung:ty-ctxt-at, r=jonas-schievink
Dylan DPC [Tue, 23 Jun 2020 01:16:22 +0000 (03:16 +0200)]
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.

4 years agoRollup merge of #73575 - dario23:typo-errorcodes-doc, r=matthewjasper
Dylan DPC [Tue, 23 Jun 2020 01:16:21 +0000 (03:16 +0200)]
Rollup merge of #73575 - dario23:typo-errorcodes-doc, r=matthewjasper

Fix typo in error_codes doc

4 years agoRollup merge of #73495 - Lucretiel:wasi-io-impls, r=sfackler
Dylan DPC [Tue, 23 Jun 2020 01:16:19 +0000 (03:16 +0200)]
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`.

4 years agoRollup merge of #71756 - carstenandrich:master, r=dtolnay
Dylan DPC [Tue, 23 Jun 2020 01:16:14 +0000 (03:16 +0200)]
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

4 years agoAuto merge of #5711 - flip1995:rustup, r=flip1995
bors [Tue, 23 Jun 2020 00:27:02 +0000 (00:27 +0000)]
Auto merge of #5711 - flip1995:rustup, r=flip1995

Rustup

changelog: none

4 years agoFix sync fallout
flip1995 [Tue, 23 Jun 2020 00:18:38 +0000 (02:18 +0200)]
Fix sync fallout

4 years agoMerge remote-tracking branch 'upstream/master' into rustup
flip1995 [Tue, 23 Jun 2020 00:18:17 +0000 (02:18 +0200)]
Merge remote-tracking branch 'upstream/master' into rustup

4 years agoAuto merge of #73007 - yoshuawuyts:socketaddr-from-string-u16, r=sfackler
bors [Tue, 23 Jun 2020 00:13:50 +0000 (00:13 +0000)]
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!

4 years agoAdd UI test for issue 73592
Gary Guo [Mon, 22 Jun 2020 22:37:05 +0000 (23:37 +0100)]
Add UI test for issue 73592

4 years agoreview comments
Esteban Küber [Mon, 22 Jun 2020 23:05:31 +0000 (16:05 -0700)]
review comments

4 years agoAddress remaining feedback items
Rich Kadel [Mon, 22 Jun 2020 22:54:28 +0000 (15:54 -0700)]
Address remaining feedback items

4 years agoplace non-obvious defaults on a separate line
Tshepang Lekhonkhobe [Mon, 22 Jun 2020 22:29:55 +0000 (00:29 +0200)]
place non-obvious defaults on a separate line

See https://github.com/rust-lang/rust/pull/73538#discussion_r443809593
for the motivation

4 years agoProvide context on E0308 involving fn items
Esteban Küber [Mon, 22 Jun 2020 19:28:16 +0000 (12:28 -0700)]
Provide context on E0308 involving fn items

4 years agoimplemented query for coverage data
Rich Kadel [Mon, 22 Jun 2020 21:11:55 +0000 (14:11 -0700)]
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

4 years agoAuto merge of #73594 - Aaron1011:revert/move-fn-self-msg, r=Manishearth
bors [Mon, 22 Jun 2020 20:30:06 +0000 (20:30 +0000)]
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

4 years agoMake AssocOp Copy
flip1995 [Mon, 22 Jun 2020 19:01:49 +0000 (21:01 +0200)]
Make AssocOp Copy

4 years agocite issue 73154
Niko Matsakis [Mon, 8 Jun 2020 23:22:10 +0000 (23:22 +0000)]
cite issue 73154

4 years agofix subtle bug in NLL type checker
Niko Matsakis [Mon, 8 Jun 2020 23:12:01 +0000 (23:12 +0000)]
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.

4 years agoWIP bless test and compare-mode=nll
Niko Matsakis [Sat, 6 Jun 2020 10:31:51 +0000 (10:31 +0000)]
WIP bless test and compare-mode=nll

4 years agoadd new coherence tests and update the documentation
Niko Matsakis [Fri, 5 Jun 2020 21:14:34 +0000 (21:14 +0000)]
add new coherence tests and update the documentation

4 years agoadd new tests from MCP and the tracking issue
Niko Matsakis [Fri, 22 May 2020 11:05:09 +0000 (11:05 +0000)]
add new tests from MCP and the tracking issue

4 years agoremove `leak_check` from the outlives predicate evaluations
Niko Matsakis [Fri, 22 May 2020 18:19:54 +0000 (18:19 +0000)]
remove `leak_check` from the outlives predicate evaluations

4 years agoremove leak-check from project
Niko Matsakis [Fri, 22 May 2020 18:16:28 +0000 (18:16 +0000)]
remove leak-check from project

4 years agoremove snapshot calls from "match" operations during select
Niko Matsakis [Fri, 22 May 2020 17:48:07 +0000 (17:48 +0000)]
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

4 years agoPoint at the call spawn when overflow occurs during monomorphization
Aaron Hill [Mon, 22 Jun 2020 02:32:35 +0000 (22:32 -0400)]
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`

4 years agoStop using old version of `syn` in `rustc-workspace-hack`
Aaron Hill [Mon, 22 Jun 2020 17:29:04 +0000 (13:29 -0400)]
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.

4 years agoStop using old version of `syn` in `rustc-workspace-hack`
Aaron Hill [Mon, 22 Jun 2020 17:29:04 +0000 (13:29 -0400)]
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.

4 years agoRe-enable Clippy tests
Aaron Hill [Sun, 21 Jun 2020 20:28:58 +0000 (16:28 -0400)]
Re-enable Clippy tests

4 years agoRevert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakis"
Aaron Hill [Sun, 21 Jun 2020 20:28:19 +0000 (16:28 -0400)]
Revert "Rollup merge of #72389 - Aaron1011:feature/move-fn-self-msg, r=nikomatsakis"

This reverts commit 372cb9b69c76a042d0b9d4b48ff6084f64c84a2c, reversing
changes made to 5c61a8dc34c3e2fc6d7f02cb288c350f0233f944.

4 years agoAuto merge of #73415 - ehuss:update-cargo, r=ehuss
bors [Mon, 22 Jun 2020 16:38:21 +0000 (16:38 +0000)]
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)