Skip to content
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

x.py: don't enable -Zconfig-profile or -Zexternal-macro-backtrace with x.py clippy #69388

Closed
wants to merge 1 commit into from

Conversation

matthiaskrgr
Copy link
Member

It seems we need this to make x.py clippy run again.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 23, 2020
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also like comments on the added checks indicating that they're (presuming this is true) limitations of clippy today.

I will note that I am not super happy with needing to do this -- it seems like a bug somewhere upstream that we have to? Is there a fix in the works? Ideally we would not have to diverge in cargo flags for clippy / rustc.

@@ -849,7 +852,7 @@ impl<'a> Builder<'a> {

// cfg(bootstrap): the flag was renamed from `-Zexternal-macro-backtrace`
// to `-Zmacro-backtrace`, keep only the latter after beta promotion.
if stage == 0 {
if stage == 0 && cmd != "clippy" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems strange to gate this flag only on stage == 0, presumably it should be around the whole thing?

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 23, 2020
@matthiaskrgr
Copy link
Member Author

Ideally we would not have to diverge in cargo flags for clippy / rustc.

I'm not sure how to avoid this as long as cargo comes from beta-channel but clippy comes from nightly channel, unless we explicitly force beta clippy to run.

@matthiaskrgr matthiaskrgr force-pushed the fix_xpy_clippy branch 4 times, most recently from a15a00b to 1413fa7 Compare February 24, 2020 12:36
@matthiaskrgr
Copy link
Member Author

@rustbot modify labels to +S-waiting-on-review, -S-waiting-on-author

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 24, 2020
@@ -759,7 +765,8 @@ impl<'a> Builder<'a> {
};

let mut rustflags = Rustflags::new(&target);
if stage != 0 {
// nightly clippy needs --cfg=bootstrap to run successfully
if stage != 0 || cmd == "clippy" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am actually rather surprised by us needing to do this, as AFAICT if the cmd is clippy we should always be in stage 0? When is that not the case today?

(and if Clippy is already in stage 0, then the right flags would be in RUSTFLAGS_BOOTSTRAP, right?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, my code comment is simply wrong.
Looking at --verbose output, we are indeed in stage 0 all the time.
Looking at the error I was getting previously

error[E0061]: this function takes 1 argument but 0 arguments were supplied
  --> src/librustc_data_structures/box_region.rs:87:52
   |
87 |         let result = Pin::new(&mut self.generator).resume();
   |                                                    ^^^^^^- supplied 0 arguments
   |
help: expected the unit value `()`; create it with empty parentheses
   |
87 |         let result = Pin::new(&mut self.generator).resume(());
   |                                                           ^^

and the corresponding code

    #[cfg(bootstrap)]
    pub fn complete(&mut self) -> R {
        // Tell the generator we want it to complete, consuming it and yielding a result
        BOX_REGION_ARG.with(|i| i.set(Action::Complete));

        let result = Pin::new(&mut self.generator).resume();
        if let GeneratorState::Complete(r) = result { r } else { panic!() }
    }

    #[cfg(not(bootstrap))]
    pub fn complete(&mut self) -> R {
        // Tell the generator we want it to complete, consuming it and yielding a result
        BOX_REGION_ARG.with(|i| i.set(Action::Complete));

        let result = Pin::new(&mut self.generator).resume(());
        if let GeneratorState::Complete(r) = result { r } else { panic!() }
    }

we actually need to disable cfg=booststrap for x.py clippy in order to have it work from what it seems.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 25, 2020
@nikomatsakis
Copy link
Contributor

r? @Mark-Simulacrum

@Mark-Simulacrum
Copy link
Member

Hm, so AFAIK x.py clippy today is just using the clippy it finds in the environment, right? Can we perhaps make sure that's a nightly clippy (e.g,. running cargo +nightly clippy) or so?

Basically I feel like this is going to some non-trivial effort to patch over the fact that we're using different versions of clippy and we don't know what we're using which feels like it's never going to work out quite as well as trying to detect what we're using. We should likely also be using the same cargo as the clippy we're using, right? vs. using the beta cargo with (for example) a nightly clippy?

@matthiaskrgr
Copy link
Member Author

matthiaskrgr commented Feb 26, 2020

Hm, so AFAIK x.py clippy today is just using the clippy it finds in the environment, right?

Yeah.

Can we perhaps make sure that's a nightly clippy

I've been thinking about whether we could simply install the "clippy" component for x.py clippy just as x.py fmt installs its own rustfmt. I'll have to take a look how this is done for rustfmt...

I would prefer to run a nightly clippy on x.py clippy since that's more up to date and we can use it to spot false positives on new lints or other clippy bugs for example.

As far as I can remember, x.py clippy has been broken most of the time, except for maybe one week after nightly gets promoted to beta, then nightly and beta get out of "sync" and x.py clippy runs into errors again...
I've been trying to make it work for myself and wanted to upstream the changes but I'm not sure how much effort trying to implement a more generic solution is worth it.

@Mark-Simulacrum
Copy link
Member

Here's a proposal:

We edit clippy-driver (or whatever the clippy we're using is) to provide the "channel" in the --version (e.g., nightly, beta, etc.). I think this is the easiest way for us to determine what "stage" we should be running in.

Then we modify the cargo function to, if we're running cargo clippy, get the version information and if it's a nightly clippy, force stage 1, if it's a beta clippy, force stage 0, and if it's a stable clippy use stage 0 but print a warning that it's not really supported to do that.

This would, I think, work well. However, it's quite a bit of work (and we'd need to wait for the channel printing to roll out) -- I would propose that in this PR we just set stage = 1 if we're running cargo clippy and document that you should be using nightly.

I think that should work, right? And we'd presumably not need any of the other changes then?

@matthiaskrgr
Copy link
Member Author

We edit clippy-driver (or whatever the clippy we're using is) to provide the "channel" in the --version (e.g., nightly, beta, etc.). I think this is the easiest way for us to determine what "stage" we should be running in.

I think this already works today: clippy-driver -vV

rustc 1.43.0-nightly (6fd8798f4 2020-02-25)
binary: rustc
commit-hash: 6fd8798f4de63328d743eb2a9a9c12e202a4a182
commit-date: 2020-02-25
host: x86_64-unknown-linux-gnu
release: 1.43.0-nightly
LLVM version: 9.0

Then we modify the cargo function to,

Are you referring to cargo code or x.py/bootstrap.rs here?

@Mark-Simulacrum
Copy link
Member

Huh, I'm pretty sure I ran that with the clippy I had (a stable clippy) and it didn't work.

x.py for the cargo function.

@joelpalmer
Copy link

Triaged

@bors
Copy link
Contributor

bors commented Mar 17, 2020

☔ The latest upstream changes (presumably #70062) made this pull request unmergeable. Please resolve the merge conflicts.

…h x.py clippy

run clippy on #[cfg(not(bootstrap)] code
@matthiaskrgr
Copy link
Member Author

rebase for @Centril

@joelpalmer joelpalmer added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 30, 2020
@Dylan-DPC-zz Dylan-DPC-zz added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 30, 2020
@Dylan-DPC-zz
Copy link

@Mark-Simulacrum this is ready for review

@matthiaskrgr
Copy link
Member Author

Sorry, this is not ready for review. I'll just close it to avoid confusion.

@matthiaskrgr matthiaskrgr deleted the fix_xpy_clippy branch January 25, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants