Skip to content

Commit adf759b

Browse files
committed
fix couple of clippy findings:
filter_map_identity iter_kv_map needless_question_mark redundant_at_rest_pattern filter_next derivable_impls
1 parent cec34a4 commit adf759b

File tree

6 files changed

+8
-16
lines changed

6 files changed

+8
-16
lines changed

compiler/rustc_builtin_macros/src/asm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ fn parse_clobber_abi<'a>(p: &mut Parser<'a>, args: &mut AsmArgs) -> PResult<'a,
401401
// should have errored above during parsing
402402
[] => unreachable!(),
403403
[(abi, _span)] => args.clobber_abis.push((*abi, full_span)),
404-
[abis @ ..] => {
404+
abis => {
405405
for (abi, span) in abis {
406406
args.clobber_abis.push((*abi, *span));
407407
}

compiler/rustc_parse/src/parser/generics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'a> Parser<'a> {
4949
&& self.check_ident()
5050
// `Const` followed by IDENT
5151
{
52-
return Ok(self.recover_const_param_with_mistyped_const(preceding_attrs, ident)?);
52+
return self.recover_const_param_with_mistyped_const(preceding_attrs, ident);
5353
}
5454

5555
// Parse optional colon and param bounds.

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ pub(super) fn encode_all_query_results<'tcx>(
183183
encoder: &mut CacheEncoder<'_, 'tcx>,
184184
query_result_index: &mut EncodedDepNodeIndex,
185185
) {
186-
for encode in super::ENCODE_QUERY_RESULTS.iter().copied().filter_map(|e| e) {
186+
for encode in super::ENCODE_QUERY_RESULTS.iter().copied().flatten() {
187187
encode(tcx, encoder, query_result_index);
188188
}
189189
}

compiler/rustc_session/src/code_stats.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,8 @@ impl CodeStats {
227227
}
228228

229229
pub fn print_vtable_sizes(&self, crate_name: &str) {
230-
let mut infos = std::mem::take(&mut *self.vtable_sizes.lock())
231-
.into_iter()
232-
.map(|(_did, stats)| stats)
233-
.collect::<Vec<_>>();
230+
let mut infos =
231+
std::mem::take(&mut *self.vtable_sizes.lock()).into_values().collect::<Vec<_>>();
234232

235233
// Primary sort: cost % in reverse order (from largest to smallest)
236234
// Secondary sort: trait_name

compiler/rustc_trait_selection/src/traits/error_reporting/on_unimplemented.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,18 +329,13 @@ pub struct OnUnimplementedNote {
329329
}
330330

331331
/// Append a message for `~const Trait` errors.
332-
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
332+
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
333333
pub enum AppendConstMessage {
334+
#[default]
334335
Default,
335336
Custom(Symbol),
336337
}
337338

338-
impl Default for AppendConstMessage {
339-
fn default() -> Self {
340-
AppendConstMessage::Default
341-
}
342-
}
343-
344339
impl<'tcx> OnUnimplementedDirective {
345340
fn parse(
346341
tcx: TyCtxt<'tcx>,

library/test/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,7 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) {
183183

184184
let test = tests
185185
.into_iter()
186-
.filter(|test| test.desc.name.as_slice() == name)
187-
.next()
186+
.find(|test| test.desc.name.as_slice() == name)
188187
.unwrap_or_else(|| panic!("couldn't find a test with the provided name '{name}'"));
189188
let TestDescAndFn { desc, testfn } = test;
190189
match testfn.into_runnable() {

0 commit comments

Comments
 (0)