Skip to content

Commit 850ba2f

Browse files
committed
Auto merge of #16451 - Urhengulas:satisfy-clippy, r=Veykril
internal: Work through temporarily allowed clippy lints, part 2 Another follow-up to rust-lang/rust-analyzer#16401.
2 parents 135a8d9 + df2c7a6 commit 850ba2f

File tree

39 files changed

+136
-149
lines changed

39 files changed

+136
-149
lines changed

Cargo.toml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -167,29 +167,14 @@ new_ret_no_self = "allow"
167167

168168
## Following lints should be tackled at some point
169169
borrowed_box = "allow"
170-
borrow_deref_ref = "allow"
171-
derivable_impls = "allow"
172170
derived_hash_with_manual_eq = "allow"
173-
field_reassign_with_default = "allow"
174171
forget_non_drop = "allow"
175-
format_collect = "allow"
176-
large_enum_variant = "allow"
177172
needless_doctest_main = "allow"
178-
new_without_default = "allow"
179173
non_canonical_clone_impl = "allow"
180174
non_canonical_partial_ord_impl = "allow"
181175
self_named_constructors = "allow"
182-
skip_while_next = "allow"
183176
too_many_arguments = "allow"
184-
toplevel_ref_arg = "allow"
185177
type_complexity = "allow"
186-
unnecessary_cast = "allow"
187-
unnecessary_filter_map = "allow"
188-
unnecessary_lazy_evaluations = "allow"
189-
unnecessary_mut_passed = "allow"
190-
useless_conversion = "allow"
191-
useless_format = "allow"
192-
wildcard_in_or_patterns = "allow"
193178
wrong_self_convention = "allow"
194179

195180
## warn at following lints

crates/flycheck/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,9 @@ impl CargoActor {
493493
// Skip certain kinds of messages to only spend time on what's useful
494494
JsonMessage::Cargo(message) => match message {
495495
cargo_metadata::Message::CompilerArtifact(artifact) if !artifact.fresh => {
496-
self.sender.send(CargoMessage::CompilerArtifact(artifact)).unwrap();
496+
self.sender
497+
.send(CargoMessage::CompilerArtifact(Box::new(artifact)))
498+
.unwrap();
497499
}
498500
cargo_metadata::Message::CompilerMessage(msg) => {
499501
self.sender.send(CargoMessage::Diagnostic(msg.message)).unwrap();
@@ -538,7 +540,7 @@ impl CargoActor {
538540
}
539541

540542
enum CargoMessage {
541-
CompilerArtifact(cargo_metadata::Artifact),
543+
CompilerArtifact(Box<cargo_metadata::Artifact>),
542544
Diagnostic(Diagnostic),
543545
}
544546

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub(super) fn print_body_hir(db: &dyn DefDatabase, body: &Body, owner: DefWithBo
3333
}
3434
)
3535
}),
36-
DefWithBodyId::InTypeConstId(_) => format!("In type const = "),
36+
DefWithBodyId::InTypeConstId(_) => "In type const = ".to_string(),
3737
DefWithBodyId::VariantId(it) => {
3838
let loc = it.lookup(db);
3939
let enum_loc = loc.parent.lookup(db);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl SsrError {
256256
"##,
257257
);
258258

259-
assert_eq!(db.body_with_source_map(def.into()).1.diagnostics(), &[]);
259+
assert_eq!(db.body_with_source_map(def).1.diagnostics(), &[]);
260260
expect![[r#"
261261
fn main() {
262262
_ = $crate::error::SsrError::new(
@@ -309,7 +309,7 @@ fn f() {
309309
"#,
310310
);
311311

312-
let (_, source_map) = db.body_with_source_map(def.into());
312+
let (_, source_map) = db.body_with_source_map(def);
313313
assert_eq!(source_map.diagnostics(), &[]);
314314

315315
for (_, def_map) in body.blocks(&db) {

crates/hir-def/src/data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ impl<'a> AssocItemCollector<'a> {
782782
self.diagnostics.push(DefDiagnostic::macro_expansion_parse_error(
783783
self.module_id.local_id,
784784
error_call_kind(),
785-
errors.into(),
785+
errors,
786786
));
787787
}
788788

crates/hir-def/src/hir/format_args.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ enum PositionUsedAs {
166166
}
167167
use PositionUsedAs::*;
168168

169+
#[allow(clippy::unnecessary_lazy_evaluations)]
169170
pub(crate) fn parse(
170171
s: &ast::String,
171172
fmt_snippet: Option<String>,
@@ -177,9 +178,9 @@ pub(crate) fn parse(
177178
let text = s.text_without_quotes();
178179
let str_style = match s.quote_offsets() {
179180
Some(offsets) => {
180-
let raw = u32::from(offsets.quotes.0.len()) - 1;
181+
let raw = usize::from(offsets.quotes.0.len()) - 1;
181182
// subtract 1 for the `r` prefix
182-
(raw != 0).then(|| raw as usize - 1)
183+
(raw != 0).then(|| raw - 1)
183184
}
184185
None => None,
185186
};
@@ -432,7 +433,7 @@ pub(crate) fn parse(
432433
}
433434
}
434435

435-
#[derive(Debug, Clone, PartialEq, Eq)]
436+
#[derive(Clone, Debug, Default, Eq, PartialEq)]
436437
pub struct FormatArgumentsCollector {
437438
arguments: Vec<FormatArgument>,
438439
num_unnamed_args: usize,
@@ -451,7 +452,7 @@ impl FormatArgumentsCollector {
451452
}
452453

453454
pub fn new() -> Self {
454-
Self { arguments: vec![], names: vec![], num_unnamed_args: 0, num_explicit_args: 0 }
455+
Default::default()
455456
}
456457

457458
pub fn add(&mut self, arg: FormatArgument) -> usize {

crates/hir-def/src/import_map.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ impl SearchMode {
297297
SearchMode::Exact => candidate.eq_ignore_ascii_case(query),
298298
SearchMode::Prefix => {
299299
query.len() <= candidate.len() && {
300-
let prefix = &candidate[..query.len() as usize];
300+
let prefix = &candidate[..query.len()];
301301
if case_sensitive {
302302
prefix == query
303303
} else {
@@ -396,7 +396,7 @@ impl Query {
396396
pub fn search_dependencies(
397397
db: &dyn DefDatabase,
398398
krate: CrateId,
399-
ref query: Query,
399+
query: &Query,
400400
) -> FxHashSet<ItemInNs> {
401401
let _p = tracing::span!(tracing::Level::INFO, "search_dependencies", ?query).entered();
402402

@@ -446,7 +446,7 @@ fn search_maps(
446446
let end = (value & 0xFFFF_FFFF) as usize;
447447
let start = (value >> 32) as usize;
448448
let ImportMap { item_to_info_map, importables, .. } = &*import_maps[import_map_idx];
449-
let importables = &importables[start as usize..end];
449+
let importables = &importables[start..end];
450450

451451
let iter = importables
452452
.iter()
@@ -516,7 +516,7 @@ mod tests {
516516
})
517517
.expect("could not find crate");
518518

519-
let actual = search_dependencies(db.upcast(), krate, query)
519+
let actual = search_dependencies(db.upcast(), krate, &query)
520520
.into_iter()
521521
.filter_map(|dependency| {
522522
let dependency_krate = dependency.krate(db.upcast())?;

crates/hir-def/src/macro_expansion_tests/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use hir_expand::{
2525
InFile, MacroFileId, MacroFileIdExt,
2626
};
2727
use span::Span;
28-
use stdx::format_to;
28+
use stdx::{format_to, format_to_acc};
2929
use syntax::{
3030
ast::{self, edit::IndentLevel},
3131
AstNode,
@@ -149,8 +149,7 @@ pub fn identity_when_valid(_attr: TokenStream, item: TokenStream) -> TokenStream
149149
if tree {
150150
let tree = format!("{:#?}", parse.syntax_node())
151151
.split_inclusive('\n')
152-
.map(|line| format!("// {line}"))
153-
.collect::<String>();
152+
.fold(String::new(), |mut acc, line| format_to_acc!(acc, "// {line}"));
154153
format_to!(expn_text, "\n{}", tree)
155154
}
156155
let range = call.syntax().text_range();

crates/hir-def/src/nameres/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1924,7 +1924,7 @@ impl ModCollector<'_, '_> {
19241924
item_tree: self.item_tree,
19251925
mod_dir,
19261926
}
1927-
.collect_in_top_module(&*items);
1927+
.collect_in_top_module(items);
19281928
if is_macro_use {
19291929
self.import_all_legacy_macros(module_id);
19301930
}

crates/hir-def/src/nameres/path_resolution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ impl DefMap {
475475
let macro_use_prelude = || {
476476
self.macro_use_prelude.get(name).map_or(PerNs::none(), |&(it, _extern_crate)| {
477477
PerNs::macros(
478-
it.into(),
478+
it,
479479
Visibility::Public,
480480
// FIXME?
481481
None, // extern_crate.map(ImportOrExternCrate::ExternCrate),

0 commit comments

Comments
 (0)