Commit graph

121105 commits

Author SHA1 Message Date
Josh Triplett 32736606fd RELEASES.md: Expand cargo tree note to mention cargo tree -d
Useful feature that people might not automatically associate with `cargo
tree`.
2020-05-31 12:39:28 -07:00
bors f6072cab13 Auto merge of #72813 - RalfJung:rollup-4ko6q8j, r=RalfJung
Rollup of 5 pull requests

Successful merges:

 - #72683 (from_u32_unchecked: check validity, and fix UB in Wtf8)
 - #72715 (Account for trailing comma when suggesting `where` clauses)
 - #72745 (generalize Borrow<[T]> for Interned<'tcx, List<T>>)
 - #72749 (Update stdarch submodule to latest head)
 - #72781 (Use `LocalDefId` instead of `NodeId` in `resolve_str_path_error`)

Failed merges:

r? @ghost
2020-05-31 13:39:05 +00:00
Ralf Jung cbc73dc263
Rollup merge of #72781 - marmeladema:rustdoc-def-id-resolve-str-path-error, r=petrochenkov
Use `LocalDefId` instead of `NodeId` in `resolve_str_path_error`

Together with https://github.com/rust-lang/rust/pull/72777 this should remove all uses of `NodeId` in `rustdoc`.

cc #50928

r? @petrochenkov
2020-05-31 12:03:30 +02:00
Ralf Jung e16bd0206b
Rollup merge of #72749 - vertexclique:vcq/update-stdarch, r=Amanieu
Update stdarch submodule to latest head

Includes avx512 work & aarch64 tme.
2020-05-31 12:03:28 +02:00
Ralf Jung e0b25905af
Rollup merge of #72745 - lcnr:interned-cleanup, r=petrochenkov
generalize Borrow<[T]> for Interned<'tcx, List<T>>
2020-05-31 12:03:26 +02:00
Ralf Jung b714f5c9ac
Rollup merge of #72715 - estebank:trailing-comma-where, r=petrochenkov
Account for trailing comma when suggesting `where` clauses

Fix #72693.
2020-05-31 12:03:24 +02:00
Ralf Jung 3bbb475f00
Rollup merge of #72683 - RalfJung:char-debug-check, r=Mark-Simulacrum
from_u32_unchecked: check validity, and fix UB in Wtf8

Fixes https://github.com/rust-lang/rust/issues/72760
2020-05-31 12:03:22 +02:00
bors 4b1f86adbe Auto merge of #72759 - alexcrichton:update-compiler-builtins, r=Mark-Simulacrum
Update compiler-builtins

Pulls in a fix for #72758, more details on the linked issue.

[Crate changes included here][changes]

[changes]: https://github.com/rust-lang/compiler-builtins/compare/0.1.28...0.1.31

Closes #72758
2020-05-31 09:54:44 +00:00
bors b6fa392238 Auto merge of #72743 - lcnr:predicate_f, r=nikomatsakis
fix EncodeWithShorthand for Predicate

r? @nikomatsakis
2020-05-31 04:44:38 +00:00
bors ea7181b5f7 Auto merge of #72116 - petrhosek:fuchsia-ld-flags, r=tmandry
Update the Fuchsia linker defaults

This updates the linker defaults aligning them with Clang. Specifically,
we use 4K pages on all platforms, we always use BIND_NOW, we prefer all
loadable segments be separate and page aligned, and we support RELR
relocations.
2020-05-31 01:07:37 +00:00
Mahmut Bulut 15201af7ed Update stdarch submodule to latest head 2020-05-31 00:12:59 +02:00
bors 8c5402efdd Auto merge of #72794 - RalfJung:rollup-gzs4nl4, r=RalfJung
Rollup of 13 pull requests

Successful merges:

 - #72543 (Account for missing lifetime in opaque and trait object return types)
 - #72625 (Improve inline asm error diagnostics)
 - #72637 (expand `env!` with def-site context)
 - #72650 (Sort sidebar elements)
 - #72657 (Allow types (with lifetimes/generics) in impl_lint_pass)
 - #72666 (Add -Z profile-emit=<path> for Gcov gcda output.)
 - #72668 (Fix missing parentheses Fn notation error)
 - #72669 (rustc_session: Cleanup session creation)
 - #72728 (Make bootstrap aware of relative libdir in stage0 compiler)
 - #72757 (rustc_lexer: Optimize shebang detection slightly)
 - #72772 (miri validation: clarify valid values of 'char')
 - #72773 (Fix is_char_boundary documentation)
 - #72777 (rustdoc: remove calls to `local_def_id_from_node_id`)

Failed merges:

r? @ghost
2020-05-30 21:23:19 +00:00
Ralf Jung 581eafcdf7
Rollup merge of #72777 - marmeladema:rustdoc-remove-local-def-id-from-node-id, r=petrochenkov
rustdoc: remove calls to `local_def_id_from_node_id`

rustdoc calls `local_def_id_from_node_id(CRATE_NODE_ID)` when it can just creates a top level `DefId` using `DefId::local(CRATE_DEF_INDEX)`.

cc #50928

r? @petrochenkov
2020-05-30 23:09:04 +02:00
Ralf Jung b7f6a0b322
Rollup merge of #72773 - Rantanen:is_char_boundary-docs, r=joshtriplett
Fix is_char_boundary documentation

Given the "start _and/or end_" wording in the original, the way I understood it was that the `str::is_char_boundary` method would also return `true` for the last byte in a UTF-8 code point sequence. (Which would have meant that for a string consisting of nothing but 1 and 2 byte UTF-8 code point sequences, it would return nothing but `true`.)

In practice the method returns `true` only for the starting byte of each sequence and the end of the string: [Playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=e9f5fc4d6bf2f1bf57a75f3c9a180770)

I was also somewhat tempted to remove the _The start and end of the string are considered to be boundaries_, since that's implied by the first sentence, but I decided to avoid bikeshedding over it and left it as it was since it's not wrong in relation to how the method behaves.
2020-05-30 23:09:02 +02:00
Ralf Jung 356d1e9f4f
Rollup merge of #72772 - RalfJung:valid-char, r=petrochenkov
miri validation: clarify valid values of 'char'

The old text said "expected a valid unicode codepoint", which is not actually correct -- it has to be a scalar value (which is a code point that is not part of a surrogate pair).
2020-05-30 23:09:00 +02:00
Ralf Jung 32481bc80a
Rollup merge of #72757 - petrochenkov:shebang, r=varkor
rustc_lexer: Optimize shebang detection slightly

Sorry, I just couldn't resist.
It shouldn't make any difference in practice.

Also, documented a previously unnoticed case with doc comments treated as regular comments during shebang detection.
2020-05-30 23:08:58 +02:00
Ralf Jung 8f1c0d0a10
Rollup merge of #72728 - o01eg:fix-72661, r=Mark-Simulacrum
Make bootstrap aware of relative libdir in stage0 compiler

Follows up #72692

Fixes #72661
2020-05-30 23:08:57 +02:00
Ralf Jung 278e26eaf6
Rollup merge of #72669 - petrochenkov:smclean, r=Mark-Simulacrum
rustc_session: Cleanup session creation

Noticed while reviewing https://github.com/rust-lang/rust/pull/72618.
2020-05-30 23:08:55 +02:00
Ralf Jung 65a02f1841
Rollup merge of #72668 - awoimbee:give-fn-parenthetical-notation-parentheses, r=estebank
Fix missing parentheses Fn notation error

Fixes  #72611
Well, fixes the error output, I think E0658 is the right error to throw in this case so I didn't change that
2020-05-30 23:08:53 +02:00
Ralf Jung ffe329250b
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.
2020-05-30 23:08:51 +02:00
Ralf Jung 320de71cdd
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 (?).
2020-05-30 23:08:49 +02:00
Ralf Jung 5f0aefda49
Rollup merge of #72650 - GuillaumeGomez:sort-sidebar-elements, r=kinnison
Sort sidebar elements

r? @kinnison
2020-05-30 23:08:47 +02:00
Ralf Jung 40fb1913e7
Rollup merge of #72637 - euclio:env-hygiene, r=davidtwco
expand `env!` with def-site context

Similar to #66349.

Fixes rust-lang/rust-clippy#5619.
2020-05-30 23:08:46 +02:00
Ralf Jung fadfcb644e
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
  |              ^^^^^^^^^^^^^^^^^^^
```
2020-05-30 23:08:44 +02:00
Ralf Jung f1661d23e3
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();
    }
}
```
2020-05-30 23:08:42 +02:00
Esteban Küber 83f6f22358 Tweak wording and spans of 'static dyn Trait/impl Trait requirements 2020-05-30 10:22:27 -07:00
Esteban Küber 6dcd744df0 Consider all possible one letter lifetimes in suggestion 2020-05-30 10:22:27 -07:00
Esteban Küber 224ad326ea Account for enclosing item when suggesting new lifetime name 2020-05-30 10:22:27 -07:00
Esteban Küber 8f7ee34379 Tweak type parameter errors to reduce verbosity 2020-05-30 10:22:26 -07:00
Esteban Küber 1d9472b470 Update nll tests 2020-05-30 10:22:26 -07:00
Esteban Küber 731ea85f21 review comment: tweak wording and account for span overlap 2020-05-30 10:22:26 -07:00
Esteban Küber 65f492be12 Account for returned dyn Trait evaluating to 'static lifetime
Provide a suggestion for `dyn Trait + '_` when possible.
2020-05-30 10:22:26 -07:00
Esteban Küber a724d9a4fb Fix NLL output 2020-05-30 10:21:58 -07:00
Esteban Küber 99d9ccd547 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`
   ```
2020-05-30 10:21:58 -07:00
Esteban Küber f49ebbb891 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();
    }
}
```
2020-05-30 10:19:41 -07:00
Arthur Woimbée c54d4fe93f Test ui suggestion fn trait notation 2020-05-30 18:40:42 +02:00
Arthur Woimbée 5a813b6dd6 Fix missing parentheses Fn notation error 2020-05-30 18:40:41 +02:00
Ralf Jung 0fb6e63c04 encode_utf8_raw is not always valid UTF-8; clarify comments 2020-05-30 17:27:34 +02:00
marmeladema 372ba2a03d Use LocalDefId instead of NodeId in resolve_str_path_error 2020-05-30 16:11:58 +01:00
bors 74e8046834 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
2020-05-30 12:49:47 +00:00
Ralf Jung 69310dea89
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
2020-05-30 13:45:15 +02:00
Ralf Jung e4c35246fc
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
2020-05-30 13:45:13 +02:00
Ralf Jung 6238e79fb6
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
2020-05-30 13:45:11 +02:00
Ralf Jung f96e3e2069
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.
2020-05-30 13:45:10 +02:00
Ralf Jung 43ae54de9c
Rollup merge of #72521 - Amanieu:fix-72484, r=petrochenkov
Properly handle InlineAsmOperand::SymFn when collecting monomorphized items

Fixes #72484
2020-05-30 13:45:08 +02:00
Ralf Jung 8d64fd80ad
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 😄
2020-05-30 13:45:06 +02:00
Ralf Jung 49ca99de93
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
2020-05-30 13:45:04 +02:00
Ralf Jung 93d45a01e7
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.
2020-05-30 13:45:02 +02:00
Ralf Jung 35db8196f9
Rollup merge of #72299 - lcnr:sized_help, r=petrochenkov
more `LocalDefId`s
2020-05-30 13:45:00 +02:00
marmeladema 4b7e44f893 rustdoc: remove calls to local_def_id_from_node_id 2020-05-30 12:30:58 +01:00