Fix the lint in clippy itself

This commit is contained in:
Sosthène Guédon 2022-07-16 12:44:33 +02:00
parent 73cd95465e
commit 332e03146e
6 changed files with 11 additions and 5 deletions

View file

@ -760,7 +760,7 @@ fn walk_parents<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> (Position, &
.and_then(|subs| subs.get(1..)) .and_then(|subs| subs.get(1..))
{ {
Some(subs) => cx.tcx.mk_substs(subs.iter().copied()), Some(subs) => cx.tcx.mk_substs(subs.iter().copied()),
None => cx.tcx.mk_substs([].iter()), None => cx.tcx.mk_substs(std::iter::empty::<ty::subst::GenericArg<'_>>()),
} && let impl_ty = if cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref() { } && let impl_ty = if cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref() {
// Trait methods taking `&self` // Trait methods taking `&self`
sub_ty sub_ty

View file

@ -516,7 +516,10 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
tcx.mk_predicates(ty_predicates.iter().map(|&(p, _)| p).chain( tcx.mk_predicates(ty_predicates.iter().map(|&(p, _)| p).chain(
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| { params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
tcx.mk_predicate(Binder::dummy(PredicateKind::Trait(TraitPredicate { tcx.mk_predicate(Binder::dummy(PredicateKind::Trait(TraitPredicate {
trait_ref: TraitRef::new(eq_trait_id, tcx.mk_substs([tcx.mk_param_from_def(param)].into_iter())), trait_ref: TraitRef::new(
eq_trait_id,
tcx.mk_substs(std::iter::once(tcx.mk_param_from_def(param))),
),
constness: BoundConstness::NotConst, constness: BoundConstness::NotConst,
polarity: ImplPolarity::Positive, polarity: ImplPolarity::Positive,
}))) })))

View file

@ -11,6 +11,8 @@ use rustc_middle::ty::adjustment::{Adjust, AutoBorrow, AutoBorrowMutability};
use rustc_middle::ty::subst::GenericArg; use rustc_middle::ty::subst::GenericArg;
use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_session::{declare_lint_pass, declare_tool_lint};
use std::iter;
declare_clippy_lint! { declare_clippy_lint! {
/// ### What it does /// ### What it does
/// Checks for redundant slicing expressions which use the full range, and /// Checks for redundant slicing expressions which use the full range, and
@ -134,7 +136,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantSlicing {
} else if let Some(target_id) = cx.tcx.lang_items().deref_target() { } else if let Some(target_id) = cx.tcx.lang_items().deref_target() {
if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions( if let Ok(deref_ty) = cx.tcx.try_normalize_erasing_regions(
cx.param_env, cx.param_env,
cx.tcx.mk_projection(target_id, cx.tcx.mk_substs([GenericArg::from(indexed_ty)].into_iter())), cx.tcx.mk_projection(target_id, cx.tcx.mk_substs(iter::once(GenericArg::from(indexed_ty)))),
) { ) {
if deref_ty == expr_ty { if deref_ty == expr_ty {
let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0; let snip = snippet_with_context(cx, indexed.span, ctxt, "..", &mut app).0;

View file

@ -490,6 +490,7 @@ impl Types {
} }
} }
} }
#[allow(clippy::iter_empty)]
match *qpath { match *qpath {
QPath::Resolved(Some(ty), p) => { QPath::Resolved(Some(ty), p) => {
context.is_nested_call = true; context.is_nested_call = true;

View file

@ -350,7 +350,7 @@ define_Conf! {
/// Lint: DISALLOWED_SCRIPT_IDENTS. /// Lint: DISALLOWED_SCRIPT_IDENTS.
/// ///
/// The list of unicode scripts allowed to be used in the scope. /// The list of unicode scripts allowed to be used in the scope.
(allowed_scripts: Vec<String> = ["Latin"].iter().map(ToString::to_string).collect()), (allowed_scripts: Vec<String> = vec!["Latin".to_string()]),
/// Lint: NON_SEND_FIELDS_IN_SEND_TY. /// Lint: NON_SEND_FIELDS_IN_SEND_TY.
/// ///
/// Whether to apply the raw pointer heuristic to determine if a type is `Send`. /// Whether to apply the raw pointer heuristic to determine if a type is `Send`.

View file

@ -797,7 +797,7 @@ fn get_lint_group_and_level_or_lint(
let result = cx.lint_store.check_lint_name( let result = cx.lint_store.check_lint_name(
lint_name, lint_name,
Some(sym::clippy), Some(sym::clippy),
&[Ident::with_dummy_span(sym::clippy)].into_iter().collect(), &std::iter::once(Ident::with_dummy_span(sym::clippy)).collect(),
); );
if let CheckLintNameResult::Tool(Ok(lint_lst)) = result { if let CheckLintNameResult::Tool(Ok(lint_lst)) = result {
if let Some(group) = get_lint_group(cx, lint_lst[0]) { if let Some(group) = get_lint_group(cx, lint_lst[0]) {