Auto merge of #11971 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
This commit is contained in:
commit
a859e5cc1c
65 changed files with 251 additions and 367 deletions
|
@ -62,7 +62,7 @@ impl LateLintPass<'_> for AbsolutePaths {
|
|||
} = self;
|
||||
|
||||
if !path.span.from_expansion()
|
||||
&& let Some(node) = cx.tcx.hir().find(hir_id)
|
||||
&& let Some(node) = cx.tcx.opt_hir_node(hir_id)
|
||||
&& !matches!(node, Node::Item(item) if matches!(item.kind, ItemKind::Use(_, _)))
|
||||
&& let [first, rest @ ..] = path.segments
|
||||
// Handle `::std`
|
||||
|
|
|
@ -9,11 +9,10 @@ use rustc_middle::ty::{self, Ty, TypeAndMut};
|
|||
use super::AS_PTR_CAST_MUT;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_to: Ty<'_>) {
|
||||
if let ty::RawPtr(
|
||||
ptrty @ TypeAndMut {
|
||||
mutbl: Mutability::Mut, ..
|
||||
},
|
||||
) = cast_to.kind()
|
||||
if let ty::RawPtr(TypeAndMut {
|
||||
mutbl: Mutability::Mut,
|
||||
ty: ptrty,
|
||||
}) = cast_to.kind()
|
||||
&& let ty::RawPtr(TypeAndMut {
|
||||
mutbl: Mutability::Not, ..
|
||||
}) = cx.typeck_results().node_type(cast_expr.hir_id).kind()
|
||||
|
@ -34,7 +33,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
|
|||
cx,
|
||||
AS_PTR_CAST_MUT,
|
||||
expr.span,
|
||||
&format!("casting the result of `as_ptr` to *{ptrty}"),
|
||||
&format!("casting the result of `as_ptr` to *mut {ptrty}"),
|
||||
"replace with",
|
||||
format!("{recv}.as_mut_ptr()"),
|
||||
applicability,
|
||||
|
|
|
@ -69,7 +69,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv
|
|||
fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
let map = cx.tcx.hir();
|
||||
if let Some(parent_id) = map.opt_parent_id(expr.hir_id)
|
||||
&& let Some(parent) = map.find(parent_id)
|
||||
&& let Some(parent) = cx.tcx.opt_hir_node(parent_id)
|
||||
{
|
||||
let expr = match parent {
|
||||
Node::Block(block) => {
|
||||
|
|
|
@ -92,7 +92,7 @@ fn contains_unhygienic_crate_reference(tts: &TokenStream) -> Option<Span> {
|
|||
{
|
||||
return Some(span);
|
||||
}
|
||||
if let TokenTree::Delimited(_, _, tts) = &curr {
|
||||
if let TokenTree::Delimited(.., tts) = &curr {
|
||||
let span = contains_unhygienic_crate_reference(tts);
|
||||
if span.is_some() {
|
||||
return span;
|
||||
|
|
|
@ -688,7 +688,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
|
|||
crate::unit_types::UNIT_ARG_INFO,
|
||||
crate::unit_types::UNIT_CMP_INFO,
|
||||
crate::unnamed_address::FN_ADDRESS_COMPARISONS_INFO,
|
||||
crate::unnamed_address::VTABLE_ADDRESS_COMPARISONS_INFO,
|
||||
crate::unnecessary_box_returns::UNNECESSARY_BOX_RETURNS_INFO,
|
||||
crate::unnecessary_map_on_constructor::UNNECESSARY_MAP_ON_CONSTRUCTOR_INFO,
|
||||
crate::unnecessary_owned_empty_strings::UNNECESSARY_OWNED_EMPTY_STRINGS_INFO,
|
||||
|
|
|
@ -1090,7 +1090,7 @@ fn report<'tcx>(
|
|||
if parent_id == data.first_expr.hir_id {
|
||||
return;
|
||||
}
|
||||
(cx.tcx.hir().get(parent_id).expect_expr().span, true)
|
||||
(cx.tcx.hir_node(parent_id).expect_expr().span, true)
|
||||
} else {
|
||||
(expr.span, false)
|
||||
};
|
||||
|
|
|
@ -195,7 +195,7 @@ impl<'tcx> LateLintPass<'tcx> for DerivableImpls {
|
|||
&& let Some(def_id) = trait_ref.trait_def_id()
|
||||
&& cx.tcx.is_diagnostic_item(sym::Default, def_id)
|
||||
&& let impl_item_hir = child.id.hir_id()
|
||||
&& let Some(Node::ImplItem(impl_item)) = cx.tcx.hir().find(impl_item_hir)
|
||||
&& let Some(Node::ImplItem(impl_item)) = cx.tcx.opt_hir_node(impl_item_hir)
|
||||
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
|
||||
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
|
||||
&& let &Adt(adt_def, args) = cx.tcx.type_of(item.owner_id).instantiate_identity().kind()
|
||||
|
|
|
@ -450,12 +450,12 @@ fn check_partial_eq_without_eq<'tcx>(cx: &LateContext<'tcx>, span: Span, trait_r
|
|||
&& let Some(def_id) = trait_ref.trait_def_id()
|
||||
&& cx.tcx.is_diagnostic_item(sym::PartialEq, def_id)
|
||||
&& let param_env = param_env_for_derived_eq(cx.tcx, adt.did(), eq_trait_def_id)
|
||||
&& !implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, &[])
|
||||
&& !implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, adt.did(),&[])
|
||||
// If all of our fields implement `Eq`, we can implement `Eq` too
|
||||
&& adt
|
||||
.all_fields()
|
||||
.map(|f| f.ty(cx.tcx, args))
|
||||
.all(|ty| implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, &[]))
|
||||
.all(|ty| implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, adt.did(), &[]))
|
||||
{
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{io, thread};
|
|||
|
||||
use crate::doc::{NEEDLESS_DOCTEST_MAIN, TEST_ATTR_IN_DOCTEST};
|
||||
use clippy_utils::diagnostics::span_lint;
|
||||
use rustc_ast::{Async, Fn, FnRetTy, Item, ItemKind};
|
||||
use rustc_ast::{CoroutineKind, Fn, FnRetTy, Item, ItemKind};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::emitter::EmitterWriter;
|
||||
use rustc_errors::Handler;
|
||||
|
@ -69,7 +69,7 @@ pub fn check(
|
|||
if !ignore {
|
||||
get_test_spans(&item, &mut test_attr_spans);
|
||||
}
|
||||
let is_async = matches!(sig.header.asyncness, Async::Yes { .. });
|
||||
let is_async = matches!(sig.header.coroutine_kind, Some(CoroutineKind::Async { .. }));
|
||||
let returns_nothing = match &sig.decl.output {
|
||||
FnRetTy::Default(..) => true,
|
||||
FnRetTy::Ty(ty) if ty.kind.is_unit() => true,
|
||||
|
|
|
@ -42,7 +42,7 @@ impl LateLintPass<'_> for EmptyDrop {
|
|||
}) = item.kind
|
||||
&& trait_ref.trait_def_id() == cx.tcx.lang_items().drop_trait()
|
||||
&& let impl_item_hir = child.id.hir_id()
|
||||
&& let Some(Node::ImplItem(impl_item)) = cx.tcx.hir().find(impl_item_hir)
|
||||
&& let Some(Node::ImplItem(impl_item)) = cx.tcx.opt_hir_node(impl_item_hir)
|
||||
&& let ImplItemKind::Fn(_, b) = &impl_item.kind
|
||||
&& let Body { value: func_expr, .. } = cx.tcx.hir().body(*b)
|
||||
&& let func_expr = peel_blocks(func_expr)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use clippy_utils::diagnostics::span_lint_hir;
|
||||
use rustc_hir::{self, intravisit, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node, Pat, PatKind};
|
||||
use rustc_hir::{intravisit, AssocItemKind, Body, FnDecl, HirId, HirIdSet, Impl, ItemKind, Node, Pat, PatKind};
|
||||
use rustc_hir_typeck::expr_use_visitor::{Delegate, ExprUseVisitor, PlaceBase, PlaceWithHirId};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::mir::FakeReadCause;
|
||||
use rustc_middle::ty::layout::LayoutOf;
|
||||
use rustc_middle::ty::{self, TraitRef, Ty};
|
||||
use rustc_middle::ty::{self, TraitRef, Ty, TyCtxt};
|
||||
use rustc_session::impl_lint_pass;
|
||||
use rustc_span::def_id::LocalDefId;
|
||||
use rustc_span::symbol::kw;
|
||||
|
@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
|
|||
.hir()
|
||||
.get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
|
||||
.def_id;
|
||||
let parent_node = cx.tcx.hir().find_by_def_id(parent_id);
|
||||
let parent_node = cx.tcx.opt_hir_node_by_def_id(parent_id);
|
||||
|
||||
let mut trait_self_ty = None;
|
||||
if let Some(Node::Item(item)) = parent_node {
|
||||
|
@ -122,8 +122,8 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
|
|||
}
|
||||
|
||||
// TODO: Replace with Map::is_argument(..) when it's fixed
|
||||
fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
|
||||
match map.find(id) {
|
||||
fn is_argument(tcx: TyCtxt<'_>, id: HirId) -> bool {
|
||||
match tcx.opt_hir_node(id) {
|
||||
Some(Node::Pat(Pat {
|
||||
kind: PatKind::Binding(..),
|
||||
..
|
||||
|
@ -131,7 +131,7 @@ fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
|
|||
_ => return false,
|
||||
}
|
||||
|
||||
matches!(map.find_parent(id), Some(Node::Param(_)))
|
||||
matches!(tcx.hir().find_parent(id), Some(Node::Param(_)))
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
||||
|
@ -154,7 +154,7 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
|||
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId) {
|
||||
if cmt.place.projections.is_empty() {
|
||||
let map = &self.cx.tcx.hir();
|
||||
if is_argument(*map, cmt.hir_id) {
|
||||
if is_argument(self.cx.tcx, cmt.hir_id) {
|
||||
// Skip closure arguments
|
||||
let parent_id = map.parent_id(cmt.hir_id);
|
||||
if let Some(Node::Expr(..)) = map.find_parent(parent_id) {
|
||||
|
|
|
@ -46,7 +46,7 @@ impl<'tcx> LateLintPass<'tcx> for Exit {
|
|||
&& let Some(def_id) = cx.qpath_res(path, path_expr.hir_id).opt_def_id()
|
||||
&& cx.tcx.is_diagnostic_item(sym::process_exit, def_id)
|
||||
&& let parent = cx.tcx.hir().get_parent_item(e.hir_id).def_id
|
||||
&& let Some(Node::Item(Item{kind: ItemKind::Fn(..), ..})) = cx.tcx.hir().find_by_def_id(parent)
|
||||
&& let Some(Node::Item(Item{kind: ItemKind::Fn(..), ..})) = cx.tcx.opt_hir_node_by_def_id(parent)
|
||||
// If the next item up is a function we check if it is an entry point
|
||||
// and only then emit a linter warning
|
||||
&& !is_entrypoint_fn(cx, parent.to_def_id())
|
||||
|
|
|
@ -111,7 +111,7 @@ fn look_in_block<'tcx, 'hir>(cx: &LateContext<'tcx>, kind: &'tcx ExprKind<'hir>)
|
|||
// Find id of the local that expr_end_of_block resolves to
|
||||
&& let ExprKind::Path(QPath::Resolved(None, expr_path)) = expr_end_of_block.kind
|
||||
&& let Res::Local(expr_res) = expr_path.res
|
||||
&& let Some(Node::Pat(res_pat)) = cx.tcx.hir().find(expr_res)
|
||||
&& let Some(Node::Pat(res_pat)) = cx.tcx.opt_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
|
||||
|
|
|
@ -92,7 +92,7 @@ fn check_result_large_err<'tcx>(cx: &LateContext<'tcx>, err_ty: Ty<'tcx>, hir_ty
|
|||
.expect("already checked this is adt")
|
||||
.did()
|
||||
.as_local()
|
||||
&& let Some(hir::Node::Item(item)) = cx.tcx.hir().find_by_def_id(local_def_id)
|
||||
&& let Some(hir::Node::Item(item)) = cx.tcx.opt_hir_node_by_def_id(local_def_id)
|
||||
&& let hir::ItemKind::Enum(ref def, _) = item.kind
|
||||
{
|
||||
let variants_size = AdtVariantInfo::new(cx, *adt, subst);
|
||||
|
|
|
@ -194,6 +194,15 @@ fn is_same_generics<'tcx>(
|
|||
.enumerate()
|
||||
.skip(1) // skip `Self` implicit arg
|
||||
.all(|(arg_index, arg)| {
|
||||
if [
|
||||
implied_by_generics.host_effect_index,
|
||||
implied_generics.host_effect_index,
|
||||
]
|
||||
.contains(&Some(arg_index))
|
||||
{
|
||||
// skip host effect params in determining whether generics are same
|
||||
return true;
|
||||
}
|
||||
if let Some(ty) = arg.as_type() {
|
||||
if let &ty::Param(ty::ParamTy { index, .. }) = ty.kind()
|
||||
// `index == 0` means that it's referring to `Self`,
|
||||
|
|
|
@ -248,7 +248,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> {
|
|||
|
||||
// Checking for slice indexing
|
||||
&& let parent_id = map.parent_id(expr.hir_id)
|
||||
&& let Some(hir::Node::Expr(parent_expr)) = map.find(parent_id)
|
||||
&& let Some(hir::Node::Expr(parent_expr)) = cx.tcx.opt_hir_node(parent_id)
|
||||
&& let hir::ExprKind::Index(_, index_expr, _) = parent_expr.kind
|
||||
&& let Some(Constant::Int(index_value)) = constant(cx, cx.typeck_results(), index_expr)
|
||||
&& let Ok(index_value) = index_value.try_into()
|
||||
|
@ -256,7 +256,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> {
|
|||
|
||||
// Make sure that this slice index is read only
|
||||
&& let maybe_addrof_id = map.parent_id(parent_id)
|
||||
&& let Some(hir::Node::Expr(maybe_addrof_expr)) = map.find(maybe_addrof_id)
|
||||
&& let Some(hir::Node::Expr(maybe_addrof_expr)) = cx.tcx.opt_hir_node(maybe_addrof_id)
|
||||
&& let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind
|
||||
{
|
||||
use_info.index_use.push((index_value, map.span(parent_expr.hir_id)));
|
||||
|
|
|
@ -122,7 +122,7 @@ fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> {
|
|||
kind: ItemKind::Impl(impl_item),
|
||||
span,
|
||||
..
|
||||
}) = cx.tcx.hir().get(id)
|
||||
}) = cx.tcx.hir_node(id)
|
||||
{
|
||||
(!span.from_expansion()
|
||||
&& impl_item.generics.params.is_empty()
|
||||
|
|
|
@ -147,7 +147,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
|
|||
&& let Some(output) =
|
||||
parse_len_output(cx, cx.tcx.fn_sig(item.owner_id).instantiate_identity().skip_binder())
|
||||
{
|
||||
let (name, kind) = match cx.tcx.hir().find(ty_hir_id) {
|
||||
let (name, kind) = match cx.tcx.opt_hir_node(ty_hir_id) {
|
||||
Some(Node::ForeignItem(x)) => (x.ident.name, "extern type"),
|
||||
Some(Node::Item(x)) => match x.kind {
|
||||
ItemKind::Struct(..) => (x.ident.name, "struct"),
|
||||
|
|
|
@ -195,7 +195,7 @@ fn check_fn_inner<'tcx>(
|
|||
.iter()
|
||||
// In principle, the result of the call to `Node::ident` could be `unwrap`ped, as `DefId` should refer to a
|
||||
// `Node::GenericParam`.
|
||||
.filter_map(|&def_id| cx.tcx.hir().get_by_def_id(def_id).ident())
|
||||
.filter_map(|&def_id| cx.tcx.hir_node_by_def_id(def_id).ident())
|
||||
.map(|ident| ident.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
|
|
|
@ -118,7 +118,7 @@ fn is_ref_iterable<'tcx>(
|
|||
.liberate_late_bound_regions(fn_id, cx.tcx.fn_sig(fn_id).skip_binder())
|
||||
&& let &[req_self_ty, req_res_ty] = &**sig.inputs_and_output
|
||||
&& let param_env = cx.tcx.param_env(fn_id)
|
||||
&& implements_trait_with_env(cx.tcx, param_env, req_self_ty, trait_id, &[])
|
||||
&& implements_trait_with_env(cx.tcx, param_env, req_self_ty, trait_id, fn_id, &[])
|
||||
&& let Some(into_iter_ty) =
|
||||
make_normalized_projection_with_regions(cx.tcx, param_env, trait_id, sym!(IntoIter), [req_self_ty])
|
||||
&& let req_res_ty = normalize_with_regions(cx.tcx, param_env, req_res_ty)
|
||||
|
|
|
@ -12,7 +12,6 @@ use rustc_lint::LateContext;
|
|||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::symbol::sym;
|
||||
use std::fmt::Display;
|
||||
use std::iter::Iterator;
|
||||
|
||||
/// Checks for `for` loops that sequentially copy items from one slice-like
|
||||
/// object to another.
|
||||
|
|
|
@ -40,7 +40,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().get(hir_id)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir_node(hir_id)
|
||||
&& let PatKind::Binding(BindingAnnotation::MUT, ..) = pat.kind
|
||||
{
|
||||
return Some(hir_id);
|
||||
|
|
|
@ -13,8 +13,7 @@ use rustc_lint::LateContext;
|
|||
use rustc_middle::middle::region;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use std::iter::{self, Iterator};
|
||||
use std::mem;
|
||||
use std::{iter, mem};
|
||||
|
||||
/// Checks for looping over a range and then indexing a sequence with it.
|
||||
/// The iteratee must be a range literal.
|
||||
|
|
|
@ -8,7 +8,7 @@ use rustc_errors::Applicability;
|
|||
use rustc_hir::{Block, Destination, Expr, ExprKind, HirId, InlineAsmOperand, Pat, Stmt, StmtKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_span::{sym, Span};
|
||||
use std::iter::{once, Iterator};
|
||||
use std::iter::once;
|
||||
|
||||
pub(super) fn check<'tcx>(
|
||||
cx: &LateContext<'tcx>,
|
||||
|
|
|
@ -11,7 +11,6 @@ use rustc_hir::{BindingAnnotation, Block, Expr, ExprKind, HirId, Mutability, Nod
|
|||
use rustc_lint::LateContext;
|
||||
use rustc_span::symbol::sym;
|
||||
use rustc_span::SyntaxContext;
|
||||
use std::iter::Iterator;
|
||||
|
||||
/// Detects for loop pushing the same item into a Vec
|
||||
pub(super) fn check<'tcx>(
|
||||
|
@ -59,12 +58,12 @@ pub(super) fn check<'tcx>(
|
|||
match cx.qpath_res(qpath, pushed_item.hir_id) {
|
||||
// immutable bindings that are initialized with literal or constant
|
||||
Res::Local(hir_id) => {
|
||||
let node = cx.tcx.hir().get(hir_id);
|
||||
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))
|
||||
&& let parent_node = cx.tcx.hir().parent_id(hir_id)
|
||||
&& let Some(Node::Local(parent_let_expr)) = cx.tcx.hir().find(parent_node)
|
||||
&& let Some(Node::Local(parent_let_expr)) = cx.tcx.opt_hir_node(parent_node)
|
||||
&& let Some(init) = parent_let_expr.init
|
||||
{
|
||||
match init.kind {
|
||||
|
|
|
@ -9,7 +9,6 @@ use rustc_middle::hir::nested_filter;
|
|||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::source_map::Spanned;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use std::iter::Iterator;
|
||||
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
enum IncrementVisitorVarState {
|
||||
|
|
|
@ -58,7 +58,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn {
|
|||
&& block.stmts.is_empty()
|
||||
&& let Some(closure_body) = desugared_async_block(cx, block)
|
||||
&& let Node::Item(Item {vis_span, ..}) | Node::ImplItem(ImplItem {vis_span, ..}) =
|
||||
cx.tcx.hir().get_by_def_id(def_id)
|
||||
cx.tcx.hir_node_by_def_id(def_id)
|
||||
{
|
||||
let header_span = span.with_hi(ret_ty.span.hi());
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid {
|
|||
// Also ensures the const is nonzero since zero can't be a divisor
|
||||
&& const1 == const2 && const2 == const3
|
||||
&& let Some(hir_id) = path_to_local(expr3)
|
||||
&& let Some(Node::Pat(_)) = cx.tcx.hir().find(hir_id)
|
||||
&& let Some(Node::Pat(_)) = cx.tcx.opt_hir_node(hir_id)
|
||||
{
|
||||
// Apply only to params or locals with annotated types
|
||||
match cx.tcx.hir().find_parent(hir_id) {
|
||||
|
|
|
@ -44,7 +44,7 @@ pub(super) fn check<'tcx>(
|
|||
// add note if not multi-line
|
||||
span_lint_and_then(cx, FILTER_NEXT, expr.span, msg, |diag| {
|
||||
let (applicability, pat) = if let Some(id) = path_to_local(recv)
|
||||
&& let Some(hir::Node::Pat(pat)) = cx.tcx.hir().find(id)
|
||||
&& let Some(hir::Node::Pat(pat)) = cx.tcx.opt_hir_node(id)
|
||||
&& let hir::PatKind::Binding(BindingAnnotation(_, Mutability::Not), _, ident, _) = pat.kind
|
||||
{
|
||||
(Applicability::Unspecified, Some((pat.span, ident)))
|
||||
|
|
|
@ -20,7 +20,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr
|
|||
"called `skip(..).next()` on an iterator",
|
||||
|diag| {
|
||||
if let Some(id) = path_to_local(recv)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir().get(id)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir_node(id)
|
||||
&& let PatKind::Binding(ann, _, _, _) = pat.kind
|
||||
&& ann != BindingAnnotation::MUT
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@ use rustc_data_structures::fx::FxHashSet;
|
|||
use rustc_errors::Applicability;
|
||||
use rustc_hir::def::Res;
|
||||
use rustc_hir::intravisit::{walk_path, Visitor};
|
||||
use rustc_hir::{self, ExprKind, HirId, Node, PatKind, Path, QPath};
|
||||
use rustc_hir::{ExprKind, HirId, Node, PatKind, Path, QPath};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
use rustc_span::{sym, Span};
|
||||
|
@ -135,7 +135,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnwrapVisitor<'a, 'tcx> {
|
|||
|
||||
fn visit_path(&mut self, path: &Path<'tcx>, _: HirId) {
|
||||
if let Res::Local(local_id) = path.res
|
||||
&& let Some(Node::Pat(pat)) = self.cx.tcx.hir().find(local_id)
|
||||
&& let Some(Node::Pat(pat)) = self.cx.tcx.opt_hir_node(local_id)
|
||||
&& let PatKind::Binding(_, local_id, ..) = pat.kind
|
||||
{
|
||||
self.identifiers.insert(local_id);
|
||||
|
@ -166,7 +166,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReferenceVisitor<'a, 'tcx> {
|
|||
&& let ExprKind::Path(ref path) = expr.kind
|
||||
&& let QPath::Resolved(_, path) = path
|
||||
&& let Res::Local(local_id) = path.res
|
||||
&& let Some(Node::Pat(pat)) = self.cx.tcx.hir().find(local_id)
|
||||
&& let Some(Node::Pat(pat)) = self.cx.tcx.opt_hir_node(local_id)
|
||||
&& let PatKind::Binding(_, local_id, ..) = pat.kind
|
||||
&& self.identifiers.contains(&local_id)
|
||||
{
|
||||
|
|
|
@ -91,7 +91,7 @@ impl Visitor<'_> for IdentVisitor<'_, '_> {
|
|||
let node = if hir_id.local_id == ItemLocalId::from_u32(0) {
|
||||
// In this case, we can just use `find`, `Owner`'s `node` field is private anyway so we can't
|
||||
// reimplement it even if we wanted to
|
||||
cx.tcx.hir().find(hir_id)
|
||||
cx.tcx.opt_hir_node(hir_id)
|
||||
} else {
|
||||
let Some(owner) = cx.tcx.hir_owner_nodes(hir_id.owner).as_owner() else {
|
||||
return;
|
||||
|
|
|
@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
|
|||
{
|
||||
let parent = cx.tcx.hir().get_parent_item(hir_id).def_id;
|
||||
if parent != CRATE_DEF_ID {
|
||||
if let hir::Node::Item(item) = cx.tcx.hir().get_by_def_id(parent) {
|
||||
if let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(parent) {
|
||||
if let hir::ItemKind::Trait(..) = &item.kind {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -220,7 +220,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingFieldsInDebug {
|
|||
&& let self_ty = cx.tcx.type_of(self_path_did).skip_binder().peel_refs()
|
||||
&& let Some(self_adt) = self_ty.ty_adt_def()
|
||||
&& let Some(self_def_id) = self_adt.did().as_local()
|
||||
&& let Some(Node::Item(self_item)) = cx.tcx.hir().find_by_def_id(self_def_id)
|
||||
&& let Some(Node::Item(self_item)) = cx.tcx.opt_hir_node_by_def_id(self_def_id)
|
||||
// NB: can't call cx.typeck_results() as we are not in a body
|
||||
&& let typeck_results = cx.tcx.typeck_body(*body_id)
|
||||
&& should_lint(cx, typeck_results, block)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use clippy_utils::diagnostics::span_lint;
|
||||
use rustc_ast::ast;
|
||||
use rustc_hir as hir;
|
||||
use rustc_lint::{self, LateContext, LateLintPass, LintContext};
|
||||
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::{sym, Span};
|
||||
|
||||
|
|
|
@ -213,7 +213,9 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
|
|||
if parent_id == cur_id {
|
||||
break;
|
||||
}
|
||||
let Some(parent_node) = map.find(parent_id) else { break };
|
||||
let Some(parent_node) = vis.cx.tcx.opt_hir_node(parent_id) else {
|
||||
break;
|
||||
};
|
||||
|
||||
let stop_early = match parent_node {
|
||||
Node::Expr(expr) => check_expr(vis, expr),
|
||||
|
|
|
@ -113,8 +113,9 @@ fn check_closures<'tcx>(
|
|||
}
|
||||
ctx.prev_bind = None;
|
||||
ctx.prev_move_to_closure.clear();
|
||||
if let Some(body) = hir
|
||||
.find_by_def_id(closure)
|
||||
if let Some(body) = cx
|
||||
.tcx
|
||||
.opt_hir_node_by_def_id(closure)
|
||||
.and_then(associated_body)
|
||||
.map(|(_, body_id)| hir.body(body_id))
|
||||
{
|
||||
|
@ -412,7 +413,7 @@ impl<'tcx> euv::Delegate<'tcx> for MutablyUsedVariablesCtxt<'tcx> {
|
|||
],
|
||||
),
|
||||
..
|
||||
}) = self.tcx.hir().get(cmt.hir_id)
|
||||
}) = self.tcx.hir_node(cmt.hir_id)
|
||||
{
|
||||
self.async_closures.insert(*def_id);
|
||||
}
|
||||
|
@ -521,7 +522,7 @@ impl<'tcx> Visitor<'tcx> for FnNeedsMutVisitor<'_, 'tcx> {
|
|||
let Self { cx, used_fn_def_ids } = self;
|
||||
|
||||
// #11182; do not lint if mutability is required elsewhere
|
||||
if let Node::Expr(expr) = cx.tcx.hir().get(hir_id)
|
||||
if let Node::Expr(expr) = cx.tcx.hir_node(hir_id)
|
||||
&& let Some(parent) = get_parent_node(cx.tcx, expr.hir_id)
|
||||
&& let ty::FnDef(def_id, _) = cx
|
||||
.tcx
|
||||
|
|
|
@ -186,6 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
|
|||
cx.param_env,
|
||||
ty,
|
||||
t,
|
||||
None,
|
||||
[Option::<ty::GenericArg<'tcx>>::None],
|
||||
)
|
||||
})
|
||||
|
|
|
@ -454,7 +454,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
|
|||
if parent_id == cur_expr.hir_id {
|
||||
break;
|
||||
}
|
||||
if let Some(Node::Expr(parent_expr)) = cx.tcx.hir().find(parent_id) {
|
||||
if let Some(Node::Expr(parent_expr)) = cx.tcx.opt_hir_node(parent_id) {
|
||||
match &parent_expr.kind {
|
||||
ExprKind::AddrOf(..) => {
|
||||
// `&e` => `e` must be referenced.
|
||||
|
|
|
@ -341,7 +341,9 @@ impl<'a, 'tcx> Visitor<'tcx> for SimilarNamesLocalVisitor<'a, 'tcx> {
|
|||
|
||||
self.apply(|this| {
|
||||
SimilarNamesNameVisitor(this).visit_pat(&arm.pat);
|
||||
this.apply(|this| walk_expr(this, &arm.body));
|
||||
if let Some(body) = &arm.body {
|
||||
this.apply(|this| walk_expr(this, body));
|
||||
}
|
||||
});
|
||||
|
||||
self.check_single_char_names();
|
||||
|
|
|
@ -94,7 +94,6 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
|
|||
{
|
||||
let mut non_send_fields = Vec::new();
|
||||
|
||||
let hir_map = cx.tcx.hir();
|
||||
for variant in adt_def.variants() {
|
||||
for field in &variant.fields {
|
||||
if let Some(field_hir_id) = field
|
||||
|
@ -104,7 +103,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSendFieldInSendTy {
|
|||
&& !is_lint_allowed(cx, NON_SEND_FIELDS_IN_SEND_TY, field_hir_id)
|
||||
&& let field_ty = field.ty(cx.tcx, impl_trait_args)
|
||||
&& !ty_allowed_in_send(cx, field_ty, send_trait)
|
||||
&& let Node::Field(field_def) = hir_map.get(field_hir_id)
|
||||
&& let Node::Field(field_def) = cx.tcx.hir_node(field_hir_id)
|
||||
{
|
||||
non_send_fields.push(NonSendField {
|
||||
def: field_def,
|
||||
|
|
|
@ -105,7 +105,9 @@ impl<'ast> Visitor<'ast> for BreakVisitor {
|
|||
fn visit_expr(&mut self, expr: &'ast Expr) {
|
||||
self.is_break = match expr.kind {
|
||||
ExprKind::Break(..) | ExprKind::Continue(..) | ExprKind::Ret(..) => true,
|
||||
ExprKind::Match(_, ref arms) => arms.iter().all(|arm| self.check_expr(&arm.body)),
|
||||
ExprKind::Match(_, ref arms) => arms.iter().all(|arm|
|
||||
arm.body.is_none() || arm.body.as_deref().is_some_and(|body| self.check_expr(body))
|
||||
),
|
||||
ExprKind::If(_, ref then, Some(ref els)) => self.check_block(then) && self.check_expr(els),
|
||||
ExprKind::If(_, _, None)
|
||||
// ignore loops for simplicity
|
||||
|
|
|
@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals {
|
|||
&& last_segment.ident == ident
|
||||
// resolve the path to its defining binding pattern
|
||||
&& let Res::Local(binding_id) = cx.qpath_res(&qpath, expr.hir_id)
|
||||
&& let Node::Pat(binding_pat) = cx.tcx.hir().get(binding_id)
|
||||
&& let Node::Pat(binding_pat) = cx.tcx.hir_node(binding_id)
|
||||
// the previous binding has the same mutability
|
||||
&& find_binding(binding_pat, ident).is_some_and(|bind| bind.1 == mutability)
|
||||
// the local does not change the effect of assignments to the binding. see #11290
|
||||
|
|
|
@ -59,4 +59,5 @@ pub static RENAMED_LINTS: &[(&str, &str)] = &[
|
|||
("clippy::undropped_manually_drops", "undropped_manually_drops"),
|
||||
("clippy::unknown_clippy_lints", "unknown_lints"),
|
||||
("clippy::unused_label", "unused_labels"),
|
||||
("clippy::vtable_address_comparisons", "ambiguous_wide_pointer_comparisons"),
|
||||
];
|
||||
|
|
|
@ -75,9 +75,9 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
|
|||
|
||||
match of_trait {
|
||||
Some(trait_ref) => {
|
||||
let mut methods_in_trait: BTreeSet<Symbol> = if let Some(Node::TraitRef(TraitRef {
|
||||
path, ..
|
||||
})) = cx.tcx.hir().find(trait_ref.hir_ref_id)
|
||||
let mut methods_in_trait: BTreeSet<Symbol> =
|
||||
if let Some(Node::TraitRef(TraitRef { path, .. })) =
|
||||
cx.tcx.opt_hir_node(trait_ref.hir_ref_id)
|
||||
&& let Res::Def(DefKind::Trait, did) = path.res
|
||||
{
|
||||
// FIXME: if
|
||||
|
|
|
@ -73,7 +73,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors {
|
|||
if let Some(self_def) = self_ty.ty_adt_def()
|
||||
&& let Some(self_local_did) = self_def.did().as_local()
|
||||
&& let self_id = cx.tcx.local_def_id_to_hir_id(self_local_did)
|
||||
&& let Some(Node::Item(x)) = cx.tcx.hir().find(self_id)
|
||||
&& let Some(Node::Item(x)) = cx.tcx.opt_hir_node(self_id)
|
||||
&& let type_name = x.ident.name.as_str().to_lowercase()
|
||||
&& (impl_item.ident.name.as_str() == type_name
|
||||
|| impl_item.ident.name.as_str().replace('_', "") == type_name)
|
||||
|
|
|
@ -64,7 +64,7 @@ impl<'tcx> LateLintPass<'tcx> for SuspiciousImpl {
|
|||
// Check for more than one binary operation in the implemented function
|
||||
// Linting when multiple operations are involved can result in false positives
|
||||
&& let parent_fn = cx.tcx.hir().get_parent_item(expr.hir_id).def_id
|
||||
&& let hir::Node::ImplItem(impl_item) = cx.tcx.hir().get_by_def_id(parent_fn)
|
||||
&& let hir::Node::ImplItem(impl_item) = cx.tcx.hir_node_by_def_id(parent_fn)
|
||||
&& let hir::ImplItemKind::Fn(_, body_id) = impl_item.kind
|
||||
&& let body = cx.tcx.hir().body(body_id)
|
||||
&& let parent_fn = cx.tcx.hir().get_parent_item(expr.hir_id).def_id
|
||||
|
|
|
@ -321,7 +321,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
|
|||
_: Span,
|
||||
def_id: LocalDefId,
|
||||
) {
|
||||
let is_in_trait_impl = if let Some(hir::Node::Item(item)) = cx.tcx.hir().find_by_def_id(
|
||||
let is_in_trait_impl = if let Some(hir::Node::Item(item)) = cx.tcx.opt_hir_node_by_def_id(
|
||||
cx.tcx
|
||||
.hir()
|
||||
.get_parent_item(cx.tcx.local_def_id_to_hir_id(def_id))
|
||||
|
@ -368,8 +368,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
|
|||
ImplItemKind::Const(ty, _) => {
|
||||
let is_in_trait_impl = if let Some(hir::Node::Item(item)) = cx
|
||||
.tcx
|
||||
.hir()
|
||||
.find_by_def_id(cx.tcx.hir().get_parent_item(item.hir_id()).def_id)
|
||||
.opt_hir_node_by_def_id(cx.tcx.hir().get_parent_item(item.hir_id()).def_id)
|
||||
{
|
||||
matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }))
|
||||
} else {
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
|
||||
use clippy_utils::diagnostics::span_lint;
|
||||
use rustc_hir::{BinOpKind, Expr, ExprKind};
|
||||
use rustc_lint::{LateContext, LateLintPass};
|
||||
use rustc_middle::ty;
|
||||
use rustc_session::declare_lint_pass;
|
||||
use rustc_span::sym;
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
|
@ -29,31 +28,7 @@ declare_clippy_lint! {
|
|||
"comparison with an address of a function item"
|
||||
}
|
||||
|
||||
declare_clippy_lint! {
|
||||
/// ### What it does
|
||||
/// Checks for comparisons with an address of a trait vtable.
|
||||
///
|
||||
/// ### Why is this bad?
|
||||
/// Comparing trait objects pointers compares an vtable addresses which
|
||||
/// are not guaranteed to be unique and could vary between different code generation units.
|
||||
/// Furthermore vtables for different types could have the same address after being merged
|
||||
/// together.
|
||||
///
|
||||
/// ### Example
|
||||
/// ```rust,ignore
|
||||
/// let a: Rc<dyn Trait> = ...
|
||||
/// let b: Rc<dyn Trait> = ...
|
||||
/// if Rc::ptr_eq(&a, &b) {
|
||||
/// ...
|
||||
/// }
|
||||
/// ```
|
||||
#[clippy::version = "1.44.0"]
|
||||
pub VTABLE_ADDRESS_COMPARISONS,
|
||||
correctness,
|
||||
"comparison with an address of a trait vtable"
|
||||
}
|
||||
|
||||
declare_lint_pass!(UnnamedAddress => [FN_ADDRESS_COMPARISONS, VTABLE_ADDRESS_COMPARISONS]);
|
||||
declare_lint_pass!(UnnamedAddress => [FN_ADDRESS_COMPARISONS]);
|
||||
|
||||
impl LateLintPass<'_> for UnnamedAddress {
|
||||
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
|
||||
|
@ -64,49 +39,10 @@ impl LateLintPass<'_> for UnnamedAddress {
|
|||
)
|
||||
}
|
||||
|
||||
fn is_trait_ptr(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
match cx.typeck_results().expr_ty_adjusted(expr).kind() {
|
||||
ty::RawPtr(ty::TypeAndMut { ty, .. }) => ty.is_trait(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn is_fn_def(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
matches!(cx.typeck_results().expr_ty(expr).kind(), ty::FnDef(..))
|
||||
}
|
||||
|
||||
if let ExprKind::Binary(binop, left, right) = expr.kind
|
||||
&& is_comparison(binop.node)
|
||||
&& is_trait_ptr(cx, left)
|
||||
&& is_trait_ptr(cx, right)
|
||||
{
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
VTABLE_ADDRESS_COMPARISONS,
|
||||
expr.span,
|
||||
"comparing trait object pointers compares a non-unique vtable address",
|
||||
None,
|
||||
"consider extracting and comparing data pointers only",
|
||||
);
|
||||
}
|
||||
|
||||
if let ExprKind::Call(func, [ref _left, ref _right]) = expr.kind
|
||||
&& let ExprKind::Path(ref func_qpath) = func.kind
|
||||
&& let Some(def_id) = cx.qpath_res(func_qpath, func.hir_id).opt_def_id()
|
||||
&& cx.tcx.is_diagnostic_item(sym::ptr_eq, def_id)
|
||||
&& let ty_param = cx.typeck_results().node_args(func.hir_id).type_at(0)
|
||||
&& ty_param.is_trait()
|
||||
{
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
VTABLE_ADDRESS_COMPARISONS,
|
||||
expr.span,
|
||||
"comparing trait object pointers compares a non-unique vtable address",
|
||||
None,
|
||||
"consider extracting and comparing data pointers only",
|
||||
);
|
||||
}
|
||||
|
||||
if let ExprKind::Binary(binop, left, right) = expr.kind
|
||||
&& is_comparison(binop.node)
|
||||
&& cx.typeck_results().expr_ty_adjusted(left).is_fn_ptr()
|
||||
|
|
|
@ -66,7 +66,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryMapOnConstructor {
|
|||
};
|
||||
match constructor_symbol {
|
||||
sym::Some | sym::Ok if path.ident.name == rustc_span::sym::map => (),
|
||||
sym::Err if path.ident.name == sym!(map_err) => (),
|
||||
sym::Err if path.ident.name == sym::map_err => (),
|
||||
_ => return,
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ impl LateLintPass<'_> for UnnecessaryStruct {
|
|||
|
||||
fn is_mutable(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
if let Some(hir_id) = path_to_local(expr)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir().get(hir_id)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir_node(hir_id)
|
||||
{
|
||||
matches!(pat.kind, PatKind::Binding(BindingAnnotation::MUT, ..))
|
||||
} else {
|
||||
|
|
|
@ -281,7 +281,7 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion {
|
|||
}
|
||||
|
||||
if let Some(id) = path_to_local(recv)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir().get(id)
|
||||
&& let Node::Pat(pat) = cx.tcx.hir_node(id)
|
||||
&& let PatKind::Binding(ann, ..) = pat.kind
|
||||
&& ann != BindingAnnotation::MUT
|
||||
{
|
||||
|
|
|
@ -218,7 +218,7 @@ fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<Ve
|
|||
ExprKind::Path(ref qpath) => match cx.qpath_res(qpath, expr.hir_id) {
|
||||
Res::Local(hir_id) => {
|
||||
let parent_id = cx.tcx.hir().parent_id(hir_id);
|
||||
if let Some(Node::Local(Local { init: Some(init), .. })) = cx.tcx.hir().find(parent_id) {
|
||||
if let Node::Local(Local { init: Some(init), .. }) = cx.tcx.hir_node(parent_id) {
|
||||
path_to_matched_type(cx, init)
|
||||
} else {
|
||||
None
|
||||
|
@ -246,7 +246,7 @@ fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<Ve
|
|||
fn read_mir_alloc_def_path<'tcx>(cx: &LateContext<'tcx>, alloc: &'tcx Allocation, ty: Ty<'_>) -> Option<Vec<String>> {
|
||||
let (alloc, ty) = if let ty::Ref(_, ty, Mutability::Not) = *ty.kind() {
|
||||
let &alloc = alloc.provenance().ptrs().values().next()?;
|
||||
if let GlobalAlloc::Memory(alloc) = cx.tcx.global_alloc(alloc) {
|
||||
if let GlobalAlloc::Memory(alloc) = cx.tcx.global_alloc(alloc.alloc_id()) {
|
||||
(alloc.inner(), ty)
|
||||
} else {
|
||||
return None;
|
||||
|
@ -264,7 +264,7 @@ fn read_mir_alloc_def_path<'tcx>(cx: &LateContext<'tcx>, alloc: &'tcx Allocation
|
|||
.ptrs()
|
||||
.values()
|
||||
.map(|&alloc| {
|
||||
if let GlobalAlloc::Memory(alloc) = cx.tcx.global_alloc(alloc) {
|
||||
if let GlobalAlloc::Memory(alloc) = cx.tcx.global_alloc(alloc.alloc_id()) {
|
||||
let alloc = alloc.inner();
|
||||
str::from_utf8(alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()))
|
||||
.ok()
|
||||
|
|
|
@ -74,7 +74,7 @@ impl LateLintPass<'_> for ZeroSizedMapValues {
|
|||
fn in_trait_impl(cx: &LateContext<'_>, hir_id: HirId) -> bool {
|
||||
let parent_id = cx.tcx.hir().get_parent_item(hir_id);
|
||||
let second_parent_id = cx.tcx.hir().get_parent_item(parent_id.into()).def_id;
|
||||
if let Some(Node::Item(item)) = cx.tcx.hir().find_by_def_id(second_parent_id) {
|
||||
if let Some(Node::Item(item)) = cx.tcx.opt_hir_node_by_def_id(second_parent_id) {
|
||||
if let ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) = item.kind {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
|
|||
Closure(box ast::Closure {
|
||||
binder: lb,
|
||||
capture_clause: lc,
|
||||
asyncness: la,
|
||||
coroutine_kind: la,
|
||||
movability: lm,
|
||||
fn_decl: lf,
|
||||
body: le,
|
||||
|
@ -197,7 +197,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
|
|||
Closure(box ast::Closure {
|
||||
binder: rb,
|
||||
capture_clause: rc,
|
||||
asyncness: ra,
|
||||
coroutine_kind: ra,
|
||||
movability: rm,
|
||||
fn_decl: rf,
|
||||
body: re,
|
||||
|
@ -206,7 +206,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
|
|||
) => {
|
||||
eq_closure_binder(lb, rb)
|
||||
&& lc == rc
|
||||
&& la.is_async() == ra.is_async()
|
||||
&& la.map_or(false, CoroutineKind::is_async) == ra.map_or(false, CoroutineKind::is_async)
|
||||
&& lm == rm
|
||||
&& eq_fn_decl(lf, rf)
|
||||
&& eq_expr(le, re)
|
||||
|
@ -236,7 +236,7 @@ pub fn eq_field(l: &ExprField, r: &ExprField) -> bool {
|
|||
pub fn eq_arm(l: &Arm, r: &Arm) -> bool {
|
||||
l.is_placeholder == r.is_placeholder
|
||||
&& eq_pat(&l.pat, &r.pat)
|
||||
&& eq_expr(&l.body, &r.body)
|
||||
&& eq_expr_opt(&l.body, &r.body)
|
||||
&& eq_expr_opt(&l.guard, &r.guard)
|
||||
&& over(&l.attrs, &r.attrs, eq_attr)
|
||||
}
|
||||
|
@ -563,9 +563,22 @@ pub fn eq_fn_sig(l: &FnSig, r: &FnSig) -> bool {
|
|||
eq_fn_decl(&l.decl, &r.decl) && eq_fn_header(&l.header, &r.header)
|
||||
}
|
||||
|
||||
fn eq_opt_coroutine_kind(l: Option<CoroutineKind>, r: Option<CoroutineKind>) -> bool {
|
||||
matches!(
|
||||
(l, r),
|
||||
(Some(CoroutineKind::Async { .. }), Some(CoroutineKind::Async { .. }))
|
||||
| (Some(CoroutineKind::Gen { .. }), Some(CoroutineKind::Gen { .. }))
|
||||
| (
|
||||
Some(CoroutineKind::AsyncGen { .. }),
|
||||
Some(CoroutineKind::AsyncGen { .. })
|
||||
)
|
||||
| (None, None)
|
||||
)
|
||||
}
|
||||
|
||||
pub fn eq_fn_header(l: &FnHeader, r: &FnHeader) -> bool {
|
||||
matches!(l.unsafety, Unsafe::No) == matches!(r.unsafety, Unsafe::No)
|
||||
&& l.asyncness.is_async() == r.asyncness.is_async()
|
||||
&& eq_opt_coroutine_kind(l.coroutine_kind, r.coroutine_kind)
|
||||
&& matches!(l.constness, Const::No) == matches!(r.constness, Const::No)
|
||||
&& eq_ext(&l.ext, &r.ext)
|
||||
}
|
||||
|
|
|
@ -267,7 +267,7 @@ fn fn_kind_pat(tcx: TyCtxt<'_>, kind: &FnKind<'_>, body: &Body<'_>, hir_id: HirI
|
|||
FnKind::Method(.., sig) => (fn_header_search_pat(sig.header), Pat::Str("")),
|
||||
FnKind::Closure => return (Pat::Str(""), expr_search_pat(tcx, body.value).1),
|
||||
};
|
||||
let start_pat = match tcx.hir().get(hir_id) {
|
||||
let start_pat = match tcx.hir_node(hir_id) {
|
||||
Node::Item(Item { vis_span, .. }) | Node::ImplItem(ImplItem { vis_span, .. }) => {
|
||||
if vis_span.is_empty() {
|
||||
start_pat
|
||||
|
|
|
@ -531,7 +531,7 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> {
|
|||
kind: ExprKind::Lit(_),
|
||||
span,
|
||||
..
|
||||
}) = self.lcx.tcx.hir().get(body_id.hir_id)
|
||||
}) = self.lcx.tcx.hir_node(body_id.hir_id)
|
||||
&& is_direct_expn_of(*span, "cfg").is_some()
|
||||
{
|
||||
return None;
|
||||
|
|
|
@ -176,10 +176,10 @@ 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>> {
|
||||
let hir = cx.tcx.hir();
|
||||
if let Some(Node::Pat(pat)) = hir.find(hir_id)
|
||||
if let Some(Node::Pat(pat)) = cx.tcx.opt_hir_node(hir_id)
|
||||
&& matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..))
|
||||
&& let parent = hir.parent_id(hir_id)
|
||||
&& let Some(Node::Local(local)) = hir.find(parent)
|
||||
&& let Some(Node::Local(local)) = cx.tcx.opt_hir_node(parent)
|
||||
{
|
||||
return local.init;
|
||||
}
|
||||
|
@ -563,7 +563,7 @@ fn local_item_children_by_name(tcx: TyCtxt<'_>, local_id: LocalDefId, name: Symb
|
|||
let hir = tcx.hir();
|
||||
|
||||
let root_mod;
|
||||
let item_kind = match hir.find_by_def_id(local_id) {
|
||||
let item_kind = match tcx.opt_hir_node_by_def_id(local_id) {
|
||||
Some(Node::Crate(r#mod)) => {
|
||||
root_mod = ItemKind::Mod(r#mod);
|
||||
&root_mod
|
||||
|
@ -712,7 +712,7 @@ pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'tcx>, def_id: LocalDefId) ->
|
|||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||
let parent_impl = cx.tcx.hir().get_parent_item(hir_id);
|
||||
if parent_impl != hir::CRATE_OWNER_ID
|
||||
&& let hir::Node::Item(item) = cx.tcx.hir().get_by_def_id(parent_impl.def_id)
|
||||
&& let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(parent_impl.def_id)
|
||||
&& let hir::ItemKind::Impl(impl_) = &item.kind
|
||||
{
|
||||
return impl_.of_trait.as_ref();
|
||||
|
@ -1242,7 +1242,7 @@ pub fn is_in_panic_handler(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
|
|||
/// Gets the name of the item the expression is in, if available.
|
||||
pub fn get_item_name(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Symbol> {
|
||||
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id).def_id;
|
||||
match cx.tcx.hir().find_by_def_id(parent_id) {
|
||||
match cx.tcx.opt_hir_node_by_def_id(parent_id) {
|
||||
Some(
|
||||
Node::Item(Item { ident, .. })
|
||||
| Node::TraitItem(TraitItem { ident, .. })
|
||||
|
@ -1319,7 +1319,7 @@ pub fn get_enclosing_block<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Optio
|
|||
let map = &cx.tcx.hir();
|
||||
let enclosing_node = map
|
||||
.get_enclosing_scope(hir_id)
|
||||
.and_then(|enclosing_id| map.find(enclosing_id));
|
||||
.and_then(|enclosing_id| cx.tcx.opt_hir_node(enclosing_id));
|
||||
enclosing_node.and_then(|node| match node {
|
||||
Node::Block(block) => Some(block),
|
||||
Node::Item(&Item {
|
||||
|
@ -2691,7 +2691,7 @@ impl<'tcx> ExprUseNode<'tcx> {
|
|||
if let Some(Node::Expr(Expr {
|
||||
kind: ExprKind::Closure(c),
|
||||
..
|
||||
})) = cx.tcx.hir().find(hir_id)
|
||||
})) = cx.tcx.opt_hir_node(hir_id)
|
||||
{
|
||||
match c.fn_decl.output {
|
||||
FnRetTy::DefaultReturn(_) => None,
|
||||
|
@ -2757,7 +2757,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> Optio
|
|||
walk_to_expr_usage(cx, e, &mut |parent, child_id| {
|
||||
// LocalTableInContext returns the wrong lifetime, so go use `expr_adjustments` instead.
|
||||
if adjustments.is_empty()
|
||||
&& let Node::Expr(e) = cx.tcx.hir().get(child_id)
|
||||
&& let Node::Expr(e) = cx.tcx.hir_node(child_id)
|
||||
{
|
||||
adjustments = cx.typeck_results().expr_adjustments(e);
|
||||
}
|
||||
|
|
|
@ -214,7 +214,17 @@ pub fn implements_trait<'tcx>(
|
|||
trait_id: DefId,
|
||||
args: &[GenericArg<'tcx>],
|
||||
) -> bool {
|
||||
implements_trait_with_env_from_iter(cx.tcx, cx.param_env, ty, trait_id, args.iter().map(|&x| Some(x)))
|
||||
let callee_id = cx
|
||||
.enclosing_body
|
||||
.map(|body| cx.tcx.hir().body_owner(body).owner.to_def_id());
|
||||
implements_trait_with_env_from_iter(
|
||||
cx.tcx,
|
||||
cx.param_env,
|
||||
ty,
|
||||
trait_id,
|
||||
callee_id,
|
||||
args.iter().map(|&x| Some(x)),
|
||||
)
|
||||
}
|
||||
|
||||
/// Same as `implements_trait` but allows using a `ParamEnv` different from the lint context.
|
||||
|
@ -223,9 +233,17 @@ pub fn implements_trait_with_env<'tcx>(
|
|||
param_env: ParamEnv<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
trait_id: DefId,
|
||||
callee_id: DefId,
|
||||
args: &[GenericArg<'tcx>],
|
||||
) -> bool {
|
||||
implements_trait_with_env_from_iter(tcx, param_env, ty, trait_id, args.iter().map(|&x| Some(x)))
|
||||
implements_trait_with_env_from_iter(
|
||||
tcx,
|
||||
param_env,
|
||||
ty,
|
||||
trait_id,
|
||||
Some(callee_id),
|
||||
args.iter().map(|&x| Some(x)),
|
||||
)
|
||||
}
|
||||
|
||||
/// Same as `implements_trait_from_env` but takes the arguments as an iterator.
|
||||
|
@ -234,6 +252,7 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
|
|||
param_env: ParamEnv<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
trait_id: DefId,
|
||||
callee_id: Option<DefId>,
|
||||
args: impl IntoIterator<Item = impl Into<Option<GenericArg<'tcx>>>>,
|
||||
) -> bool {
|
||||
// Clippy shouldn't have infer types
|
||||
|
@ -245,12 +264,9 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
|
|||
}
|
||||
|
||||
let infcx = tcx.infer_ctxt().build();
|
||||
let trait_ref = TraitRef::new(
|
||||
tcx,
|
||||
trait_id,
|
||||
Some(GenericArg::from(ty))
|
||||
let args = args
|
||||
.into_iter()
|
||||
.chain(args.into_iter().map(|arg| {
|
||||
.map(|arg| {
|
||||
arg.into().unwrap_or_else(|| {
|
||||
let orig = TypeVariableOrigin {
|
||||
kind: TypeVariableOriginKind::MiscVariable,
|
||||
|
@ -258,7 +274,26 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
|
|||
};
|
||||
infcx.next_ty_var(orig).into()
|
||||
})
|
||||
})),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// If an effect arg was not specified, we need to specify it.
|
||||
let effect_arg = if tcx
|
||||
.generics_of(trait_id)
|
||||
.host_effect_index
|
||||
.is_some_and(|x| args.get(x - 1).is_none())
|
||||
{
|
||||
Some(GenericArg::from(callee_id.map_or(tcx.consts.true_, |def_id| {
|
||||
tcx.expected_host_effect_param_for_body(def_id)
|
||||
})))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let trait_ref = TraitRef::new(
|
||||
tcx,
|
||||
trait_id,
|
||||
Some(GenericArg::from(ty)).into_iter().chain(args).chain(effect_arg),
|
||||
);
|
||||
|
||||
debug_assert_matches!(
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
[toolchain]
|
||||
channel = "nightly-2023-12-05"
|
||||
channel = "nightly-2023-12-16"
|
||||
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#![allow(undropped_manually_drops)]
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(unused_labels)]
|
||||
#![allow(ambiguous_wide_pointer_comparisons)]
|
||||
#![warn(clippy::almost_complete_range)]
|
||||
#![warn(clippy::disallowed_names)]
|
||||
#![warn(clippy::blocks_in_conditions)]
|
||||
|
@ -108,5 +109,6 @@
|
|||
#![warn(undropped_manually_drops)]
|
||||
#![warn(unknown_lints)]
|
||||
#![warn(unused_labels)]
|
||||
#![warn(ambiguous_wide_pointer_comparisons)]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#![allow(undropped_manually_drops)]
|
||||
#![allow(unknown_lints)]
|
||||
#![allow(unused_labels)]
|
||||
#![allow(ambiguous_wide_pointer_comparisons)]
|
||||
#![warn(clippy::almost_complete_letter_range)]
|
||||
#![warn(clippy::blacklisted_name)]
|
||||
#![warn(clippy::block_in_if_condition_expr)]
|
||||
|
@ -108,5 +109,6 @@
|
|||
#![warn(clippy::undropped_manually_drops)]
|
||||
#![warn(clippy::unknown_clippy_lints)]
|
||||
#![warn(clippy::unused_label)]
|
||||
#![warn(clippy::vtable_address_comparisons)]
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range`
|
||||
--> $DIR/rename.rs:54:9
|
||||
--> $DIR/rename.rs:55:9
|
||||
|
|
||||
LL | #![warn(clippy::almost_complete_letter_range)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range`
|
||||
|
@ -8,340 +8,346 @@ LL | #![warn(clippy::almost_complete_letter_range)]
|
|||
= help: to override `-D warnings` add `#[allow(renamed_and_removed_lints)]`
|
||||
|
||||
error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names`
|
||||
--> $DIR/rename.rs:55:9
|
||||
--> $DIR/rename.rs:56:9
|
||||
|
|
||||
LL | #![warn(clippy::blacklisted_name)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names`
|
||||
|
||||
error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_conditions`
|
||||
--> $DIR/rename.rs:56:9
|
||||
--> $DIR/rename.rs:57:9
|
||||
|
|
||||
LL | #![warn(clippy::block_in_if_condition_expr)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions`
|
||||
|
||||
error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_conditions`
|
||||
--> $DIR/rename.rs:57:9
|
||||
--> $DIR/rename.rs:58:9
|
||||
|
|
||||
LL | #![warn(clippy::block_in_if_condition_stmt)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions`
|
||||
|
||||
error: lint `clippy::blocks_in_if_conditions` has been renamed to `clippy::blocks_in_conditions`
|
||||
--> $DIR/rename.rs:58:9
|
||||
--> $DIR/rename.rs:59:9
|
||||
|
|
||||
LL | #![warn(clippy::blocks_in_if_conditions)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_conditions`
|
||||
|
||||
error: lint `clippy::box_vec` has been renamed to `clippy::box_collection`
|
||||
--> $DIR/rename.rs:59:9
|
||||
--> $DIR/rename.rs:60:9
|
||||
|
|
||||
LL | #![warn(clippy::box_vec)]
|
||||
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection`
|
||||
|
||||
error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes`
|
||||
--> $DIR/rename.rs:60:9
|
||||
--> $DIR/rename.rs:61:9
|
||||
|
|
||||
LL | #![warn(clippy::const_static_lifetime)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes`
|
||||
|
||||
error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity`
|
||||
--> $DIR/rename.rs:61:9
|
||||
--> $DIR/rename.rs:62:9
|
||||
|
|
||||
LL | #![warn(clippy::cyclomatic_complexity)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity`
|
||||
|
||||
error: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq`
|
||||
--> $DIR/rename.rs:62:9
|
||||
--> $DIR/rename.rs:63:9
|
||||
|
|
||||
LL | #![warn(clippy::derive_hash_xor_eq)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq`
|
||||
|
||||
error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods`
|
||||
--> $DIR/rename.rs:63:9
|
||||
--> $DIR/rename.rs:64:9
|
||||
|
|
||||
LL | #![warn(clippy::disallowed_method)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods`
|
||||
|
||||
error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types`
|
||||
--> $DIR/rename.rs:64:9
|
||||
--> $DIR/rename.rs:65:9
|
||||
|
|
||||
LL | #![warn(clippy::disallowed_type)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types`
|
||||
|
||||
error: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression`
|
||||
--> $DIR/rename.rs:65:9
|
||||
--> $DIR/rename.rs:66:9
|
||||
|
|
||||
LL | #![warn(clippy::eval_order_dependence)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression`
|
||||
|
||||
error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion`
|
||||
--> $DIR/rename.rs:66:9
|
||||
--> $DIR/rename.rs:67:9
|
||||
|
|
||||
LL | #![warn(clippy::identity_conversion)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion`
|
||||
|
||||
error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok`
|
||||
--> $DIR/rename.rs:67:9
|
||||
--> $DIR/rename.rs:68:9
|
||||
|
|
||||
LL | #![warn(clippy::if_let_some_result)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok`
|
||||
|
||||
error: lint `clippy::incorrect_clone_impl_on_copy_type` has been renamed to `clippy::non_canonical_clone_impl`
|
||||
--> $DIR/rename.rs:68:9
|
||||
--> $DIR/rename.rs:69:9
|
||||
|
|
||||
LL | #![warn(clippy::incorrect_clone_impl_on_copy_type)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_clone_impl`
|
||||
|
||||
error: lint `clippy::incorrect_partial_ord_impl_on_ord_type` has been renamed to `clippy::non_canonical_partial_ord_impl`
|
||||
--> $DIR/rename.rs:69:9
|
||||
--> $DIR/rename.rs:70:9
|
||||
|
|
||||
LL | #![warn(clippy::incorrect_partial_ord_impl_on_ord_type)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::non_canonical_partial_ord_impl`
|
||||
|
||||
error: lint `clippy::integer_arithmetic` has been renamed to `clippy::arithmetic_side_effects`
|
||||
--> $DIR/rename.rs:70:9
|
||||
--> $DIR/rename.rs:71:9
|
||||
|
|
||||
LL | #![warn(clippy::integer_arithmetic)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::arithmetic_side_effects`
|
||||
|
||||
error: lint `clippy::logic_bug` has been renamed to `clippy::overly_complex_bool_expr`
|
||||
--> $DIR/rename.rs:71:9
|
||||
--> $DIR/rename.rs:72:9
|
||||
|
|
||||
LL | #![warn(clippy::logic_bug)]
|
||||
| ^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::overly_complex_bool_expr`
|
||||
|
||||
error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default`
|
||||
--> $DIR/rename.rs:72:9
|
||||
--> $DIR/rename.rs:73:9
|
||||
|
|
||||
LL | #![warn(clippy::new_without_default_derive)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default`
|
||||
|
||||
error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map`
|
||||
--> $DIR/rename.rs:73:9
|
||||
--> $DIR/rename.rs:74:9
|
||||
|
|
||||
LL | #![warn(clippy::option_and_then_some)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map`
|
||||
|
||||
error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used`
|
||||
--> $DIR/rename.rs:74:9
|
||||
--> $DIR/rename.rs:75:9
|
||||
|
|
||||
LL | #![warn(clippy::option_expect_used)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
|
||||
|
||||
error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or`
|
||||
--> $DIR/rename.rs:75:9
|
||||
--> $DIR/rename.rs:76:9
|
||||
|
|
||||
LL | #![warn(clippy::option_map_unwrap_or)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
|
||||
|
||||
error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
|
||||
--> $DIR/rename.rs:76:9
|
||||
--> $DIR/rename.rs:77:9
|
||||
|
|
||||
LL | #![warn(clippy::option_map_unwrap_or_else)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
|
||||
|
||||
error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used`
|
||||
--> $DIR/rename.rs:77:9
|
||||
--> $DIR/rename.rs:78:9
|
||||
|
|
||||
LL | #![warn(clippy::option_unwrap_used)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
|
||||
|
||||
error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow`
|
||||
--> $DIR/rename.rs:78:9
|
||||
--> $DIR/rename.rs:79:9
|
||||
|
|
||||
LL | #![warn(clippy::ref_in_deref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow`
|
||||
|
||||
error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used`
|
||||
--> $DIR/rename.rs:79:9
|
||||
--> $DIR/rename.rs:80:9
|
||||
|
|
||||
LL | #![warn(clippy::result_expect_used)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used`
|
||||
|
||||
error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or`
|
||||
--> $DIR/rename.rs:80:9
|
||||
--> $DIR/rename.rs:81:9
|
||||
|
|
||||
LL | #![warn(clippy::result_map_unwrap_or_else)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or`
|
||||
|
||||
error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used`
|
||||
--> $DIR/rename.rs:81:9
|
||||
--> $DIR/rename.rs:82:9
|
||||
|
|
||||
LL | #![warn(clippy::result_unwrap_used)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
|
||||
|
||||
error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str`
|
||||
--> $DIR/rename.rs:82:9
|
||||
--> $DIR/rename.rs:83:9
|
||||
|
|
||||
LL | #![warn(clippy::single_char_push_str)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str`
|
||||
|
||||
error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions`
|
||||
--> $DIR/rename.rs:83:9
|
||||
--> $DIR/rename.rs:84:9
|
||||
|
|
||||
LL | #![warn(clippy::stutter)]
|
||||
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions`
|
||||
|
||||
error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl`
|
||||
--> $DIR/rename.rs:84:9
|
||||
--> $DIR/rename.rs:85:9
|
||||
|
|
||||
LL | #![warn(clippy::to_string_in_display)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::recursive_format_impl`
|
||||
|
||||
error: lint `clippy::unwrap_or_else_default` has been renamed to `clippy::unwrap_or_default`
|
||||
--> $DIR/rename.rs:85:9
|
||||
--> $DIR/rename.rs:86:9
|
||||
|
|
||||
LL | #![warn(clippy::unwrap_or_else_default)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_or_default`
|
||||
|
||||
error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters`
|
||||
--> $DIR/rename.rs:86:9
|
||||
--> $DIR/rename.rs:87:9
|
||||
|
|
||||
LL | #![warn(clippy::zero_width_space)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters`
|
||||
|
||||
error: lint `clippy::cast_ref_to_mut` has been renamed to `invalid_reference_casting`
|
||||
--> $DIR/rename.rs:87:9
|
||||
--> $DIR/rename.rs:88:9
|
||||
|
|
||||
LL | #![warn(clippy::cast_ref_to_mut)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_reference_casting`
|
||||
|
||||
error: lint `clippy::clone_double_ref` has been renamed to `suspicious_double_ref_op`
|
||||
--> $DIR/rename.rs:88:9
|
||||
--> $DIR/rename.rs:89:9
|
||||
|
|
||||
LL | #![warn(clippy::clone_double_ref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `suspicious_double_ref_op`
|
||||
|
||||
error: lint `clippy::cmp_nan` has been renamed to `invalid_nan_comparisons`
|
||||
--> $DIR/rename.rs:89:9
|
||||
--> $DIR/rename.rs:90:9
|
||||
|
|
||||
LL | #![warn(clippy::cmp_nan)]
|
||||
| ^^^^^^^^^^^^^^^ help: use the new name: `invalid_nan_comparisons`
|
||||
|
||||
error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
|
||||
--> $DIR/rename.rs:90:9
|
||||
--> $DIR/rename.rs:91:9
|
||||
|
|
||||
LL | #![warn(clippy::drop_bounds)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds`
|
||||
|
||||
error: lint `clippy::drop_copy` has been renamed to `dropping_copy_types`
|
||||
--> $DIR/rename.rs:91:9
|
||||
--> $DIR/rename.rs:92:9
|
||||
|
|
||||
LL | #![warn(clippy::drop_copy)]
|
||||
| ^^^^^^^^^^^^^^^^^ help: use the new name: `dropping_copy_types`
|
||||
|
||||
error: lint `clippy::drop_ref` has been renamed to `dropping_references`
|
||||
--> $DIR/rename.rs:92:9
|
||||
--> $DIR/rename.rs:93:9
|
||||
|
|
||||
LL | #![warn(clippy::drop_ref)]
|
||||
| ^^^^^^^^^^^^^^^^ help: use the new name: `dropping_references`
|
||||
|
||||
error: lint `clippy::fn_null_check` has been renamed to `useless_ptr_null_checks`
|
||||
--> $DIR/rename.rs:93:9
|
||||
--> $DIR/rename.rs:94:9
|
||||
|
|
||||
LL | #![warn(clippy::fn_null_check)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `useless_ptr_null_checks`
|
||||
|
||||
error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles`
|
||||
--> $DIR/rename.rs:94:9
|
||||
--> $DIR/rename.rs:95:9
|
||||
|
|
||||
LL | #![warn(clippy::for_loop_over_option)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles`
|
||||
|
||||
error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles`
|
||||
--> $DIR/rename.rs:95:9
|
||||
--> $DIR/rename.rs:96:9
|
||||
|
|
||||
LL | #![warn(clippy::for_loop_over_result)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles`
|
||||
|
||||
error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles`
|
||||
--> $DIR/rename.rs:96:9
|
||||
--> $DIR/rename.rs:97:9
|
||||
|
|
||||
LL | #![warn(clippy::for_loops_over_fallibles)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles`
|
||||
|
||||
error: lint `clippy::forget_copy` has been renamed to `forgetting_copy_types`
|
||||
--> $DIR/rename.rs:97:9
|
||||
--> $DIR/rename.rs:98:9
|
||||
|
|
||||
LL | #![warn(clippy::forget_copy)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_copy_types`
|
||||
|
||||
error: lint `clippy::forget_ref` has been renamed to `forgetting_references`
|
||||
--> $DIR/rename.rs:98:9
|
||||
--> $DIR/rename.rs:99:9
|
||||
|
|
||||
LL | #![warn(clippy::forget_ref)]
|
||||
| ^^^^^^^^^^^^^^^^^^ help: use the new name: `forgetting_references`
|
||||
|
||||
error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter`
|
||||
--> $DIR/rename.rs:99:9
|
||||
--> $DIR/rename.rs:100:9
|
||||
|
|
||||
LL | #![warn(clippy::into_iter_on_array)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter`
|
||||
|
||||
error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering`
|
||||
--> $DIR/rename.rs:100:9
|
||||
--> $DIR/rename.rs:101:9
|
||||
|
|
||||
LL | #![warn(clippy::invalid_atomic_ordering)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering`
|
||||
|
||||
error: lint `clippy::invalid_ref` has been renamed to `invalid_value`
|
||||
--> $DIR/rename.rs:101:9
|
||||
--> $DIR/rename.rs:102:9
|
||||
|
|
||||
LL | #![warn(clippy::invalid_ref)]
|
||||
| ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value`
|
||||
|
||||
error: lint `clippy::invalid_utf8_in_unchecked` has been renamed to `invalid_from_utf8_unchecked`
|
||||
--> $DIR/rename.rs:102:9
|
||||
--> $DIR/rename.rs:103:9
|
||||
|
|
||||
LL | #![warn(clippy::invalid_utf8_in_unchecked)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_from_utf8_unchecked`
|
||||
|
||||
error: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop`
|
||||
--> $DIR/rename.rs:103:9
|
||||
--> $DIR/rename.rs:104:9
|
||||
|
|
||||
LL | #![warn(clippy::let_underscore_drop)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop`
|
||||
|
||||
error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums`
|
||||
--> $DIR/rename.rs:104:9
|
||||
--> $DIR/rename.rs:105:9
|
||||
|
|
||||
LL | #![warn(clippy::mem_discriminant_non_enum)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums`
|
||||
|
||||
error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
|
||||
--> $DIR/rename.rs:105:9
|
||||
--> $DIR/rename.rs:106:9
|
||||
|
|
||||
LL | #![warn(clippy::panic_params)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics`
|
||||
|
||||
error: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally`
|
||||
--> $DIR/rename.rs:106:9
|
||||
--> $DIR/rename.rs:107:9
|
||||
|
|
||||
LL | #![warn(clippy::positional_named_format_parameters)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `named_arguments_used_positionally`
|
||||
|
||||
error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr`
|
||||
--> $DIR/rename.rs:107:9
|
||||
--> $DIR/rename.rs:108:9
|
||||
|
|
||||
LL | #![warn(clippy::temporary_cstring_as_ptr)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr`
|
||||
|
||||
error: lint `clippy::undropped_manually_drops` has been renamed to `undropped_manually_drops`
|
||||
--> $DIR/rename.rs:108:9
|
||||
--> $DIR/rename.rs:109:9
|
||||
|
|
||||
LL | #![warn(clippy::undropped_manually_drops)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `undropped_manually_drops`
|
||||
|
||||
error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints`
|
||||
--> $DIR/rename.rs:109:9
|
||||
--> $DIR/rename.rs:110:9
|
||||
|
|
||||
LL | #![warn(clippy::unknown_clippy_lints)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints`
|
||||
|
||||
error: lint `clippy::unused_label` has been renamed to `unused_labels`
|
||||
--> $DIR/rename.rs:110:9
|
||||
--> $DIR/rename.rs:111:9
|
||||
|
|
||||
LL | #![warn(clippy::unused_label)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels`
|
||||
|
||||
error: aborting due to 57 previous errors
|
||||
error: lint `clippy::vtable_address_comparisons` has been renamed to `ambiguous_wide_pointer_comparisons`
|
||||
--> $DIR/rename.rs:112:9
|
||||
|
|
||||
LL | #![warn(clippy::vtable_address_comparisons)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `ambiguous_wide_pointer_comparisons`
|
||||
|
||||
error: aborting due to 58 previous errors
|
||||
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
use std::fmt::Debug;
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[warn(clippy::vtable_address_comparisons)]
|
||||
#[allow(clippy::borrow_as_ptr)]
|
||||
|
||||
fn main() {
|
||||
let a: *const dyn Debug = &1 as &dyn Debug;
|
||||
let b: *const dyn Debug = &1 as &dyn Debug;
|
||||
|
||||
// These should fail:
|
||||
let _ = a == b;
|
||||
//~^ ERROR: comparing trait object pointers compares a non-unique vtable address
|
||||
let _ = a != b;
|
||||
//~^ ERROR: comparing trait object pointers compares a non-unique vtable address
|
||||
let _ = a < b;
|
||||
//~^ ERROR: comparing trait object pointers compares a non-unique vtable address
|
||||
let _ = a <= b;
|
||||
//~^ ERROR: comparing trait object pointers compares a non-unique vtable address
|
||||
let _ = a > b;
|
||||
//~^ ERROR: comparing trait object pointers compares a non-unique vtable address
|
||||
let _ = a >= b;
|
||||
//~^ ERROR: comparing trait object pointers compares a non-unique vtable address
|
||||
ptr::eq(a, b);
|
||||
//~^ ERROR: comparing trait object pointers compares a non-unique vtable address
|
||||
|
||||
let a = &1 as &dyn Debug;
|
||||
let b = &1 as &dyn Debug;
|
||||
ptr::eq(a, b);
|
||||
//~^ ERROR: comparing trait object pointers compares a non-unique vtable address
|
||||
|
||||
// These should be fine:
|
||||
let a = &1;
|
||||
ptr::eq(a, a);
|
||||
|
||||
let a = Rc::new(1);
|
||||
Rc::ptr_eq(&a, &a);
|
||||
|
||||
let a = Arc::new(1);
|
||||
Arc::ptr_eq(&a, &a);
|
||||
|
||||
let a: Rc<dyn Debug> = Rc::new(1);
|
||||
Rc::ptr_eq(&a, &a);
|
||||
|
||||
let a: Arc<dyn Debug> = Arc::new(1);
|
||||
Arc::ptr_eq(&a, &a);
|
||||
|
||||
let a: &[u8] = b"";
|
||||
ptr::eq(a, a);
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
error: comparing trait object pointers compares a non-unique vtable address
|
||||
--> $DIR/vtable_address_comparisons.rs:14:13
|
||||
|
|
||||
LL | let _ = a == b;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider extracting and comparing data pointers only
|
||||
= note: `-D clippy::vtable-address-comparisons` implied by `-D warnings`
|
||||
= help: to override `-D warnings` add `#[allow(clippy::vtable_address_comparisons)]`
|
||||
|
||||
error: comparing trait object pointers compares a non-unique vtable address
|
||||
--> $DIR/vtable_address_comparisons.rs:16:13
|
||||
|
|
||||
LL | let _ = a != b;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider extracting and comparing data pointers only
|
||||
|
||||
error: comparing trait object pointers compares a non-unique vtable address
|
||||
--> $DIR/vtable_address_comparisons.rs:18:13
|
||||
|
|
||||
LL | let _ = a < b;
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider extracting and comparing data pointers only
|
||||
|
||||
error: comparing trait object pointers compares a non-unique vtable address
|
||||
--> $DIR/vtable_address_comparisons.rs:20:13
|
||||
|
|
||||
LL | let _ = a <= b;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider extracting and comparing data pointers only
|
||||
|
||||
error: comparing trait object pointers compares a non-unique vtable address
|
||||
--> $DIR/vtable_address_comparisons.rs:22:13
|
||||
|
|
||||
LL | let _ = a > b;
|
||||
| ^^^^^
|
||||
|
|
||||
= help: consider extracting and comparing data pointers only
|
||||
|
||||
error: comparing trait object pointers compares a non-unique vtable address
|
||||
--> $DIR/vtable_address_comparisons.rs:24:13
|
||||
|
|
||||
LL | let _ = a >= b;
|
||||
| ^^^^^^
|
||||
|
|
||||
= help: consider extracting and comparing data pointers only
|
||||
|
||||
error: comparing trait object pointers compares a non-unique vtable address
|
||||
--> $DIR/vtable_address_comparisons.rs:26:5
|
||||
|
|
||||
LL | ptr::eq(a, b);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider extracting and comparing data pointers only
|
||||
|
||||
error: comparing trait object pointers compares a non-unique vtable address
|
||||
--> $DIR/vtable_address_comparisons.rs:31:5
|
||||
|
|
||||
LL | ptr::eq(a, b);
|
||||
| ^^^^^^^^^^^^^
|
||||
|
|
||||
= help: consider extracting and comparing data pointers only
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue