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

Fix suggestions for x.py setup #77400

Merged
merged 4 commits into from
Oct 7, 2020
Merged

Conversation

alarsyo
Copy link
Contributor

@alarsyo alarsyo commented Oct 1, 2020

#76631 introduced a new setup command to x.py

By default the command prompts for a profile to use:

Welcome to the Rust project! What do you want to do with x.py?
a) Contribute to the standard library
b) Contribute to the compiler
c) Contribute to the compiler, and also modify LLVM or codegen
d) Install Rust from source

and then displays command suggestions, depending on which profile was chosen. However the mapping between chosen profile and suggestion isn't exact, leading to suggestions not being shown if the user presses c or d. (because "c" is translated to "llvm" and "d" to "maintainer", but suggestions trigger for "codegen" and "user" respectively)

A more thorough refactor would stop using "strings-as-type" to make sure this kind of error doesn't happen, but it may be overkill for that kind of "script" program?

Tagging the setup command author: @jyn514

@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(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 Oct 1, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 1, 2020

r? @jyn514

@jyn514
Copy link
Member

jyn514 commented Oct 1, 2020

A more thorough refactor would stop using "strings-as-type" to make sure this kind of error doesn't happen, but it may be overkill for that kind of "script" program?

That seems like it would be useful, yeah. I thought of doing it in the original PR but never got around to it. Maybe something like this?

enum Profile {
  Compiler,
  Codegen,
  Library,
  User,
}

// keeps case-insensitive matching, etc.
impl FromStr for Profile { ... }
impl Display for Profile { ... }
impl Profile {
  fn include_path(&self, src_path: &Path) -> PathBuf
}

@jyn514 jyn514 added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) C-bug Category: This is a bug. labels Oct 1, 2020
src/bootstrap/setup.rs Outdated Show resolved Hide resolved
@jyn514 jyn514 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 Oct 1, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 5, 2020

@alarsyo are you still interested in making the more general change I mentioned in #77400 (comment)? No problem if not, this is good to merge as-is.

@alarsyo
Copy link
Contributor Author

alarsyo commented Oct 5, 2020

I am! Pushing a patch soon

src/bootstrap/flags.rs Outdated Show resolved Hide resolved
"b" | "compiler" => Ok(Profile::Compiler),
"c" | "llvm" | "codegen" => Ok(Profile::Codegen),
"d" | "maintainer" | "user" => Ok(Profile::User),
_ => Err(ProfileErr { name: s.to_string() }),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not happy with having the a, b, c, d letters from the prompt as part of the FromStr implementation, maybe having a match like this

match choice_string {
    "a" => Profile::Library,
    "b" => Profile::Compiler,
    "c" => Profile::Codegen,
    "d" => Profile::User,
    other => match other.parse() {
        Ok(profile) => profile,
        Err(prof_err) => { print error, continue;}
    }
}

in the prompting function would be better

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's a big deal either way. I kind of like it the way it is since it means there's only one place the match has to be exhaustive, but you could convince me it would be easier to keep a/b/c in sync if it's next to the prompt.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, having only one match to keep exhaustive might be best :)

src/bootstrap/setup.rs Outdated Show resolved Hide resolved
Copy link
Member

@jyn514 jyn514 left a comment

Choose a reason for hiding this comment

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

This already looks a lot better :)

src/bootstrap/flags.rs Outdated Show resolved Hide resolved
"b" | "compiler" => Ok(Profile::Compiler),
"c" | "llvm" | "codegen" => Ok(Profile::Codegen),
"d" | "maintainer" | "user" => Ok(Profile::User),
_ => Err(ProfileErr { name: s.to_string() }),
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's a big deal either way. I kind of like it the way it is since it means there's only one place the match has to be exhaustive, but you could convince me it would be easier to keep a/b/c in sync if it's next to the prompt.

src/bootstrap/setup.rs Outdated Show resolved Hide resolved
src/bootstrap/setup.rs Outdated Show resolved Hide resolved
@jyn514
Copy link
Member

jyn514 commented Oct 5, 2020

@bors r+

Thanks for working on this!

@bors
Copy link
Contributor

bors commented Oct 5, 2020

📌 Commit c09cf00d782bc16e795bf278eb67ee017240cbe6 has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 5, 2020
@bors
Copy link
Contributor

bors commented Oct 6, 2020

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

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 6, 2020
@alarsyo
Copy link
Contributor Author

alarsyo commented Oct 6, 2020

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 6, 2020
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 6, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 6, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Oct 6, 2020

📌 Commit d67a7e6 has been approved by jyn514

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 6, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 6, 2020
Rollup of 11 pull requests

Successful merges:

 - rust-lang#76784 (Add some docs to rustdoc::clean::inline and def_id functions)
 - rust-lang#76911 (fix VecDeque::iter_mut aliasing issues)
 - rust-lang#77400 (Fix suggestions for x.py setup)
 - rust-lang#77515 (Update to chalk 0.31)
 - rust-lang#77568 (inliner: use caller param_env)
 - rust-lang#77571 (Use matches! for core::char methods)
 - rust-lang#77582 (Move `EarlyOtherwiseBranch` to mir-opt-level 2)
 - rust-lang#77590 (Update RLS and Rustfmt)
 - rust-lang#77605 (Fix rustc_def_path to show the full path and not the trimmed one)
 - rust-lang#77614 (Let backends access span information)
 - rust-lang#77624 (Add c as a shorthand check alternative for new options rust-lang#77603)

Failed merges:

r? `@ghost`
@bors bors merged commit 59707c5 into rust-lang:master Oct 7, 2020
@rustbot rustbot added this to the 1.49.0 milestone Oct 7, 2020
@alarsyo alarsyo deleted the xpy-setup-suggestions branch October 7, 2020 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants