]> git.lizzy.rs Git - rust.git/log
rust.git
4 years agoRollup merge of #72666 - ivanloz:profile_emit_flag, r=matthewjasper
Ralf Jung [Sat, 30 May 2020 21:08:51 +0000 (23:08 +0200)]
Rollup merge of #72666 - ivanloz:profile_emit_flag, r=matthewjasper

Add -Z profile-emit=<path> for Gcov gcda output.

Adds a -Z flag to control the file path that the Gcov gcda output is
written to during runtime. This flag expects a path and filename, e.g.
-Z profile-emit=gcov/out/lib.gcda.

This works similar to GCC/Clang's -fprofile-dir flag which allows
control over the output path for gcda coverage files.

4 years agoRollup merge of #72657 - flip1995:impl_lint_pass-ty, r=matthewjasper
Ralf Jung [Sat, 30 May 2020 21:08:49 +0000 (23:08 +0200)]
Rollup merge of #72657 - flip1995:impl_lint_pass-ty, r=matthewjasper

Allow types (with lifetimes/generics) in impl_lint_pass

cc https://github.com/rust-lang/rust-clippy/pull/5279#discussion_r430790267

This allows to implement `LintPass` for types with lifetimes and/or generics. The only thing, I'm not sure of is the `LintPass::name` function, which now includes the lifetime(s) (which will be `'_` most of the time) in the name returned for the lint pass, if it exists. But I don't think that this should be a problem, since the `LintPass::name` is never used for output for the user (?).

4 years agoRollup merge of #72650 - GuillaumeGomez:sort-sidebar-elements, r=kinnison
Ralf Jung [Sat, 30 May 2020 21:08:47 +0000 (23:08 +0200)]
Rollup merge of #72650 - GuillaumeGomez:sort-sidebar-elements, r=kinnison

Sort sidebar elements

r? @kinnison

4 years agoRollup merge of #72637 - euclio:env-hygiene, r=davidtwco
Ralf Jung [Sat, 30 May 2020 21:08:46 +0000 (23:08 +0200)]
Rollup merge of #72637 - euclio:env-hygiene, r=davidtwco

expand `env!` with def-site context

Similar to #66349.

Fixes rust-lang/rust-clippy#5619.

4 years agoRollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov
Ralf Jung [Sat, 30 May 2020 21:08:44 +0000 (23:08 +0200)]
Rollup merge of #72625 - Amanieu:asm-srcloc, r=petrochenkov

Improve inline asm error diagnostics

Previously we were just using the raw LLVM error output (with line, caret, etc) as the diagnostic message, which ends up looking rather out of place with our existing diagnostics.

The new diagnostics properly format the diagnostics and also take advantage of LLVM's per-line `srcloc` attribute to map an error in inline assembly directly to the relevant line of source code.

Incidentally also fixes #71639 by disabling `srcloc` metadata during LTO builds since we don't know what crate it might have come from. We can only resolve `srcloc`s from the currently crate since it indexes into the source map for the current crate.

Fixes #72664
Fixes #71639

r? @petrochenkov

### Old style

```rust
#![feature(llvm_asm)]

fn main() {
    unsafe {
        let _x: i32;
        llvm_asm!(
            "mov $0, $1
             invalid_instruction $0, $1
             mov $0, $1"
             : "=&r" (_x)
             : "r" (0)
             :: "intel"
        );
    }
}
```

```
error: <inline asm>:3:14: error: invalid instruction mnemonic 'invalid_instruction'
             invalid_instruction ecx, eax
             ^~~~~~~~~~~~~~~~~~~

  --> src/main.rs:6:9
   |
6  | /         llvm_asm!(
7  | |             "mov $0, $1
8  | |              invalid_instruction $0, $1
9  | |              mov $0, $1"
...  |
12 | |              :: "intel"
13 | |         );
   | |__________^
```

### New style

```rust
#![feature(asm)]

fn main() {
    unsafe {
        asm!(
            "mov {0}, {1}
             invalid_instruction {0}, {1}
             mov {0}, {1}",
            out(reg) _,
            in(reg) 0i64,
        );
    }
}
```

```
error: invalid instruction mnemonic 'invalid_instruction'
 --> test.rs:7:14
  |
7 |              invalid_instruction {0}, {1}
  |              ^
  |
note: instantiated into assembly here
 --> <inline asm>:3:14
  |
3 |              invalid_instruction rax, rcx
  |              ^^^^^^^^^^^^^^^^^^^
```

4 years agoRollup merge of #72543 - estebank:opaque-missing-lts-in-fn, r=nikomatsakis
Ralf Jung [Sat, 30 May 2020 21:08:42 +0000 (23:08 +0200)]
Rollup merge of #72543 - estebank:opaque-missing-lts-in-fn, r=nikomatsakis

Account for missing lifetime in opaque and trait object return types

When encountering an opaque closure return type that needs to bound a
lifetime to the function's arguments, including borrows and type params,
provide appropriate suggestions that lead to working code.

Get the user from

```rust
fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
where
    G: Get<T>
{
    move || {
        *dest = g.get();
    }
}
```

to

```rust
fn foo<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() +'a
where
    G: Get<T>
{
    move || {
        *dest = g.get();
    }
}
```

4 years agoTweak wording and spans of `'static` `dyn Trait`/`impl Trait` requirements
Esteban Küber [Thu, 28 May 2020 18:54:40 +0000 (11:54 -0700)]
Tweak wording and spans of `'static` `dyn Trait`/`impl Trait` requirements

4 years agoConsider all possible one letter lifetimes in suggestion
Esteban Küber [Wed, 27 May 2020 22:44:42 +0000 (15:44 -0700)]
Consider all possible one letter lifetimes in suggestion

4 years agoAccount for enclosing item when suggesting new lifetime name
Esteban Küber [Wed, 27 May 2020 22:33:23 +0000 (15:33 -0700)]
Account for enclosing item when suggesting new lifetime name

4 years agoTweak type parameter errors to reduce verbosity
Esteban Küber [Wed, 27 May 2020 18:15:58 +0000 (11:15 -0700)]
Tweak type parameter errors to reduce verbosity

4 years agoUpdate nll tests
Esteban Küber [Wed, 27 May 2020 00:22:47 +0000 (17:22 -0700)]
Update nll tests

4 years agoreview comment: tweak wording and account for span overlap
Esteban Küber [Wed, 27 May 2020 00:20:08 +0000 (17:20 -0700)]
review comment: tweak wording and account for span overlap

4 years agoAccount for returned `dyn Trait` evaluating to `'static` lifetime
Esteban Küber [Tue, 26 May 2020 20:13:19 +0000 (13:13 -0700)]
Account for returned `dyn Trait` evaluating to `'static` lifetime

Provide a suggestion for `dyn Trait + '_` when possible.

4 years agoFix NLL output
Esteban Küber [Sun, 24 May 2020 19:00:40 +0000 (12:00 -0700)]
Fix NLL output

4 years agoImprove output of argument anonymous borrow missing annotation involving opaque retur...
Esteban Küber [Sun, 24 May 2020 18:52:12 +0000 (11:52 -0700)]
Improve output of argument anonymous borrow missing annotation involving opaque return type

Go from

```
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
  --> file8.rs:22:5
   |
22 | /     move || {
23 | |         *dest = g.get();
24 | |     }
   | |_____^
   |
note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the function body at 18:1...
  --> file8.rs:18:1
   |
18 | / fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
19 | | where
20 | |     G: Get<T>
21 | | {
...  |
24 | |     }
25 | | }
   | |_^
note: ...so that the types are compatible
  --> file8.rs:22:5
   |
22 | /     move || { //~ ERROR cannot infer an appropriate lifetime
23 | |         *dest = g.get();
24 | |     }
   | |_____^
   = note: expected  `&mut T`
              found  `&mut T`
note: but, the lifetime must be valid for the lifetime `'a` as defined on the function body at 18:8...
  --> file8.rs:18:8
   |
18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
   |        ^^
note: ...so that return value is valid for the call
  --> file8.rs:18:45
   |
18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
   |                                             ^^^^^^^^^^^^^^^^^^^^^^^
```

to

```
error[E0621]: explicit lifetime required in the type of `dest`
  --> file8.rs:18:45
   |
18 | fn bat<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
   |                                  ------     ^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
   |                                  |
   |                                  help: add explicit lifetime `'a` to the type of `dest`: `&'a mut T`
   ```

4 years agoAccount for missing lifetime in opaque return type
Esteban Küber [Sun, 24 May 2020 17:34:03 +0000 (10:34 -0700)]
Account for missing lifetime in opaque return type

When encountering an opaque closure return type that needs to bound a
lifetime to the function's arguments, including borrows and type params,
provide appropriate suggestions that lead to working code.

Get the user from

```rust
fn foo<G, T>(g: G, dest: &mut T) -> impl FnOnce()
where
    G: Get<T>
{
    move || {
        *dest = g.get();
    }
}
```

to

```rust
fn foo<'a, G: 'a, T>(g: G, dest: &'a mut T) -> impl FnOnce() +'a
where
    G: Get<T>
{
    move || {
        *dest = g.get();
    }
}
```

4 years agoAuto merge of #72778 - RalfJung:rollup-f01z68m, r=RalfJung
bors [Sat, 30 May 2020 12:49:47 +0000 (12:49 +0000)]
Auto merge of #72778 - RalfJung:rollup-f01z68m, r=RalfJung

Rollup of 9 pull requests

Successful merges:

 - #72299 (more `LocalDefId`s)
 - #72368 (Resolve overflow behavior for RangeFrom)
 - #72441 (Fix ICE with explicit late-bound lifetimes)
 - #72499 (Override Box::<[T]>::clone_from)
 - #72521 (Properly handle InlineAsmOperand::SymFn when collecting monomorphized items)
 - #72540 (mir: adjust conditional in recursion limit check)
 - #72563 (multiple Return terminators are possible)
 - #72585 (Only capture tokens for items with outer attributes)
 - #72607 (Eagerly lower asm sub-expressions to HIR even if there is an error)

Failed merges:

r? @ghost

4 years agoRollup merge of #72607 - Amanieu:fix-72570, r=oli-obk
Ralf Jung [Sat, 30 May 2020 11:45:15 +0000 (13:45 +0200)]
Rollup merge of #72607 - Amanieu:fix-72570, r=oli-obk

Eagerly lower asm sub-expressions to HIR even if there is an error

Fixes #72570

r? @oli-obk

4 years agoRollup merge of #72585 - Aaron1011:feature/opt-item-tokens, r=petrochenkov
Ralf Jung [Sat, 30 May 2020 11:45:13 +0000 (13:45 +0200)]
Rollup merge of #72585 - Aaron1011:feature/opt-item-tokens, r=petrochenkov

Only capture tokens for items with outer attributes

Suggested by @petrochenkov in https://github.com/rust-lang/rust/issues/43081#issuecomment-633389225

4 years agoRollup merge of #72563 - RalfJung:multi-return, r=matthewjasper
Ralf Jung [Sat, 30 May 2020 11:45:11 +0000 (13:45 +0200)]
Rollup merge of #72563 - RalfJung:multi-return, r=matthewjasper

multiple Return terminators are possible

@ecstatic-morse mentioned in https://github.com/rust-lang/rust/issues/72515 that multiple `Return` terminators are possible. Update the docs accordingly.

Cc @rust-lang/wg-mir-opt

4 years agoRollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, r=varkor
Ralf Jung [Sat, 30 May 2020 11:45:10 +0000 (13:45 +0200)]
Rollup merge of #72540 - davidtwco:issue-67552-mono-collector-comparison, r=varkor

mir: adjust conditional in recursion limit check

Fixes #67552.

This PR adjusts the condition used in the recursion limit check of
the monomorphization collector, from `>` to `>=`.

In #67552, the test case had infinite indirect recursion, repeating a
handful of functions (from the perspective of the monomorphization
collector): `rec` -> `identity` -> `Iterator::count` -> `Iterator::fold`
-> `Iterator::next` -> `rec`.

During this process, `resolve_associated_item` was invoked for
`Iterator::fold` (during the construction of an `Instance`), and
ICE'd due to substitutions needing inference. However, previous
iterations of this recursion would have called this function for
`Iterator::fold` - and did! - and succeeded in doing so (trivially
checkable from debug logging, `()` is present where `_` is in the substs
of the failing execution).

The expected outcome of this test case would be a recursion limit error
(which is present when the `identity` fn indirection is removed), and
the recursion depth of `rec` is increasing (other functions finish
collecting their neighbours and thus have their recursion depths reset).

When the ICE occurs, the recursion depth of `rec` is 256 (which matches
the recursion limit), which suggests perhaps that a different part of
the compiler is using a `>=` comparison and returning a different result
on this recursion rather than what it returned in every previous
recursion, thus stopping the monomorphization collector from reporting
an error on the next recursion, where `recursion_depth_of_rec > 256`
would have been true.

With grep and some educated guesses, we can determine that
the recursion limit check at line 818 in
`src/librustc_trait_selection/traits/project.rs` is the other check that
is using a different comparison. Modifying either comparison to be `>` or
`>=` respectively will fix the error, but changing the monomorphization
collector produces the nicer error.

4 years agoRollup merge of #72521 - Amanieu:fix-72484, r=petrochenkov
Ralf Jung [Sat, 30 May 2020 11:45:08 +0000 (13:45 +0200)]
Rollup merge of #72521 - Amanieu:fix-72484, r=petrochenkov

Properly handle InlineAsmOperand::SymFn when collecting monomorphized items

Fixes #72484

4 years agoRollup merge of #72499 - mendess:master, r=dtolnay
Ralf Jung [Sat, 30 May 2020 11:45:06 +0000 (13:45 +0200)]
Rollup merge of #72499 - mendess:master, r=dtolnay

Override Box::<[T]>::clone_from

Avoid dropping and reallocating when cloning to an existing box if the lengths are the same.

It would be nice if this could also be specialized for `Copy` but I don't know how that works since it's not on stable. Will gladly look into it if it's deemed as a good idea.

This is my first PR with code, hope I did everything right :smile:

4 years agoRollup merge of #72441 - doctorn:late-bound-lifetime-ice, r=nikomatsakis
Ralf Jung [Sat, 30 May 2020 11:45:04 +0000 (13:45 +0200)]
Rollup merge of #72441 - doctorn:late-bound-lifetime-ice, r=nikomatsakis

Fix ICE with explicit late-bound lifetimes

Rather than returning an explicit late-bound lifetime as a generic argument count mismatch (which is not necessarily true), this PR propagates the presence of explicit late-bound lifetimes.

This avoids an ICE that can occur due to the presence of explicit late-bound lifetimes when building generic substitutions by explicitly ignoring them.

r? @varkor

cc @davidtwco (this removes a check you introduced in #60892)

Resolves #72278

4 years agoRollup merge of #72368 - CAD97:rangeto, r=dtolnay
Ralf Jung [Sat, 30 May 2020 11:45:02 +0000 (13:45 +0200)]
Rollup merge of #72368 - CAD97:rangeto, r=dtolnay

Resolve overflow behavior for RangeFrom

This specifies a documented unspecified implementation detail of `RangeFrom` and makes it consistently implement the specified behavior.

Specifically, `(u8::MAX).next()` is defined to cause an overflow, and resolve that overflow in the same manner as the `Step::forward` implementation.

The inconsistency that has existed is `<RangeFrom as Iterator>::nth`. The existing behavior should be plain to see after #69659: the skipping part previously always panicked if it caused an overflow, but the final step (to set up the state for further iteration) has always been debug-checked.

The inconsistency, then, is that `RangeFrom::nth` does not implement the same behavior as the naive (and default) implementation of just calling `next` multiple times. This PR aligns `RangeFrom::nth` to have identical behavior to the naive implementation. It also lines up with the standard behavior of primitive math in Rust everywhere else in the language: debug checked overflow.

cc @Amanieu

---

Followup to #69659. Closes #25708 (by documenting the panic as intended).

The documentation wording is preliminary and can probably be improved.

This will probably need an FCP, as it changes observable stable behavior.

4 years agoRollup merge of #72299 - lcnr:sized_help, r=petrochenkov
Ralf Jung [Sat, 30 May 2020 11:45:00 +0000 (13:45 +0200)]
Rollup merge of #72299 - lcnr:sized_help, r=petrochenkov

more `LocalDefId`s

4 years agomore `LocalDefId`s
Bastian Kauschke [Sun, 17 May 2020 15:02:57 +0000 (17:02 +0200)]
more `LocalDefId`s

4 years agomultiple Return terminators are possible
Ralf Jung [Mon, 25 May 2020 09:41:58 +0000 (11:41 +0200)]
multiple Return terminators are possible

4 years agoAuto merge of #72768 - JohnTitor:rollup-6kwokh6, r=JohnTitor
bors [Sat, 30 May 2020 07:56:05 +0000 (07:56 +0000)]
Auto merge of #72768 - JohnTitor:rollup-6kwokh6, r=JohnTitor

Rollup of 10 pull requests

Successful merges:

 - #72033 (Update RELEASES.md for 1.44.0)
 - #72162 (Add Extend::{extend_one,extend_reserve})
 - #72419 (Miri read_discriminant: return a scalar instead of raw underlying bytes)
 - #72621 (Don't bail out of trait selection when predicate references an error)
 - #72677 (Fix diagnostics for `@ ..` binding pattern in tuples and tuple structs)
 - #72710 (Add test to make sure -Wunused-crate-dependencies works with tests)
 - #72724 (Revert recursive `TokenKind::Interpolated` expansion for now)
 - #72741 (Remove unused mut from long-linker-command-lines test)
 - #72750 (Remove remaining calls to `as_local_node_id`)
 - #72752 (remove mk_bool)

Failed merges:

r? @ghost

4 years agoRollup merge of #72752 - lcnr:remove-mk_bool, r=estebank
Yuki Okushi [Sat, 30 May 2020 03:39:24 +0000 (12:39 +0900)]
Rollup merge of #72752 - lcnr:remove-mk_bool, r=estebank

remove mk_bool

4 years agoRollup merge of #72750 - marmeladema:remove-as-local-node-id, r=petrochenkov
Yuki Okushi [Sat, 30 May 2020 03:39:23 +0000 (12:39 +0900)]
Rollup merge of #72750 - marmeladema:remove-as-local-node-id, r=petrochenkov

Remove remaining calls to `as_local_node_id`

Split out from https://github.com/rust-lang/rust/pull/72552

cc https://github.com/rust-lang/rust/issues/50928

4 years agoRollup merge of #72741 - tmiasko:unused-mut, r=Mark-Simulacrum
Yuki Okushi [Sat, 30 May 2020 03:39:21 +0000 (12:39 +0900)]
Rollup merge of #72741 - tmiasko:unused-mut, r=Mark-Simulacrum

Remove unused mut from long-linker-command-lines test

4 years agoRollup merge of #72724 - Aaron1011:revert-tokenstream-expand, r=petrochenkov
Yuki Okushi [Sat, 30 May 2020 03:39:19 +0000 (12:39 +0900)]
Rollup merge of #72724 - Aaron1011:revert-tokenstream-expand, r=petrochenkov

Revert recursive `TokenKind::Interpolated` expansion for now

The crater run https://github.com/rust-lang/rust/issues/72622 revealed many root regressions, at least one of which is going to take some time to fix.

For now, let's revert https://github.com/rust-lang/rust/pull/72388 to allow the 709 affected crates to continue building on the latest nightly.

4 years agoRollup merge of #72710 - jsgf:unused-deps-test, r=jsgf
Yuki Okushi [Sat, 30 May 2020 03:39:18 +0000 (12:39 +0900)]
Rollup merge of #72710 - jsgf:unused-deps-test, r=jsgf

Add test to make sure -Wunused-crate-dependencies works with tests

Make sure code in `#[test]` blocks counts as a use of a crate.

4 years agoRollup merge of #72677 - chrissimpkins:fix-72574, r=estebank
Yuki Okushi [Sat, 30 May 2020 03:39:16 +0000 (12:39 +0900)]
Rollup merge of #72677 - chrissimpkins:fix-72574, r=estebank

Fix diagnostics for `@ ..` binding pattern in tuples and tuple structs

Fixes #72574
Associated https://github.com/rust-lang/rust/pull/72534 https://github.com/rust-lang/rust/issues/72373

Includes a new suggestion with `Applicability::MaybeIncorrect` confidence level.

### Before

#### tuple

```
error: `..` patterns are not allowed here
 --> src/main.rs:4:19
  |
4 |         (_a, _x @ ..) => {}
  |                   ^^
  |
  = note: only allowed in tuple, tuple struct, and slice patterns

error[E0308]: mismatched types
 --> src/main.rs:4:9
  |
3 |     match x {
  |           - this expression has type `({integer}, {integer}, {integer})`
4 |         (_a, _x @ ..) => {}
  |         ^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 2 elements
  |
  = note: expected tuple `({integer}, {integer}, {integer})`
             found tuple `(_, _)`

error: aborting due to 2 previous errors
```

#### tuple struct

```
error: `..` patterns are not allowed here
 --> src/main.rs:6:25
  |
6 |         Binder(_a, _x @ ..) => {}
  |                         ^^
  |
  = note: only allowed in tuple, tuple struct, and slice patterns

error[E0023]: this pattern has 2 fields, but the corresponding tuple struct has 3 fields
 --> src/main.rs:6:9
  |
1 | struct Binder(i32, i32, i32);
  | ----------------------------- tuple struct defined here
...
6 |         Binder(_a, _x @ ..) => {}
  |         ^^^^^^^^^^^^^^^^^^^ expected 3 fields, found 2

error: aborting due to 2 previous errors
```

### After

*Note: final output edited during source review discussion, see thread for details*

#### tuple

```
error: `_x @` is not allowed in a tuple
 --> src/main.rs:4:14
  |
4 |         (_a, _x @ ..) => {}
  |              ^^^^^^^ is only allowed in a slice
  |
help: replace with `..` or use a different valid pattern
  |
4 |         (_a, ..) => {}
  |              ^^

error[E0308]: mismatched types
 --> src/main.rs:4:9
  |
3 |     match x {
  |           - this expression has type `({integer}, {integer}, {integer})`
4 |         (_a, _x @ ..) => {}
  |         ^^^^^^^^^^^^^ expected a tuple with 3 elements, found one with 1 element
  |
  = note: expected tuple `({integer}, {integer}, {integer})`
             found tuple `(_,)`

error: aborting due to 2 previous errors
```

#### tuple struct

```
error: `_x @` is not allowed in a tuple struct
 --> src/main.rs:6:20
  |
6 |         Binder(_a, _x @ ..) => {}
  |                    ^^^^^^^ is only allowed in a slice
  |
help: replace with `..` or use a different valid pattern
  |
6 |         Binder(_a, ..) => {}
  |                    ^^

error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 3 fields
 --> src/main.rs:6:9
  |
1 | struct Binder(i32, i32, i32);
  | ----------------------------- tuple struct defined here
...
6 |         Binder(_a, _x @ ..) => {}
  |         ^^^^^^^^^^^^^^^^^^^ expected 3 fields, found 1

error: aborting due to 2 previous errors
```

r? @estebank

4 years agoRollup merge of #72621 - Aaron1011:fix/trait-select-error, r=nikomatsakis
Yuki Okushi [Sat, 30 May 2020 03:39:14 +0000 (12:39 +0900)]
Rollup merge of #72621 - Aaron1011:fix/trait-select-error, r=nikomatsakis

Don't bail out of trait selection when predicate references an error

Fixes #72590

With PR #70551, observing a `ty::Error` guarantees that compilation is
going to fail. Therefore, there are no soundness impliciations to
continuing on when we encounter a `ty::Error` - we can only affect
whether or not additional error messags are emitted.

By not bailing out, we avoid incorrectly determining that types are
`!Sized` when a type error is present, which allows us to avoid emitting
additional spurious error messages.

The original comment mentioned this code being shared by coherence -
howver, this change resulted in no diagnostic changes in any of the
existing tests.

4 years agoRollup merge of #72419 - RalfJung:read-discriminant, r=oli-obk,eddyb
Yuki Okushi [Sat, 30 May 2020 03:39:12 +0000 (12:39 +0900)]
Rollup merge of #72419 - RalfJung:read-discriminant, r=oli-obk,eddyb

Miri read_discriminant: return a scalar instead of raw underlying bytes

r? @oli-obk @eddyb

4 years agoRollup merge of #72162 - cuviper:extend_one, r=Mark-Simulacrum
Yuki Okushi [Sat, 30 May 2020 03:39:10 +0000 (12:39 +0900)]
Rollup merge of #72162 - cuviper:extend_one, r=Mark-Simulacrum

Add Extend::{extend_one,extend_reserve}

This adds new optional methods on `Extend`: `extend_one` add a single
element to the collection, and `extend_reserve` pre-allocates space for
the predicted number of incoming elements. These are used in `Iterator`
for `partition` and `unzip` as they shuffle elements one-at-a-time into
their respective collections.

4 years agoRollup merge of #72033 - XAMPPRocky:relnotes-1.44.0, r=Mark-Simulacrum
Yuki Okushi [Sat, 30 May 2020 03:39:09 +0000 (12:39 +0900)]
Rollup merge of #72033 - XAMPPRocky:relnotes-1.44.0, r=Mark-Simulacrum

Update RELEASES.md for 1.44.0

### [Rendered](https://github.com/XAMPPRocky/rust/blob/relnotes-1.44.0/RELEASES.md)

r? @Mark-Simulacrum
cc @rust-lang/release

4 years agoAdd extend_one tracking issue 72631
Josh Stone [Tue, 26 May 2020 21:15:29 +0000 (14:15 -0700)]
Add extend_one tracking issue 72631

4 years agoRemove an old comment from HashMap::extend_reserve
Josh Stone [Tue, 26 May 2020 21:03:34 +0000 (14:03 -0700)]
Remove an old comment from HashMap::extend_reserve

4 years agoUse a canonical name for extend_reserve(additional)
Josh Stone [Tue, 26 May 2020 21:01:26 +0000 (14:01 -0700)]
Use a canonical name for extend_reserve(additional)

Co-authored-by: David Tolnay <dtolnay@gmail.com>
4 years agoAdd Extend::{extend_one,extend_reserve}
Josh Stone [Wed, 13 May 2020 03:09:55 +0000 (20:09 -0700)]
Add Extend::{extend_one,extend_reserve}

This adds new optional methods on `Extend`: `extend_one` add a single
element to the collection, and `extend_reserve` pre-allocates space for
the predicted number of incoming elements. These are used in `Iterator`
for `partition` and `unzip` as they shuffle elements one-at-a-time into
their respective collections.

4 years agoAuto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJung
bors [Fri, 29 May 2020 23:43:20 +0000 (23:43 +0000)]
Auto merge of #72756 - RalfJung:rollup-tbjmtx2, r=RalfJung

Rollup of 9 pull requests

Successful merges:

 - #67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes)
 - #71095 (impl From<[T; N]> for Box<[T]>)
 - #71500 (Make pointer offset methods/intrinsics const)
 - #71804 (linker: Support `-static-pie` and `-static -shared`)
 - #71862 (Implement RFC 2585: unsafe blocks in unsafe fn)
 - #72103 (borrowck `DefId` -> `LocalDefId`)
 - #72407 (Various minor improvements to Ipv6Addr::Display)
 - #72413 (impl Step for char (make Range*<char> iterable))
 - #72439 (NVPTX support for new asm!)

Failed merges:

r? @ghost

4 years agomore type sanity checks in Miri
Ralf Jung [Fri, 29 May 2020 22:02:30 +0000 (00:02 +0200)]
more type sanity checks in Miri

4 years agofix diagnostics for `@ ..` binding pattern in tuples and tuple structs
Chris Simpkins [Fri, 29 May 2020 20:03:46 +0000 (16:03 -0400)]
fix diagnostics for `@ ..` binding pattern in tuples and tuple structs

fix comment

add newline for tidy fmt error...

edit suggestion message

change the suggestion message to better handle cases with binding modes

Apply suggestions from estebank code review

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
edits to address source review

Apply suggestions from estebank code review #2

Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
update test files

4 years agoRollup merge of #72439 - westernmagic:master, r=Amanieu
Ralf Jung [Fri, 29 May 2020 19:58:34 +0000 (21:58 +0200)]
Rollup merge of #72439 - westernmagic:master, r=Amanieu

NVPTX support for new asm!

This PR implements the new `asm!` syntax for the `nvptx64-nvidia-cuda` target.

r? @Amanieu

4 years agoRollup merge of #72413 - CAD97:char-range, r=dtolnay
Ralf Jung [Fri, 29 May 2020 19:58:32 +0000 (21:58 +0200)]
Rollup merge of #72413 - CAD97:char-range, r=dtolnay

impl Step for char (make Range*<char> iterable)

[[irlo thread]](https://internals.rust-lang.org/t/mini-rfc-make-range-char-work/12392?u=cad97) [[godbolt asm example]](https://rust.godbolt.org/z/fdveKo)

Add an implementation of the `Step` trait for `char`, which has the effect of making `RangeInclusive<char>` (and the other range types) iterable.

I've used the surrogate range magic numbers as magic numbers here rather than e.g. a `const SURROGATE_RANGE = 0xD800..0xE000` because these numbers appear to be used as magic numbers elsewhere and there doesn't exist constants for them yet. These files definitely aren't where surrogate range constants should live.

`ExactSizeIterator` is not implemented because `0x10FFFF` is bigger than fits in a `usize == u16`. However, given we already provide some `ExactSizeIterator` that are not correct on 16 bit targets, we might still want to consider providing it for `Range`[`Inclusive`]`<char>`, as it is definitely _very_ convenient. (At the very least, we want to make sure `.count()` doesn't bother iterating the range.)

The second commit in this PR changes a call to `Step::forward` to use `Step::forward_unchecked` in `RangeInclusive::next`. This is because without this patch, iteration over all codepoints (`'\0'..=char::MAX`) does not successfully optimize out the panicking branch. This was mentioned in the PR that updated `Step` to its current design, but was deemed not yet necessary as it did not impact codegen for integral types.

More of `Range*`'s implementations' calls to `Step` methods will probably want to see if they can use the `_unchecked` version as (if) we open up `Step` to being implemented on more types.

---

cc @rust-lang/libs, this is insta-stable and a fairly significant addition to `Range*`'s capabilities; this is the first instance of a noncontinuous domain being iterable with `Range` (or, well, anything other than primitive integers). I don't think this needs a full RFC, but it should definitely get some decent eyes on it.

4 years agoRollup merge of #72407 - Lucretiel:ipv6-display, r=Mark-Simulacrum
Ralf Jung [Fri, 29 May 2020 19:58:29 +0000 (21:58 +0200)]
Rollup merge of #72407 - Lucretiel:ipv6-display, r=Mark-Simulacrum

Various minor improvements to Ipv6Addr::Display

Cleaned up `Ipv6Addr::Display`, especially with an eye towards simplifying and reducing duplicated logic. Also added a fast-path optimization, similar to #72399 and #72398.

- Defer to `Ipv4Addr::fmt` when printing an Ipv4 address
- Fast path: write directly to `f` without an intermediary buffer when there are no alignment options
- Simplify finding the inner zeroes-span

4 years agoRollup merge of #72103 - lcnr:borrowck-localdefid, r=jonas-schievink
Ralf Jung [Fri, 29 May 2020 19:58:27 +0000 (21:58 +0200)]
Rollup merge of #72103 - lcnr:borrowck-localdefid, r=jonas-schievink

borrowck `DefId` -> `LocalDefId`

Replaces some `DefId`s which must always be local with `LocalDefId` in `librustc_mir/borrowck`.

cc @marmeladema

4 years agoRollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, r=nikomatsakis
Ralf Jung [Fri, 29 May 2020 19:58:25 +0000 (21:58 +0200)]
Rollup merge of #71862 - LeSeulArtichaut:unsafe-block-in-unsafe-fn, r=nikomatsakis

Implement RFC 2585: unsafe blocks in unsafe fn

Tracking issue: #71668
r? @RalfJung cc @nikomatsakis

4 years agoRollup merge of #71804 - petrochenkov:static-pie, r=cuviper
Ralf Jung [Fri, 29 May 2020 19:58:24 +0000 (21:58 +0200)]
Rollup merge of #71804 - petrochenkov:static-pie, r=cuviper

linker: Support `-static-pie` and `-static -shared`

This PR adds support for passing linker arguments for creating statically linked position-independent executables and "statically linked" shared libraries.

Therefore it incorporates the majority of https://github.com/rust-lang/rust/pull/70740 except for the linker rerun hack and actually flipping the "`static-pie` is supported" switch for musl targets.

4 years agoRollup merge of #71500 - josephlr:offset, r=oli-obk,RalfJung
Ralf Jung [Fri, 29 May 2020 19:58:22 +0000 (21:58 +0200)]
Rollup merge of #71500 - josephlr:offset, r=oli-obk,RalfJung

Make pointer offset methods/intrinsics const

Implements #71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112).

I added some tests what's allowed and what's UB. Let me know if any other cases should be added.

CC: @RalfJung @oli-obk
4 years agoRollup merge of #71095 - pickfire:box-from-array, r=dtolnay
Ralf Jung [Fri, 29 May 2020 19:58:19 +0000 (21:58 +0200)]
Rollup merge of #71095 - pickfire:box-from-array, r=dtolnay

impl From<[T; N]> for Box<[T]>

Based on https://github.com/rust-lang/rust/pull/68692

4 years agoRollup merge of #67460 - estebank:named-lts, r=nikomatsakis
Ralf Jung [Fri, 29 May 2020 19:58:14 +0000 (21:58 +0200)]
Rollup merge of #67460 - estebank:named-lts, r=nikomatsakis

Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes

Fix #66406, fix #72106.

```
error: `impl` item signature doesn't match `trait` item signature
  --> $DIR/trait-param-without-lifetime-constraint.rs:14:5
   |
LL |     fn get_relation(&self) -> To;
   |     ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL |     fn get_relation(&self) -> &ProofReader {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
   |
   = note: expected `fn(&Article) -> &ProofReader`
              found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
  --> $DIR/trait-param-without-lifetime-constraint.rs:10:31
   |
LL |     fn get_relation(&self) -> To;
   |                               ^^ consider borrowing this type parameter in the trait
```

r? @nikomatsakis

4 years agoAuto merge of #72747 - Dylan-DPC:rollup-vvydkgl, r=Dylan-DPC
bors [Fri, 29 May 2020 19:50:22 +0000 (19:50 +0000)]
Auto merge of #72747 - Dylan-DPC:rollup-vvydkgl, r=Dylan-DPC

Rollup of 9 pull requests

Successful merges:

 - #72310 (Add Peekable::next_if)
 - #72383 (Suggest using std::mem::drop function instead of explicit destructor call)
 - #72398 (SocketAddr and friends now correctly pad its content)
 - #72465 (Warn about unused captured variables)
 - #72568 (Implement total_cmp for f32, f64)
 - #72572 (Add some regression tests)
 - #72591 (librustc_middle: Rename upvar_list to closure_captures)
 - #72701 (Fix grammar in liballoc raw_vec)
 - #72731 (Add missing empty line in E0619 explanation)

Failed merges:

r? @ghost

4 years agoRemove remaining calls to `as_local_node_id`
marmeladema [Sun, 24 May 2020 22:39:39 +0000 (23:39 +0100)]
Remove remaining calls to `as_local_node_id`

4 years agoremove mk_bool
Bastian Kauschke [Fri, 29 May 2020 18:41:26 +0000 (20:41 +0200)]
remove mk_bool

4 years agoRollup merge of #72731 - GuillaumeGomez:cleanup-e0619, r=Dylan-DPC
Dylan DPC [Fri, 29 May 2020 18:21:26 +0000 (20:21 +0200)]
Rollup merge of #72731 - GuillaumeGomez:cleanup-e0619, r=Dylan-DPC

Add missing empty line in E0619 explanation

r? @Dylan-DPC

4 years agoRollup merge of #72701 - pickfire:patch-1, r=Mark-Simulacrum
Dylan DPC [Fri, 29 May 2020 18:21:24 +0000 (20:21 +0200)]
Rollup merge of #72701 - pickfire:patch-1, r=Mark-Simulacrum

Fix grammar in liballoc raw_vec

4 years agoRollup merge of #72591 - sexxi-goose:rename_upvar_list-to-closure_captures, r=matthew...
Dylan DPC [Fri, 29 May 2020 18:21:22 +0000 (20:21 +0200)]
Rollup merge of #72591 - sexxi-goose:rename_upvar_list-to-closure_captures, r=matthewjasper

librustc_middle: Rename upvar_list to closure_captures

As part of supporting RFC 2229, we will be capturing all the places that
are mentioned in a closure. Currently the `upvar_list` field gives access to a `FxIndexMap<HirId, Upvar>` map. Eventually this will change, with the `upvar_list` having a more general structure that expresses captured paths, not just the mentioned `upvars`. We will make those changes in subsequent PRs.

This commit modifies the name of the `upvar_list` map to `closure_captures` in `TypeckTables`.

r? @matthewjasper

4 years agoRollup merge of #72572 - JohnTitor:add-tests, r=matthewjasper
Dylan DPC [Fri, 29 May 2020 18:21:20 +0000 (20:21 +0200)]
Rollup merge of #72572 - JohnTitor:add-tests, r=matthewjasper

Add some regression tests

Closes #68532
Closes #70121
Closes #71042
CC #56445

r? @matthewjasper since they (except for #71042) are related to #72362.

4 years agoRollup merge of #72568 - golddranks:add_total_cmp_to_floats, r=sfackler
Dylan DPC [Fri, 29 May 2020 18:21:18 +0000 (20:21 +0200)]
Rollup merge of #72568 - golddranks:add_total_cmp_to_floats, r=sfackler

Implement total_cmp for f32, f64

# Overview
* Implements method `total_cmp` on `f32` and `f64`. This method implements a float comparison that, unlike the standard `partial_cmp`, is total (defined on all values) in accordance to the IEEE 754 (rev 2008) §5.10 `totalOrder` predicate.
* The method has an API similar to `cmp`: `pub fn total_cmp(&self, other: &Self) -> crate::cmp::Ordering { ... }`.
* Implements tests.
* Has documentation.

# Justification for the API
* Total ordering for `f32` and `f64` has been discussed many time before:
  * https://internals.rust-lang.org/t/pre-pre-rfc-range-restricting-wrappers-for-floating-point-types/6701
  * https://github.com/rust-lang/rfcs/issues/1249
  * https://github.com/rust-lang/rust/pull/53938
  * https://github.com/rust-lang/rust/issues/5585
* The lack of total ordering leads to frequent complaints, especially from people new to Rust.
  * This is an ergonomics issue that needs to be addressed.
  * However, the default behaviour of implementing only `PartialOrd` is intentional, as relaxing it might lead to correctness issues.
* Most earlier implementations and discussions have been focusing on a wrapper type that implements trait `Ord`. Such a wrapper type is, however not easy to add because of the large API surface added.
* As a minimal step that hopefully proves uncontroversial, we can implement a stand-alone method `total_cmp` on floating point types.
  * I expect adding such methods should be uncontroversial because...
    * Similar methods on `f32` and `f64` would be warranted even in case stdlib would provide a wrapper type that implements `Ord` some day.
    * It implements functionality that is standardised. (IEEE 754, 2008 rev. §5.10 Note, that the 2019 revision relaxes the ordering. The way we do ordering in this method conforms to the stricter 2008 standard.)
* With stdlib APIs such as `slice::sort_by` and `slice::binary_search_by` that allow users to provide a custom ordering criterion, providing additional helper methods is a minimal way of adding ordering functionality.
  * Not also does it allow easily using aforementioned APIs, it also provides an easy and well-tested primitive for the users and library authors to implement an `Ord`-implementing wrapper, if needed.

4 years agoRollup merge of #72465 - tmiasko:liveness-upvars, r=nikomatsakis
Dylan DPC [Fri, 29 May 2020 18:21:17 +0000 (20:21 +0200)]
Rollup merge of #72465 - tmiasko:liveness-upvars, r=nikomatsakis

Warn about unused captured variables

Include captured variables in liveness analysis. Warn when captured variables
are unused (but possibly read or written to). Warn about dead assignments to
captured variables.

Fixes #37707.
Fixes #47128.
Fixes #63220.

4 years agoRollup merge of #72398 - Lucretiel:ip-socket-display, r=Mark-Simulacrum
Dylan DPC [Fri, 29 May 2020 18:21:15 +0000 (20:21 +0200)]
Rollup merge of #72398 - Lucretiel:ip-socket-display, r=Mark-Simulacrum

SocketAddr and friends now correctly pad its content

Currently, `IpAddr` and friends correctly respect formatting parameters when printing via `Display`. This PR makes SocketAddr and friends do the same thing.

4 years agoRollup merge of #72383 - DarkEld3r:issue-72322, r=matthewjasper
Dylan DPC [Fri, 29 May 2020 18:21:13 +0000 (20:21 +0200)]
Rollup merge of #72383 - DarkEld3r:issue-72322, r=matthewjasper

Suggest using std::mem::drop function instead of explicit destructor call

I would prefer to give a better suggestion that includes code example, but I'm currently stuck on getting the correct span for that.

Closes #72322.

4 years agoRollup merge of #72310 - jyn514:peekable-next-if, r=dtolnay
Dylan DPC [Fri, 29 May 2020 18:21:11 +0000 (20:21 +0200)]
Rollup merge of #72310 - jyn514:peekable-next-if, r=dtolnay

Add Peekable::next_if

Prior art:

`rust_analyzer` uses [`Parser::eat`](https://github.com/rust-analyzer/rust-analyzer/blob/50f4ae798b7c54d417ee88455b87fd0477473150/crates/ra_parser/src/parser.rs#L94), which is `next_if` specialized to `|y| self.next_if(|x| x == y)`.

Basically every other parser I've run into in Rust has an equivalent of `Parser::eat`; see for example

- [cranelift](https://github.com/bytecodealliance/wasmtime/blob/94190d57244b26baf36629c88104b0ba516510cf/cranelift/reader/src/parser.rs#L498)
- [rcc](https://github.com/jyn514/rcc/blob/a8159c3904a0c950fbba817bf9109023fad69033/src/parse/mod.rs#L231)
- [crunch](https://github.com/Kixiron/crunch-lang/blob/8521874fab8a7d62bfa7dea8bd1da94b63e31be8/crates/crunch-parser/src/parser/mod.rs#L213-L241)

Possible extensions: A specialization of `next_if` to using `Eq::eq`. The only difficulty here is the naming - maybe `next_if_eq`?

Alternatives:
- Instead of `func: impl FnOnce(&I::Item) -> bool`, use `func: impl FnOnce(I::Item) -> Option<I::Item>`. This has the advantage that `func` can move the value if necessary, but means that there is no guarantee `func` will return the same value it was given.
- Instead of `fn next_if(...) -> Option<I::Item>`, use `fn next_if(...) -> bool`. This makes the common case of `iter.next_if(f).is_some()` easier, but makes the unusual case impossible.

Bikeshedding on naming:
- `next_if` could be renamed to `consume_if` (to match `eat`, but a little more formally)
- `next_if_eq` could be renamed to `consume`. This is more concise but less self-explanatory if you haven't written a lot of parsers.
- Both of the above, but with `consume` replaced by `eat`.

4 years agoUpdate RELEASES.md
XAMPPRocky [Fri, 29 May 2020 16:25:34 +0000 (18:25 +0200)]
Update RELEASES.md

4 years agoAdd Span to arena_types! for decoding &'tcx [Span]
Amanieu d'Antras [Tue, 26 May 2020 21:44:43 +0000 (22:44 +0100)]
Add Span to arena_types! for decoding &'tcx [Span]

4 years agoImprove inline asm error diagnostics
Amanieu d'Antras [Tue, 26 May 2020 19:07:59 +0000 (20:07 +0100)]
Improve inline asm error diagnostics

4 years agoliveness: Warn about unused captured variables
Tomasz Miąsko [Fri, 22 May 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Warn about unused captured variables

4 years agoliveness: Include upvars in the analysis
Tomasz Miąsko [Thu, 21 May 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Include upvars in the analysis

4 years agoliveness: Remove unused fallthrough_ln
Tomasz Miąsko [Thu, 21 May 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Remove unused fallthrough_ln

4 years agoliveness: Remove unused clean_exit_var
Tomasz Miąsko [Thu, 21 May 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Remove unused clean_exit_var

4 years agoliveness: Log information about used variables
Tomasz Miąsko [Wed, 20 May 2020 00:00:00 +0000 (00:00 +0000)]
liveness: Log information about used variables

4 years agoAuto merge of #72671 - flip1995:clippyup, r=Xanewok
bors [Fri, 29 May 2020 11:16:45 +0000 (11:16 +0000)]
Auto merge of #72671 - flip1995:clippyup, r=Xanewok

Update Clippy, RLS, and rustfmt

r? @Dylan-DPC

This makes Clippy test-pass again: 3089c3b

Otherwise this includes bugfixes and a few new lints.

Fixes #72231
Fixes #72232

4 years agoUpdate RELEASES.md
XAMPPRocky [Fri, 29 May 2020 10:49:13 +0000 (12:49 +0200)]
Update RELEASES.md

4 years agoRemove flaky test and document the other's flakiness
mendess [Fri, 29 May 2020 10:18:15 +0000 (11:18 +0100)]
Remove flaky test and document the other's flakiness

4 years agoUpdate RELEASES.md
XAMPPRocky [Fri, 29 May 2020 09:45:25 +0000 (11:45 +0200)]
Update RELEASES.md

4 years agoUpdate RELEASES.md
XAMPPRocky [Fri, 29 May 2020 09:36:50 +0000 (11:36 +0200)]
Update RELEASES.md

4 years agoAdd missing empty line in E0619 explanation
Guillaume Gomez [Fri, 29 May 2020 09:06:48 +0000 (11:06 +0200)]
Add missing empty line in E0619 explanation

4 years agoAuto merge of #72727 - JohnTitor:rollup-nni16m2, r=JohnTitor
bors [Fri, 29 May 2020 07:52:06 +0000 (07:52 +0000)]
Auto merge of #72727 - JohnTitor:rollup-nni16m2, r=JohnTitor

Rollup of 11 pull requests

Successful merges:

 - #71633 (Impl Error for Infallible)
 - #71843 (Tweak and stabilize AtomicN::fetch_update)
 - #72288 (Stabilization of weak-into-raw)
 - #72324 (Stabilize AtomicN::fetch_min and AtomicN::fetch_max)
 - #72452 (Clarified the documentation for Formatter::precision)
 - #72495 (Improve E0601 explanation)
 - #72534 (Improve missing `@` in slice binding pattern diagnostics)
 - #72547 (Added a codegen test for a recent optimization for overflow-checks=on)
 - #72711 (remove redundant `mk_const`)
 - #72713 (Whitelist #[allow_internal_unstable])
 - #72720 (Clarify the documentation of `take`)

Failed merges:

r? @ghost

4 years agoAdd fibersapi feature to winapi in rustc-workspace-hack
flip1995 [Fri, 29 May 2020 06:19:58 +0000 (08:19 +0200)]
Add fibersapi feature to winapi in rustc-workspace-hack

Co-authored-by: Eric Huss <ehuss@users.noreply.github.com>
4 years agoRollup merge of #72720 - poliorcetics:clarify-take-doc, r=joshtriplett
Yuki Okushi [Fri, 29 May 2020 06:07:11 +0000 (15:07 +0900)]
Rollup merge of #72720 - poliorcetics:clarify-take-doc, r=joshtriplett

Clarify the documentation of `take`

This PR addresses the concerns of #61222, adding an example for the behaviour of `Iterator::take` when there are less than `n` elements.

4 years agoRollup merge of #72713 - rust-lang:jonas-schievink-patch-2, r=Mark-Simulacrum
Yuki Okushi [Fri, 29 May 2020 06:07:09 +0000 (15:07 +0900)]
Rollup merge of #72713 - rust-lang:jonas-schievink-patch-2, r=Mark-Simulacrum

Whitelist #[allow_internal_unstable]

This should hopefully work around https://github.com/rust-lang/rust/issues/65023, which currently makes almost every bootstrap fail for me.

4 years agoRollup merge of #72711 - lcnr:fixme-heyho, r=jonas-schievink
Yuki Okushi [Fri, 29 May 2020 06:07:07 +0000 (15:07 +0900)]
Rollup merge of #72711 - lcnr:fixme-heyho, r=jonas-schievink

remove redundant `mk_const`

Taken from #72675 as this is fairly unrelated and that PR is more difficult than I imagined,
so it may take some time until it lands.

4 years agoRollup merge of #72547 - alex:patch-1, r=oli-obk
Yuki Okushi [Fri, 29 May 2020 06:07:05 +0000 (15:07 +0900)]
Rollup merge of #72547 - alex:patch-1, r=oli-obk

Added a codegen test for a recent optimization for overflow-checks=on

Closes #58692

4 years agoRollup merge of #72534 - chrissimpkins:fix-72373, r=estebank
Yuki Okushi [Fri, 29 May 2020 06:07:04 +0000 (15:07 +0900)]
Rollup merge of #72534 - chrissimpkins:fix-72373, r=estebank

Improve missing `@` in slice binding pattern diagnostics

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

Includes a new suggestion with `Applicability::MaybeIncorrect` confidence level.

Before:

```
 --> src/main.rs:5:19
  |
5 |         [h, ref ts..] => foo(c, n - h) + foo(ts, n),
  |                   -^
  |                   |
  |                   expected one of `,`, `@`, `]`, or `|`
  |                   help: missing `,`

error[E0308]: mismatched types
 --> src/main.rs:5:46
  |
5 |         [h, ref ts..] => foo(c, n - h) + foo(ts, n),
  |                                              ^^ expected slice `[u32]`, found `u32`
  |
  = note: expected reference `&[u32]`
             found reference `&u32`

error: aborting due to 2 previous errors
```

After:

```
error: expected one of `,`, `@`, `]`, or `|`, found `..`
 --> src/main.rs:5:20
  |
5 |         [h, ref ts..] => foo(c, n - h) + foo(ts, n),
  |                    ^^ expected one of `,`, `@`, `]`, or `|`
  |
help: if you meant to bind the contents of the rest of the array pattern into `ts`, use `@`
  |
5 |         [h, ref ts @ ..] => foo(c, n - h) + foo(ts, n),
  |                    ^

error: aborting due to previous error
```

r? @estebank

4 years agoRollup merge of #72495 - GuillaumeGomez:cleanup-e0601, r=Dylan-DPC
Yuki Okushi [Fri, 29 May 2020 06:07:02 +0000 (15:07 +0900)]
Rollup merge of #72495 - GuillaumeGomez:cleanup-e0601, r=Dylan-DPC

Improve E0601 explanation

r? @Dylan-DPC

4 years agoRollup merge of #72452 - Lucretiel:precision-doc, r=dtolnay
Yuki Okushi [Fri, 29 May 2020 06:06:59 +0000 (15:06 +0900)]
Rollup merge of #72452 - Lucretiel:precision-doc, r=dtolnay

Clarified the documentation for Formatter::precision

Added a note that `precision` is interpreted as max-width when formatting strings

4 years agoRollup merge of #72324 - Amanieu:atomic_minmax, r=dtolnay
Yuki Okushi [Fri, 29 May 2020 06:06:57 +0000 (15:06 +0900)]
Rollup merge of #72324 - Amanieu:atomic_minmax, r=dtolnay

Stabilize AtomicN::fetch_min and AtomicN::fetch_max

Some architectures (ARMv8.1 LSE and RISC-V) have specific instructions for atomic min/max which the compiler can only generate through explicit instrinsics.

4 years agoRollup merge of #72288 - vorner:stabilize-weak-into-raw, r=dtolnay
Yuki Okushi [Fri, 29 May 2020 06:06:55 +0000 (15:06 +0900)]
Rollup merge of #72288 - vorner:stabilize-weak-into-raw, r=dtolnay

Stabilization of weak-into-raw

Closes #60728.

There are also two removals of `#![feature(weak_into_raw)]` in the `src/tools/miri` submodule. How should I synchronize the changes with there?

* I can ignore it for now and once this gets merged, update the tool, send a pull request to that one and then reference the changes to rustc.
* I could try submitting the changes to miri first, but then the build would fail there, because the attribute would still be needed.

I think the first one is the correct one, extrapolating from the contributing guidelines (even though they speak about breaking the tools and this should not break it, as extra feature should not hurt).

4 years agoRollup merge of #71843 - sfackler:cas-loop-cleanup, r=dtolnay
Yuki Okushi [Fri, 29 May 2020 06:06:53 +0000 (15:06 +0900)]
Rollup merge of #71843 - sfackler:cas-loop-cleanup, r=dtolnay

Tweak and stabilize AtomicN::fetch_update

The fetch_update method implements a compare-and-swap loop to update the value in an atomic to an arbitrary value computed by a closure.

I've applied a few tweaks suggested by @mystor in this comment on the tracking issue: https://github.com/rust-lang/rust/issues/48655#issuecomment-496036553. Specifically, the load and store ordering arguments have been swapped to match with the orderings of `compare_exchange`, and the closure has been moved from the first to last argument.

Moving the closure to the last argument is a change away from other methods on the atomic types which place the ordering(s) last, but matches with the broad convention that closure arguments come last in functions. In particular, rustfmt style lays calls with multi-line closures out more cleanly when the closure comes last.

4 years agoRollup merge of #71633 - a1phyr:infallible_error, r=dtolnay
Yuki Okushi [Fri, 29 May 2020 06:06:48 +0000 (15:06 +0900)]
Rollup merge of #71633 - a1phyr:infallible_error, r=dtolnay

Impl Error for Infallible

This PR only changes the place where `impl Error for Infallible` is documented, as one could think that it is not the case when reading https://doc.rust-lang.org/nightly/std/convert/enum.Infallible.html.

Fixes #70842

4 years agoFix missing import lost in revert
Aaron Hill [Fri, 29 May 2020 04:35:02 +0000 (00:35 -0400)]
Fix missing import lost in revert

4 years agoClarify comment message & MAX_LENGTH const
Nathan West [Fri, 22 May 2020 19:59:38 +0000 (15:59 -0400)]
Clarify comment message & MAX_LENGTH const

4 years agoAdded fast-path, tests
Nathan West [Wed, 20 May 2020 20:29:36 +0000 (16:29 -0400)]
Added fast-path, tests

4 years ago`SocketAddr(V4|V6)?`::Display now correctly pads its content
Nathan West [Wed, 20 May 2020 19:21:24 +0000 (15:21 -0400)]
`SocketAddr(V4|V6)?`::Display now correctly pads its content

IpAddr and friends pad when displaying; SocketAddr now does this as well

4 years agoRevert "Move functions to librustc_parse"
Aaron Hill [Fri, 29 May 2020 04:19:11 +0000 (00:19 -0400)]
Revert "Move  functions to librustc_parse"

This reverts commit 7a4c1865fb2f58c57e3f09645515dec8be3022c6.

4 years agoRevert "Recursively expand nonterminals"
Aaron Hill [Fri, 29 May 2020 04:19:10 +0000 (00:19 -0400)]
Revert "Recursively expand nonterminals"

This reverts commit 2af0218bf1ffca0750a352554f20a07b760a30a8.