Skip to content

Enable MIR-borrowck-only output #46097

Closed
@nikomatsakis

Description

@nikomatsakis

Currently, if you pass -Zborrowck-mir, we output both the AST output (tagged with (Ast)) and the MIR output (tagged with (Mir)).

Example:

> cd src/test/compile-fail
> rustc -Zborrowck-mir borrowck/borrowck-unary-move.rs
error[E0505]: cannot move out of `x` because it is borrowed (Ast)
  --> borrowck/borrowck-unary-move.rs:17:10
   |
16 |     let y = &*x;
   |              -- borrow of `*x` occurs here
17 |     free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed
   |          ^ move out of `x` occurs here

error[E0505]: cannot move out of `x` because it is borrowed (Mir)
  --> borrowck/borrowck-unary-move.rs:17:10
   |
16 |     let y = &*x;
   |             --- borrow of `(*x)` occurs here
17 |     free(x); //[ast]~ ERROR cannot move out of `x` because it is borrowed
   |          ^ move out of `x` occurs here

error: aborting due to 2 previous errors

I would like to alter the switch to be one where there are three mores:

-Zborrowck=ast -- the default, emits only AST
-Zborrowck=mir -- emits only MIR errors (and doesn't write `(Mir)`)
-Zborrowck=compare -- emits both, like `-Zborrowck-mir` does today.

This will be useful as we progress towards our yearly goal of having a working "demo", since the demo isn't very good if people are seeing the old and new errors. It will also be less annoying for editing the unit tests, since we won't need three copies of each error. And if we want the current output when running by hand, it is still available.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions