mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Auto merge of #12748 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
This commit is contained in:
commit
1325425589
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clippy"
|
||||
version = "0.1.79"
|
||||
version = "0.1.80"
|
||||
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
|
||||
repository = "https://github.com/rust-lang/rust-clippy"
|
||||
readme = "README.md"
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clippy_config"
|
||||
version = "0.1.79"
|
||||
version = "0.1.80"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clippy_lints"
|
||||
version = "0.1.79"
|
||||
version = "0.1.80"
|
||||
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
|
||||
repository = "https://github.com/rust-lang/rust-clippy"
|
||||
readme = "README.md"
|
||||
|
@ -9,8 +9,8 @@ use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_ty, Visitor};
|
||||
use rustc_hir::{
|
||||
self as hir, BindingAnnotation, Body, BodyId, BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node,
|
||||
Pat, PatKind, Path, QPath, TyKind, UnOp,
|
||||
self as hir, BindingMode, Body, BodyId, BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, Pat,
|
||||
PatKind, Path, QPath, TyKind, UnOp,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
|
||||
@ -599,7 +599,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing<'tcx> {
|
||||
}
|
||||
|
||||
fn check_pat(&mut self, cx: &LateContext<'tcx>, pat: &'tcx Pat<'_>) {
|
||||
if let PatKind::Binding(BindingAnnotation::REF, id, name, _) = pat.kind {
|
||||
if let PatKind::Binding(BindingMode::REF, id, name, _) = pat.kind {
|
||||
if let Some(opt_prev_pat) = self.ref_locals.get_mut(&id) {
|
||||
// This binding id has been seen before. Add this pattern to the list of changes.
|
||||
if let Some(prev_pat) = opt_prev_pat {
|
||||
|
@ -5,7 +5,7 @@ use clippy_utils::ty::type_diagnostic_name;
|
||||
use clippy_utils::usage::{local_used_after_expr, local_used_in};
|
||||
use clippy_utils::{get_path_from_caller_to_method_type, is_adjusted, path_to_local, path_to_local_id};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BindingAnnotation, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety};
|
||||
use rustc_hir::{BindingMode, Expr, ExprKind, FnRetTy, Param, PatKind, QPath, TyKind, Unsafety};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::{
|
||||
@ -229,7 +229,7 @@ fn check_inputs(
|
||||
&& params.iter().zip(self_arg.into_iter().chain(args)).all(|(p, arg)| {
|
||||
matches!(
|
||||
p.pat.kind,
|
||||
PatKind::Binding(BindingAnnotation::NONE, id, _, None)
|
||||
PatKind::Binding(BindingMode::NONE, id, _, None)
|
||||
if path_to_local_id(arg, id)
|
||||
)
|
||||
// Only allow adjustments which change regions (i.e. re-borrowing).
|
||||
|
@ -4,7 +4,7 @@ use clippy_utils::source::snippet_with_applicability;
|
||||
use clippy_utils::{is_expn_of, path_def_id};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::{BindingAnnotation, Block, BlockCheckMode, Expr, ExprKind, Node, PatKind, QPath, Stmt, StmtKind};
|
||||
use rustc_hir::{BindingMode, Block, BlockCheckMode, Expr, ExprKind, Node, PatKind, QPath, Stmt, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::{sym, ExpnId};
|
||||
@ -114,7 +114,7 @@ fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>)
|
||||
&& let Node::Pat(res_pat) = cx.tcx.hir_node(expr_res)
|
||||
|
||||
// Find id of the local we found in the block
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, local_hir_id, _ident, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, local_hir_id, _ident, None) = local.pat.kind
|
||||
|
||||
// If those two are the same hir id
|
||||
&& res_pat.hir_id == local_hir_id
|
||||
|
@ -185,7 +185,7 @@ fn is_mutable_pat(cx: &LateContext<'_>, pat: &hir::Pat<'_>, tys: &mut DefIdSet)
|
||||
if let hir::PatKind::Wild = pat.kind {
|
||||
return false; // ignore `_` patterns
|
||||
}
|
||||
if cx.tcx.has_typeck_results(pat.hir_id.owner.to_def_id()) {
|
||||
if cx.tcx.has_typeck_results(pat.hir_id.owner.def_id) {
|
||||
is_mutable_ty(cx, cx.tcx.typeck(pat.hir_id.owner.def_id).pat_ty(pat), tys)
|
||||
} else {
|
||||
false
|
||||
@ -233,7 +233,7 @@ fn mutates_static<'tcx>(cx: &LateContext<'tcx>, body: &'tcx hir::Body<'_>) -> bo
|
||||
Call(_, args) => {
|
||||
let mut tys = DefIdSet::default();
|
||||
for arg in args {
|
||||
if cx.tcx.has_typeck_results(arg.hir_id.owner.to_def_id())
|
||||
if cx.tcx.has_typeck_results(arg.hir_id.owner.def_id)
|
||||
&& is_mutable_ty(cx, cx.tcx.typeck(arg.hir_id.owner.def_id).expr_ty(arg), &mut tys)
|
||||
&& is_mutated_static(arg)
|
||||
{
|
||||
@ -246,7 +246,7 @@ fn mutates_static<'tcx>(cx: &LateContext<'tcx>, body: &'tcx hir::Body<'_>) -> bo
|
||||
MethodCall(_, receiver, args, _) => {
|
||||
let mut tys = DefIdSet::default();
|
||||
for arg in std::iter::once(receiver).chain(args.iter()) {
|
||||
if cx.tcx.has_typeck_results(arg.hir_id.owner.to_def_id())
|
||||
if cx.tcx.has_typeck_results(arg.hir_id.owner.def_id)
|
||||
&& is_mutable_ty(cx, cx.tcx.typeck(arg.hir_id.owner.def_id).expr_ty(arg), &mut tys)
|
||||
&& is_mutated_static(arg)
|
||||
{
|
||||
|
@ -93,12 +93,9 @@ fn find_slice_values(cx: &LateContext<'_>, pat: &hir::Pat<'_>) -> FxIndexMap<Hir
|
||||
let mut slices: FxIndexMap<HirId, SliceLintInformation> = FxIndexMap::default();
|
||||
pat.walk_always(|pat| {
|
||||
// We'll just ignore mut and ref mut for simplicity sake right now
|
||||
if let hir::PatKind::Binding(
|
||||
hir::BindingAnnotation(by_ref, hir::Mutability::Not),
|
||||
value_hir_id,
|
||||
ident,
|
||||
sub_pat,
|
||||
) = pat.kind && by_ref != hir::ByRef::Yes(hir::Mutability::Mut)
|
||||
if let hir::PatKind::Binding(hir::BindingMode(by_ref, hir::Mutability::Not), value_hir_id, ident, sub_pat) =
|
||||
pat.kind
|
||||
&& by_ref != hir::ByRef::Yes(hir::Mutability::Mut)
|
||||
{
|
||||
// This block catches bindings with sub patterns. It would be hard to build a correct suggestion
|
||||
// for them and it's likely that the user knows what they are doing in such a case.
|
||||
|
@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
|
||||
use clippy_utils::visitors::is_local_used;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{BindingAnnotation, Mutability};
|
||||
use rustc_hir::{BindingMode, Mutability};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
||||
@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for LetIfSeq {
|
||||
};
|
||||
|
||||
let mutability = match mode {
|
||||
BindingAnnotation(_, Mutability::Mut) => "<mut> ",
|
||||
BindingMode(_, Mutability::Mut) => "<mut> ",
|
||||
_ => "",
|
||||
};
|
||||
|
||||
|
@ -7,7 +7,7 @@ use clippy_utils::{higher, is_res_lang_ctor, path_res, peel_blocks_with_stmt};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::lang_items::LangItem;
|
||||
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Node, Pat, PatKind, Stmt, StmtKind};
|
||||
use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, Node, Pat, PatKind, Stmt, StmtKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::Span;
|
||||
|
||||
@ -107,7 +107,7 @@ fn get_binding(pat: &Pat<'_>) -> Option<HirId> {
|
||||
hir_id = None;
|
||||
return;
|
||||
}
|
||||
if let BindingAnnotation::NONE = annotation {
|
||||
if let BindingMode::NONE = annotation {
|
||||
hir_id = Some(id);
|
||||
}
|
||||
});
|
||||
|
@ -2,7 +2,7 @@ use super::MUT_RANGE_BOUND;
|
||||
use clippy_utils::diagnostics::span_lint_and_note;
|
||||
use clippy_utils::{get_enclosing_block, higher, path_to_local};
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, Node, PatKind};
|
||||
use rustc_hir::{BindingMode, Expr, ExprKind, HirId, Node, PatKind};
|
||||
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::LateContext;
|
||||
@ -41,7 +41,7 @@ fn mut_warn_with_span(cx: &LateContext<'_>, span: Option<Span>) {
|
||||
fn check_for_mutability(cx: &LateContext<'_>, bound: &Expr<'_>) -> Option<HirId> {
|
||||
if let Some(hir_id) = path_to_local(bound)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir_node(hir_id)
|
||||
&& let PatKind::Binding(BindingAnnotation::MUT, ..) = pat.kind
|
||||
&& let PatKind::Binding(BindingMode::MUT, ..) = pat.kind
|
||||
{
|
||||
return Some(hir_id);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::intravisit::{walk_expr, Visitor};
|
||||
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Mutability, Node, Pat, PatKind, Stmt, StmtKind};
|
||||
use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, Mutability, Node, Pat, PatKind, Stmt, StmtKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::SyntaxContext;
|
||||
@ -61,7 +61,7 @@ pub(super) fn check<'tcx>(
|
||||
let node = cx.tcx.hir_node(hir_id);
|
||||
if let Node::Pat(pat) = node
|
||||
&& let PatKind::Binding(bind_ann, ..) = pat.kind
|
||||
&& !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut))
|
||||
&& !matches!(bind_ann, BindingMode(_, Mutability::Mut))
|
||||
&& let Node::LetStmt(parent_let_expr) = cx.tcx.parent_hir_node(hir_id)
|
||||
&& let Some(init) = parent_let_expr.init
|
||||
{
|
||||
|
@ -1,11 +1,12 @@
|
||||
use super::UNUSED_ENUMERATE_INDEX;
|
||||
use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_then};
|
||||
use clippy_utils::source::snippet;
|
||||
use clippy_utils::{match_def_path, pat_is_wild, sugg};
|
||||
use clippy_utils::{pat_is_wild, sugg};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_hir::{Expr, ExprKind, Pat, PatKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty;
|
||||
use rustc_span::sym;
|
||||
|
||||
/// Checks for the `UNUSED_ENUMERATE_INDEX` lint.
|
||||
///
|
||||
@ -16,9 +17,9 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, pat: &Pat<'tcx>, arg: &Expr<'_
|
||||
&& let ty = cx.typeck_results().expr_ty(arg)
|
||||
&& pat_is_wild(cx, &index.kind, body)
|
||||
&& let ty::Adt(base, _) = *ty.kind()
|
||||
&& match_def_path(cx, base.did(), &clippy_utils::paths::CORE_ITER_ENUMERATE_STRUCT)
|
||||
&& cx.tcx.is_diagnostic_item(sym::Enumerate, base.did())
|
||||
&& let Some((DefKind::AssocFn, call_id)) = cx.typeck_results().type_dependent_def(arg.hir_id)
|
||||
&& match_def_path(cx, call_id, &clippy_utils::paths::CORE_ITER_ENUMERATE_METHOD)
|
||||
&& cx.tcx.is_diagnostic_item(sym::enumerate_method, call_id)
|
||||
{
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
|
@ -4,7 +4,7 @@ use clippy_utils::source::snippet_opt;
|
||||
use clippy_utils::visitors::{is_local_used, local_used_once};
|
||||
use clippy_utils::{is_trait_method, path_to_local_id};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BindingAnnotation, ExprKind, LetStmt, Node, PatKind, StmtKind};
|
||||
use rustc_hir::{BindingMode, ExprKind, LetStmt, Node, PatKind, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::sym;
|
||||
@ -62,7 +62,7 @@ impl_lint_pass!(ManualHashOne => [MANUAL_HASH_ONE]);
|
||||
impl LateLintPass<'_> for ManualHashOne {
|
||||
fn check_local(&mut self, cx: &LateContext<'_>, local: &LetStmt<'_>) {
|
||||
// `let mut hasher = seg.build_hasher();`
|
||||
if let PatKind::Binding(BindingAnnotation::MUT, hasher, _, None) = local.pat.kind
|
||||
if let PatKind::Binding(BindingMode::MUT, hasher, _, None) = local.pat.kind
|
||||
&& let Some(init) = local.init
|
||||
&& !init.span.from_expansion()
|
||||
&& let ExprKind::MethodCall(seg, build_hasher, [], _) = init.kind
|
||||
|
@ -11,7 +11,7 @@ use rustc_ast::util::parser::PREC_POSTFIX;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::LangItem::{OptionNone, OptionSome};
|
||||
use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, Mutability, Pat, PatKind, Path, QPath};
|
||||
use rustc_hir::{BindingMode, Expr, ExprKind, HirId, Mutability, Pat, PatKind, Path, QPath};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::{sym, SyntaxContext};
|
||||
|
||||
@ -139,7 +139,7 @@ where
|
||||
}
|
||||
|
||||
// `ref` and `ref mut` annotations were handled earlier.
|
||||
let annotation = if matches!(annotation, BindingAnnotation::MUT) {
|
||||
let annotation = if matches!(annotation, BindingMode::MUT) {
|
||||
"mut "
|
||||
} else {
|
||||
""
|
||||
|
@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::source::snippet_with_applicability;
|
||||
use clippy_utils::{is_res_lang_ctor, path_res, peel_blocks};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Arm, BindingAnnotation, ByRef, Expr, ExprKind, LangItem, Mutability, PatKind, QPath};
|
||||
use rustc_hir::{Arm, BindingMode, ByRef, Expr, ExprKind, LangItem, Mutability, PatKind, QPath};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty;
|
||||
|
||||
@ -67,7 +67,7 @@ fn is_none_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> bool {
|
||||
fn is_ref_some_arm(cx: &LateContext<'_>, arm: &Arm<'_>) -> Option<Mutability> {
|
||||
if let PatKind::TupleStruct(ref qpath, [first_pat, ..], _) = arm.pat.kind
|
||||
&& is_res_lang_ctor(cx, cx.qpath_res(qpath, arm.pat.hir_id), LangItem::OptionSome)
|
||||
&& let PatKind::Binding(BindingAnnotation(ByRef::Yes(mutabl), _), .., ident, _) = first_pat.kind
|
||||
&& let PatKind::Binding(BindingMode(ByRef::Yes(mutabl), _), .., ident, _) = first_pat.kind
|
||||
&& let ExprKind::Call(e, [arg]) = peel_blocks(arm.body).kind
|
||||
&& is_res_lang_ctor(cx, path_res(cx, e), LangItem::OptionSome)
|
||||
&& let ExprKind::Path(QPath::Resolved(_, path2)) = arg.kind
|
||||
|
@ -8,7 +8,7 @@ use clippy_utils::{
|
||||
};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::LangItem::OptionNone;
|
||||
use rustc_hir::{Arm, BindingAnnotation, ByRef, Expr, ExprKind, ItemKind, Node, Pat, PatKind, Path, QPath};
|
||||
use rustc_hir::{Arm, BindingMode, ByRef, Expr, ExprKind, ItemKind, Node, Pat, PatKind, Path, QPath};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::sym;
|
||||
|
||||
@ -178,7 +178,7 @@ fn pat_same_as_expr(pat: &Pat<'_>, expr: &Expr<'_>) -> bool {
|
||||
},
|
||||
)),
|
||||
) => {
|
||||
return !matches!(annot, BindingAnnotation(ByRef::Yes(_), _)) && pat_ident.name == first_seg.ident.name;
|
||||
return !matches!(annot, BindingMode(ByRef::Yes(_), _)) && pat_ident.name == first_seg.ident.name;
|
||||
},
|
||||
// Example: `Custom::TypeA => Custom::TypeB`, or `None => None`
|
||||
(PatKind::Path(QPath::Resolved(_, p_path)), ExprKind::Path(QPath::Resolved(_, e_path))) => {
|
||||
|
@ -4,7 +4,7 @@ use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, peel_mid_ty_re
|
||||
use clippy_utils::{is_lint_allowed, is_unit_expr, is_wild, peel_blocks, peel_hir_pat_refs, peel_n_hir_expr_refs};
|
||||
use core::cmp::max;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Arm, BindingAnnotation, Block, Expr, ExprKind, Pat, PatKind};
|
||||
use rustc_hir::{Arm, BindingMode, Block, Expr, ExprKind, Pat, PatKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::{sym, Span};
|
||||
@ -166,7 +166,7 @@ fn collect_pat_paths<'a>(acc: &mut Vec<Ty<'a>>, cx: &LateContext<'a>, pat: &Pat<
|
||||
let p_ty = cx.typeck_results().pat_ty(p);
|
||||
collect_pat_paths(acc, cx, p, p_ty);
|
||||
}),
|
||||
PatKind::TupleStruct(..) | PatKind::Binding(BindingAnnotation::NONE, .., None) | PatKind::Path(_) => {
|
||||
PatKind::TupleStruct(..) | PatKind::Binding(BindingMode::NONE, .., None) | PatKind::Path(_) => {
|
||||
acc.push(ty);
|
||||
},
|
||||
_ => {},
|
||||
|
@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::source::snippet_with_context;
|
||||
use clippy_utils::ty::is_copy;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BindingAnnotation, ByRef, Expr, ExprKind, MatchSource, Node, PatKind, QPath};
|
||||
use rustc_hir::{BindingMode, ByRef, Expr, ExprKind, MatchSource, Node, PatKind, QPath};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::adjustment::Adjust;
|
||||
use rustc_middle::ty::print::with_forced_trimmed_paths;
|
||||
@ -69,7 +69,7 @@ pub(super) fn check(
|
||||
_ => false,
|
||||
},
|
||||
// local binding capturing a reference
|
||||
Node::LetStmt(l) if matches!(l.pat.kind, PatKind::Binding(BindingAnnotation(ByRef::Yes(_), _), ..)) => {
|
||||
Node::LetStmt(l) if matches!(l.pat.kind, PatKind::Binding(BindingMode(ByRef::Yes(_), _), ..)) => {
|
||||
return;
|
||||
},
|
||||
_ => false,
|
||||
|
@ -1,7 +1,7 @@
|
||||
use clippy_utils::diagnostics::{span_lint, span_lint_and_then};
|
||||
use clippy_utils::source::snippet;
|
||||
use clippy_utils::ty::implements_trait;
|
||||
use rustc_ast::{BindingAnnotation, Mutability};
|
||||
use rustc_ast::{BindingMode, Mutability};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::LateContext;
|
||||
@ -45,7 +45,7 @@ pub(super) fn check<'tcx>(
|
||||
span_lint_and_then(cx, FILTER_NEXT, expr.span, msg, |diag| {
|
||||
let (applicability, pat) = if let Some(id) = path_to_local(recv)
|
||||
&& let hir::Node::Pat(pat) = cx.tcx.hir_node(id)
|
||||
&& let hir::PatKind::Binding(BindingAnnotation(_, Mutability::Not), _, ident, _) = pat.kind
|
||||
&& let hir::PatKind::Binding(BindingMode(_, Mutability::Not), _, ident, _) = pat.kind
|
||||
{
|
||||
(Applicability::Unspecified, Some((pat.span, ident)))
|
||||
} else {
|
||||
|
@ -6,7 +6,7 @@ use clippy_utils::diagnostics::{multispan_sugg, span_lint_and_sugg, span_lint_an
|
||||
use clippy_utils::source::{snippet, snippet_with_applicability};
|
||||
use clippy_utils::ty::is_type_diagnostic_item;
|
||||
use clippy_utils::{pat_is_wild, sugg};
|
||||
use rustc_hir::{BindingAnnotation, Body, BorrowKind, ByRef, Expr, ExprKind, Mutability, Pat, PatKind};
|
||||
use rustc_hir::{BindingMode, Body, BorrowKind, ByRef, Expr, ExprKind, Mutability, Pat, PatKind};
|
||||
use rustc_lint::{LateContext, LintContext};
|
||||
use rustc_middle::ty;
|
||||
use rustc_span::{sym, Span};
|
||||
|
@ -1,7 +1,7 @@
|
||||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use clippy_utils::source::snippet_opt;
|
||||
use clippy_utils::ty::{implements_trait, is_copy};
|
||||
use rustc_ast::BindingAnnotation;
|
||||
use rustc_ast::BindingMode;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Body, Expr, ExprKind, HirId, HirIdSet, PatKind};
|
||||
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
|
||||
@ -89,8 +89,7 @@ pub(super) fn check<'tcx>(
|
||||
}
|
||||
|
||||
match it.kind {
|
||||
PatKind::Binding(BindingAnnotation(_, Mutability::Mut), _, _, _)
|
||||
| PatKind::Ref(_, Mutability::Mut) => {
|
||||
PatKind::Binding(BindingMode(_, Mutability::Mut), _, _, _) | PatKind::Ref(_, Mutability::Mut) => {
|
||||
to_be_discarded = true;
|
||||
false
|
||||
},
|
||||
|
@ -3,7 +3,7 @@ use clippy_utils::source::snippet;
|
||||
use clippy_utils::{is_trait_method, path_to_local};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{BindingAnnotation, Node, PatKind};
|
||||
use rustc_hir::{BindingMode, Node, PatKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::sym;
|
||||
|
||||
@ -22,7 +22,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr
|
||||
if let Some(id) = path_to_local(recv)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir_node(id)
|
||||
&& let PatKind::Binding(ann, _, _, _) = pat.kind
|
||||
&& ann != BindingAnnotation::MUT
|
||||
&& ann != BindingMode::MUT
|
||||
{
|
||||
application = Applicability::Unspecified;
|
||||
diag.span_help(
|
||||
|
@ -51,13 +51,13 @@ pub(super) fn check(cx: &LateContext<'_>, e: &hir::Expr<'_>, recv: &hir::Expr<'_
|
||||
let closure_expr = peel_blocks(closure_body.value);
|
||||
match closure_body.params[0].pat.kind {
|
||||
hir::PatKind::Ref(inner, Mutability::Not) => {
|
||||
if let hir::PatKind::Binding(hir::BindingAnnotation::NONE, .., name, None) = inner.kind {
|
||||
if let hir::PatKind::Binding(hir::BindingMode::NONE, .., name, None) = inner.kind {
|
||||
if ident_eq(name, closure_expr) {
|
||||
lint_explicit_closure(cx, e.span, recv.span, true, msrv);
|
||||
}
|
||||
}
|
||||
},
|
||||
hir::PatKind::Binding(hir::BindingAnnotation::NONE, .., name, None) => {
|
||||
hir::PatKind::Binding(hir::BindingMode::NONE, .., name, None) => {
|
||||
match closure_expr.kind {
|
||||
hir::ExprKind::Unary(hir::UnOp::Deref, inner) => {
|
||||
if ident_eq(name, inner) {
|
||||
|
@ -11,7 +11,7 @@ use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{Applicability, MultiSpan};
|
||||
use rustc_hir::intravisit::{walk_block, walk_expr, Visitor};
|
||||
use rustc_hir::{
|
||||
BindingAnnotation, Block, Expr, ExprKind, HirId, HirIdSet, LetStmt, Mutability, Node, PatKind, Stmt, StmtKind,
|
||||
BindingMode, Block, Expr, ExprKind, HirId, HirIdSet, LetStmt, Mutability, Node, PatKind, Stmt, StmtKind,
|
||||
};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
@ -86,7 +86,7 @@ pub(super) fn check<'tcx>(
|
||||
}
|
||||
},
|
||||
Node::LetStmt(l) => {
|
||||
if let PatKind::Binding(BindingAnnotation::NONE | BindingAnnotation::MUT, id, _, None) = l.pat.kind
|
||||
if let PatKind::Binding(BindingMode::NONE | BindingMode::MUT, id, _, None) = l.pat.kind
|
||||
&& let ty = cx.typeck_results().expr_ty(collect_expr)
|
||||
&& [sym::Vec, sym::VecDeque, sym::BinaryHeap, sym::LinkedList]
|
||||
.into_iter()
|
||||
|
@ -8,7 +8,7 @@ use clippy_utils::{is_diag_item_method, match_def_path, path_to_local_id, paths}
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{
|
||||
BindingAnnotation, Expr, ExprKind, HirId, LangItem, LetStmt, MatchSource, Node, Pat, PatKind, QPath, Stmt, StmtKind,
|
||||
BindingMode, Expr, ExprKind, HirId, LangItem, LetStmt, MatchSource, Node, Pat, PatKind, QPath, Stmt, StmtKind,
|
||||
};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty;
|
||||
@ -129,7 +129,7 @@ fn check_manual_split_once_indirect(
|
||||
let ctxt = expr.span.ctxt();
|
||||
let mut parents = cx.tcx.hir().parent_iter(expr.hir_id);
|
||||
if let (_, Node::LetStmt(local)) = parents.next()?
|
||||
&& let PatKind::Binding(BindingAnnotation::MUT, iter_binding_id, iter_ident, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::MUT, iter_binding_id, iter_ident, None) = local.pat.kind
|
||||
&& let (iter_stmt_id, Node::Stmt(_)) = parents.next()?
|
||||
&& let (_, Node::Block(enclosing_block)) = parents.next()?
|
||||
&& let mut stmts = enclosing_block
|
||||
@ -200,7 +200,7 @@ fn indirect_usage<'tcx>(
|
||||
) -> Option<IndirectUsage<'tcx>> {
|
||||
if let StmtKind::Let(&LetStmt {
|
||||
pat: Pat {
|
||||
kind: PatKind::Binding(BindingAnnotation::NONE, _, ident, None),
|
||||
kind: PatKind::Binding(BindingMode::NONE, _, ident, None),
|
||||
..
|
||||
},
|
||||
init: Some(init_expr),
|
||||
|
@ -1,7 +1,6 @@
|
||||
use clippy_utils::diagnostics::{multispan_sugg_with_applicability, span_lint_hir_and_then};
|
||||
use clippy_utils::paths::{CORE_ITER_ENUMERATE_METHOD, CORE_ITER_ENUMERATE_STRUCT};
|
||||
use clippy_utils::source::{snippet, snippet_opt};
|
||||
use clippy_utils::{expr_or_init, is_trait_method, match_def_path, pat_is_wild};
|
||||
use clippy_utils::{expr_or_init, is_trait_method, pat_is_wild};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{Expr, ExprKind, FnDecl, PatKind, TyKind};
|
||||
use rustc_lint::LateContext;
|
||||
@ -42,7 +41,7 @@ pub(super) fn check(cx: &LateContext<'_>, call_expr: &Expr<'_>, recv: &Expr<'_>,
|
||||
let recv_ty = cx.typeck_results().expr_ty(recv);
|
||||
if let Some(recv_ty_defid) = recv_ty.ty_adt_def().map(AdtDef::did)
|
||||
// If we call a method on a `std::iter::Enumerate` instance
|
||||
&& match_def_path(cx, recv_ty_defid, &CORE_ITER_ENUMERATE_STRUCT)
|
||||
&& cx.tcx.is_diagnostic_item(sym::Enumerate, recv_ty_defid)
|
||||
// If we are calling a method of the `Iterator` trait
|
||||
&& is_trait_method(cx, call_expr, sym::Iterator)
|
||||
// And the map argument is a closure
|
||||
@ -75,7 +74,7 @@ pub(super) fn check(cx: &LateContext<'_>, call_expr: &Expr<'_>, recv: &Expr<'_>,
|
||||
&& let ExprKind::MethodCall(_, enumerate_recv, _, enumerate_span) = recv_init_expr.kind
|
||||
&& let Some(enumerate_defid) = cx.typeck_results().type_dependent_def_id(recv_init_expr.hir_id)
|
||||
// Make sure the method call is `std::iter::Iterator::enumerate`.
|
||||
&& match_def_path(cx, enumerate_defid, &CORE_ITER_ENUMERATE_METHOD)
|
||||
&& cx.tcx.is_diagnostic_item(sym::enumerate_method, enumerate_defid)
|
||||
{
|
||||
// Check if the tuple type was explicit. It may be the type system _needs_ the type of the element
|
||||
// that would be explicitly in the closure.
|
||||
|
@ -9,7 +9,7 @@ use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{
|
||||
BinOpKind, BindingAnnotation, Body, ByRef, Expr, ExprKind, FnDecl, Mutability, PatKind, QPath, Stmt, StmtKind,
|
||||
BinOpKind, BindingMode, Body, ByRef, Expr, ExprKind, FnDecl, Mutability, PatKind, QPath, Stmt, StmtKind,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
@ -129,7 +129,7 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
|
||||
if !is_lint_allowed(cx, REF_PATTERNS, arg.pat.hir_id) {
|
||||
return;
|
||||
}
|
||||
if let PatKind::Binding(BindingAnnotation(ByRef::Yes(_), _), ..) = arg.pat.kind {
|
||||
if let PatKind::Binding(BindingMode(ByRef::Yes(_), _), ..) = arg.pat.kind {
|
||||
span_lint(
|
||||
cx,
|
||||
TOPLEVEL_REF_ARG,
|
||||
@ -144,7 +144,7 @@ impl<'tcx> LateLintPass<'tcx> for LintPass {
|
||||
fn check_stmt(&mut self, cx: &LateContext<'tcx>, stmt: &'tcx Stmt<'_>) {
|
||||
if !in_external_macro(cx.tcx.sess, stmt.span)
|
||||
&& let StmtKind::Let(local) = stmt.kind
|
||||
&& let PatKind::Binding(BindingAnnotation(ByRef::Yes(mutabl), _), .., name, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode(ByRef::Yes(mutabl), _), .., name, None) = local.pat.kind
|
||||
&& let Some(init) = local.init
|
||||
// Do not emit if clippy::ref_patterns is not allowed to avoid having two lints for the same issue.
|
||||
&& is_lint_allowed(cx, REF_PATTERNS, local.pat.hir_id)
|
||||
|
@ -1,5 +1,5 @@
|
||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use rustc_ast::ast::{BindingAnnotation, ByRef, Lifetime, Mutability, Param, PatKind, Path, TyKind};
|
||||
use rustc_ast::ast::{BindingMode, ByRef, Lifetime, Mutability, Param, PatKind, Path, TyKind};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
@ -117,13 +117,13 @@ impl EarlyLintPass for NeedlessArbitrarySelfType {
|
||||
|
||||
match &p.ty.kind {
|
||||
TyKind::Path(None, path) => {
|
||||
if let PatKind::Ident(BindingAnnotation(ByRef::No, mutbl), _, _) = p.pat.kind {
|
||||
if let PatKind::Ident(BindingMode(ByRef::No, mutbl), _, _) = p.pat.kind {
|
||||
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl);
|
||||
}
|
||||
},
|
||||
TyKind::Ref(lifetime, mut_ty) => {
|
||||
if let TyKind::Path(None, path) = &mut_ty.ty.kind
|
||||
&& let PatKind::Ident(BindingAnnotation::NONE, _, _) = p.pat.kind
|
||||
&& let PatKind::Ident(BindingMode::NONE, _, _) = p.pat.kind
|
||||
{
|
||||
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Ref(*lifetime), mut_ty.mutbl);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use clippy_utils::diagnostics::span_lint_and_then;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BindingAnnotation, Mutability, Node, Pat, PatKind};
|
||||
use rustc_hir::{BindingMode, Mutability, Node, Pat, PatKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
||||
@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowedRef {
|
||||
|
||||
match pat.kind {
|
||||
// Check sub_pat got a `ref` keyword (excluding `ref mut`).
|
||||
PatKind::Binding(BindingAnnotation::REF, _, ident, None) => {
|
||||
PatKind::Binding(BindingMode::REF, _, ident, None) => {
|
||||
span_lint_and_then(
|
||||
cx,
|
||||
NEEDLESS_BORROWED_REFERENCE,
|
||||
@ -128,7 +128,7 @@ fn check_subpatterns<'tcx>(
|
||||
|
||||
for subpattern in subpatterns {
|
||||
match subpattern.kind {
|
||||
PatKind::Binding(BindingAnnotation::REF, _, ident, None) => {
|
||||
PatKind::Binding(BindingMode::REF, _, ident, None) => {
|
||||
// `ref ident`
|
||||
// ^^^^
|
||||
let span = subpattern.span.until(ident.span);
|
||||
|
@ -6,8 +6,7 @@ use clippy_utils::visitors::{for_each_expr, for_each_expr_with_closures, is_loca
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_errors::{Applicability, MultiSpan};
|
||||
use rustc_hir::{
|
||||
BindingAnnotation, Block, Expr, ExprKind, HirId, LetStmt, LocalSource, MatchSource, Node, Pat, PatKind, Stmt,
|
||||
StmtKind,
|
||||
BindingMode, Block, Expr, ExprKind, HirId, LetStmt, LocalSource, MatchSource, Node, Pat, PatKind, Stmt, StmtKind,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
@ -369,7 +368,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit {
|
||||
init: None,
|
||||
pat:
|
||||
&Pat {
|
||||
kind: PatKind::Binding(BindingAnnotation::NONE, binding_id, _, None),
|
||||
kind: PatKind::Binding(BindingMode::NONE, binding_id, _, None),
|
||||
..
|
||||
},
|
||||
source: LocalSource::Normal,
|
||||
|
@ -9,8 +9,8 @@ use rustc_ast::ast::Attribute;
|
||||
use rustc_errors::{Applicability, Diag};
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{
|
||||
BindingAnnotation, Body, FnDecl, GenericArg, HirId, HirIdSet, Impl, ItemKind, LangItem, Mutability, Node, PatKind,
|
||||
QPath, TyKind,
|
||||
BindingMode, Body, FnDecl, GenericArg, HirId, HirIdSet, Impl, ItemKind, LangItem, Mutability, Node, PatKind, QPath,
|
||||
TyKind,
|
||||
};
|
||||
use rustc_hir_typeck::expr_use_visitor as euv;
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
@ -192,7 +192,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
||||
})
|
||||
&& !implements_borrow_trait
|
||||
&& !all_borrowable_trait
|
||||
&& let PatKind::Binding(BindingAnnotation(_, Mutability::Not), canonical_id, ..) = arg.pat.kind
|
||||
&& let PatKind::Binding(BindingMode(_, Mutability::Not), canonical_id, ..) = arg.pat.kind
|
||||
&& !moved_vars.contains(&canonical_id)
|
||||
{
|
||||
// Dereference suggestion
|
||||
|
@ -7,7 +7,7 @@ use clippy_utils::{
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk};
|
||||
use rustc_hir::{Arm, BindingAnnotation, Expr, ExprKind, MatchSource, Mutability, Pat, PatKind, Path, QPath, UnOp};
|
||||
use rustc_hir::{Arm, BindingMode, Expr, ExprKind, MatchSource, Mutability, Pat, PatKind, Path, QPath, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::SyntaxContext;
|
||||
@ -129,7 +129,7 @@ fn try_get_option_occurrence<'tcx>(
|
||||
.filter_map(|(id, &c)| none_captures.get(id).map(|&c2| (c, c2)))
|
||||
.all(|(x, y)| x.is_imm_ref() && y.is_imm_ref())
|
||||
{
|
||||
let capture_mut = if bind_annotation == BindingAnnotation::MUT {
|
||||
let capture_mut = if bind_annotation == BindingMode::MUT {
|
||||
"mut "
|
||||
} else {
|
||||
""
|
||||
@ -149,8 +149,8 @@ fn try_get_option_occurrence<'tcx>(
|
||||
(mutb == Mutability::Not, mutb == Mutability::Mut)
|
||||
},
|
||||
_ => (
|
||||
bind_annotation == BindingAnnotation::REF,
|
||||
bind_annotation == BindingAnnotation::REF_MUT,
|
||||
bind_annotation == BindingMode::REF,
|
||||
bind_annotation == BindingMode::REF_MUT,
|
||||
),
|
||||
};
|
||||
|
||||
|
@ -10,7 +10,7 @@ use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::intravisit::FnKind;
|
||||
use rustc_hir::{BindingAnnotation, Body, FnDecl, Impl, ItemKind, MutTy, Mutability, Node, PatKind};
|
||||
use rustc_hir::{BindingMode, Body, FnDecl, Impl, ItemKind, MutTy, Mutability, Node, PatKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::adjustment::{Adjust, PointerCoercion};
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
@ -221,7 +221,7 @@ impl<'tcx> PassByRefOrValue {
|
||||
// if function has a body and parameter is annotated with mut, ignore
|
||||
if let Some(param) = fn_body.and_then(|body| body.params.get(index)) {
|
||||
match param.pat.kind {
|
||||
PatKind::Binding(BindingAnnotation::NONE, _, _, _) => {},
|
||||
PatKind::Binding(BindingMode::NONE, _, _, _) => {},
|
||||
_ => continue,
|
||||
}
|
||||
}
|
||||
|
@ -11,9 +11,8 @@ use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::hir_id::{HirId, HirIdMap};
|
||||
use rustc_hir::intravisit::{walk_expr, Visitor};
|
||||
use rustc_hir::{
|
||||
self as hir, AnonConst, BinOpKind, BindingAnnotation, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg,
|
||||
ImplItemKind, ItemKind, Lifetime, Mutability, Node, Param, PatKind, QPath, TraitFn, TraitItem, TraitItemKind,
|
||||
TyKind, Unsafety,
|
||||
self as hir, AnonConst, BinOpKind, BindingMode, Body, Expr, ExprKind, FnRetTy, FnSig, GenericArg, ImplItemKind,
|
||||
ItemKind, Lifetime, Mutability, Node, Param, PatKind, QPath, TraitFn, TraitItem, TraitItemKind, TyKind, Unsafety,
|
||||
};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_infer::traits::{Obligation, ObligationCause};
|
||||
@ -606,7 +605,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args:
|
||||
Some((Node::Stmt(_), _)) => (),
|
||||
Some((Node::LetStmt(l), _)) => {
|
||||
// Only trace simple bindings. e.g `let x = y;`
|
||||
if let PatKind::Binding(BindingAnnotation::NONE, id, _, None) = l.pat.kind {
|
||||
if let PatKind::Binding(BindingMode::NONE, id, _, None) = l.pat.kind {
|
||||
self.bindings.insert(id, args_idx);
|
||||
} else {
|
||||
set_skip_flag();
|
||||
@ -687,9 +686,7 @@ fn check_ptr_arg_usage<'tcx>(cx: &LateContext<'tcx>, body: &'tcx Body<'_>, args:
|
||||
.filter_map(|(i, arg)| {
|
||||
let param = &body.params[arg.idx];
|
||||
match param.pat.kind {
|
||||
PatKind::Binding(BindingAnnotation::NONE, id, _, None)
|
||||
if !is_lint_allowed(cx, PTR_ARG, param.hir_id) =>
|
||||
{
|
||||
PatKind::Binding(BindingMode::NONE, id, _, None) if !is_lint_allowed(cx, PTR_ARG, param.hir_id) => {
|
||||
Some((id, i))
|
||||
},
|
||||
_ => {
|
||||
|
@ -14,8 +14,8 @@ use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::LangItem::{self, OptionNone, OptionSome, ResultErr, ResultOk};
|
||||
use rustc_hir::{
|
||||
BindingAnnotation, Block, Body, ByRef, Expr, ExprKind, LetStmt, Mutability, Node, PatKind, PathSegment, QPath,
|
||||
Stmt, StmtKind,
|
||||
BindingMode, Block, Body, ByRef, Expr, ExprKind, LetStmt, Mutability, Node, PatKind, PathSegment, QPath, Stmt,
|
||||
StmtKind,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty::Ty;
|
||||
@ -283,7 +283,7 @@ fn check_if_let_some_or_err_and_early_return<'tcx>(cx: &LateContext<'tcx>, expr:
|
||||
&& !is_else_clause(cx.tcx, expr)
|
||||
&& let PatKind::TupleStruct(ref path1, [field], ddpos) = let_pat.kind
|
||||
&& ddpos.as_opt_usize().is_none()
|
||||
&& let PatKind::Binding(BindingAnnotation(by_ref, _), bind_id, ident, None) = field.kind
|
||||
&& let PatKind::Binding(BindingMode(by_ref, _), bind_id, ident, None) = field.kind
|
||||
&& let caller_ty = cx.typeck_results().expr_ty(let_expr)
|
||||
&& let if_block = IfBlockType::IfLet(
|
||||
cx.qpath_res(path1, let_pat.hir_id),
|
||||
|
@ -3,7 +3,7 @@ use clippy_utils::is_from_proc_macro;
|
||||
use clippy_utils::ty::needs_ordered_drop;
|
||||
use rustc_ast::Mutability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::{BindingAnnotation, ByRef, ExprKind, HirId, LetStmt, Node, Pat, PatKind, QPath};
|
||||
use rustc_hir::{BindingMode, ByRef, ExprKind, HirId, LetStmt, Node, Pat, PatKind, QPath};
|
||||
use rustc_hir_typeck::expr_use_visitor::PlaceBase;
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals {
|
||||
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) {
|
||||
if !local.span.is_desugaring(DesugaringKind::Async)
|
||||
// the pattern is a single by-value binding
|
||||
&& let PatKind::Binding(BindingAnnotation(ByRef::No, mutability), _, ident, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode(ByRef::No, mutability), _, ident, None) = local.pat.kind
|
||||
// the binding is not type-ascribed
|
||||
&& local.ty.is_none()
|
||||
// the expression is a resolved path
|
||||
@ -109,7 +109,7 @@ fn is_by_value_closure_capture(cx: &LateContext<'_>, redefinition: HirId, root_v
|
||||
}
|
||||
|
||||
/// Find the annotation of a binding introduced by a pattern, or `None` if it's not introduced.
|
||||
fn find_binding(pat: &Pat<'_>, name: Ident) -> Option<BindingAnnotation> {
|
||||
fn find_binding(pat: &Pat<'_>, name: Ident) -> Option<BindingMode> {
|
||||
let mut ret = None;
|
||||
|
||||
pat.each_binding_or_first(&mut |annotation, _, _, ident| {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use clippy_utils::diagnostics::span_lint_and_help;
|
||||
use rustc_ast::ast::{BindingAnnotation, Pat, PatKind};
|
||||
use rustc_ast::ast::{BindingMode, Pat, PatKind};
|
||||
use rustc_lint::{EarlyContext, EarlyLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
||||
@ -28,7 +28,7 @@ declare_lint_pass!(RefPatterns => [REF_PATTERNS]);
|
||||
|
||||
impl EarlyLintPass for RefPatterns {
|
||||
fn check_pat(&mut self, cx: &EarlyContext<'_>, pat: &Pat) {
|
||||
if let PatKind::Ident(BindingAnnotation::REF, _, _) = pat.kind
|
||||
if let PatKind::Ident(BindingMode::REF, _, _) = pat.kind
|
||||
&& !pat.span.from_expansion()
|
||||
{
|
||||
span_lint_and_help(
|
||||
|
@ -4,7 +4,7 @@ use clippy_utils::source::snippet;
|
||||
use clippy_utils::{is_from_proc_macro, path_to_local_id};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, LetStmt, PatKind, QPath, Stmt, StmtKind};
|
||||
use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, LetStmt, PatKind, QPath, Stmt, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_session::impl_lint_pass;
|
||||
@ -71,7 +71,7 @@ impl<'tcx> LateLintPass<'tcx> for ReserveAfterInitialization {
|
||||
|
||||
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) {
|
||||
if let Some(init_expr) = local.init
|
||||
&& let PatKind::Binding(BindingAnnotation::MUT, id, _, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::MUT, id, _, None) = local.pat.kind
|
||||
&& !in_external_macro(cx.sess(), local.span)
|
||||
&& let Some(init) = get_vec_init_kind(cx, init_expr)
|
||||
&& !matches!(
|
||||
|
@ -7,7 +7,7 @@ use clippy_utils::{
|
||||
};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::intravisit::{walk_block, walk_expr, walk_stmt, Visitor};
|
||||
use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, PatKind, Stmt, StmtKind};
|
||||
use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, PatKind, Stmt, StmtKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::symbol::sym;
|
||||
@ -120,7 +120,7 @@ impl<'tcx> LateLintPass<'tcx> for SlowVectorInit {
|
||||
// Matches statements which initializes vectors. For example: `let mut vec = Vec::with_capacity(10)`
|
||||
// or `Vec::new()`
|
||||
if let StmtKind::Let(local) = stmt.kind
|
||||
&& let PatKind::Binding(BindingAnnotation::MUT, local_id, _, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::MUT, local_id, _, None) = local.pat.kind
|
||||
&& let Some(init) = local.init
|
||||
&& let Some(size_expr) = Self::as_vec_initializer(cx, init)
|
||||
{
|
||||
|
@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::source::snippet;
|
||||
use clippy_utils::ty::is_copy;
|
||||
use clippy_utils::{get_parent_expr, path_to_local};
|
||||
use rustc_hir::{BindingAnnotation, Expr, ExprKind, Node, PatKind, UnOp};
|
||||
use rustc_hir::{BindingMode, Expr, ExprKind, Node, PatKind, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_session::declare_lint_pass;
|
||||
|
||||
@ -84,7 +84,7 @@ fn is_mutable(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
if let Some(hir_id) = path_to_local(expr)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir_node(hir_id)
|
||||
{
|
||||
matches!(pat.kind, PatKind::Binding(BindingAnnotation::MUT, ..))
|
||||
matches!(pat.kind, PatKind::Binding(BindingMode::MUT, ..))
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
@ -137,12 +137,12 @@ fn insert_necessary_parens(pat: &mut P<Pat>) {
|
||||
struct Visitor;
|
||||
impl MutVisitor for Visitor {
|
||||
fn visit_pat(&mut self, pat: &mut P<Pat>) {
|
||||
use ast::BindingAnnotation;
|
||||
use ast::BindingMode;
|
||||
noop_visit_pat(pat, self);
|
||||
let target = match &mut pat.kind {
|
||||
// `i @ a | b`, `box a | b`, and `& mut? a | b`.
|
||||
Ident(.., Some(p)) | Box(p) | Ref(p, _) if matches!(&p.kind, Or(ps) if ps.len() > 1) => p,
|
||||
Ref(p, Mutability::Not) if matches!(p.kind, Ident(BindingAnnotation::MUT, ..)) => p, // `&(mut x)`
|
||||
Ref(p, Mutability::Not) if matches!(p.kind, Ident(BindingMode::MUT, ..)) => p, // `&(mut x)`
|
||||
_ => return,
|
||||
};
|
||||
target.kind = Paren(P(take_pat(target)));
|
||||
|
@ -5,7 +5,7 @@ use clippy_utils::ty::{is_copy, is_type_diagnostic_item, same_type_and_consts};
|
||||
use clippy_utils::{get_parent_expr, is_trait_method, is_ty_alias, path_to_local};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_hir::{BindingAnnotation, Expr, ExprKind, HirId, MatchSource, Node, PatKind};
|
||||
use rustc_hir::{BindingMode, Expr, ExprKind, HirId, MatchSource, Node, PatKind};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_infer::traits::Obligation;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
@ -282,7 +282,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
||||
if let Some(id) = path_to_local(recv)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir_node(id)
|
||||
&& let PatKind::Binding(ann, ..) = pat.kind
|
||||
&& ann != BindingAnnotation::MUT
|
||||
&& ann != BindingMode::MUT
|
||||
{
|
||||
// Do not remove .into_iter() applied to a non-mutable local variable used in
|
||||
// a larger expression context as it would differ in mutability.
|
||||
|
@ -7,8 +7,8 @@ use rustc_ast::LitIntType;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::{
|
||||
ArrayLen, BindingAnnotation, CaptureBy, Closure, ClosureKind, CoroutineKind, ExprKind, FnRetTy, HirId, Lit,
|
||||
PatKind, QPath, StmtKind, TyKind,
|
||||
ArrayLen, BindingMode, CaptureBy, Closure, ClosureKind, CoroutineKind, ExprKind, FnRetTy, HirId, Lit, PatKind,
|
||||
QPath, StmtKind, TyKind,
|
||||
};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::declare_lint_pass;
|
||||
@ -645,14 +645,14 @@ impl<'a, 'tcx> PrintVisitor<'a, 'tcx> {
|
||||
bind!(self, name);
|
||||
opt_bind!(self, sub);
|
||||
let ann = match ann {
|
||||
BindingAnnotation::NONE => "NONE",
|
||||
BindingAnnotation::REF => "REF",
|
||||
BindingAnnotation::MUT => "MUT",
|
||||
BindingAnnotation::REF_MUT => "REF_MUT",
|
||||
BindingAnnotation::MUT_REF => "MUT_REF",
|
||||
BindingAnnotation::MUT_REF_MUT => "MUT_REF_MUT",
|
||||
BindingMode::NONE => "NONE",
|
||||
BindingMode::REF => "REF",
|
||||
BindingMode::MUT => "MUT",
|
||||
BindingMode::REF_MUT => "REF_MUT",
|
||||
BindingMode::MUT_REF => "MUT_REF",
|
||||
BindingMode::MUT_REF_MUT => "MUT_REF_MUT",
|
||||
};
|
||||
kind!("Binding(BindingAnnotation::{ann}, _, {name}, {sub})");
|
||||
kind!("Binding(BindingMode::{ann}, _, {name}, {sub})");
|
||||
self.ident(name);
|
||||
sub.if_some(|p| self.pat(p));
|
||||
},
|
||||
|
@ -6,9 +6,7 @@ use clippy_utils::{get_parent_expr, path_to_local_id};
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::{
|
||||
BindingAnnotation, Block, Expr, ExprKind, HirId, LetStmt, Mutability, PatKind, QPath, Stmt, StmtKind, UnOp,
|
||||
};
|
||||
use rustc_hir::{BindingMode, Block, Expr, ExprKind, HirId, LetStmt, Mutability, PatKind, QPath, Stmt, StmtKind, UnOp};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_middle::lint::in_external_macro;
|
||||
use rustc_session::impl_lint_pass;
|
||||
@ -159,7 +157,7 @@ impl<'tcx> LateLintPass<'tcx> for VecInitThenPush {
|
||||
|
||||
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) {
|
||||
if let Some(init_expr) = local.init
|
||||
&& let PatKind::Binding(BindingAnnotation::MUT, id, name, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::MUT, id, name, None) = local.pat.kind
|
||||
&& !in_external_macro(cx.sess(), local.span)
|
||||
&& let Some(init) = get_vec_init_kind(cx, init_expr)
|
||||
&& !matches!(init, VecInitKind::WithExprCapacity(_))
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "clippy_utils"
|
||||
version = "0.1.79"
|
||||
version = "0.1.80"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
|
@ -446,7 +446,18 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
|
||||
pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
|
||||
use ForeignItemKind::*;
|
||||
match (l, r) {
|
||||
(Static(lt, lm, le), Static(rt, rm, re)) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re),
|
||||
(
|
||||
Static(box StaticForeignItem {
|
||||
ty: lt,
|
||||
mutability: lm,
|
||||
expr: le,
|
||||
}),
|
||||
Static(box StaticForeignItem {
|
||||
ty: rt,
|
||||
mutability: rm,
|
||||
expr: re,
|
||||
}),
|
||||
) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le, re),
|
||||
(
|
||||
Fn(box ast::Fn {
|
||||
defaultness: ld,
|
||||
|
@ -7,7 +7,7 @@ use rustc_data_structures::fx::FxHasher;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::MatchSource::TryDesugar;
|
||||
use rustc_hir::{
|
||||
ArrayLen, BinOpKind, BindingAnnotation, Block, BodyId, Closure, Expr, ExprField, ExprKind, FnRetTy, GenericArg,
|
||||
ArrayLen, BinOpKind, BindingMode, Block, BodyId, Closure, Expr, ExprField, ExprKind, FnRetTy, GenericArg,
|
||||
GenericArgs, HirId, HirIdMap, InlineAsmOperand, LetExpr, Lifetime, LifetimeName, Pat, PatField, PatKind, Path,
|
||||
PathSegment, PrimTy, QPath, Stmt, StmtKind, Ty, TyKind, TypeBinding,
|
||||
};
|
||||
@ -947,7 +947,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
||||
pub fn hash_pat(&mut self, pat: &Pat<'_>) {
|
||||
std::mem::discriminant(&pat.kind).hash(&mut self.s);
|
||||
match pat.kind {
|
||||
PatKind::Binding(BindingAnnotation(by_ref, mutability), _, _, pat) => {
|
||||
PatKind::Binding(BindingMode(by_ref, mutability), _, _, pat) => {
|
||||
std::mem::discriminant(&by_ref).hash(&mut self.s);
|
||||
std::mem::discriminant(&mutability).hash(&mut self.s);
|
||||
if let Some(pat) = pat {
|
||||
|
@ -99,7 +99,7 @@ use rustc_hir::hir_id::{HirIdMap, HirIdSet};
|
||||
use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};
|
||||
use rustc_hir::LangItem::{OptionNone, OptionSome, ResultErr, ResultOk};
|
||||
use rustc_hir::{
|
||||
self as hir, def, Arm, ArrayLen, BindingAnnotation, Block, BlockCheckMode, Body, ByRef, Closure, Destination, Expr,
|
||||
self as hir, def, Arm, ArrayLen, BindingMode, Block, BlockCheckMode, Body, ByRef, Closure, Destination, Expr,
|
||||
ExprField, ExprKind, FnDecl, FnRetTy, GenericArgs, HirId, Impl, ImplItem, ImplItemKind, ImplItemRef, Item,
|
||||
ItemKind, LangItem, LetStmt, MatchSource, Mutability, Node, OwnerId, Param, Pat, PatKind, Path, PathSegment,
|
||||
PrimTy, QPath, Stmt, StmtKind, TraitItem, TraitItemKind, TraitItemRef, TraitRef, TyKind, UnOp,
|
||||
@ -184,7 +184,7 @@ pub fn expr_or_init<'a, 'b, 'tcx: 'b>(cx: &LateContext<'tcx>, mut expr: &'a Expr
|
||||
/// canonical binding `HirId`.
|
||||
pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Expr<'tcx>> {
|
||||
if let Node::Pat(pat) = cx.tcx.hir_node(hir_id)
|
||||
&& matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..))
|
||||
&& matches!(pat.kind, PatKind::Binding(BindingMode::NONE, ..))
|
||||
&& let Node::LetStmt(local) = cx.tcx.parent_hir_node(hir_id)
|
||||
{
|
||||
return local.init;
|
||||
|
@ -19,8 +19,6 @@ pub const BTREESET_ITER: [&str; 6] = ["alloc", "collections", "btree", "set", "B
|
||||
pub const CLONE_TRAIT_METHOD: [&str; 4] = ["core", "clone", "Clone", "clone"];
|
||||
pub const CORE_ITER_CLONED: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "cloned"];
|
||||
pub const CORE_ITER_COPIED: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "copied"];
|
||||
pub const CORE_ITER_ENUMERATE_METHOD: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "enumerate"];
|
||||
pub const CORE_ITER_ENUMERATE_STRUCT: [&str; 5] = ["core", "iter", "adapters", "enumerate", "Enumerate"];
|
||||
pub const CORE_ITER_FILTER: [&str; 6] = ["core", "iter", "traits", "iterator", "Iterator", "filter"];
|
||||
pub const CORE_RESULT_OK_METHOD: [&str; 4] = ["core", "result", "Result", "ok"];
|
||||
pub const CSTRING_AS_C_STR: [&str; 5] = ["alloc", "ffi", "c_str", "CString", "as_c_str"];
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "declare_clippy_lint"
|
||||
version = "0.1.79"
|
||||
version = "0.1.80"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2024-04-18"
|
||||
channel = "nightly-2024-05-02"
|
||||
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(inline_const)]
|
||||
#![warn(clippy::indexing_slicing)]
|
||||
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
|
||||
// we want to avoid false positives.
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: indexing may panic
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:27:5
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:26:5
|
||||
|
|
||||
LL | x[index];
|
||||
| ^^^^^^^^
|
||||
@ -9,7 +9,7 @@ LL | x[index];
|
||||
= help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]`
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:42:5
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:41:5
|
||||
|
|
||||
LL | v[0];
|
||||
| ^^^^
|
||||
@ -17,7 +17,7 @@ LL | v[0];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:43:5
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:42:5
|
||||
|
|
||||
LL | v[10];
|
||||
| ^^^^^
|
||||
@ -25,7 +25,7 @@ LL | v[10];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:44:5
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:43:5
|
||||
|
|
||||
LL | v[1 << 3];
|
||||
| ^^^^^^^^^
|
||||
@ -33,7 +33,7 @@ LL | v[1 << 3];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:50:5
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:49:5
|
||||
|
|
||||
LL | v[N];
|
||||
| ^^^^
|
||||
@ -41,7 +41,7 @@ LL | v[N];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:51:5
|
||||
--> tests/ui-toml/suppress_lint_in_const/test.rs:50:5
|
||||
|
|
||||
LL | v[M];
|
||||
| ^^^^
|
||||
|
@ -10,7 +10,7 @@
|
||||
arithmetic_overflow,
|
||||
unconditional_panic
|
||||
)]
|
||||
#![feature(const_mut_refs, inline_const)]
|
||||
#![feature(const_mut_refs)]
|
||||
#![warn(clippy::arithmetic_side_effects)]
|
||||
|
||||
extern crate proc_macro_derive;
|
||||
|
@ -5,7 +5,7 @@ if let StmtKind::Local(local) = stmt.kind
|
||||
&& match_qpath(qpath, &["char"])
|
||||
&& let ExprKind::Lit(ref lit) = expr.kind
|
||||
&& let LitKind::Int(69, LitIntType::Unsuffixed) = lit.node
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
|
||||
&& name.as_str() == "x"
|
||||
{
|
||||
// report your lint here
|
||||
|
@ -4,13 +4,13 @@ if let ExprKind::Block(block, None) = expr.kind
|
||||
&& let Some(init) = local.init
|
||||
&& let ExprKind::Lit(ref lit) = init.kind
|
||||
&& let LitKind::Int(42, LitIntType::Signed(IntTy::I32)) = lit.node
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
|
||||
&& name.as_str() == "x"
|
||||
&& let StmtKind::Local(local1) = block.stmts[1].kind
|
||||
&& let Some(init1) = local1.init
|
||||
&& let ExprKind::Lit(ref lit1) = init1.kind
|
||||
&& let LitKind::Float(_, LitFloatType::Suffixed(FloatTy::F32)) = lit1.node
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local1.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local1.pat.kind
|
||||
&& name1.as_str() == "_t"
|
||||
&& let StmtKind::Semi(e) = block.stmts[2].kind
|
||||
&& let ExprKind::Unary(UnOp::Neg, inner) = e.kind
|
||||
@ -28,7 +28,7 @@ if let ExprKind::Block(block, None) = expr.kind
|
||||
&& let ExprKind::Path(ref qpath) = func.kind
|
||||
&& match_qpath(qpath, &["String", "new"])
|
||||
&& args.is_empty()
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
|
||||
&& name.as_str() == "expr"
|
||||
&& let Some(trailing_expr) = block.expr
|
||||
&& let ExprKind::Call(func1, args1) = trailing_expr.kind
|
||||
|
@ -1,5 +1,5 @@
|
||||
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = pat.kind
|
||||
&& name.as_str() == "y"
|
||||
&& let ExprKind::Struct(qpath, fields, None) = arg.kind
|
||||
&& matches!(qpath, QPath::LangItem(LangItem::Range, _))
|
||||
@ -16,7 +16,7 @@ if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::Fo
|
||||
&& let Some(init) = local.init
|
||||
&& let ExprKind::Path(ref qpath1) = init.kind
|
||||
&& match_qpath(qpath1, &["y"])
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
|
||||
&& name1.as_str() == "z"
|
||||
&& block.expr.is_none()
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ if let StmtKind::Local(local) = stmt.kind
|
||||
&& let ExprKind::Path(ref qpath3) = inner2.kind
|
||||
&& match_qpath(qpath3, &["x"])
|
||||
&& block.expr.is_none()
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local.pat.kind
|
||||
&& name.as_str() == "print_text"
|
||||
{
|
||||
// report your lint here
|
||||
|
@ -1,5 +1,5 @@
|
||||
if let Some(higher::ForLoop { pat: pat, arg: arg, body: body, .. }) = higher::ForLoop::hir(expr)
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = pat.kind
|
||||
&& name.as_str() == "i"
|
||||
&& let ExprKind::Struct(qpath, fields, None) = arg.kind
|
||||
&& matches!(qpath, QPath::LangItem(LangItem::Range, _))
|
||||
|
@ -20,7 +20,7 @@ if let StmtKind::Local(local) = stmt.kind
|
||||
&& let Some(init1) = local1.init
|
||||
&& let ExprKind::Lit(ref lit4) = init1.kind
|
||||
&& let LitKind::Int(3, LitIntType::Unsuffixed) = lit4.node
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name, None) = local1.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name, None) = local1.pat.kind
|
||||
&& name.as_str() == "x"
|
||||
&& let Some(trailing_expr) = block.expr
|
||||
&& let ExprKind::Path(ref qpath) = trailing_expr.kind
|
||||
@ -29,7 +29,7 @@ if let StmtKind::Local(local) = stmt.kind
|
||||
&& arms[2].guard.is_none()
|
||||
&& let ExprKind::Lit(ref lit5) = arms[2].body.kind
|
||||
&& let LitKind::Int(1, LitIntType::Unsuffixed) = lit5.node
|
||||
&& let PatKind::Binding(BindingAnnotation::NONE, _, name1, None) = local.pat.kind
|
||||
&& let PatKind::Binding(BindingMode::NONE, _, name1, None) = local.pat.kind
|
||||
&& name1.as_str() == "a"
|
||||
{
|
||||
// report your lint here
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(let_chains, inline_const)]
|
||||
#![feature(let_chains)]
|
||||
#![warn(clippy::bool_to_int_with_if)]
|
||||
#![allow(unused, dead_code, clippy::unnecessary_operation, clippy::no_effect)]
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(let_chains, inline_const)]
|
||||
#![feature(let_chains)]
|
||||
#![warn(clippy::bool_to_int_with_if)]
|
||||
#![allow(unused, dead_code, clippy::unnecessary_operation, clippy::no_effect)]
|
||||
|
||||
|
@ -16,7 +16,7 @@ fn foo(
|
||||
|
||||
fn skip_on_statements() {
|
||||
#[rustfmt::skip]
|
||||
5+3;
|
||||
{ 5+3; }
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
@ -33,11 +33,11 @@ mod foo {
|
||||
#[clippy::msrv = "1.29"]
|
||||
fn msrv_1_29() {
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+29;
|
||||
{ 1+29; }
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.30"]
|
||||
fn msrv_1_30() {
|
||||
#[rustfmt::skip]
|
||||
1+30;
|
||||
{ 1+30; }
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ fn foo(
|
||||
|
||||
fn skip_on_statements() {
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
5+3;
|
||||
{ 5+3; }
|
||||
}
|
||||
|
||||
#[cfg_attr(rustfmt, rustfmt_skip)]
|
||||
@ -33,11 +33,11 @@ mod foo {
|
||||
#[clippy::msrv = "1.29"]
|
||||
fn msrv_1_29() {
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+29;
|
||||
{ 1+29; }
|
||||
}
|
||||
|
||||
#[clippy::msrv = "1.30"]
|
||||
fn msrv_1_30() {
|
||||
#[cfg_attr(rustfmt, rustfmt::skip)]
|
||||
1+30;
|
||||
{ 1+30; }
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(inline_const)]
|
||||
#![warn(clippy::const_is_empty)]
|
||||
#![allow(clippy::needless_late_init, unused_must_use)]
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:6:8
|
||||
--> tests/ui/const_is_empty.rs:5:8
|
||||
|
|
||||
LL | if "".is_empty() {
|
||||
| ^^^^^^^^^^^^^
|
||||
@ -8,151 +8,151 @@ LL | if "".is_empty() {
|
||||
= help: to override `-D warnings` add `#[allow(clippy::const_is_empty)]`
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:9:8
|
||||
--> tests/ui/const_is_empty.rs:8:8
|
||||
|
|
||||
LL | if "foobar".is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:15:8
|
||||
--> tests/ui/const_is_empty.rs:14:8
|
||||
|
|
||||
LL | if b"".is_empty() {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:18:8
|
||||
--> tests/ui/const_is_empty.rs:17:8
|
||||
|
|
||||
LL | if b"foobar".is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:35:8
|
||||
--> tests/ui/const_is_empty.rs:34:8
|
||||
|
|
||||
LL | if empty2.is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:38:8
|
||||
--> tests/ui/const_is_empty.rs:37:8
|
||||
|
|
||||
LL | if non_empty2.is_empty() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:60:13
|
||||
--> tests/ui/const_is_empty.rs:59:13
|
||||
|
|
||||
LL | let _ = EMPTY_STR.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:62:13
|
||||
--> tests/ui/const_is_empty.rs:61:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_STR.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:64:13
|
||||
--> tests/ui/const_is_empty.rs:63:13
|
||||
|
|
||||
LL | let _ = EMPTY_BSTR.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:66:13
|
||||
--> tests/ui/const_is_empty.rs:65:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_BSTR.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:68:13
|
||||
--> tests/ui/const_is_empty.rs:67:13
|
||||
|
|
||||
LL | let _ = EMPTY_ARRAY.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:70:13
|
||||
--> tests/ui/const_is_empty.rs:69:13
|
||||
|
|
||||
LL | let _ = EMPTY_ARRAY_REPEAT.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:72:13
|
||||
--> tests/ui/const_is_empty.rs:71:13
|
||||
|
|
||||
LL | let _ = EMPTY_U8_SLICE.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:74:13
|
||||
--> tests/ui/const_is_empty.rs:73:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_U8_SLICE.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:76:13
|
||||
--> tests/ui/const_is_empty.rs:75:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_ARRAY.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:78:13
|
||||
--> tests/ui/const_is_empty.rs:77:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_ARRAY_REPEAT.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:80:13
|
||||
--> tests/ui/const_is_empty.rs:79:13
|
||||
|
|
||||
LL | let _ = EMPTY_REF_ARRAY.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:82:13
|
||||
--> tests/ui/const_is_empty.rs:81:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_REF_ARRAY.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:84:13
|
||||
--> tests/ui/const_is_empty.rs:83:13
|
||||
|
|
||||
LL | let _ = EMPTY_SLICE.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:86:13
|
||||
--> tests/ui/const_is_empty.rs:85:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_SLICE.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:88:13
|
||||
--> tests/ui/const_is_empty.rs:87:13
|
||||
|
|
||||
LL | let _ = NON_EMPTY_SLICE_REPEAT.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:94:13
|
||||
--> tests/ui/const_is_empty.rs:93:13
|
||||
|
|
||||
LL | let _ = value.is_empty();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to false
|
||||
--> tests/ui/const_is_empty.rs:97:13
|
||||
--> tests/ui/const_is_empty.rs:96:13
|
||||
|
|
||||
LL | let _ = x.is_empty();
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:99:13
|
||||
--> tests/ui/const_is_empty.rs:98:13
|
||||
|
|
||||
LL | let _ = "".is_empty();
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:101:13
|
||||
--> tests/ui/const_is_empty.rs:100:13
|
||||
|
|
||||
LL | let _ = b"".is_empty();
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this expression always evaluates to true
|
||||
--> tests/ui/const_is_empty.rs:155:13
|
||||
--> tests/ui/const_is_empty.rs:154:13
|
||||
|
|
||||
LL | let _ = val.is_empty();
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -1,9 +1,10 @@
|
||||
// Regression test for #5238 / https://github.com/rust-lang/rust/pull/69562
|
||||
|
||||
#![feature(coroutines, coroutine_trait)]
|
||||
#![feature(coroutines, coroutine_trait, stmt_expr_attributes)]
|
||||
|
||||
fn main() {
|
||||
let _ = || {
|
||||
let _ = #[coroutine]
|
||||
|| {
|
||||
yield;
|
||||
};
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ help: replace the `Into` implementation with `From<ExplicitPaths>`
|
||||
LL ~ impl core::convert::From<crate::ExplicitPaths> for bool {
|
||||
LL ~ fn from(mut val: crate::ExplicitPaths) -> Self {
|
||||
LL ~ let in_closure = || val.0;
|
||||
LL |
|
||||
LL |
|
||||
LL ~ val.0 = false;
|
||||
LL ~ val.0
|
||||
|
|
||||
|
@ -1,6 +1,5 @@
|
||||
//@compile-flags: -Zdeduplicate-diagnostics=yes
|
||||
|
||||
#![feature(inline_const)]
|
||||
#![warn(clippy::indexing_slicing)]
|
||||
// We also check the out_of_bounds_indexing lint here, because it lints similar things and
|
||||
// we want to avoid false positives.
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:16:20
|
||||
--> tests/ui/indexing_slicing_index.rs:15:20
|
||||
|
|
||||
LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-restriction-lint-in-const` default is false.
|
||||
| ^^^^^^^^^^
|
||||
@ -10,19 +10,19 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re
|
||||
= help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]`
|
||||
|
||||
error[E0080]: evaluation of `main::{constant#3}` failed
|
||||
--> tests/ui/indexing_slicing_index.rs:48:14
|
||||
--> tests/ui/indexing_slicing_index.rs:47:14
|
||||
|
|
||||
LL | const { &ARR[idx4()] };
|
||||
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
|
||||
|
||||
note: erroneous constant encountered
|
||||
--> tests/ui/indexing_slicing_index.rs:48:5
|
||||
--> tests/ui/indexing_slicing_index.rs:47:5
|
||||
|
|
||||
LL | const { &ARR[idx4()] };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:29:5
|
||||
--> tests/ui/indexing_slicing_index.rs:28:5
|
||||
|
|
||||
LL | x[index];
|
||||
| ^^^^^^^^
|
||||
@ -30,7 +30,7 @@ LL | x[index];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:32:5
|
||||
--> tests/ui/indexing_slicing_index.rs:31:5
|
||||
|
|
||||
LL | x[4];
|
||||
| ^^^^
|
||||
@ -39,13 +39,13 @@ LL | x[4];
|
||||
= help: to override `-D warnings` add `#[allow(clippy::out_of_bounds_indexing)]`
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:34:5
|
||||
--> tests/ui/indexing_slicing_index.rs:33:5
|
||||
|
|
||||
LL | x[1 << 3];
|
||||
| ^^^^^^^^^
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:45:14
|
||||
--> tests/ui/indexing_slicing_index.rs:44:14
|
||||
|
|
||||
LL | const { &ARR[idx()] };
|
||||
| ^^^^^^^^^^
|
||||
@ -54,7 +54,7 @@ LL | const { &ARR[idx()] };
|
||||
= note: the suggestion might not be applicable in constant blocks
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:48:14
|
||||
--> tests/ui/indexing_slicing_index.rs:47:14
|
||||
|
|
||||
LL | const { &ARR[idx4()] };
|
||||
| ^^^^^^^^^^^
|
||||
@ -63,13 +63,13 @@ LL | const { &ARR[idx4()] };
|
||||
= note: the suggestion might not be applicable in constant blocks
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:55:5
|
||||
--> tests/ui/indexing_slicing_index.rs:54:5
|
||||
|
|
||||
LL | y[4];
|
||||
| ^^^^
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:58:5
|
||||
--> tests/ui/indexing_slicing_index.rs:57:5
|
||||
|
|
||||
LL | v[0];
|
||||
| ^^^^
|
||||
@ -77,7 +77,7 @@ LL | v[0];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:60:5
|
||||
--> tests/ui/indexing_slicing_index.rs:59:5
|
||||
|
|
||||
LL | v[10];
|
||||
| ^^^^^
|
||||
@ -85,7 +85,7 @@ LL | v[10];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:62:5
|
||||
--> tests/ui/indexing_slicing_index.rs:61:5
|
||||
|
|
||||
LL | v[1 << 3];
|
||||
| ^^^^^^^^^
|
||||
@ -93,13 +93,13 @@ LL | v[1 << 3];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:70:5
|
||||
--> tests/ui/indexing_slicing_index.rs:69:5
|
||||
|
|
||||
LL | x[N];
|
||||
| ^^^^
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:73:5
|
||||
--> tests/ui/indexing_slicing_index.rs:72:5
|
||||
|
|
||||
LL | v[N];
|
||||
| ^^^^
|
||||
@ -107,7 +107,7 @@ LL | v[N];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: indexing may panic
|
||||
--> tests/ui/indexing_slicing_index.rs:75:5
|
||||
--> tests/ui/indexing_slicing_index.rs:74:5
|
||||
|
|
||||
LL | v[M];
|
||||
| ^^^^
|
||||
@ -115,7 +115,7 @@ LL | v[M];
|
||||
= help: consider using `.get(n)` or `.get_mut(n)` instead
|
||||
|
||||
error: index is out of bounds
|
||||
--> tests/ui/indexing_slicing_index.rs:79:13
|
||||
--> tests/ui/indexing_slicing_index.rs:78:13
|
||||
|
|
||||
LL | let _ = x[4];
|
||||
| ^^^^
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(coroutines)]
|
||||
#![warn(clippy::large_futures)]
|
||||
#![allow(clippy::never_loop)]
|
||||
#![allow(clippy::future_not_send)]
|
||||
|
@ -1,4 +1,3 @@
|
||||
#![feature(coroutines)]
|
||||
#![warn(clippy::large_futures)]
|
||||
#![allow(clippy::never_loop)]
|
||||
#![allow(clippy::future_not_send)]
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: large future with a size of 16385 bytes
|
||||
--> tests/ui/large_futures.rs:11:9
|
||||
--> tests/ui/large_futures.rs:10:9
|
||||
|
|
||||
LL | big_fut([0u8; 1024 * 16]).await;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(big_fut([0u8; 1024 * 16]))`
|
||||
@ -8,37 +8,37 @@ LL | big_fut([0u8; 1024 * 16]).await;
|
||||
= help: to override `-D warnings` add `#[allow(clippy::large_futures)]`
|
||||
|
||||
error: large future with a size of 16386 bytes
|
||||
--> tests/ui/large_futures.rs:15:5
|
||||
--> tests/ui/large_futures.rs:14:5
|
||||
|
|
||||
LL | f.await
|
||||
| ^ help: consider `Box::pin` on it: `Box::pin(f)`
|
||||
|
||||
error: large future with a size of 16387 bytes
|
||||
--> tests/ui/large_futures.rs:20:9
|
||||
--> tests/ui/large_futures.rs:19:9
|
||||
|
|
||||
LL | wait().await;
|
||||
| ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())`
|
||||
|
||||
error: large future with a size of 16387 bytes
|
||||
--> tests/ui/large_futures.rs:25:13
|
||||
--> tests/ui/large_futures.rs:24:13
|
||||
|
|
||||
LL | wait().await;
|
||||
| ^^^^^^ help: consider `Box::pin` on it: `Box::pin(wait())`
|
||||
|
||||
error: large future with a size of 65540 bytes
|
||||
--> tests/ui/large_futures.rs:33:5
|
||||
--> tests/ui/large_futures.rs:32:5
|
||||
|
|
||||
LL | foo().await;
|
||||
| ^^^^^ help: consider `Box::pin` on it: `Box::pin(foo())`
|
||||
|
||||
error: large future with a size of 49159 bytes
|
||||
--> tests/ui/large_futures.rs:35:5
|
||||
--> tests/ui/large_futures.rs:34:5
|
||||
|
|
||||
LL | calls_fut(fut).await;
|
||||
| ^^^^^^^^^^^^^^ help: consider `Box::pin` on it: `Box::pin(calls_fut(fut))`
|
||||
|
||||
error: large future with a size of 65540 bytes
|
||||
--> tests/ui/large_futures.rs:48:5
|
||||
--> tests/ui/large_futures.rs:47:5
|
||||
|
|
||||
LL | / async {
|
||||
LL | |
|
||||
@ -59,7 +59,7 @@ LL + })
|
||||
|
|
||||
|
||||
error: large future with a size of 65540 bytes
|
||||
--> tests/ui/large_futures.rs:60:13
|
||||
--> tests/ui/large_futures.rs:59:13
|
||||
|
|
||||
LL | / async {
|
||||
LL | | let x = [0i32; 1024 * 16];
|
||||
|
@ -71,7 +71,7 @@ LL | result
|
||||
help: return the expression directly
|
||||
|
|
||||
LL ~
|
||||
LL |
|
||||
LL |
|
||||
LL ~ (match self {
|
||||
LL + E::A(x) => x,
|
||||
LL + E::B(x) => x,
|
||||
|
@ -2,7 +2,6 @@
|
||||
//@aux-build:proc_macros.rs
|
||||
#![allow(clippy::needless_if, unused)]
|
||||
#![warn(clippy::manual_is_infinite, clippy::manual_is_finite)]
|
||||
#![feature(inline_const)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate proc_macros;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: manually checking if a float is infinite
|
||||
--> tests/ui/manual_float_methods.rs:23:8
|
||||
--> tests/ui/manual_float_methods.rs:22:8
|
||||
|
|
||||
LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
|
||||
@ -8,7 +8,7 @@ LL | if x == f32::INFINITY || x == f32::NEG_INFINITY {}
|
||||
= help: to override `-D warnings` add `#[allow(clippy::manual_is_infinite)]`
|
||||
|
||||
error: manually checking if a float is finite
|
||||
--> tests/ui/manual_float_methods.rs:24:8
|
||||
--> tests/ui/manual_float_methods.rs:23:8
|
||||
|
|
||||
LL | if x != f32::INFINITY && x != f32::NEG_INFINITY {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -29,13 +29,13 @@ LL | if !x.is_infinite() {}
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: manually checking if a float is infinite
|
||||
--> tests/ui/manual_float_methods.rs:25:8
|
||||
--> tests/ui/manual_float_methods.rs:24:8
|
||||
|
|
||||
LL | if x == INFINITE || x == NEG_INFINITE {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
|
||||
|
||||
error: manually checking if a float is finite
|
||||
--> tests/ui/manual_float_methods.rs:26:8
|
||||
--> tests/ui/manual_float_methods.rs:25:8
|
||||
|
|
||||
LL | if x != INFINITE && x != NEG_INFINITE {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -54,13 +54,13 @@ LL | if !x.is_infinite() {}
|
||||
| ~~~~~~~~~~~~~~~~
|
||||
|
||||
error: manually checking if a float is infinite
|
||||
--> tests/ui/manual_float_methods.rs:28:8
|
||||
--> tests/ui/manual_float_methods.rs:27:8
|
||||
|
|
||||
LL | if x == f64::INFINITY || x == f64::NEG_INFINITY {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the dedicated method instead: `x.is_infinite()`
|
||||
|
||||
error: manually checking if a float is finite
|
||||
--> tests/ui/manual_float_methods.rs:29:8
|
||||
--> tests/ui/manual_float_methods.rs:28:8
|
||||
|
|
||||
LL | if x != f64::INFINITY && x != f64::NEG_INFINITY {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -17,7 +17,7 @@ LL ~ if let Some(<stripped>) = s.strip_prefix("ab") {
|
||||
LL ~ str::to_string(<stripped>);
|
||||
LL |
|
||||
LL ~ <stripped>.to_string();
|
||||
LL |
|
||||
LL |
|
||||
LL ~ str::to_string(<stripped>);
|
||||
LL ~ <stripped>.to_string();
|
||||
|
|
||||
@ -39,7 +39,7 @@ LL ~ if let Some(<stripped>) = s.strip_suffix("bc") {
|
||||
LL ~ str::to_string(<stripped>);
|
||||
LL |
|
||||
LL ~ <stripped>.to_string();
|
||||
LL |
|
||||
LL |
|
||||
LL ~ str::to_string(<stripped>);
|
||||
LL ~ <stripped>.to_string();
|
||||
|
|
||||
|
@ -1,4 +1,4 @@
|
||||
#![feature(inline_const, try_blocks)]
|
||||
#![feature(try_blocks)]
|
||||
#![allow(
|
||||
clippy::eq_op,
|
||||
clippy::single_match,
|
||||
|
@ -1,5 +1,4 @@
|
||||
#![allow(clippy::assertions_on_constants, clippy::eq_op, clippy::let_unit_value)]
|
||||
#![feature(inline_const)]
|
||||
#![warn(clippy::unimplemented, clippy::unreachable, clippy::todo, clippy::panic)]
|
||||
|
||||
extern crate core;
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: `panic` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:23:5
|
||||
--> tests/ui/panicking_macros.rs:22:5
|
||||
|
|
||||
LL | panic!();
|
||||
| ^^^^^^^^
|
||||
@ -8,19 +8,19 @@ LL | panic!();
|
||||
= help: to override `-D warnings` add `#[allow(clippy::panic)]`
|
||||
|
||||
error: `panic` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:26:5
|
||||
--> tests/ui/panicking_macros.rs:25:5
|
||||
|
|
||||
LL | panic!("message");
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `panic` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:28:5
|
||||
--> tests/ui/panicking_macros.rs:27:5
|
||||
|
|
||||
LL | panic!("{} {}", "panic with", "multiple arguments");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `todo` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:35:5
|
||||
--> tests/ui/panicking_macros.rs:34:5
|
||||
|
|
||||
LL | todo!();
|
||||
| ^^^^^^^
|
||||
@ -29,19 +29,19 @@ LL | todo!();
|
||||
= help: to override `-D warnings` add `#[allow(clippy::todo)]`
|
||||
|
||||
error: `todo` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:38:5
|
||||
--> tests/ui/panicking_macros.rs:37:5
|
||||
|
|
||||
LL | todo!("message");
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `todo` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:40:5
|
||||
--> tests/ui/panicking_macros.rs:39:5
|
||||
|
|
||||
LL | todo!("{} {}", "panic with", "multiple arguments");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `unimplemented` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:47:5
|
||||
--> tests/ui/panicking_macros.rs:46:5
|
||||
|
|
||||
LL | unimplemented!();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
@ -50,19 +50,19 @@ LL | unimplemented!();
|
||||
= help: to override `-D warnings` add `#[allow(clippy::unimplemented)]`
|
||||
|
||||
error: `unimplemented` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:50:5
|
||||
--> tests/ui/panicking_macros.rs:49:5
|
||||
|
|
||||
LL | unimplemented!("message");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `unimplemented` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:52:5
|
||||
--> tests/ui/panicking_macros.rs:51:5
|
||||
|
|
||||
LL | unimplemented!("{} {}", "panic with", "multiple arguments");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: usage of the `unreachable!` macro
|
||||
--> tests/ui/panicking_macros.rs:59:5
|
||||
--> tests/ui/panicking_macros.rs:58:5
|
||||
|
|
||||
LL | unreachable!();
|
||||
| ^^^^^^^^^^^^^^
|
||||
@ -71,37 +71,37 @@ LL | unreachable!();
|
||||
= help: to override `-D warnings` add `#[allow(clippy::unreachable)]`
|
||||
|
||||
error: usage of the `unreachable!` macro
|
||||
--> tests/ui/panicking_macros.rs:62:5
|
||||
--> tests/ui/panicking_macros.rs:61:5
|
||||
|
|
||||
LL | unreachable!("message");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: usage of the `unreachable!` macro
|
||||
--> tests/ui/panicking_macros.rs:64:5
|
||||
--> tests/ui/panicking_macros.rs:63:5
|
||||
|
|
||||
LL | unreachable!("{} {}", "panic with", "multiple arguments");
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `panic` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:71:5
|
||||
--> tests/ui/panicking_macros.rs:70:5
|
||||
|
|
||||
LL | panic!();
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `todo` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:73:5
|
||||
--> tests/ui/panicking_macros.rs:72:5
|
||||
|
|
||||
LL | todo!();
|
||||
| ^^^^^^^
|
||||
|
||||
error: `unimplemented` should not be present in production code
|
||||
--> tests/ui/panicking_macros.rs:75:5
|
||||
--> tests/ui/panicking_macros.rs:74:5
|
||||
|
|
||||
LL | unimplemented!();
|
||||
| ^^^^^^^^^^^^^^^^
|
||||
|
||||
error: usage of the `unreachable!` macro
|
||||
--> tests/ui/panicking_macros.rs:77:5
|
||||
--> tests/ui/panicking_macros.rs:76:5
|
||||
|
|
||||
LL | unreachable!();
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
@ -1,7 +1,7 @@
|
||||
//@aux-build:proc_macros.rs
|
||||
#![allow(unused, clippy::no_effect, clippy::needless_pass_by_ref_mut)]
|
||||
#![warn(clippy::redundant_locals)]
|
||||
#![feature(async_closure, coroutines)]
|
||||
#![feature(async_closure, coroutines, stmt_expr_attributes)]
|
||||
|
||||
extern crate proc_macros;
|
||||
use proc_macros::{external, with_span};
|
||||
@ -191,14 +191,20 @@ fn issue12225() {
|
||||
let v4 = v4;
|
||||
dbg!(&v4);
|
||||
});
|
||||
assert_static(static || {
|
||||
let v5 = v5;
|
||||
yield;
|
||||
});
|
||||
assert_static(|| {
|
||||
let v6 = v6;
|
||||
yield;
|
||||
});
|
||||
assert_static(
|
||||
#[coroutine]
|
||||
static || {
|
||||
let v5 = v5;
|
||||
yield;
|
||||
},
|
||||
);
|
||||
assert_static(
|
||||
#[coroutine]
|
||||
|| {
|
||||
let v6 = v6;
|
||||
yield;
|
||||
},
|
||||
);
|
||||
|
||||
fn foo(a: &str, b: &str) {}
|
||||
|
||||
|
@ -27,7 +27,7 @@ LL | || do_nothing(value)
|
||||
LL | || });
|
||||
| ||______^- help: try: `if let Ok(value) = x.field { ... }`
|
||||
| |______|
|
||||
|
|
||||
|
|
||||
|
||||
error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()`
|
||||
--> tests/ui/result_map_unit_fn_unfixable.rs:37:5
|
||||
|
@ -85,7 +85,7 @@ LL | | ///! b
|
||||
help: use an inner doc comment to document the parent module or crate
|
||||
|
|
||||
LL ~ //! a
|
||||
LL |
|
||||
LL |
|
||||
LL ~ //! b
|
||||
|
|
||||
|
||||
|
@ -1,35 +1,11 @@
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:10:9
|
||||
|
|
||||
LL | /// - First String:
|
||||
| ^^^^ help: consider using four spaces per tab
|
||||
|
|
||||
= note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]`
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:11:9
|
||||
|
|
||||
LL | /// - needs to be inside here
|
||||
| ^^^^^^^^ help: consider using four spaces per tab
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:14:9
|
||||
|
|
||||
LL | /// - Second String:
|
||||
| ^^^^ help: consider using four spaces per tab
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:15:9
|
||||
|
|
||||
LL | /// - needs to be inside here
|
||||
| ^^^^^^^^ help: consider using four spaces per tab
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:6:5
|
||||
|
|
||||
LL | /// - first one
|
||||
| ^^^^ help: consider using four spaces per tab
|
||||
|
|
||||
= note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]`
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:6:13
|
||||
@ -49,5 +25,29 @@ error: using tabs in doc comments is not recommended
|
||||
LL | /// - second one
|
||||
| ^^^^ help: consider using four spaces per tab
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:10:9
|
||||
|
|
||||
LL | /// - First String:
|
||||
| ^^^^ help: consider using four spaces per tab
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:11:9
|
||||
|
|
||||
LL | /// - needs to be inside here
|
||||
| ^^^^^^^^ help: consider using four spaces per tab
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:14:9
|
||||
|
|
||||
LL | /// - Second String:
|
||||
| ^^^^ help: consider using four spaces per tab
|
||||
|
||||
error: using tabs in doc comments is not recommended
|
||||
--> tests/ui/tabs_in_doc_comments.rs:15:9
|
||||
|
|
||||
LL | /// - needs to be inside here
|
||||
| ^^^^^^^^ help: consider using four spaces per tab
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user