-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Split MIR building into its own crate #67901
Conversation
fd9a5cd
to
25b21d3
Compare
let ecx = mk_eval_cx(tcx, DUMMY_SP, param_env, false); | ||
let op = ecx.eval_const_to_op(val, None).unwrap(); | ||
ecx.read_discriminant(op).unwrap().1 | ||
|
||
let variant = ecx.read_discriminant(op).unwrap().1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the only change in this PR that’s not trivial code movement.
r=me once #67898 lands. |
@@ -505,6 +505,15 @@ rustc_queries! { | |||
desc { "extract field of const" } | |||
} | |||
|
|||
/// Destructure a constant ADT or array into its variant indent and its |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent vs. ident vs. index... typo?
@@ -0,0 +1,27 @@ | |||
//! Construction of MIR from HIR. | |||
//! | |||
//! This crate also contains the match exhaustiveness and usefulness checking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's follow up with moving this out from here as well (into two crates, one for HAIR and one for match checking)? It feels unrelated to MIR building other than the HAIR structure as an in-between IR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match "exhaustiveness" and "usefulness" calculations referred to here are probably fairly bad description for what is being done in that code. They do not do any analysis that result in user-visible messages or anything of the sort. Rather that analysis is performed entirely as the part of – and for the purpose of – building MIR graph that only contains the relevant and necessary branches.
The analysis and the code building portions are heavily interleaved and I don’t believe splitting just for the sake of splitting is meaningful here. Especially now that librustc_mir_build
is a relatively tiny crate already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Match "exhaustiveness" and "usefulness" calculations referred to here are probably fairly bad description for what is being done in that code.
On the contrary, they feel like apt descriptions of the analysis that hair::{_match, check_match}
and friends are doing.
They do not do any analysis that result in user-visible messages or anything of the sort.
Match checking certainly results in emitting plenty of its own error messages whether it be from exhaustiveness checking or other types of analysis in check_match
.
Rather that analysis is performed entirely as the part of – and for the purpose of – building MIR graph that only contains the relevant and necessary branches.
I don't think that's correct. MIR is in fact not sound by construction due to not verifying the exhaustiveness of match
es which is done on HAIR, which I think is a language in its own right. One could say that rustc_typeck is only performed for the purpose of eventual MIR output, but that doesn't make HIR less of a language.
The analysis and the code building portions are heavily interleaved and I don’t believe splitting just for the sake of splitting is meaningful here. Especially now that
librustc_mir_build
is a relatively tiny crate already.
I grepped quickly and searching for crate::build
seems to generate zero hits in src/librustc_mir/hair/
so this doesn't seem to be accurate?
☔ The latest upstream changes (presumably #67886) made this pull request unmergeable. Please resolve the merge conflicts. |
25b21d3
to
7aa8ae0
Compare
@bors r=nagisa rollup=never |
📌 Commit 7aa8ae0 has been approved by |
…gisa Split MIR building into its own crate This moves `rustc_mir::{build, hair, lints}` to `rustc_mir_build`. The new crate only has a `provide` function as it's public API. Based on rust-lang#67898 cc @Centril @rust-lang/compiler r? @oli-obk
☔ The latest upstream changes (presumably #67970) made this pull request unmergeable. Please resolve the merge conflicts. |
d12f1e7
to
7f25b4c
Compare
☔ The latest upstream changes (presumably #68034) made this pull request unmergeable. Please resolve the merge conflicts. |
7f25b4c
to
fc33b1e
Compare
@bors r=nagisa |
📌 Commit fc33b1ea17da5dc929d66b2b80c307022a7ab7a5 has been approved by |
This comment has been minimized.
This comment has been minimized.
fc33b1e
to
a4dd1e7
Compare
@bors r=nagisa |
📌 Commit a4dd1e715361ba100fcfb01b8e662f04f01e3270 has been approved by |
This comment has been minimized.
This comment has been minimized.
a4dd1e7
to
a8df033
Compare
@bors r=nagisa |
📌 Commit a8df0332e94fee565f4455424b894b1fab9c3566 has been approved by |
@bors p=1 |
⌛ Testing commit a8df0332e94fee565f4455424b894b1fab9c3566 with merge d7bad2591ffb41b516587165853001fff3267731... |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
a8df033
to
b358929
Compare
@bors r=nagisa |
📌 Commit b358929 has been approved by |
Split MIR building into its own crate This moves `rustc_mir::{build, hair, lints}` to `rustc_mir_build`. The new crate only has a `provide` function as it's public API. Based on #67898 cc @Centril @rust-lang/compiler r? @oli-obk
☀️ Test successful - checks-azure |
/// The constituent parts of an ADT or array. | ||
#[derive(Copy, Clone, Debug, HashStable)] | ||
pub struct DestructuredConst<'tcx> { | ||
pub variant: VariantIdx, | ||
pub fields: &'tcx [&'tcx ty::Const<'tcx>], | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be under mir::interpret
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷 seems fine to me here. It's just a query return type that you won't ever mention yourself. You'll just access the fields.
This moves
rustc_mir::{build, hair, lints}
torustc_mir_build
.The new crate only has a
provide
function as it's public API.Based on #67898
cc @Centril @rust-lang/compiler
r? @oli-obk