-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
some kind of #[cfg] story for rustfix #51208
Comments
I think the suggestion here to make is:
That'll catch tests and then you'd also need to pass --target and --features for other common cfg situations. Unfortunately I'm not sure we can realistically and automatically do better than that |
I think having people manually specify the cfg flags or other features they want is just fine. I have no idea what |
Ah sorry that's a relatively new feature in Cargo where "target" means "test" or "benchark" or "binary" or "library". So instead of |
Marking as part of the milestone, but solely to verify that migrating in presence of features and/or targets can be done manually (so --all-targets, maybe --features ...); we don't need automation for alpha. |
It seems to me that to mark this bug as closed we need the following:
@alexcrichton's comment above suggests that the first item can be achieved by executing the following command:
If so, I think that's fine, but we have to update the migration instructions. It is not clear to me if there is also a way to handle features, but if there is, then it should also be documented and explained. Specifically, it seems fine to me if users have to manually re-run @killercup — the reason we pinged you is to confirm the presence/absence of those capabilities in rustfix. |
So If exclusive features are present users need to run with This is now largely an issue of updating the edition guide, filing an issue there as well which I'll link from to here. |
I don't see how we can possibly do better than this. It seems fine to me that if people have a complex web of features, they can run the migration tool more than once. Features that truly cannot be used together are truly problematic for cargo anyway, since cargo takes the union of the features that appear in the dependency graph (and hence one crate might demand feature X and another unrelated crate might demand feature Y). The other scenario that could happen though is that there is code which is dead unless feature X xor feature Y is used. Not sure how common that would be, but it would not be handled by running with "zero" and "all" features. Regardless, it seems to me that for alpha at least we are done here. I could imagine adding other convenience feature(s) (e.g., perhaps some way to run repeatedly for each feature individually) but it would come later if at all (imo), and would probably want to be informed by the patterns that users need. Maybe we should ask people to give feedback on precisely this point? We could ask them what feature "patterns" they might have found useful. |
I like the idea of collecting feedback on how features are used and what patterns they'd fine useful. I think one place where we potentially could do better is add an allow-by-default lint that has a span of every byte that it "sees" -- essentially all code. However, since cfg'd code would not be seen by this lint it could work as a code coverage like tool for rustfix. I'm not sure if that's feasible, but seems plausible. |
I've opened rust-lang/rustfix#128 to help this along and try to officially give this "the same story as all other cargo commands" |
I think we really need to make |
@nrc perhaps yeah, but I'm sort of coming around to the idea of having I think we'll probably want to update the edition guide though for |
Ok Otherwise I'm now going to close this in favor of two issues:
I think those should be sufficient to close this, so closing! |
I think we need to be able to handle multiple
#[cfg]
settings for rustfix — at minimum, using#[cfg(test)]
code is super common. We obviously can't handle all cfg's at once, but perhaps we should include some way to run rustfix more than once, with distinct cfg settings? (And the default could run for both no cfg and#[cfg(test)]
?)cc @alexcrichton @killercup @zackmdavis
The text was updated successfully, but these errors were encountered: