-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
groundwork for rustc_clean/dirty improvements #44983
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
the failures are because TODO is depricated. It should compile and pass tests as-is. |
the goal of this is to make tests in #44924 more succinct, as well as make it easy to add additional assertions later. If we wanted to assert a different DefNode, we can just add it to the groups that it makes sense for and fix the tests (manually validating that the fixes make sense, obviously). It will also reduce boilerplate. This:
Will become this:
This:
Will become this:
Or equivalently this:
|
You can use |
Thanks, @vitiral! I think this is a good initiative. I've been a bit skeptical initially because I like how an explicit list makes it easy to see what exactly is tested. However, I think that is outweighed by reducing the amount of redundancy and being able to test new kinds of Let's iterate on the specific design some more:
If we would infer the group, the above examples could look like: #[rustc_clean(except="Hir, HirBody, TypeOfItem", cfg="cfail3")]
#[rustc_clean(cfg="cfail3")]
struct Abc { ... } That's pretty nice, actually |
I think that sounds great! So are you thinking of removing Groups alltogether then? I think far harder to read (or at least understand) is what might be missing in any assertion. This covers all possible things that might change for any DepNode, so it makes it very clear. Let me see how possible this is... |
Got some help from @nikomatsakis We want to match on the |
Also, I think the initial implementation will still support I'll open a new issue before this gets merged to remove that behavior. I don't want to change thousands of lines of code to get this feature. |
I opened #45009 to track this feature through to completion. I'd like to convert this PR to just support multiple DefNode's in |
bab96fa
to
b5bae56
Compare
So @michaelwoerister this PR should be good to go |
b5bae56
to
e7ff6f6
Compare
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.
Very good, thank you, @vitiral!
If you address the two nits this is ready to merge.
if out.contains(label) { | ||
self.tcx.sess.span_fatal( | ||
item.span, | ||
&format!("dep-node label `{}` is repeated (possibly by a group)", label)); |
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.
This doesn't really handle groups yet, does it?
let mut out = Vec::with_capacity(labels.len()); | ||
let def_path_hash = self.tcx.def_path_hash(def_id); | ||
for label in labels.iter() { | ||
match DepNode::from_label_string(label, def_path_hash.clone()) { |
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.
The .clone()
should be unnecessary as DefPathHash
is Copy
.
e7ff6f6
to
ad9b1ed
Compare
@michaelwoerister just pushed an ammended commit with your changes. |
📌 Commit ad9b1ed has been approved by |
@michaelwoerister forgot to mention: we won't be supporting "groups" at all -- just auto-detection. That's what you wanted right? (technically we will create "hidden groups" to use when assigning which assertions to do when auto-detecting, but there won't be any user-facing groups) |
Yes, that's what I expected. |
@michaelwoerister I've almost got part2 ready, but it depends on these changes (I didn't think it would take this long to merge). How should I proceed? Should I just push a PR that doesn't properly diff against master? I could also just edit these commits (and you could pause bors), as it's not like anyone depends on them. |
groundwork for rustc_clean/dirty improvements This is a WIP PR that needs mentoring from @michaelwoerister. There are several TODOs but no outstanding questions (except for the main one -- **is this the right approach?**) This is the plumbing for supporing groups in `rustc_clean(labels="...")`, as well as supporting an `except="..."` which will remove the excepted labels in the "clean" check and then assert that they are dirty (this is still TODO). See the code TODO's and example comments for a rough design. I'd like to know if this is the design you would like to do, and then I can go about actually filling out the groups and implementing the remaining logic.
☀️ Test successful - status-appveyor, status-travis |
This is a WIP PR that needs mentoring from @michaelwoerister.
There are several TODOs but no outstanding questions (except for the main one -- is this the right approach?)
This is the plumbing for supporing groups in
rustc_clean(labels="...")
, as well as supporting anexcept="..."
which will remove the excepted labels in the "clean" check and then assert that they are dirty (this is still TODO).See the code TODO's and example comments for a rough design.
I'd like to know if this is the design you would like to do, and then I can go about actually filling out the groups and implementing the remaining logic.