Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn main() {
}

macro_rules! each_subcommand{
($mac:ident) => ({
($mac:ident) => {
$mac!(bench);
$mac!(build);
$mac!(clean);
Expand Down Expand Up @@ -91,7 +91,14 @@ macro_rules! each_subcommand{
$mac!(verify_project);
$mac!(version);
$mac!(yank);
})
}
}

mod subcommands {
macro_rules! declare_mod {
($name:ident) => ( pub mod $name; )
}
each_subcommand!(declare_mod);
Copy link
Member

Choose a reason for hiding this comment

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

Weird, I'm kinda surprised that this doesn't require the path to the source file to be src/bin/subcommands/foo.rs...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it should require that. Right now, macro-expanded non-inline module declarations are always treated as if they were at the file root due to a bug in the macro expander.

Copy link
Member

Choose a reason for hiding this comment

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

wheeeeeee

}

/**
Expand Down Expand Up @@ -152,10 +159,9 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {

macro_rules! cmd{
($name:ident) => (if args[1] == stringify!($name).replace("_", "-") {
mod $name;
config.shell().set_verbose(true);
let r = cargo::call_main_without_stdin($name::execute, config,
$name::USAGE,
let r = cargo::call_main_without_stdin(subcommands::$name::execute, config,
subcommands::$name::USAGE,
&args,
false);
cargo::process_executed(r, &mut config.shell());
Expand Down Expand Up @@ -232,7 +238,7 @@ fn list_commands(config: &Config) -> BTreeSet<String> {
}

macro_rules! add_cmd {
($cmd:ident) => (commands.insert(stringify!($cmd).replace("_", "-")))
($cmd:ident) => ({ commands.insert(stringify!($cmd).replace("_", "-")); })
}
each_subcommand!(add_cmd);
commands
Expand Down