-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed as not planned
Closed as not planned
Copy link
Labels
A-run-makeArea: port run-make Makefiles to rmake.rsArea: port run-make Makefiles to rmake.rsA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
impl_helper_methods
worked reasonably well while prototyping, but now I realized a trait with default provided methods is a better fit for making it easier and less verbose to implement command wrappers. This is because command_output
can be a required method checked by rustc, while we can provide helper methods but still allow individual command wrapper instances to override as desired.
pub trait CommandWrapper {
// required method
fn command_output(self) -> std::command::Output;
// provided helper methods
fn run(self) -> std::command::Output { ... }
fn run_fail(self, expected_exit_code: i32) -> std::command::Output { ... }
}
then implementors can write
pub struct Rustc { cmd: Command }
impl CommandWrapper for Rustc {
fn command_output(self) -> Output { ... }
}
impl Rustc {
// ... other helper methods
}
Unresolved questions
- If these helper methods are moved on to a trait, then test writers will have to bring the trait in scope in order to use the helper methods. Is it worth the extra typing?
Metadata
Metadata
Assignees
Labels
A-run-makeArea: port run-make Makefiles to rmake.rsArea: port run-make Makefiles to rmake.rsA-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.