-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Enable MIR-borrowck-only output #46097
Comments
Mentoring instructionsThis is where the rust/src/librustc/session/config.rs Lines 976 to 977 in 5f1c37a
That is part of a macro that ultimately defines the borrowck: bool = (false, parse_opt_string, [UNTRACKED],
"select which borrowck is used (`ast`, `mir`, or `compare`)"), This will change from a #[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
enum BorrowckMode {
Ast,
Mir,
Compare,
} Then we will add a field in the /// Determines which borrow checker(s) to run. This is the parsed, sanitized
/// version of `debugging_opts.borrowck`, which is just a plain string.
borrowck_mode: BorrowckMode, (The setup here is that there is an Then we can add some code around here that will parse the
OK, once we've done that, we should get a few compilation errors because the field impl BorrowckMode {
/// Should the AST-based borrow checker execute at all?
pub fn use_ast(self) -> bool {
match self {
BorrowckMode::Ast => true,
BorrowckMode::Compare => true,
BorrowckMode::Mir => false,
}
}
...
} and so on so that we can convert to Finally, we have to make the AST-based borrow checker not execute (or at least not report errors) unless we are in the right mode. It's actually easier to just make it not report errors: this is because the AST-based borrowck is still used for giving "unused mut" warnings, so if we just skip it altogether we'll get a bunch of weird warnings. To make it not report errors, though, we just have to modify the functions in this file, having them check the origin and just do nothing if it is wrong. |
Oh, one last thing. We have to edit all the tests! They can be changed from having |
I want to work on this! |
@LooMaclin there seems to be a conflict here! |
Especially, I'm almost done with my PR, the only thing that remains is updating the tests which is a bit time intensive... |
@est31 no problem. im stop working on that |
Add a MIR-borrowck-only output mode Removes the `-Z borrowck-mir` flag in favour of a `-Z borrowck=mode` flag where mode can be `mir`, `ast`, or `compare`. * The `ast` mode represents the current default, passing `-Z borrowck=ast` is equivalent to not passing it at all. * The `compare` mode outputs both the output of the MIR borrow checker and the AST borrow checker, each error with `(Ast)` and `(Mir)` appended. This mode has the same behaviour as `-Z borrowck-mir` had before this commit. * The `mir` mode only outputs the results of the MIR borrow checker, while suppressing the errors of the ast borrow checker The PR also updates the tests to use the new flags. closes #46097
Currently, if you pass
-Zborrowck-mir
, we output both the AST output (tagged with(Ast)
) and the MIR output (tagged with(Mir)
).Example:
I would like to alter the switch to be one where there are three mores:
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.
The text was updated successfully, but these errors were encountered: