Skip to content

Commit 332e031

Browse files
committed
Fix the lint in clippy itself
1 parent 73cd954 commit 332e031

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

clippy_lints/src/dereference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ fn walk_parents<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> (Position, &
760760
.and_then(|subs| subs.get(1..))
761761
{
762762
Some(subs) => cx.tcx.mk_substs(subs.iter().copied()),
763-
None => cx.tcx.mk_substs([].iter()),
763+
None => cx.tcx.mk_substs(std::iter::empty::<ty::subst::GenericArg<'_>>()),
764764
} && let impl_ty = if cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref() {
765765
// Trait methods taking `&self`
766766
sub_ty

clippy_lints/src/derive.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,10 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
516516
tcx.mk_predicates(ty_predicates.iter().map(|&(p, _)| p).chain(
517517
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
518518
tcx.mk_predicate(Binder::dummy(PredicateKind::Trait(TraitPredicate {
519-
trait_ref: TraitRef::new(eq_trait_id, tcx.mk_substs([tcx.mk_param_from_def(param)].into_iter())),
519+
trait_ref: TraitRef::new(
520+
eq_trait_id,
521+
tcx.mk_substs(std::iter::once(tcx.mk_param_from_def(param))),
522+
),
520523
constness: BoundConstness::NotConst,
521524
polarity: ImplPolarity::Positive,
522525
})))

clippy_lints/src/redundant_slicing.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use rustc_middle::ty::adjustment::{Adjust, AutoBorrow, AutoBorrowMutability};
1111
use rustc_middle::ty::subst::GenericArg;
1212
use rustc_session::{declare_lint_pass, declare_tool_lint};
1313

14+
use std::iter;
15+
1416
declare_clippy_lint! {
1517
/// ### What it does
1618
/// Checks for redundant slicing expressions which use the full range, and
@@ -134,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing {
134136
} else if let Some(target_id) = cx.tcx.lang_items().deref_target() {
135137
if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions(
136138
cx.param_env,
137-
cx.tcx.mk_projection(target_id, cx.tcx.mk_substs([GenericArg::from(indexed_ty)].into_iter())),
139+
cx.tcx.mk_projection(target_id, cx.tcx.mk_substs(iter::once(GenericArg::from(indexed_ty)))),
138140
) {
139141
if deref_ty == expr_ty {
140142
let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0;

clippy_lints/src/types/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,7 @@ impl Types {
490490
}
491491
}
492492
}
493+
#[allow(clippy::iter_empty)]
493494
match *qpath {
494495
QPath::Resolved(Some(ty), p) => {
495496
context.is_nested_call = true;

clippy_lints/src/utils/conf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ define_Conf! {
350350
/// Lint: DISALLOWED_SCRIPT_IDENTS.
351351
///
352352
/// The list of unicode scripts allowed to be used in the scope.
353-
(allowed_scripts: Vec<String> = ["Latin"].iter().map(ToString::to_string).collect()),
353+
(allowed_scripts: Vec<String> = vec!["Latin".to_string()]),
354354
/// Lint: NON_SEND_FIELDS_IN_SEND_TY.
355355
///
356356
/// Whether to apply the raw pointer heuristic to determine if a type is `Send`.

clippy_lints/src/utils/internal_lints/metadata_collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ fn get_lint_group_and_level_or_lint(
797797
let result = cx.lint_store.check_lint_name(
798798
lint_name,
799799
Some(sym::clippy),
800-
&[Ident::with_dummy_span(sym::clippy)].into_iter().collect(),
800+
&std::iter::once(Ident::with_dummy_span(sym::clippy)).collect(),
801801
);
802802
if let CheckLintNameResult::Tool(Ok(lint_lst)) = result {
803803
if let Some(group) = get_lint_group(cx, lint_lst[0]) {

0 commit comments

Comments
 (0)