Skip to content

Commit dfa3677

Browse files
authored
Rollup merge of #72109 - matthiaskrgr:cl8ppy, r=Dylan-DPC
Fix clippy warnings Fixes clippy::{cone_on_copy, filter_next, redundant_closure, single_char_pattern, len_zero,redundant_field_names, useless_format, identity_conversion, map_clone, into_iter_on_ref, needless_return, option_as_ref_deref, unused_unit, unnecessary_mut_passed} r? @Dylan-DPC
2 parents dd53768 + 8bfd845 commit dfa3677

File tree

24 files changed

+68
-79
lines changed

24 files changed

+68
-79
lines changed

src/librustc_attr/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ pub fn eval_condition(
634634
[NestedMetaItem::Literal(Lit { span, .. })
635635
| NestedMetaItem::MetaItem(MetaItem { span, .. })] => {
636636
sess.span_diagnostic
637-
.struct_span_err(*span, &*format!("expected a version literal"))
637+
.struct_span_err(*span, "expected a version literal")
638638
.emit();
639639
return false;
640640
}

src/librustc_data_structures/tiny_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<T: PartialEq> TinyList<T> {
5252
if &e.data == data {
5353
return true;
5454
}
55-
elem = e.next.as_ref().map(|e| &**e);
55+
elem = e.next.as_deref();
5656
}
5757
false
5858
}
@@ -62,7 +62,7 @@ impl<T: PartialEq> TinyList<T> {
6262
let (mut elem, mut count) = (self.head.as_ref(), 0);
6363
while let Some(ref e) = elem {
6464
count += 1;
65-
elem = e.next.as_ref().map(|e| &**e);
65+
elem = e.next.as_deref();
6666
}
6767
count
6868
}

src/librustc_infer/traits/util.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,7 @@ pub fn elaborate_predicates<'tcx>(
112112
tcx: TyCtxt<'tcx>,
113113
predicates: impl Iterator<Item = ty::Predicate<'tcx>>,
114114
) -> Elaborator<'tcx> {
115-
let obligations =
116-
predicates.into_iter().map(|predicate| predicate_obligation(predicate, None)).collect();
115+
let obligations = predicates.map(|predicate| predicate_obligation(predicate, None)).collect();
117116
elaborate_obligations(tcx, obligations)
118117
}
119118

@@ -149,7 +148,7 @@ impl Elaborator<'tcx> {
149148
// Get predicates declared on the trait.
150149
let predicates = tcx.super_predicates_of(data.def_id());
151150

152-
let obligations = predicates.predicates.into_iter().map(|(pred, span)| {
151+
let obligations = predicates.predicates.iter().map(|(pred, span)| {
153152
predicate_obligation(
154153
pred.subst_supertrait(tcx, &data.to_poly_trait_ref()),
155154
Some(*span),

src/librustc_interface/queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl<'tcx> Queries<'tcx> {
137137
let result = passes::register_plugins(
138138
self.session(),
139139
&*self.codegen_backend().metadata_loader(),
140-
self.compiler.register_lints.as_ref().map(|p| &**p).unwrap_or_else(|| empty),
140+
self.compiler.register_lints.as_deref().unwrap_or_else(|| empty),
141141
krate,
142142
&crate_name,
143143
);

src/librustc_middle/dep_graph/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
7272
})
7373
}
7474

75-
fn read_deps<OP>(op: OP) -> ()
75+
fn read_deps<OP>(op: OP)
7676
where
77-
OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps>>) -> (),
77+
OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps>>),
7878
{
7979
ty::tls::with_context_opt(|icx| {
8080
let icx = if let Some(icx) = icx { icx } else { return };

src/librustc_middle/hir/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ pub fn provide(providers: &mut Providers<'_>) {
7878
&tcx.untracked_crate.modules[&module]
7979
};
8080
providers.hir_owner = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].signature;
81-
providers.hir_owner_nodes =
82-
|tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_ref().map(|nodes| &**nodes);
81+
providers.hir_owner_nodes = |tcx, id| tcx.index_hir(LOCAL_CRATE).map[id].with_bodies.as_deref();
8382
map::provide(providers);
8483
}

src/librustc_middle/ty/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'tcx> AssociatedItems<'tcx> {
280280
&self,
281281
name: Symbol,
282282
) -> impl '_ + Iterator<Item = &ty::AssocItem> {
283-
self.items.get_by_key(&name).map(|v| *v)
283+
self.items.get_by_key(&name).copied()
284284
}
285285

286286
/// Returns an iterator over all associated items with the given name.

src/librustc_middle/ty/trait_def.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,7 @@ impl<'tcx> TyCtxt<'tcx> {
171171
pub fn all_impls(self, def_id: DefId) -> impl Iterator<Item = DefId> + 'tcx {
172172
let TraitImpls { blanket_impls, non_blanket_impls } = self.trait_impls_of(def_id);
173173

174-
blanket_impls
175-
.into_iter()
176-
.chain(non_blanket_impls.into_iter().map(|(_, v)| v).flatten())
177-
.cloned()
174+
blanket_impls.iter().chain(non_blanket_impls.iter().map(|(_, v)| v).flatten()).cloned()
178175
}
179176
}
180177

src/librustc_mir_build/hair/pattern/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl<'tcx> MatchVisitor<'_, 'tcx> {
246246
);
247247
}
248248

249-
adt_defined_here(&mut cx, &mut err, pattern_ty, &witnesses);
249+
adt_defined_here(&cx, &mut err, pattern_ty, &witnesses);
250250
err.note(&format!("the matched value is of type `{}`", pattern_ty));
251251
err.emit();
252252
}

src/librustc_mir_build/hair/pattern/const_to_pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl<'a, 'tcx> ConstToPat<'a, 'tcx> {
121121
)
122122
}
123123
traits::NonStructuralMatchTy::Dynamic => {
124-
format!("trait objects cannot be used in patterns")
124+
"trait objects cannot be used in patterns".to_string()
125125
}
126126
traits::NonStructuralMatchTy::Param => {
127127
bug!("use of constant whose type is a parameter inside a pattern")

0 commit comments

Comments
 (0)