Skip to content

Commit 08e60c6

Browse files
authored
Rollup merge of #78733 - matthiaskrgr:cl11ppy, r=jyn514
fix a couple of clippy warnings: filter_next manual_strip redundant_static_lifetimes single_char_pattern unnecessary_cast unused_unit op_ref redundant_closure useless_conversion
2 parents 0878abd + bcd2f2d commit 08e60c6

File tree

11 files changed

+14
-21
lines changed

11 files changed

+14
-21
lines changed

compiler/rustc_ast/src/attr/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ pub fn list_contains_name(items: &[NestedMetaItem], name: Symbol) -> bool {
360360
impl MetaItem {
361361
fn token_trees_and_spacings(&self) -> Vec<TreeAndSpacing> {
362362
let mut idents = vec![];
363-
let mut last_pos = BytePos(0 as u32);
363+
let mut last_pos = BytePos(0_u32);
364364
for (i, segment) in self.path.segments.iter().enumerate() {
365365
let is_first = i == 0;
366366
if !is_first {

compiler/rustc_infer/src/infer/error_reporting/need_type_info.rs

-1
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
739739
"cannot infer {} {} {} `{}`{}",
740740
kind_str, preposition, descr, type_name, parent_desc
741741
)
742-
.into()
743742
}
744743
}
745744
}

compiler/rustc_interface/src/util.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ pub fn get_codegen_backend(sopts: &config::Options) -> Box<dyn CodegenBackend> {
246246

247247
INIT.call_once(|| {
248248
#[cfg(feature = "llvm")]
249-
const DEFAULT_CODEGEN_BACKEND: &'static str = "llvm";
249+
const DEFAULT_CODEGEN_BACKEND: &str = "llvm";
250250

251251
#[cfg(not(feature = "llvm"))]
252-
const DEFAULT_CODEGEN_BACKEND: &'static str = "cranelift";
252+
const DEFAULT_CODEGEN_BACKEND: &str = "cranelift";
253253

254254
let codegen_name = sopts
255255
.debugging_opts
@@ -414,11 +414,10 @@ pub fn get_codegen_sysroot(backend_name: &str) -> fn() -> Box<dyn CodegenBackend
414414
let libdir = filesearch::relative_target_lib_path(&sysroot, &target);
415415
sysroot.join(libdir).with_file_name("codegen-backends")
416416
})
417-
.filter(|f| {
417+
.find(|f| {
418418
info!("codegen backend candidate: {}", f.display());
419419
f.exists()
420-
})
421-
.next();
420+
});
422421
let sysroot = sysroot.unwrap_or_else(|| {
423422
let candidates = sysroot_candidates
424423
.iter()

compiler/rustc_middle/src/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ impl<'tcx> TyCtxt<'tcx> {
399399
def_id: DefId,
400400
id: Option<HirId>,
401401
span: Span,
402-
unmarked: impl FnOnce(Span, DefId) -> (),
402+
unmarked: impl FnOnce(Span, DefId),
403403
) {
404404
let soft_handler = |lint, span, msg: &_| {
405405
self.struct_span_lint_hir(lint, id.unwrap_or(hir::CRATE_HIR_ID), span, |lint| {

compiler/rustc_middle/src/mir/terminator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl SwitchTargets {
4646
pub fn new(targets: impl Iterator<Item = (u128, BasicBlock)>, otherwise: BasicBlock) -> Self {
4747
let (values, mut targets): (SmallVec<_>, SmallVec<_>) = targets.unzip();
4848
targets.push(otherwise);
49-
Self { values: values.into(), targets }
49+
Self { values, targets }
5050
}
5151

5252
/// Builds a switch targets definition that jumps to `then` if the tested value equals `value`,

compiler/rustc_mir/src/borrow_check/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
120120
let move_out = self.move_data.moves[(*move_site).moi];
121121
let moved_place = &self.move_data.move_paths[move_out.path].place;
122122
// `*(_1)` where `_1` is a `Box` is actually a move out.
123-
let is_box_move = moved_place.as_ref().projection == &[ProjectionElem::Deref]
123+
let is_box_move = moved_place.as_ref().projection == [ProjectionElem::Deref]
124124
&& self.body.local_decls[moved_place.local].ty.is_box();
125125

126126
!is_box_move

compiler/rustc_mir/src/transform/match_branches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
6363
};
6464

6565
// Check that destinations are identical, and if not, then don't optimize this block
66-
if &bbs[first].terminator().kind != &bbs[second].terminator().kind {
66+
if bbs[first].terminator().kind != bbs[second].terminator().kind {
6767
continue;
6868
}
6969

compiler/rustc_resolve/src/late/diagnostics.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1886,9 +1886,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
18861886
if snippet.starts_with('&') && !snippet.starts_with("&'") {
18871887
introduce_suggestion
18881888
.push((param.span, format!("&'a {}", &snippet[1..])));
1889-
} else if snippet.starts_with("&'_ ") {
1890-
introduce_suggestion
1891-
.push((param.span, format!("&'a {}", &snippet[4..])));
1889+
} else if let Some(stripped) = snippet.strip_prefix("&'_ ") {
1890+
introduce_suggestion.push((param.span, format!("&'a {}", &stripped)));
18921891
}
18931892
}
18941893
}

compiler/rustc_span/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,7 @@ fn normalize_src(src: &mut String, start_pos: BytePos) -> Vec<NormalizedPos> {
15741574

15751575
/// Removes UTF-8 BOM, if any.
15761576
fn remove_bom(src: &mut String, normalized_pos: &mut Vec<NormalizedPos>) {
1577-
if src.starts_with("\u{feff}") {
1577+
if src.starts_with('\u{feff}') {
15781578
src.drain(..3);
15791579
normalized_pos.push(NormalizedPos { pos: BytePos(0), diff: 3 });
15801580
}

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -1388,11 +1388,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
13881388
trait_ref: &ty::PolyTraitRef<'tcx>,
13891389
) {
13901390
let get_trait_impl = |trait_def_id| {
1391-
self.tcx.find_map_relevant_impl(
1392-
trait_def_id,
1393-
trait_ref.skip_binder().self_ty(),
1394-
|impl_def_id| Some(impl_def_id),
1395-
)
1391+
self.tcx.find_map_relevant_impl(trait_def_id, trait_ref.skip_binder().self_ty(), Some)
13961392
};
13971393
let required_trait_path = self.tcx.def_path_str(trait_ref.def_id());
13981394
let all_traits = self.tcx.all_traits(LOCAL_CRATE);

compiler/rustc_trait_selection/src/traits/fulfill.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
499499
Err(ErrorHandled::TooGeneric) => {
500500
pending_obligation.stalled_on = substs
501501
.iter()
502-
.filter_map(|ty| TyOrConstInferVar::maybe_from_generic_arg(ty))
502+
.filter_map(TyOrConstInferVar::maybe_from_generic_arg)
503503
.collect();
504504
ProcessResult::Unchanged
505505
}

0 commit comments

Comments
 (0)