Skip to content

Commit afccc3f

Browse files
authored
Merge pull request #949 from epage/clippy
style: Make clippy happy
2 parents d722ed8 + d93d0b8 commit afccc3f

File tree

20 files changed

+225
-161
lines changed

20 files changed

+225
-161
lines changed

Cargo.toml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,73 @@ set-version = ["cli"]
110110
cli = ["color", "clap"]
111111
color = ["concolor-control/auto"]
112112
test-external-apis = []
113+
114+
[lints.rust]
115+
rust_2018_idioms = { level = "warn", priority = -1 }
116+
unnameable_types = "warn"
117+
unreachable_pub = "warn"
118+
unsafe_op_in_unsafe_fn = "warn"
119+
unused_lifetimes = "warn"
120+
unused_macro_rules = "warn"
121+
unused_qualifications = "warn"
122+
123+
[lints.clippy]
124+
bool_assert_comparison = "allow"
125+
branches_sharing_code = "allow"
126+
checked_conversions = "warn"
127+
collapsible_else_if = "allow"
128+
create_dir = "warn"
129+
dbg_macro = "warn"
130+
debug_assert_with_mut_call = "warn"
131+
doc_markdown = "warn"
132+
empty_enum = "warn"
133+
enum_glob_use = "warn"
134+
expl_impl_clone_on_copy = "warn"
135+
explicit_deref_methods = "warn"
136+
explicit_into_iter_loop = "warn"
137+
fallible_impl_from = "warn"
138+
filter_map_next = "warn"
139+
flat_map_option = "warn"
140+
float_cmp_const = "warn"
141+
fn_params_excessive_bools = "warn"
142+
from_iter_instead_of_collect = "warn"
143+
if_same_then_else = "allow"
144+
implicit_clone = "warn"
145+
imprecise_flops = "warn"
146+
inconsistent_struct_constructor = "warn"
147+
inefficient_to_string = "warn"
148+
infinite_loop = "warn"
149+
invalid_upcast_comparisons = "warn"
150+
large_digit_groups = "warn"
151+
large_stack_arrays = "warn"
152+
large_types_passed_by_value = "warn"
153+
let_and_return = "allow" # sometimes good to name what you are returning
154+
linkedlist = "warn"
155+
lossy_float_literal = "warn"
156+
macro_use_imports = "warn"
157+
mem_forget = "warn"
158+
mutex_integer = "warn"
159+
needless_continue = "allow"
160+
needless_for_each = "warn"
161+
negative_feature_names = "warn"
162+
path_buf_push_overwrite = "warn"
163+
ptr_as_ptr = "warn"
164+
rc_mutex = "warn"
165+
redundant_feature_names = "warn"
166+
ref_option_ref = "warn"
167+
rest_pat_in_fully_bound_structs = "warn"
168+
result_large_err = "allow"
169+
same_functions_in_if_condition = "warn"
170+
self_named_module_files = "allow" # false positive
171+
semicolon_if_nothing_returned = "warn"
172+
str_to_string = "warn"
173+
string_add = "warn"
174+
string_add_assign = "warn"
175+
string_lit_as_bytes = "warn"
176+
string_to_string = "warn"
177+
todo = "warn"
178+
trait_duplication_in_bounds = "warn"
179+
uninlined_format_args = "warn"
180+
verbose_file_reads = "warn"
181+
wildcard_imports = "warn"
182+
zero_sized_map_values = "warn"

src/bin/add/add.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Examples:
1616
#[command(override_usage = "\
1717
cargo add [OPTIONS] <DEP>[@<VERSION>] [+<FEATURE>,...] ...
1818
cargo add [OPTIONS] <DEP_PATH> [+<FEATURE>,...] ...")]
19-
pub struct AddArgs {
19+
pub(crate) struct AddArgs {
2020
/// Reference to a package to add as a dependency
2121
///
2222
/// You can reference a packages by:{n}
@@ -146,7 +146,7 @@ pub struct AddArgs {
146146
}
147147

148148
impl AddArgs {
149-
pub fn exec(self) -> CargoResult<()> {
149+
pub(crate) fn exec(self) -> CargoResult<()> {
150150
anyhow::bail!(
151151
"`cargo add` has been merged into cargo 1.62+ as of cargo-edit 0.10, either
152152
- Upgrade cargo, like with `rustup update`

src/bin/add/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use clap::Parser;
33

44
#[derive(Debug, Parser)]
55
#[command(bin_name = "cargo")]
6-
pub enum Command {
6+
pub(crate) enum Command {
77
Add(crate::add::AddArgs),
88
}
99

1010
impl Command {
11-
pub fn exec(self) -> CargoResult<()> {
11+
pub(crate) fn exec(self) -> CargoResult<()> {
1212
match self {
1313
Self::Add(add) => add.exec(),
1414
}
@@ -18,5 +18,5 @@ impl Command {
1818
#[test]
1919
fn verify_app() {
2020
use clap::CommandFactory;
21-
Command::command().debug_assert()
21+
Command::command().debug_assert();
2222
}

src/bin/rm/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use clap::Parser;
33

44
#[derive(Debug, Parser)]
55
#[command(bin_name = "cargo")]
6-
pub enum Command {
6+
pub(crate) enum Command {
77
Rm(crate::rm::RmArgs),
88
}
99

1010
impl Command {
11-
pub fn exec(self) -> CargoResult<()> {
11+
pub(crate) fn exec(self) -> CargoResult<()> {
1212
match self {
1313
Self::Rm(add) => add.exec(),
1414
}
@@ -18,5 +18,5 @@ impl Command {
1818
#[test]
1919
fn verify_app() {
2020
use clap::CommandFactory;
21-
Command::command().debug_assert()
21+
Command::command().debug_assert();
2222
}

src/bin/rm/rm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::path::PathBuf;
55
/// Remove a dependency from a Cargo.toml manifest file.
66
#[derive(Debug, Args)]
77
#[command(version)]
8-
pub struct RmArgs {
8+
pub(crate) struct RmArgs {
99
/// Dependencies to be removed
1010
#[arg(value_name = "DEP_ID", required = true)]
1111
crates: Vec<String>,
@@ -44,7 +44,7 @@ pub struct RmArgs {
4444
}
4545

4646
impl RmArgs {
47-
pub fn exec(&self) -> CargoResult<()> {
47+
pub(crate) fn exec(&self) -> CargoResult<()> {
4848
anyhow::bail!(
4949
"`cargo rm` has been merged into cargo 1.66+ as of cargo-edit 0.12, either
5050
- Upgrade cargo, like with `rustup update`

src/bin/set-version/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use clap::Parser;
44
#[derive(Debug, Parser)]
55
#[command(bin_name = "cargo")]
66
#[command(styles = clap_cargo::style::CLAP_STYLING)]
7-
pub enum Command {
7+
pub(crate) enum Command {
88
SetVersion(crate::set_version::VersionArgs),
99
}
1010

1111
impl Command {
12-
pub fn exec(self) -> CargoResult<()> {
12+
pub(crate) fn exec(self) -> CargoResult<()> {
1313
match self {
1414
Self::SetVersion(add) => add.exec(),
1515
}
@@ -19,5 +19,5 @@ impl Command {
1919
#[test]
2020
fn verify_app() {
2121
use clap::CommandFactory;
22-
Command::command().debug_assert()
22+
Command::command().debug_assert();
2323
}

src/bin/set-version/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::fmt::Display;
22

3-
pub use cargo_edit::CargoResult;
3+
pub(crate) use cargo_edit::CargoResult;
44

5-
pub use cargo_edit::Error;
5+
pub(crate) use cargo_edit::Error;
66

77
/// User requested to downgrade a crate
88
pub(crate) fn version_downgrade_err(current: impl Display, requested: impl Display) -> Error {

src/bin/set-version/set_version.rs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use std::path::PathBuf;
44
use cargo_edit::{LocalManifest, shell_status, shell_warn, upgrade_requirement};
55
use clap::Args;
66

7-
use crate::errors::*;
7+
use crate::errors::CargoResult;
88
use crate::version::BumpLevel;
99
use crate::version::TargetVersion;
1010

1111
/// Change a package's version in the local manifest file (i.e. Cargo.toml).
1212
#[derive(Debug, Args)]
1313
#[command(version)]
1414
#[command(group = clap::ArgGroup::new("ver").multiple(false))]
15-
pub struct VersionArgs {
15+
pub(crate) struct VersionArgs {
1616
/// Version to change manifests to
1717
#[arg(group = "ver")]
1818
target: Option<semver::Version>,
@@ -77,7 +77,7 @@ pub struct VersionArgs {
7777
}
7878

7979
impl VersionArgs {
80-
pub fn exec(self) -> CargoResult<()> {
80+
pub(crate) fn exec(self) -> CargoResult<()> {
8181
exec(self)
8282
}
8383
}
@@ -179,20 +179,20 @@ fn exec(args: VersionArgs) -> CargoResult<()> {
179179

180180
if update_workspace_version {
181181
let mut ws_manifest = LocalManifest::try_new(&root_manifest_path)?;
182-
if let Some(current) = ws_manifest.get_workspace_version() {
183-
if let Some(next) = target.bump(&current, metadata.as_deref())? {
184-
shell_status(
185-
"Upgrading",
186-
&format!("workspace version from {current} to {next}"),
187-
)?;
188-
ws_manifest.set_workspace_version(&next);
189-
changed = true;
190-
if !dry_run {
191-
ws_manifest.write()?;
192-
}
193-
194-
// Deferring `update_dependents` to the per-package logic
182+
if let Some(current) = ws_manifest.get_workspace_version()
183+
&& let Some(next) = target.bump(&current, metadata.as_deref())?
184+
{
185+
shell_status(
186+
"Upgrading",
187+
&format!("workspace version from {current} to {next}"),
188+
)?;
189+
ws_manifest.set_workspace_version(&next);
190+
changed = true;
191+
if !dry_run {
192+
ws_manifest.write()?;
195193
}
194+
195+
// Deferring `update_dependents` to the per-package logic
196196
}
197197
}
198198

@@ -229,7 +229,7 @@ fn exec(args: VersionArgs) -> CargoResult<()> {
229229
&root_manifest_path,
230230
&workspace_members,
231231
dry_run,
232-
)?
232+
)?;
233233
}
234234
}
235235

src/bin/set-version/version.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ use std::str::FromStr;
22

33
use cargo_edit::VersionExt;
44

5-
use crate::errors::*;
5+
use crate::errors::{CargoResult, version_downgrade_err};
66

77
#[derive(Clone, Debug)]
8-
pub enum TargetVersion {
8+
pub(crate) enum TargetVersion {
99
Relative(BumpLevel),
1010
Absolute(semver::Version),
1111
}
1212

1313
impl TargetVersion {
14-
pub fn bump(
14+
pub(crate) fn bump(
1515
&self,
1616
current: &semver::Version,
1717
metadata: Option<&str>,
@@ -56,7 +56,7 @@ impl Default for TargetVersion {
5656
}
5757

5858
#[derive(Debug, Clone, Copy)]
59-
pub enum BumpLevel {
59+
pub(crate) enum BumpLevel {
6060
Major,
6161
Minor,
6262
Patch,
@@ -87,7 +87,7 @@ impl FromStr for BumpLevel {
8787
}
8888

8989
impl BumpLevel {
90-
pub fn bump_version(
90+
pub(crate) fn bump_version(
9191
self,
9292
version: &mut semver::Version,
9393
metadata: Option<&str>,

src/bin/upgrade/cli.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ use clap::Parser;
44
#[derive(Debug, Parser)]
55
#[command(bin_name = "cargo")]
66
#[command(styles = clap_cargo::style::CLAP_STYLING)]
7-
pub enum Command {
7+
pub(crate) enum Command {
88
Upgrade(crate::upgrade::UpgradeArgs),
99
}
1010

1111
impl Command {
12-
pub fn exec(self) -> CargoResult<()> {
12+
pub(crate) fn exec(self) -> CargoResult<()> {
1313
match self {
1414
Self::Upgrade(add) => add.exec(),
1515
}
@@ -19,5 +19,5 @@ impl Command {
1919
#[test]
2020
fn verify_app() {
2121
use clap::CommandFactory;
22-
Command::command().debug_assert()
22+
Command::command().debug_assert();
2323
}

0 commit comments

Comments
 (0)