Skip to content

Commit

Permalink
Rename --force to --allow-downgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed May 27, 2022
1 parent f43c44f commit 1ef2043
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
10 changes: 5 additions & 5 deletions cargo-dylint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ pub struct Dylint {
#[clap(long, help = "Load all discovered libraries")]
pub all: bool,

#[clap(long, hide = true)]
pub allow_downgrade: bool,

#[clap(long, hide = true)]
pub bisect: bool,

#[clap(long, help = "Automatically apply lint suggestions")]
pub fix: bool,

#[clap(long, hide = true)]
pub force: bool,

#[clap(long, hide = true)]
pub isolate: bool,

Expand Down Expand Up @@ -160,9 +160,9 @@ impl From<Dylint> for dylint::Dylint {
fn from(opts: Dylint) -> Self {
let Dylint {
all,
allow_downgrade,
bisect,
fix,
force,
isolate,
keep_going,
libs,
Expand All @@ -182,9 +182,9 @@ impl From<Dylint> for dylint::Dylint {
} = opts;
Self {
all,
allow_downgrade,
bisect,
fix,
force,
isolate,
keep_going,
libs,
Expand Down
2 changes: 1 addition & 1 deletion cargo-dylint/tests/package_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ fn downgrade_upgrade_package() {
.failure()
.stderr(predicate::str::contains("Refusing to downgrade toolchain"));

upgrade().args(&["--force"]).assert().success();
upgrade().args(&["--allow-downgrade"]).assert().success();

dylint_internal::cargo::build("downgraded dylint-template", false)
.sanitize_environment()
Expand Down
6 changes: 3 additions & 3 deletions dylint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ lazy_static! {
#[derive(Debug, Default)]
pub struct Dylint {
pub all: bool,
pub allow_downgrade: bool,
pub bisect: bool,
pub fix: bool,
pub force: bool,
pub isolate: bool,
pub keep_going: bool,
pub libs: Vec<String>,
Expand Down Expand Up @@ -83,8 +83,8 @@ pub fn run(opts: &Dylint) -> Result<()> {
bail!("`--bisect` can be used only with `--upgrade`");
}

if opts.force && opts.upgrade_path.is_none() {
bail!("`--force` can be used only with `--upgrade`");
if opts.allow_downgrade && opts.upgrade_path.is_none() {
bail!("`--allow-downgrade` can be used only with `--upgrade`");
}

if opts.isolate && opts.new_path.is_none() {
Expand Down
5 changes: 3 additions & 2 deletions dylint/src/package_options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,15 @@ pub fn upgrade_package(opts: &Dylint, path: &Path) -> Result<()> {
let old_channel = channel(path)?;

let should_find_and_replace = if_chain! {
if !opts.force;
if !opts.allow_downgrade;
if let Some(new_nightly) = parse_as_nightly(&rev.channel);
if let Some(old_nightly) = parse_as_nightly(&old_channel);
if new_nightly < old_nightly;
then {
if !opts.bisect {
bail!(
"Refusing to downgrade toolchain from `{}` to `{}`. Use `--force` to override.",
"Refusing to downgrade toolchain from `{}` to `{}`. \
Use `--allow-downgrade` to override.",
old_channel,
rev.channel
);
Expand Down
4 changes: 2 additions & 2 deletions examples/crate_wide_allow/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

**What it does:** Checks for use of `#![allow(...)]` at the crate level.

**Why is this bad?** Such uses cannot be overriden with `--warn` or `--deny` from the
command line. They _can_ be overriden with `--force-warn` or `--forbid`, but one must
**Why is this bad?** Such uses cannot be overridden with `--warn` or `--deny` from the
command line. They _can_ be overridden with `--force-warn` or `--forbid`, but one must
know the `#![allow(...)]` are present to use these unconventional options.

**Known problems:** None.
Expand Down
4 changes: 2 additions & 2 deletions examples/crate_wide_allow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use rustc_span::sym;
dylint_linting::declare_early_lint! {
/// **What it does:** Checks for use of `#![allow(...)]` at the crate level.
///
/// **Why is this bad?** Such uses cannot be overriden with `--warn` or `--deny` from the
/// command line. They *can* be overriden with `--force-warn` or `--forbid`, but one must
/// **Why is this bad?** Such uses cannot be overridden with `--warn` or `--deny` from the
/// command line. They *can* be overridden with `--force-warn` or `--forbid`, but one must
/// know the `#![allow(...)]` are present to use these unconventional options.
///
/// **Known problems:** None.
Expand Down

0 comments on commit 1ef2043

Please sign in to comment.