Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #91413

Closed
wants to merge 16 commits into from

Conversation

matthiaskrgr
Copy link
Member

Successful merges:

Failed merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

nbdd0121 and others added 16 commits September 24, 2021 22:55
... if they use arbitrary enum discriminant. Code like

```rust
enum Enum {
    Foo = 1,
    Bar(),
    Baz{}
}
```

seems to be unintentionally allowed so we couldn't disallow them now,
but we could disallow them if arbitrary enum discriminant is used before
1.56 hits stable.
When we point at a binding to suggest giving it a type, erase all the
type for ADTs that have been resolved, leaving only the ones that could
not be inferred. For small shallow types this is not a problem, but for
big nested types with lots of params, this can otherwise cause a lot of
unnecessary visual output.
When the value of a const param isn't inferred, replace it with the
param name from the definition.
Version 5 adds Branch Regions which are a prerequisite for branch coverage.
Version 6 can use the zeroth filename as prefix for other relative files.
This commit augments Swatinem's initial commit in uncommitted PR rust-lang#90047,
which was a great starting point, but did not fully support LLVM
Coverage Mapping Format version 6.

Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.

Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.

This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
Disallow non-c-like but "fieldless" ADTs from being casted to integer if they use arbitrary enum discriminant

Code like

```rust
#[repr(u8)]
enum Enum {
    Foo /* = 0 */,
    Bar(),
    Baz{}
}

let x = Enum::Bar() as u8;
```

seems to be unintentionally allowed so we couldn't disallow them now ~~, but we could disallow them if arbitrary enum discriminant is used before 1.56 hits stable~~ (stabilization was reverted).

Related: rust-lang#88621

`@rustbot` label +T-lang
…=nagisa

Only shown relevant type params in E0283 label

When we point at a binding to suggest giving it a type, erase all the
type for ADTs that have been resolved, leaving only the ones that could
not be inferred. For small shallow types this is not a problem, but for
big nested types with lots of params, this can otherwise cause a lot of
unnecessary visual output.
…kh726

Remove all migrate.nll.stderr files

There are a few ui tests that setup the revisions like:
```rust
// revisions: migrate nll`
// [nll]compile-flags: -Zborrowck=mir
```

However most of them fail to disable the nll compare mode like this:
```rust
// ignore-compare-mode-nll
```

This ends up generating confusing files ending in `.migrate.nll.stderr` because the nll compare mode is run on top of the migrate revision.

This PR fixes this by adding `ignore-compare-mode-nll` to these tests.

I would have just made these tests use compare modes instead but I assume the reason these tests are messing around with revisions instead of just letting the nll compare mode do its thing is to enforce error annotations for both migrate and nll.
Relying on just compare modes would only have the error annotations for migrate.
… r=tmandry

Add support for LLVM coverage mapping format versions 5 and 6

This PR cherry-pick's Swatinem's initial commit in unsubmitted PR rust-lang#90047.

My additional commit augments Swatinem's great starting point, but adds full support for LLVM
Coverage Mapping Format version 6, conditionally, if compiling with LLVM 13.

Version 6 requires adding the compilation directory when file paths are
relative, and since Rustc coverage maps use relative paths, we should
add the expected compilation directory entry.

Note, however, that with the compilation directory, coverage reports
from `llvm-cov show` can now report file names (when the report includes
more than one file) with the full absolute path to the file.

This would be a problem for test results, but the workaround (for the
rust coverage tests) is to include an additional `llvm-cov show`
parameter: `--compilation-dir=.`
…l, r=cjgillot

Improve error message for `E0659` if the source is not available

Fixes rust-lang#91028. The fix is similar to those in rust-lang#89233 and rust-lang#87088. With this change, instead of the dangling
```
note: `Option` could also refer to the enum defined here
```
I get
```
note: `Option` could also refer to an enum from prelude
```
If the standard library source code _is_ available, the output does not change.
@rustbot rustbot added the rollup A PR which is a rollup label Dec 1, 2021
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=6

@bors
Copy link
Contributor

bors commented Dec 1, 2021

📌 Commit 90af5e6 has been approved by matthiaskrgr

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 1, 2021
@rust-log-analyzer
Copy link
Collaborator

The job mingw-check failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
    Checking rustc_passes v0.0.0 (/checkout/compiler/rustc_passes)
    Checking rustc_monomorphize v0.0.0 (/checkout/compiler/rustc_monomorphize)
    Checking rustc_query_impl v0.0.0 (/checkout/compiler/rustc_query_impl)
    Checking rustc_save_analysis v0.0.0 (/checkout/compiler/rustc_save_analysis)
error[E0053]: method `fold_ty` has an incompatible type for trait
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:913:43
    |
913 |     fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
    |                                           |
    |                                           |
    |                                           expected enum `Result`, found `&TyS<'tcx>`
    |                                           help: change the output type to match the trait: `Result<&'tcx TyS<'tcx>, !>`
    |
    = note: expected fn pointer `fn(&mut ResolvedTypeParamEraser<'tcx>, &'tcx TyS<'tcx>) -> Result<&'tcx TyS<'tcx>, !>`
               found fn pointer `fn(&mut ResolvedTypeParamEraser<'tcx>, &'tcx TyS<'tcx>) -> &'tcx TyS<'tcx>`

error[E0053]: method `fold_ty` has an incompatible type for trait
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:990:43
    |
990 |     fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
    |                                           |
    |                                           |
    |                                           expected enum `Result`, found `&TyS<'tcx>`
    |                                           help: change the output type to match the trait: `Result<&'tcx TyS<'tcx>, !>`
    |
    = note: expected fn pointer `fn(&mut ErrTypeParamEraser<'tcx>, &'tcx TyS<'tcx>) -> Result<&'tcx TyS<'tcx>, !>`
               found fn pointer `fn(&mut ErrTypeParamEraser<'tcx>, &'tcx TyS<'tcx>) -> &'tcx TyS<'tcx>`
error[E0308]: mismatched types
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:603:63
    |
    |
603 |                 let ty = ErrTypeParamEraser(self.tcx).fold_ty(ty);
    |                                                               ^^ expected `&TyS<'_>`, found enum `Result`
    |
    = note: expected reference `&TyS<'_>`
                    found enum `Result<&TyS<'_>, !>`
error[E0308]: mismatched types
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:604:39
    |
    |
604 |                 let ty = ty_to_string(ty);
    |                                       ^^ expected `&TyS<'tcx>`, found enum `Result`
    |
    = note: expected reference `&'tcx TyS<'tcx>`
                    found enum `Result<&TyS<'_>, !>`

error[E0308]: `match` arms have incompatible types
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:930:30
    |
925 |                       .map(|(subst, param)| match &(subst.unpack(), &param.kind) {
    |  ___________________________________________-
926 | |                         (_, ty::GenericParamDefKind::Type { has_default: true, .. }) => subst,
    | |                                                                                         ----- this is found to be of type `rustc_middle::ty::subst::GenericArg<'_>`
927 | |                         (crate::infer::GenericArgKind::Const(c), _) => {
928 | |                             self.replace_infers(c, param.index, param.name).into()
    | |                             ------------------------------------------------------ this is found to be of type `rustc_middle::ty::subst::GenericArg<'_>`
929 | |                         }
930 | |                         _ => subst.super_fold_with(self),
    | |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `rustc_middle::ty::subst::GenericArg`, found enum `Result`
931 | |                     })
    | |_____________________- `match` arms have incompatible types
    |
    = note: expected type `rustc_middle::ty::subst::GenericArg<'_>`
               found enum `Result<rustc_middle::ty::subst::GenericArg<'_>, !>`
error[E0599]: no method named `kind` found for enum `Result` in the current scope
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:952:26
    |
952 |                 match ty.kind() {
952 |                 match ty.kind() {
    |                          ^^^^ method not found in `Result<&TyS<'_>, !>`

error[E0308]: `match` arms have incompatible types
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:955:26
952 | /                 match ty.kind() {
952 | /                 match ty.kind() {
953 | |                     // Avoid `&_`, these can be safely presented as `_`.
954 | |                     ty::Error(_) => self.tcx().ty_error(),
    | |                                     --------------------- this is found to be of type `&TyS<'_>`
955 | |                     _ => t.super_fold_with(self),
    | |                          ^^^^^^^^^^^^^^^^^^^^^^^ expected `&TyS<'_>`, found enum `Result`
956 | |                 }
    | |_________________- `match` arms have incompatible types
    |
    = note: expected type `&TyS<'_>`
               found enum `Result<&TyS<'_>, !>`
error[E0308]: mismatched types
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:969:34
    |
    |
969 |                 .mk_ty(ty::Array(self.fold_ty(ty), self.replace_infers(c, 0, Symbol::intern("N")))),
    |                                  ^^^^^^^^^^^^^^^^ expected `&TyS<'_>`, found enum `Result`
    |
    = note: expected reference `&TyS<'_>`
                    found enum `Result<&TyS<'_>, !>`

error[E0308]: `match` arms have incompatible types
   --> compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs:993:18
991 | /         match t.kind() {
991 | /         match t.kind() {
992 | |             ty::Error(_) => self.tcx().mk_ty_var(ty::TyVid::from_u32(0)),
    | |                             -------------------------------------------- this is found to be of type `&'tcx TyS<'tcx>`
993 | |             _ => t.super_fold_with(self),
    | |                  ^^^^^^^^^^^^^^^^^^^^^^^ expected `&TyS<'tcx>`, found enum `Result`
994 | |         }
    | |_________- `match` arms have incompatible types
    |
    = note: expected reference `&'tcx TyS<'tcx>`
                    found enum `Result<&TyS<'_>, !>`
    Checking rustc_codegen_ssa v0.0.0 (/checkout/compiler/rustc_codegen_ssa)
    Checking rustc_resolve v0.0.0 (/checkout/compiler/rustc_resolve)
Some errors have detailed explanations: E0053, E0308, E0599.
For more information about an error, try `rustc --explain E0053`.

@matthiaskrgr
Copy link
Member Author

@bors r- 😄

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 1, 2021
@matthiaskrgr matthiaskrgr deleted the rollup-xymm2y3 branch December 12, 2021 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.