Commit graph

153359 commits

Author SHA1 Message Date
est31
1cd1cd034b Remove box syntax from rustc_ast 2021-08-18 09:25:26 +02:00
est31
8b0b7ef812 Remove box syntax from rustc_mir_build 2021-08-18 09:25:26 +02:00
bors
679dea4cc3 Auto merge of #87738 - lqd:polonius-master, r=nikomatsakis
Update `polonius-engine` to 0.13.0

This PR updates the use of `polonius-engine` to the recently released 0.13.0:
- this version renamed a lot of relations to match the current terminology
- "illegal subset relationships errors" (AKA "subset errors" or "universal region errors" in rustc parlance) have been implemented in all variants, and therefore the `Hybrid` variant can be the rustc default once again
- some of the blessed expectations were updated: new tests have been added since the last time I updated the tests, diagnostics have changed, etc.

In particular:
- a few tests had trivial expectations changes such as basic diagnostics changes for the migrate-mode and full NLLs
- others were recursion and lengths limits which emits a file, and under the polonius compare-mode, the folder has a different name
- a few tests were ignored in the NLL compare-mode for reasons that obviously also apply to Polonius
- some diagnostics were unified so that older expectations no longer made sense: the NLL and Polonius outputs were identical.
- in a few cases Polonius gets a chance to emit more errors than NLLs

A few tests in the compare-mode still are super slow and trigger the 60s warning, or OOM rustc during fact generation, and I've detailed these [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/186049-t-compiler.2Fwg-polonius/topic/Challenges.20for.20move.2Finit.2C.20liveness.2C.20and.20.60Location.3A.3AAll.60):
- `src/test/ui/numbers-arithmetic/saturating-float-casts.rs` -> OOM during rustc fact generation
- `src/test/ui/numbers-arithmetic/num-wrapping.rs`
- `src/test/ui/issues/issue-72933-match-stack-overflow.rs`
- `src/test/ui/issues/issue-74564-if-expr-stack-overflow.rs`
- `src/test/ui/repr/repr-no-niche.rs`

In addition, 2 tests don't currently pass and I didn't want to bless them now: they deal with HRTBs and miss errors that NLLs emit. We're currently trying to see if we need chalk to deal with HRTB errors (as we thought we would have to) but during the recent sprint, we discovered that we may be able to detect some of these errors in a way that resembles subset errors:
- `ui/hrtb/hrtb-just-for-static.rs` -> 3 errors in NLL, 2 in polonius: a missing error about HRTB + needing to outlive 'static
- `ui/issues/issue-26217.rs` -> missing HRTB that makes the test compile instead of emitting an error

We'll keep talking about this at the next sprint as well.

cc `@rust-lang/wg-polonius` r? `@nikomatsakis`
2021-08-18 05:50:55 +00:00
Charles Lew
6b1c52ff25 Fold vtable_trait_upcasting_coercion_new_vptr_slot logic into obligation processing. 2021-08-18 13:00:27 +08:00
Charles Lew
1e605023ec Properly generate multiple candidates for trait upcasting coercion. 2021-08-18 13:00:27 +08:00
Will Crichton
0ce96bdcfa Fix bug in fmt_diff_with 2021-08-17 20:55:15 -07:00
bors
cbe3afece5 Auto merge of #87728 - GuillaumeGomez:doc-test-attr-checks, r=jyn514
Add "doc(test(...))" attribute checks

Fixes #82672.

r? `@camelid`
2021-08-18 03:21:12 +00:00
Josh Stone
35fd99c779 Add needs-asm-support to more tests
These were found as test failures on s390x for RHEL and Fedora.
2021-08-17 18:43:09 -07:00
bors
02b27f1e70 Auto merge of #86860 - fee1-dead:stabilize, r=LeSeulArtichaut
Stabilize `arbitrary_enum_discriminant`

Closes #60553.

----

## Stabilization Report

_copied from https://github.com/rust-lang/rust/issues/60553#issuecomment-865922311_

### Summary

Enables a user to specify *explicit* discriminants on arbitrary enums.

Previously, this was hard to achieve:

```rust
#[repr(u8)]
enum Foo {
    A(u8) = 0,
    B(i8) = 1,
    C(bool) = 42,
}
```

Someone would need to add 41 hidden variants in between as a workaround with implicit discriminants.

In conjunction with [RFC 2195](https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md), this feature would provide more flexibility for FFI and unsafe code involving enums.

### Test cases

Most tests are in [`src/test/ui/enum-discriminant`](https://github.com/rust-lang/rust/tree/master/src/test/ui/enum-discriminant), there are two [historical](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/tag-variant-disr-non-nullary.rs) [tests](https://github.com/rust-lang/rust/blob/master/src/test/ui/parser/issue-17383.rs) that are now covered by the feature (removed by this pr due to them being obsolete).

### Edge cases

The feature is well defined and does not have many edge cases.
One [edge case](https://github.com/rust-lang/rust/issues/70509) was related to another unstable feature named `repr128` and is resolved.

### Previous PRs

The [implementation PR](https://github.com/rust-lang/rust/pull/60732) added documentation to the Unstable Book, https://github.com/rust-lang/reference/pull/1055 was opened as a continuation of https://github.com/rust-lang/reference/pull/639.

### Resolution of unresolved questions

The questions are resolved in https://github.com/rust-lang/rust/issues/60553#issuecomment-511235271.

----

(someone please add `needs-fcp`)
2021-08-18 01:00:17 +00:00
Eric Huss
b5cbf2ffef Update cargo 2021-08-17 17:38:07 -07:00
Will Crichton
907ce72c43 Expose graphviz modules 2021-08-17 16:12:11 -07:00
bors
adf1688447 Auto merge of #86808 - fee1-dead:constify-1, r=oli-obk
constified implementations of `Default`
2021-08-17 22:30:09 +00:00
Sebastian Widua
71e4f44793 Fix example in Extend<(A, B)> impl 2021-08-17 22:27:06 +02:00
bors
30a0a9b694 Auto merge of #86977 - vakaras:body_with_borrowck_facts, r=nikomatsakis
Enable compiler consumers to obtain mir::Body with Polonius facts.

This PR adds a function (``get_body_with_borrowck_facts``) that can be used by compiler consumers to obtain ``mir::Body`` with accompanying borrow checker information.

The most important borrow checker information that [our verifier called Prusti](https://github.com/viperproject/prusti-dev) needs is lifetime constraints. I have not found a reasonable way to compute the lifetime constraints on the Prusti side. In the compiler, the constraints are computed during the borrow checking phase and then dropped. This PR adds an additional parameter to the `do_mir_borrowck` function that tells it to return the computed information instead of dropping it.

The additionally returned information by `do_mir_borrowck` contains a ``mir::Body`` with non-erased lifetime regions and Polonius facts. I have decided to reuse the Polonius facts because this way I needed fewer changes to the compiler and Polonius facts contains other useful information that we otherwise would need to recompute.

Just FYI: up to now, Prusti was obtaining this information by [parsing the compiler logs](b58ced8dfd/prusti-interface/src/environment/borrowck/regions.rs (L25-L39)). This is not only a hacky approach, but we also reached its limits.

r? `@nikomatsakis`
2021-08-17 19:08:31 +00:00
the8472
6c92bae7fa
[review] fix comment
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2021-08-17 19:31:32 +02:00
bors
d83da1d05d Auto merge of #88083 - m-ou-se:non-fmt-panics-suggest-debug, r=estebank
Improve non_fmt_panics suggestion based on trait impls.

This improves the non_fmt_panics lint suggestions by checking first which trait (Display or Debug) are actually implemented on the type.

Fixes https://github.com/rust-lang/rust/issues/87313

Fixes https://github.com/rust-lang/rust/issues/87999

Before:

```
help: add a "{}" format string to Display the message
  |
2 |     panic!("{}", Some(1));
  |            +++++
help: or use std::panic::panic_any instead
  |
2 |     std::panic::panic_any(Some(1));
  |     ~~~~~~~~~~~~~~~~~~~~~
```

After:

```
help: add a "{:?}" format string to use the Debug implementation of `Option<i32>`
  |
2 |     panic!("{:?}", Some(1));
  |            +++++++
help: or use std::panic::panic_any instead
  |
2 |     std::panic::panic_any(Some(1));
  |     ~~~~~~~~~~~~~~~~~~~~~
```

r? `@estebank`
2021-08-17 16:43:40 +00:00
Guillaume Gomez
7ce7fe7176 Add background-color on clickable definitions in source code 2021-08-17 16:47:24 +02:00
bors
806b3995b8 Auto merge of #88056 - erikdesjardins:revertzst, r=oli-obk
Revert "Auto merge of #83417 - erikdesjardins:enableremovezsts, r=oli-obk"

This reverts commit 8007b506ac, reversing changes made to e55c13e109.

Fixes #88043

r? `@oli-obk`
2021-08-17 14:02:55 +00:00
Vytautas Astrauskas
9142d6ddf0 Fix obtain-borrowck failure on Windows. 2021-08-17 13:06:27 +02:00
inquisitivecrystal
fdf09130df Fix environment variable getter docs 2021-08-17 00:37:52 -07:00
Deadbeef
6bd2ecba72
Add ui test 2021-08-17 07:15:59 +00:00
Deadbeef
b5afa6807b
Constified Default implementations
The libs-api team agrees to allow const_trait_impl to appear in the
standard library as long as stable code cannot be broken (they are
properly gated) this means if the compiler teams thinks it's okay, then
it's okay.

My priority on constifying would be:

	1. Non-generic impls (e.g. Default) or generic impls with no
	   bounds
	2. Generic functions with bounds (that use const impls)
	3. Generic impls with bounds
	4. Impls for traits with associated types

For people opening constification PRs: please cc me and/or oli-obk.
2021-08-17 07:15:54 +00:00
bors
aa8f27bf4d Auto merge of #87668 - estebank:tweak-bound-output, r=oli-obk
Use note for pointing at bound introducing requirement

Modify output for pointing where a trait bound obligation is introduced in an E0277 from using a span label to using a note in order to always preserve order of the output:

Before:
```
error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
  --> $DIR/bounds-on-assoc-in-trait.rs:18:28
   |
LL |     type A: Iterator<Item: Debug>;
   |                            ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
   |
  ::: $SRC_DIR/core/src/fmt/mod.rs:LL:COL
   |
LL | pub trait Debug {
   | --------------- required by this bound in `Debug`
   |
   = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item`
```
After:
```
error[E0277]: `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
  --> $DIR/bounds-on-assoc-in-trait.rs:18:28
   |
LL |     type A: Iterator<Item: Debug>;
   |                            ^^^^^ `<<Self as Case1>::A as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug`
   |
   = help: the trait `Debug` is not implemented for `<<Self as Case1>::A as Iterator>::Item`
note: required by a bound in `Debug`
  --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
   |
LL | pub trait Debug {
   | ^^^^^^^^^^^^^^^ required by this bound in `Debug`
```
2021-08-17 06:59:49 +00:00
bors
3b5df01439 Auto merge of #87119 - jyn514:rustfmt-doc-private, r=Mark-Simulacrum
Document private items for rustfmt

This is possible now that https://github.com/rust-lang/rust/pull/73936 has been merged.
2021-08-17 04:18:55 +00:00
Michael Hall
51cf318dbc remove unnecessary empty check 2021-08-17 12:26:24 +10:00
bors
a183141e2d Auto merge of #87990 - Aaron1011:moved-src-dir, r=cjgillot
Include (potentially remapped) working dir in crate hash

Fixes #85019

A `SourceFile` created during compilation may have a relative
path (e.g. if rustc itself is invoked with a relative path).
When we write out crate metadata, we convert all relative paths
to absolute paths using the current working directory.

However, the working directory is not included in the crate hash.
This means that the crate metadata can change while the crate
hash remains the same. Among other problems, this can cause a
fingerprint mismatch ICE, since incremental compilation uses
the crate metadata hash to determine if a foreign query is green.

This commit moves the field holding the working directory from
`Session` to `Options`, including it as part of the crate hash.

cc `@ohsayan`
2021-08-17 01:32:15 +00:00
Tomasz Miąsko
9a0ee05c3d Split critical edge targeting the start block 2021-08-17 00:00:00 +00:00
bors
0e41c6201f Auto merge of #88094 - m-ou-se:rollup-2fxss0q, r=m-ou-se
Rollup of 10 pull requests

Successful merges:

 - #87178 ([rustdoc] Copy only item path to clipboard rather than full `use` statement.)
 - #87677 (Adding explicit notice of lack of documentation for Tier 2 Platforms)
 - #87958 (Closure migration multispan suggestions)
 - #87967 (Detect fake spans in non_fmt_panic lint.)
 - #88011 (Enable `--all-targets` for `x.py check` unconditionally)
 - #88030 (Assign FIXMEs to me and remove obsolete ones)
 - #88052 (Update redox_syscall)
 - #88055 (Update RELEASES.md for 1.55.0)
 - #88080 (Skip assert ICE with default_method_body_is_const)
 - #88089 (Rustdoc font test)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2021-08-16 22:33:36 +00:00
Mara Bos
d5ec5aa783
Rollup merge of #88089 - dns2utf8:rustdoc_font_test, r=GuillaumeGomez
Rustdoc font test

 Add a font test based on #85669 fixes #85632.

r? `@jsha` `@GuillaumeGomez`
2021-08-16 23:37:35 +02:00
Mara Bos
4de53c427b
Rollup merge of #88080 - fee1-dead:iterator-const, r=oli-obk
Skip assert ICE with default_method_body_is_const

functions marked with #[default_method_body_is_const] would
ICE when being const checked due to it not being a const function:
`tcx.is_const_fn_raw(did)` returns false. We should skip this assert
when it is marked with that attribute.

r? `@oli-obk`
2021-08-16 23:37:34 +02:00
Mara Bos
18a7b6d32a
Rollup merge of #88055 - Mark-Simulacrum:relnotes-1.55, r=Mark-Simulacrum
Update RELEASES.md for 1.55.0

Reopening https://github.com/rust-lang/rust/pull/87624 after some edits and a force-push caused GitHub to close the PR.
2021-08-16 23:37:33 +02:00
Mara Bos
280ac7f49f
Rollup merge of #88052 - bjorn3:update_redox_syscall, r=Mark-Simulacrum
Update redox_syscall

The currently pinned version doesn't compile with the latest rustc nightly

cc ``@jackpot51``
2021-08-16 23:37:31 +02:00
Mara Bos
fa4edcc851
Rollup merge of #88030 - fee1-dead:fixme, r=oli-obk
Assign FIXMEs to me and remove obsolete ones

Also fixed capitalization of documentation

We also don't need to transform predicates to be non-const since we basically ignore const predicates in non-const contexts.

r? `````@oli-obk`````
2021-08-16 23:37:30 +02:00
Mara Bos
fe71be7f34
Rollup merge of #88011 - jyn514:check-all-targets, r=Mark-Simulacrum
Enable `--all-targets` for `x.py check` unconditionally

Now that Cargo deduplicates diagnostics from different targets, this doesn't flood the console with
duplicate errors.

Note that this doesn't add `--all-targets` in `Builder::cargo` directly because `impl Step for Std`
actually wants to omit `--all-targets` the first time while it's still building libtest.

When passed `--all-targets`, this warns that the option isn't needed, but still continues to compile.

Fixes https://github.com/rust-lang/rust/issues/87846.
r? ``@Mark-Simulacrum``
2021-08-16 23:37:29 +02:00
Mara Bos
beeff0440f
Rollup merge of #87967 - m-ou-se:non-fmt-panic-detect-fake-spans, r=cjgillot
Detect fake spans in non_fmt_panic lint.

This addresses https://github.com/rust-lang/rust/issues/87621

Some proc_macros claim that the user wrote all of the tokens it outputs, by applying a span from the input to all of the produced tokens. That can result in confusing suggestions, as in #87621. This is a simple patch that avoids suggesting anything for `panic!("{}")` if the span of `"{}"` and `panic!(..)` are identical, which is normally not possible.
2021-08-16 23:37:28 +02:00
Mara Bos
d7df1b13da
Rollup merge of #87958 - m-ou-se:closure-migration-multispan-suggestions, r=estebank
Closure migration multispan suggestions

This changes the `rust_2021_incompatible_closure_captures` lint to only suggest inserting the parts that need to be inserted, instead of suggesting to replace the entire closure by an almost identical closure with one statement added.

Before:
```
[...]
help: add a dummy let to cause `a` to be fully captured
   |
5  ~     let _ = || {
6  +         let _ = &a;
7  +         dbg!(a.0);
8  +         println!("1");
9  +         println!("2");
10 +         println!("3");
 ...
   |

[...]
help: add a dummy let to cause `b` to be fully captured
   |
14 |     let _ = || { let _ = &b; dbg!(b.0); };
   |                ~~~~~~~~~~~~~~~~~~~~~~~~~~

[...]
help: add a dummy let to cause `c` to be fully captured
   |
16 |     let _ = || { let _ = &c; dbg!(c.0) };
   |                ~~~~~~~~~~~~~~~~~~~~~~~~~
```

After:
```
[...]
help: add a dummy let to cause `a` to be fully captured
   |
5  ~     let _ = || {
6  +         let _ = &a;
   |

[...]
help: add a dummy let to cause `b` to be fully captured
   |
14 |     let _ = || { let _ = &b; dbg!(b.0); };
   |                  +++++++++++

[...]
help: add a dummy let to cause `c` to be fully captured
   |
16 |     let _ = || { let _ = &c; dbg!(c.0) };
   |                +++++++++++++           +
```
2021-08-16 23:37:27 +02:00
Mara Bos
84ca374bcb
Rollup merge of #87677 - amalik18:issue-2788-fix, r=pietroalbini
Adding explicit notice of lack of documentation for Tier 2 Platforms

Fixing: https://github.com/rust-lang/rustup/issues/2788
2021-08-16 23:37:26 +02:00
Mara Bos
2dbb2f7420
Rollup merge of #87178 - moxian:rd-use, r=jyn514
[rustdoc] Copy only item path to clipboard rather than full `use` statement.

The (somewhat) recent addition of the "copy item import to clipboard" button is extremely nice.

However, i tend to write my code with fully qualified paths wherever feasible and only resort to `use` statements as a refactoring pass. This makes the "copy to clipboard" workflow awkward to use, as i would be copy-pasting that as, say

```rust
impl use std::ops::Add; for MyType {
```

and then go back  and remove the `use ` and `;`.

This PR removes the `use ;` decorations, making it much nicer to use for fully-qualified items. I argue, however, that this does not noticeably degrade experience for those who prefer to import items, since the hard part about those is getting the path right, and writing the `use ;` decoration can be done by hand with little effort.
2021-08-16 23:37:25 +02:00
Guillaume Gomez
d4293ffcb3 Move working checks into separate test files 2021-08-16 23:17:27 +02:00
Guillaume Gomez
4ba54ff60b Add UI tests for doc(test(...)) attribute checks 2021-08-16 23:17:27 +02:00
Guillaume Gomez
cbfe8749c2 Add check for doc(test(...)) attribute 2021-08-16 23:17:26 +02:00
The8472
ff12ab2d99 correct overflows in the backslide case, add test 2021-08-16 22:15:52 +02:00
Stefan Schindler
2f486d5f8d Merge the two test files as they are testing the same features 2021-08-16 21:50:13 +02:00
Stefan Schindler
ee4521e19b Add a font test based on #85669 2021-08-16 21:50:12 +02:00
Stefan Schindler
5e4657d3f7 Fix double output of the summary line 2021-08-16 21:50:12 +02:00
Nikita Popov
f3ae726f30 Update to LLVM 13 2021-08-16 20:24:02 +02:00
Nikita Popov
3cfb7305dd Relax internal/private checks in coverage IR test
Since https://reviews.llvm.org/D103355 this will usually also use
internal rather than private on Windows as well. We don't
particularly care about this implementation detail, just accept
either.
2021-08-16 20:24:02 +02:00
Esteban Küber
39f220ce12 Use note to point at bound introducing requirement 2021-08-16 17:47:22 +00:00
Guillaume Gomez
9c21da6ece Take into account jobs number for rustdoc gui tests 2021-08-16 19:22:27 +02:00
Nikita Popov
6a454edce9 Dispose LLVM context after TargetMachine
The TargetMachine may be referencing data in the context. In
particular, at least the GlobalISel instruction selector stored
in the TM may reference a TrackedMDNode DebugLoc that destruction
of the TargetMachine will try to untrack.
2021-08-16 18:28:18 +02:00