Skip to content

Commit 7e74066

Browse files
committed
Fix clippy lints
1 parent d26853a commit 7e74066

File tree

156 files changed

+728
-839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+728
-839
lines changed

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,5 @@ type_complexity = "allow"
112112
question_mark = "allow"
113113
# We have macros that rely on this currently
114114
enum_variant_names = "allow"
115+
# Builder pattern disagrees
116+
new_ret_no_self = "allow"

crates/base-db/src/fixture.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl ChangeFixture {
116116
let toolchain = toolchain
117117
.map(|it| {
118118
ReleaseChannel::from_str(&it)
119-
.unwrap_or_else(|| panic!("unknown release channel found: {it}"))
119+
.unwrap_or_else(|()| panic!("unknown release channel found: {it}"))
120120
})
121121
.unwrap_or(ReleaseChannel::Stable);
122122
let mut change = Change::new();

crates/base-db/src/input.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,13 +282,17 @@ impl ReleaseChannel {
282282
ReleaseChannel::Nightly => "nightly",
283283
}
284284
}
285+
}
286+
287+
impl FromStr for ReleaseChannel {
288+
type Err = ();
285289

286-
pub fn from_str(str: &str) -> Option<Self> {
287-
Some(match str {
290+
fn from_str(str: &str) -> Result<Self, Self::Err> {
291+
Ok(match str {
288292
"" => ReleaseChannel::Stable,
289293
"nightly" => ReleaseChannel::Nightly,
290294
_ if str.starts_with("beta") => ReleaseChannel::Beta,
291-
_ => return None,
295+
_ => return Err(()),
292296
})
293297
}
294298
}

crates/flycheck/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ impl CargoActor {
513513
}
514514
}
515515

516+
#[allow(clippy::large_enum_variant)]
516517
enum CargoMessage {
517518
CompilerArtifact(cargo_metadata::Artifact),
518519
Diagnostic(Diagnostic),

crates/hir-def/src/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ fn parse_comma_sep<S>(subtree: &tt::Subtree<S>) -> Vec<SmolStr> {
379379
}
380380

381381
impl AttrsWithOwner {
382-
pub(crate) fn attrs_with_owner(db: &dyn DefDatabase, owner: AttrDefId) -> Self {
382+
pub(crate) fn attrs_with_owner_query(db: &dyn DefDatabase, owner: AttrDefId) -> Self {
383383
Self { attrs: db.attrs(owner), owner }
384384
}
385385

crates/hir-def/src/body.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,12 +242,12 @@ impl Body {
242242
}
243243
}
244244
Pat::Or(args) | Pat::Tuple { args, .. } | Pat::TupleStruct { args, .. } => {
245-
args.iter().copied().for_each(|p| f(p));
245+
args.iter().copied().for_each(&mut f);
246246
}
247247
Pat::Ref { pat, .. } => f(*pat),
248248
Pat::Slice { prefix, slice, suffix } => {
249249
let total_iter = prefix.iter().chain(slice.iter()).chain(suffix.iter());
250-
total_iter.copied().for_each(|p| f(p));
250+
total_iter.copied().for_each(&mut f);
251251
}
252252
Pat::Record { args, .. } => {
253253
args.iter().for_each(|RecordFieldPat { pat, .. }| f(*pat));

crates/hir-def/src/body/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ impl ExprCollector<'_> {
811811
expr: iterator,
812812
arms: Box::new([MatchArm { pat: iter_pat, guard: None, expr: loop_outer }]),
813813
},
814-
syntax_ptr.clone(),
814+
syntax_ptr,
815815
)
816816
}
817817

crates/hir-def/src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ impl<'a> AssocItemCollector<'a> {
739739
self.diagnostics.push(DefDiagnostic::macro_expansion_parse_error(
740740
self.module_id.local_id,
741741
error_call_kind(),
742-
errors.into(),
742+
errors,
743743
));
744744
}
745745

crates/hir-def/src/data/adt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ fn lower_struct(
473473
trace: &mut Trace<FieldData, Either<ast::TupleField, ast::RecordField>>,
474474
ast: &InFile<ast::StructKind>,
475475
) -> StructKind {
476-
let ctx = LowerCtx::new(db, &expander.hygiene(), ast.file_id);
476+
let ctx = LowerCtx::new(db, expander.hygiene(), ast.file_id);
477477

478478
match &ast.value {
479479
ast::StructKind::Tuple(fl) => {

crates/hir-def/src/db.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub trait DefDatabase: InternDatabase + ExpandDatabase + Upcast<dyn ExpandDataba
193193
fn attrs(&self, def: AttrDefId) -> Attrs;
194194

195195
#[salsa::transparent]
196-
#[salsa::invoke(AttrsWithOwner::attrs_with_owner)]
196+
#[salsa::invoke(AttrsWithOwner::attrs_with_owner_query)]
197197
fn attrs_with_owner(&self, def: AttrDefId) -> AttrsWithOwner;
198198

199199
// endregion:attrs
@@ -271,10 +271,8 @@ fn crate_supports_no_std(db: &dyn DefDatabase, crate_id: CrateId) -> bool {
271271
None => continue,
272272
};
273273

274-
let segments = tt.split(|tt| match tt {
275-
tt::TokenTree::Leaf(tt::Leaf::Punct(p)) if p.char == ',' => true,
276-
_ => false,
277-
});
274+
let segments =
275+
tt.split(|tt| matches!(tt, tt::TokenTree::Leaf(tt::Leaf::Punct(p)) if p.char == ','));
278276
for output in segments.skip(1) {
279277
match output {
280278
[tt::TokenTree::Leaf(tt::Leaf::Ident(ident))] if ident.text == "no_std" => {

0 commit comments

Comments
 (0)