Skip to content

Shadowing command with alias as a default configuration #8360

@woshilapin

Description

@woshilapin

Describe the problem you are trying to solve
I often run the same commands over and over with the same set of flags (--all-features, --all-targets, --deny warnings). Then I found out about the .cargo/config and the [alias] section. So I thought about doing a recursive alias (like I would do with aliases in a shell).

[alias]
clippy = "clippy --workspace --all-features --all-targets -- --deny warnings"

But this is not possible as it is shadowing the existing clippy command. Actually, it might even be a bug because this is what I get when I'm trying to do that.

$> cargo clippy

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
[1]    2198266 abort (core dumped)  cargo clippy

Describe the solution you'd like
Like aliases in a shell, I'd expect the alias defined above to just work when typing cargo clippy.

One nice advantage would be that all the project's contributors would follow the same configuration for the project (including the CI).

Notes
I'm throwing the idea but I'm also aware of the weirdness in a recursive definition. It might not be desirable.

Another possible drawback: it might be harder to use the original clippy command. For example, in shell, if we had an alias ls="ls -l", we could use the original command (and therefore deactivate the -l option) by doing /usr/bin/ls. Not sure how to reproduce a similar behavior with cargo.

Related issues
#2901

Metadata

Metadata

Assignees

Labels

A-aliasesArea: command aliasesC-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions