Commit Graph

129006 Commits

Author SHA1 Message Date
Mara Bos df95dcebf5
Add missing `mut`.
Co-authored-by: David Tolnay <dtolnay@gmail.com>
2020-10-15 21:45:09 +02:00
Mara Bos f83446b836 Reword safety guarantee of Pin::static_{ref,mut}.
Co-authored-by: Peter Todd <pete@petertodd.org>
2020-10-13 13:13:09 +02:00
Mara Bos 2c71f682d7 Add Pin::static_mut. 2020-10-12 20:00:56 +02:00
Mara Bos 104c0f0194 Rename Pin::new_static to Pin::static_ref. 2020-10-12 20:00:44 +02:00
Mara Bos 390883e888 Make Pin::new_static const. 2020-10-09 00:06:39 +02:00
Mara Bos 64839ee00a Add Pin::new_static. 2020-10-08 23:51:56 +02:00
bors ccea570488 Auto merge of #77678 - jyn514:tracing, r=Mark-Simulacrum
Upgrade to tracing-subscriber 0.2.13

The primary motivation is to get the changes from
https://github.com/tokio-rs/tracing/pull/990. Example output:

```
$ RUSTDOC_LOG=debug rustdoc +rustc2
warning: some trace filter directives would enable traces that are disabled statically
 | `debug` would enable the DEBUG level for all targets
 = note: the static max level is `info`
 = help: to enable DEBUG logging, remove the `max_level_info` feature
```

r? `@Mark-Simulacrum`
cc `@hawkw` ❤️
2020-10-08 13:38:29 +00:00
bors 382848989f Auto merge of #77581 - ecstatic-morse:dataflow-dump-mir-graphviz, r=davidtwco
Use `pretty::create_dump_file` for dumping dataflow results

The old code wasn't incorporating promoteds into the path, meaning other `dot` files could get clobbered. Use the MIR dump infrastructure to generate paths so that this doesn't occur in the future.
2020-10-08 11:42:24 +00:00
bors f1dab244d7 Auto merge of #77682 - Mark-Simulacrum:bump-stage0, r=pietroalbini
Bump to 1.48 bootstrap compiler

r? `@pietroalbini` (but anyone can feel free to review)
2020-10-08 09:50:35 +00:00
bors 1565699830 Auto merge of #77644 - GuillaumeGomez:fix-tooltip-text-display, r=jyn514
Fix tooltip text display

Currently, when we hover the icon, the text doesn't show up:

![Screenshot from 2020-10-07 11-30-44](https://user-images.githubusercontent.com/3050060/95313768-cc402200-0890-11eb-95a4-a1ae8e38aee1.png)

The bug was spotted by `@Nemo157`

r? `@jyn514`
2020-10-08 07:55:19 +00:00
bors 9c07010b7f Auto merge of #77631 - jyn514:helpful-changelog, r=RalfJung
Make src/bootstrap/CHANGELOG.md more helpful

Addresses fe6fc555ac (r42949241).

r? `@RalfJung`
cc `@Mark-Simulacrum`
2020-10-08 05:50:49 +00:00
bors cc662cd454 Auto merge of #77683 - jyn514:git-hook, r=Mark-Simulacrum
Unset GIT_DIR in pre-commit hook

Works around https://github.com/rust-lang/rust/issues/77620. This won't help any other hooks you write manually, but hopefully people won't feel the need to do that now there's an 'official' one.

r? `@Mark-Simulacrum`
cc `@caass`
2020-10-08 03:58:55 +00:00
bors d9985fc108 Auto merge of #75470 - estebank:bare-type-expr, r=davidtwco
Detect blocks that could be struct expr bodies

This approach lives exclusively in the parser, so struct expr bodies
that are syntactically correct on their own but are otherwise incorrect
will still emit confusing errors, like in the following case:

```rust
fn foo() -> Foo {
    bar: Vec::new()
}
```

```
error[E0425]: cannot find value `bar` in this scope
 --> src/file.rs:5:5
  |
5 |     bar: Vec::new()
  |     ^^^ expecting a type here because of type ascription

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 --> src/file.rs:5:15
  |
5 |     bar: Vec::new()
  |               ^^^^^ only `Fn` traits may use parentheses

error[E0107]: wrong number of type arguments: expected 1, found 0
 --> src/file.rs:5:10
  |
5 |     bar: Vec::new()
  |          ^^^^^^^^^^ expected 1 type argument
  ```

If that field had a trailing comma, that would be a parse error and it
would trigger the new, more targetted, error:

```
error: struct literal body without path
 --> file.rs:4:17
  |
4 |   fn foo() -> Foo {
  |  _________________^
5 | |     bar: Vec::new(),
6 | | }
  | |_^
  |
help: you might have forgotten to add the struct literal inside the block
  |
4 | fn foo() -> Foo { Path {
5 |     bar: Vec::new(),
6 | } }
  |
```

Partially address last remaining part of #34255.
2020-10-08 01:37:27 +00:00
Mark Rousskov d8c035abbf Bump to 1.48 bootstrap compiler 2020-10-07 19:51:36 -04:00
Joshua Nelson f4989494bf Unset GIT_DIR in pre-commit hook
Works around https://github.com/rust-lang/rust/issues/77620
2020-10-07 19:50:27 -04:00
bors e055f87cdf Auto merge of #77597 - simonvandel:uninhabited-hashset, r=jonas-schievink
perf: UninhabitedEnumBranching avoid n^2

Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants

I have only profiled locally against `match-stress-enum`, so we should have it perf tested to make sure it does not regress other crates.
2020-10-07 23:44:57 +00:00
Joshua Nelson 8b22d079bf Upgrade to tracing 0.2.13
The primary motivation is to get the changes from
https://github.com/tokio-rs/tracing/pull/990. Example output:

```
$ RUSTDOC_LOG=debug rustdoc +rustc2
warning: some trace filter directives would enable traces that are disabled statically
 | `debug` would enable the DEBUG level for all targets
 = note: the static max level is `info`
 = help: to enable DEBUG logging, remove the `max_level_info` feature
```

- Remove useless test

  This was testing for an ICE when passing `RUST_LOG=rustc_middle`.  I
  noticed it because it started giving the tracing warning (because tests
  are not run with debug-logging enabled). Since this bug seems unlikely
  to re-occur, I just removed it altogether.
2020-10-07 19:27:10 -04:00
bors 91a79fb29a Auto merge of #76985 - hbina:clone_check, r=estebank
Prevent stack overflow in deeply nested types.

Related issue #75577 (?)

Unfortunately, I am unable to test whether this actually solves the problem because apparently, 12GB RAM + 2GB swap is not enough to compile the (admittedly toy) source file.
2020-10-07 21:51:12 +00:00
Esteban Küber e5f83bcd04 Detect blocks that could be struct expr bodies
This approach lives exclusively in the parser, so struct expr bodies
that are syntactically correct on their own but are otherwise incorrect
will still emit confusing errors, like in the following case:

```rust
fn foo() -> Foo {
    bar: Vec::new()
}
```

```
error[E0425]: cannot find value `bar` in this scope
 --> src/file.rs:5:5
  |
5 |     bar: Vec::new()
  |     ^^^ expecting a type here because of type ascription

error[E0214]: parenthesized type parameters may only be used with a `Fn` trait
 --> src/file.rs:5:15
  |
5 |     bar: Vec::new()
  |               ^^^^^ only `Fn` traits may use parentheses

error[E0107]: wrong number of type arguments: expected 1, found 0
 --> src/file.rs:5:10
  |
5 |     bar: Vec::new()
  |          ^^^^^^^^^^ expected 1 type argument
  ```

If that field had a trailing comma, that would be a parse error and it
would trigger the new, more targetted, error:

```
error: struct literal body without path
 --> file.rs:4:17
  |
4 |   fn foo() -> Foo {
  |  _________________^
5 | |     bar: Vec::new(),
6 | | }
  | |_^
  |
help: you might have forgotten to add the struct literal inside the block
  |
4 | fn foo() -> Foo { Path {
5 |     bar: Vec::new(),
6 | } }
  |
```

Partially address last part of #34255.
2020-10-07 13:40:52 -07:00
Simon Vandel Sillesen e231c47aa6 perf: UninhabitedEnumBranching void n^2
Avoid n² complexity. This showed up in a profile for match-stress-enum that has 8192 variants
2020-10-07 22:06:08 +02:00
bors 4437b4b150 Auto merge of #77464 - ecstatic-morse:const-fn-impl-trait, r=oli-obk
Give `impl Trait` in a `const fn` its own feature gate

...previously it was gated under `#![feature(const_fn)]`.

I think we actually want to do this in all const-contexts? If so, this should be `#![feature(const_impl_trait)]` instead. I don't think there's any way to make use of `impl Trait` within a `const` initializer.

cc #77463

r? `@oli-obk`
2020-10-07 19:59:52 +00:00
bors 28928c750c Auto merge of #77617 - AnthonyMikh:slice_windows_no_bounds_checking, r=lcnr
Eliminate bounds checking in slice::Windows

This is how `<core::slice::Windows as Iterator>::next` looks right now:

```rust
fn next(&mut self) -> Option<&'a [T]> {
    if self.size > self.v.len() {
        None
    } else {
        let ret = Some(&self.v[..self.size]);
        self.v = &self.v[1..];
        ret
    }
}
```

The line with `self.v = &self.v[1..];` relies on assumption that `self.v` is definitely not empty at this point. Else branch is taken when `self.size <= self.v.len()`, so `self.v` can be empty if `self.size` is zero. In practice, since `Windows` is never created directly but rather trough `[T]::windows` which panics when `size` is zero, `self.size` is never zero. However, the compiler doesn't know about this check, so it keeps the code which checks bounds and panics.

Using `NonZeroUsize` lets the compiler know about this invariant and reliably eliminate bounds checking without `unsafe` on `-O2`. Here is assembly of `Windows<'a, u32>::next` before and after this change ([goldbolt](https://godbolt.org/z/xrefzx)):

<details>
<summary>Before</summary>

```
example::next:
        push    rax
        mov     rcx, qword ptr [rdi + 8]
        mov     rdx, qword ptr [rdi + 16]
        cmp     rdx, rcx
        jbe     .LBB0_2
        xor     eax, eax
        pop     rcx
        ret
.LBB0_2:
        test    rcx, rcx
        je      .LBB0_5
        mov     rax, qword ptr [rdi]
        mov     rsi, rax
        add     rsi, 4
        add     rcx, -1
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rcx
        pop     rcx
        ret
.LBB0_5:
        lea     rdx, [rip + .L__unnamed_1]
        mov     edi, 1
        xor     esi, esi
        call    qword ptr [rip + core::slice::slice_index_order_fail@GOTPCREL]
        ud2

.L__unnamed_2:
        .ascii  "./example.rs"

.L__unnamed_1:
        .quad   .L__unnamed_2
        .asciz  "\f\000\000\000\000\000\000\000\016\000\000\000\027\000\000"
```

</details>

<details>
<summary>After</summary>

```
example::next:
        mov     rcx, qword ptr [rdi + 8]
        mov     rdx, qword ptr [rdi + 16]
        cmp     rdx, rcx
        jbe     .LBB0_2
        xor     eax, eax
        ret
.LBB0_2:
        mov     rax, qword ptr [rdi]
        lea     rsi, [rax + 4]
        add     rcx, -1
        mov     qword ptr [rdi], rsi
        mov     qword ptr [rdi + 8], rcx
        ret
```

</details>

Note the lack of call to `core::slice::slice_index_order_fail` in second snippet.

#### Possible reasons _not_ to merge this PR:

* this changes the error message on panic in `[T]::windows`. However, AFAIK this messages are not covered by backwards compatibility policy.
2020-10-07 17:31:56 +00:00
bors deec530523 Auto merge of #77341 - davidtwco:issue-73427-you-might-have-meant-variant, r=estebank
resolve: improve "try using the enum's variant"

Fixes #73427.

This PR improves the "try using the enum's variant" suggestion:

- Variants in suggestions would not result in more errors (e.g. use of a struct variant is only suggested if the suggestion can trivially construct that variant). Therefore, suggestions are only   emitted for variants that have no fields (since the suggestion can't know what value fields would have).
- Suggestions include the syntax for constructing the variant. If a struct or tuple variant is suggested, then it is constructed in the suggestion - unless in pattern-matching or when arguments are already provided.
- A help message is added which mentions the variants which are no longer suggested.

All of the diagnostic logic introduced by this PR is separated from the normal code path for a successful compilation.

r? `@estebank`
2020-10-07 15:37:47 +00:00
AnthonyMikh e699e83758 Add codegen test 2020-10-07 16:17:01 +03:00
bors a14bf4862d Auto merge of #77595 - petrochenkov:asmident, r=oli-obk
builtin_macros: Fix use of interpolated identifiers in `asm!`

Fixes https://github.com/rust-lang/rust/issues/77584
2020-10-07 11:51:51 +00:00
bors 8ae3b50976 Auto merge of #77119 - GuillaumeGomez:unclosed-html-tag-lint, r=jyn514
Unclosed html tag lint

Part of #67799.

I think `@ollie27` will be interested (`@Manishearth` too since they opened the issue ;) ).

r? `@jyn514`
2020-10-07 09:56:51 +00:00
Guillaume Gomez 0e45ad890d Fix tooltip text display 2020-10-07 11:31:15 +02:00
bors 5296ac6565 Auto merge of #77637 - ehuss:update-cargo, r=ehuss
Update cargo

3 commits in 75615f8e69f748d7ef0df7bc0b064a9b1f5c78b2..9d1a4863abd9237dbf9d1b74c78632b6a205f6bb
2020-09-29 18:42:19 +0000 to 2020-10-05 18:29:52 +0000
- Add LTO to the metadata filename hash. (rust-lang/cargo#8755)
- Fix dylib+rlib with LTO. (rust-lang/cargo#8754)
- Homepage doc cargo metadata (rust-lang/cargo#8744)
2020-10-07 05:12:28 +00:00
bors c9ced8523b Auto merge of #77626 - tamird:parse-scope-id, r=dtolnay
Parse SocketAddrV6::scope_id

r? `@dtolnay`
2020-10-07 03:11:06 +00:00
bors 5779815f89 Auto merge of #74194 - mbrubeck:slice-eq, r=sfackler
Add PartialEq impls for Vec <-> slice

This is a follow-up to #71660 and rust-lang/rfcs#2917 to add two more missing vec/slice PartialEq impls:

```
impl<A, B> PartialEq<[B]> for Vec<A> where A: PartialEq<B> { .. }
impl<A, B> PartialEq<Vec<B>> for [A] where A: PartialEq<B> { .. }
```

Since this is insta-stable, it should go through the `@rust-lang/libs` FCP process.  Note that I used version 1.47.0 for the `stable` attribute because I assume this will not merge before the 1.46.0 branch is cut next week.
2020-10-07 01:20:11 +00:00
Eric Huss 7b25c9929c Update cargo 2020-10-06 17:45:56 -07:00
bors 59dafb876e Auto merge of #77630 - Dylan-DPC:rollup-kfwl55z, r=Dylan-DPC
Rollup of 11 pull requests

Successful merges:

 - #76784 (Add some docs to rustdoc::clean::inline and def_id functions)
 - #76911 (fix VecDeque::iter_mut aliasing issues)
 - #77400 (Fix suggestions for x.py setup)
 - #77515 (Update to chalk 0.31)
 - #77568 (inliner: use caller param_env)
 - #77571 (Use matches! for core::char methods)
 - #77582 (Move `EarlyOtherwiseBranch` to mir-opt-level 2)
 - #77590 (Update RLS and Rustfmt)
 - #77605 (Fix rustc_def_path to show the full path and not the trimmed one)
 - #77614 (Let backends access span information)
 - #77624 (Add c as a shorthand check alternative for new options #77603)

Failed merges:

r? `@ghost`
2020-10-06 23:07:17 +00:00
Joshua Nelson 2a41342e9c Make src/bootstrap/CHANGELOG.md more helpful 2020-10-06 18:28:01 -04:00
Dylan DPC f600154be6
Rollup merge of #77624 - akoptelov:c-all-targets-fix, r=jyn514
Add c as a shorthand check alternative for new options #77603

There is a missing "c" that is a shorthand for "check" in newly added match arm for handling check-specific options.
2020-10-07 00:16:16 +02:00
Dylan DPC 1b056157e9
Rollup merge of #77614 - khyperia:set_span, r=eddyb
Let backends access span information

Sometimes, a backend may need to emit warnings, errors, or otherwise need to know the span of the current item in a basic block. So, add a `set_span` method to give the backend that information.

The `set_source_location` method already partially does this, however, it's disabled when debug info is disabled. There needs to be a way to unconditionally provide the span.
2020-10-07 00:16:14 +02:00
Dylan DPC 207832bdc0
Rollup merge of #77605 - da-x:fix-rustc-def-path, r=petrochenkov
Fix rustc_def_path to show the full path and not the trimmed one

Follow-up fix for #73996.
2020-10-07 00:16:12 +02:00
Dylan DPC 6951c3180e
Rollup merge of #77590 - Xanewok:update-rls, r=dtolnay
Update RLS and Rustfmt

refs: https://github.com/rust-lang/rls/pull/1701

cc @calebcartwright

r? @dtolnay
2020-10-07 00:16:10 +02:00
Dylan DPC 6b4dbb196c
Rollup merge of #77582 - ecstatic-morse:disable-early-otherwise-branch, r=wesleywiser
Move `EarlyOtherwiseBranch` to mir-opt-level 2

cc #75119

This didn't have an [effect in most cases](https://perf.rust-lang.org/compare.html?start=81e02708f1f4760244756548981277d5199baa9a&end=2e0edc0f28c5647141bedba02e7a222d3a5dc9c3&stat=instructions:u), and is not trivially sound. Let it bake at `mir-opt-level=2` for a while.

Also, this missed the cutoff for beta, so we'll have to backport this.
r? @wesleywiser
2020-10-07 00:16:08 +02:00
Dylan DPC 5314c72de8
Rollup merge of #77571 - pickfire:patch-6, r=cramertj
Use matches! for core::char methods
2020-10-07 00:16:07 +02:00
Dylan DPC 83c58d6fb6
Rollup merge of #77568 - lcnr:mir-inline-def-id, r=ecstatic-morse
inliner: use caller param_env

We used the callee param env instead of the caller param env by accident in #77430, this PR fixes that and caches it in the `Inliner` struct.

fixes #77564

r? @ecstatic-morse
2020-10-07 00:16:05 +02:00
Dylan DPC a7a75b908a
Rollup merge of #77515 - jackh726:chalk-0.31, r=matthewjasper
Update to chalk 0.31

Gonna assign @nikomatsakis to the review here, but since he is pretty busy recently, if anyone else wants to review this, that would be much appreciated.

r? @nikomatsakis
2020-10-07 00:16:03 +02:00
Dylan DPC 59707c5748
Rollup merge of #77400 - alarsyo:xpy-setup-suggestions, r=jyn514
Fix suggestions for x.py setup

#76631 introduced a new `setup` command to x.py

By default the command prompts for a profile to use:

```
Welcome to the Rust project! What do you want to do with x.py?
a) Contribute to the standard library
b) Contribute to the compiler
c) Contribute to the compiler, and also modify LLVM or codegen
d) Install Rust from source
```

and then displays command suggestions, depending on which profile was chosen. However [the mapping between chosen profile](9cba260df0/src/bootstrap/setup.rs (L75-L85)) and [suggestion](9cba260df0/src/bootstrap/setup.rs (L42-L47)) isn't exact, leading to suggestions not being shown if the user presses `c` or `d`. (because "c" is translated to "llvm" and "d" to "maintainer", but suggestions trigger for "codegen" and "user" respectively)

A more thorough refactor would stop using "strings-as-type" to make sure this kind of error doesn't happen, but it may be overkill for that kind of "script" program?

Tagging the setup command author: @jyn514
2020-10-07 00:16:01 +02:00
Dylan DPC 5ae45ea4e2
Rollup merge of #76911 - RalfJung:vecdeque-aliasing, r=oli-obk
fix VecDeque::iter_mut aliasing issues

Fixes https://github.com/rust-lang/rust/issues/74029
2020-10-07 00:15:59 +02:00
Dylan DPC d26ca984c3
Rollup merge of #76784 - lzutao:rd_doc, r=GuillaumeGomez
Add some docs to rustdoc::clean::inline and def_id functions

Split from #76571 .
2020-10-07 00:15:58 +02:00
Tamir Duberstein 49ade22bd9
Parse SocketAddrV6::scope_id 2020-10-06 22:13:15 +00:00
Tamir Duberstein a093957f43
Avoid unused return 2020-10-06 22:12:16 +00:00
bors 98edd1fbf8 Auto merge of #77386 - joshtriplett:static-glibc, r=petrochenkov
Support static linking with glibc and target-feature=+crt-static

With this change, it's possible to build on a linux-gnu target and pass
RUSTFLAGS='-C target-feature=+crt-static' or the equivalent via a
`.cargo/config.toml` file, and get a statically linked executable.

Update to libc 0.2.78, which adds support for static linking with glibc.

Add `crt_static_respected` to the `linux_base` target spec.

Update `android_base` and `linux_musl_base` accordingly. Avoid enabling
crt_static_respected on Android platforms, since that hasn't been
tested.

Closes https://github.com/rust-lang/rust/issues/65447.
2020-10-06 21:11:04 +00:00
Alexander Koptelov db46f43977 Add c as a shorthand check alternative for new options #77603 2020-10-06 22:05:11 +03:00
Dylan MacKenzie b5693a39d9 Update error code page 2020-10-06 11:22:24 -07:00
Jack Huey 23491084bc Update to chalk 0.31. Implement some unimplemented. Ignore some tests in compare mode chalk don't finish. 2020-10-06 14:14:25 -04:00