r? @ghost

changelog: none
This commit is contained in:
Philipp Krones 2025-04-03 20:12:28 +00:00 committed by GitHub
commit 7bb54d91be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 288 additions and 851 deletions

View file

@ -1,7 +1,7 @@
[package]
name = "clippy"
# begin autogenerated version
version = "0.1.87"
version = "0.1.88"
# end autogenerated version
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"

View file

@ -1,7 +1,7 @@
[package]
name = "clippy_config"
# begin autogenerated version
version = "0.1.87"
version = "0.1.88"
# end autogenerated version
edition = "2024"
publish = false

View file

@ -1,7 +1,7 @@
[package]
name = "clippy_lints"
# begin autogenerated version
version = "0.1.87"
version = "0.1.88"
# end autogenerated version
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
repository = "https://github.com/rust-lang/rust-clippy"

View file

@ -36,14 +36,14 @@ fn check_duplicated_attr(
}
let Some(ident) = attr.ident() else { return };
let name = ident.name;
if name == sym::doc || name == sym::cfg_attr || name == sym::rustc_on_unimplemented || name == sym::reason {
if name == sym::doc || name == sym::cfg_attr_trace || name == sym::rustc_on_unimplemented || name == sym::reason {
// FIXME: Would be nice to handle `cfg_attr` as well. Only problem is to check that cfg
// conditions are the same.
// `#[rustc_on_unimplemented]` contains duplicated subattributes, that's expected.
return;
}
if let Some(direct_parent) = parent.last()
&& ["cfg", "cfg_attr"].contains(&direct_parent.as_str())
&& direct_parent == sym::cfg_trace.as_str()
&& [sym::all, sym::not, sym::any].contains(&name)
{
// FIXME: We don't correctly check `cfg`s for now, so if it's more complex than just a one

View file

@ -143,7 +143,7 @@ pub(super) fn check<'tcx>(
if cast_from.kind() == cast_to.kind() && !expr.span.in_external_macro(cx.sess().source_map()) {
if let Some(id) = path_to_local(cast_expr)
&& !cx.tcx.hir().span(id).eq_ctxt(cast_expr.span)
&& !cx.tcx.hir_span(id).eq_ctxt(cast_expr.span)
{
// Binding context is different than the identifiers context.
// Weird macro wizardry could be involved here.

View file

@ -32,7 +32,7 @@ declare_lint_pass!(CfgNotTest => [CFG_NOT_TEST]);
impl EarlyLintPass for CfgNotTest {
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &rustc_ast::Attribute) {
if attr.has_name(rustc_span::sym::cfg) && contains_not_test(attr.meta_item_list().as_deref(), false) {
if attr.has_name(rustc_span::sym::cfg_trace) && contains_not_test(attr.meta_item_list().as_deref(), false) {
span_lint_and_then(
cx,
CFG_NOT_TEST,

View file

@ -53,7 +53,7 @@ declare_lint_pass!(CrateInMacroDef => [CRATE_IN_MACRO_DEF]);
impl EarlyLintPass for CrateInMacroDef {
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
if let ItemKind::MacroDef(macro_def) = &item.kind
if let ItemKind::MacroDef(_, macro_def) = &item.kind
&& item.attrs.iter().any(is_macro_export)
&& let Some(span) = contains_unhygienic_crate_reference(&macro_def.body.tokens)
{

View file

@ -641,7 +641,6 @@ pub static LINTS: &[&crate::LintInfo] = &[
crate::precedence::PRECEDENCE_INFO,
crate::precedence::PRECEDENCE_BITS_INFO,
crate::ptr::CMP_NULL_INFO,
crate::ptr::INVALID_NULL_PTR_USAGE_INFO,
crate::ptr::MUT_FROM_REF_INFO,
crate::ptr::PTR_ARG_INFO,
crate::ptr::PTR_EQ_INFO,

View file

@ -134,7 +134,7 @@ impl<'tcx> LateLintPass<'tcx> for Default {
&& let ty::Adt(adt, args) = *binding_type.kind()
&& adt.is_struct()
&& let variant = adt.non_enum_variant()
&& (adt.did().is_local() || !variant.is_field_list_non_exhaustive())
&& !variant.field_list_has_applicable_non_exhaustive()
&& let module_did = cx.tcx.parent_module(stmt.hir_id)
&& variant
.fields

View file

@ -131,6 +131,8 @@ declare_with_version! { RENAMED(RENAMED_VERSION): &[(&str, &str)] = &[
("clippy::clone_double_ref", "suspicious_double_ref_op"),
#[clippy::version = ""]
("clippy::cmp_nan", "invalid_nan_comparisons"),
#[clippy::version = "CURRENT_RUSTC_VERSION"]
("clippy::invalid_null_ptr_usage", "invalid_null_arguments"),
#[clippy::version = "1.86.0"]
("clippy::double_neg", "double_negations"),
#[clippy::version = ""]

View file

@ -254,7 +254,7 @@ fn check_hash_peq<'tcx>(
|diag| {
if let Some(local_def_id) = impl_id.as_local() {
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialEq` implemented here");
diag.span_note(cx.tcx.hir_span(hir_id), "`PartialEq` implemented here");
}
},
);
@ -298,7 +298,7 @@ fn check_ord_partial_ord<'tcx>(
span_lint_and_then(cx, DERIVE_ORD_XOR_PARTIAL_ORD, span, mess, |diag| {
if let Some(local_def_id) = impl_id.as_local() {
let hir_id = cx.tcx.local_def_id_to_hir_id(local_def_id);
diag.span_note(cx.tcx.hir().span(hir_id), "`PartialOrd` implemented here");
diag.span_note(cx.tcx.hir_span(hir_id), "`PartialOrd` implemented here");
}
});
}
@ -324,11 +324,9 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
// there's a Copy impl for any instance of the adt.
if !is_copy(cx, ty) {
if ty_subs.non_erasable_generics().next().is_some() {
let has_copy_impl = cx.tcx.all_local_trait_impls(()).get(&copy_id).is_some_and(|impls| {
impls.iter().any(|&id| {
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
let has_copy_impl = cx.tcx.local_trait_impls(copy_id).iter().any(|&id| {
matches!(cx.tcx.type_of(id).instantiate_identity().kind(), ty::Adt(adt, _)
if ty_adt.did() == adt.did())
})
});
if !has_copy_impl {
return;

View file

@ -13,16 +13,16 @@ use rustc_parse::parser::ForceCollect;
use rustc_session::parse::ParseSess;
use rustc_span::edition::Edition;
use rustc_span::source_map::{FilePathMapping, SourceMap};
use rustc_span::{FileName, Pos, sym};
use rustc_span::{FileName, Ident, Pos, sym};
use super::Fragments;
fn get_test_spans(item: &Item, test_attr_spans: &mut Vec<Range<usize>>) {
fn get_test_spans(item: &Item, ident: Ident, test_attr_spans: &mut Vec<Range<usize>>) {
test_attr_spans.extend(
item.attrs
.iter()
.find(|attr| attr.has_name(sym::test))
.map(|attr| attr.span.lo().to_usize()..item.ident.span.hi().to_usize()),
.map(|attr| attr.span.lo().to_usize()..ident.span.hi().to_usize()),
);
}
@ -64,10 +64,13 @@ pub fn check(
match parser.parse_item(ForceCollect::No) {
Ok(Some(item)) => match &item.kind {
ItemKind::Fn(box Fn {
sig, body: Some(block), ..
}) if item.ident.name == sym::main => {
ident,
sig,
body: Some(block),
..
}) if ident.name == sym::main => {
if !ignore {
get_test_spans(&item, &mut test_attr_spans);
get_test_spans(&item, *ident, &mut test_attr_spans);
}
let is_async = matches!(sig.header.coroutine_kind, Some(CoroutineKind::Async { .. }));
let returns_nothing = match &sig.decl.output {
@ -85,10 +88,10 @@ pub fn check(
}
},
// Another function was found; this case is ignored for needless_doctest_main
ItemKind::Fn(box Fn { .. }) => {
ItemKind::Fn(fn_) => {
eligible = false;
if !ignore {
get_test_spans(&item, &mut test_attr_spans);
get_test_spans(&item, fn_.ident, &mut test_attr_spans);
}
},
// Tests with one of these items are ignored

View file

@ -63,7 +63,7 @@ impl_lint_pass!(DuplicateMod => [DUPLICATE_MOD]);
impl EarlyLintPass for DuplicateMod {
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
if let ItemKind::Mod(_, ModKind::Loaded(_, Inline::No, mod_spans, _)) = &item.kind
if let ItemKind::Mod(_, _, ModKind::Loaded(_, Inline::No, mod_spans, _)) = &item.kind
&& let FileName::Real(real) = cx.sess().source_map().span_to_filename(mod_spans.inner_span)
&& let Some(local_path) = real.into_local_path()
&& let Ok(absolute_path) = local_path.canonicalize()

View file

@ -8,8 +8,7 @@ use rustc_errors::{Applicability, Diag, SuggestionStyle};
use rustc_lexer::TokenKind;
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
use rustc_session::impl_lint_pass;
use rustc_span::symbol::kw;
use rustc_span::{BytePos, ExpnKind, Ident, InnerSpan, Span, SpanData, Symbol};
use rustc_span::{BytePos, ExpnKind, Ident, InnerSpan, Span, SpanData, Symbol, kw};
declare_clippy_lint! {
/// ### What it does
@ -375,21 +374,23 @@ impl EmptyLineAfter {
&mut self,
cx: &EarlyContext<'_>,
kind: &ItemKind,
ident: &Ident,
ident: Option<Ident>,
span: Span,
attrs: &[Attribute],
id: NodeId,
) {
self.items.push(ItemInfo {
kind: kind.descr(),
name: ident.name,
span: if span.contains(ident.span) {
// FIXME: this `sym::empty` can be leaked, see
// https://github.com/rust-lang/rust/pull/138740#discussion_r2021979899
name: if let Some(ident) = ident { ident.name } else { kw::Empty },
span: if let Some(ident) = ident {
span.with_hi(ident.span.hi())
} else {
span.with_hi(span.lo())
},
mod_items: match kind {
ItemKind::Mod(_, ModKind::Loaded(items, _, _, _)) => items
ItemKind::Mod(_, _, ModKind::Loaded(items, _, _, _)) => items
.iter()
.filter(|i| !matches!(i.span.ctxt().outer_expn_data().kind, ExpnKind::AstPass(_)))
.map(|i| i.id)
@ -471,7 +472,7 @@ impl EarlyLintPass for EmptyLineAfter {
self.check_item_kind(
cx,
&item.kind.clone().into(),
&item.ident,
item.kind.ident(),
item.span,
&item.attrs,
item.id,
@ -482,7 +483,7 @@ impl EarlyLintPass for EmptyLineAfter {
self.check_item_kind(
cx,
&item.kind.clone().into(),
&item.ident,
item.kind.ident(),
item.span,
&item.attrs,
item.id,
@ -490,6 +491,6 @@ impl EarlyLintPass for EmptyLineAfter {
}
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
self.check_item_kind(cx, &item.kind, &item.ident, item.span, &item.attrs, item.id);
self.check_item_kind(cx, &item.kind, item.kind.ident(), item.span, &item.attrs, item.id);
}
}

View file

@ -74,10 +74,9 @@ declare_lint_pass!(EmptyWithBrackets => [EMPTY_STRUCTS_WITH_BRACKETS, EMPTY_ENUM
impl EarlyLintPass for EmptyWithBrackets {
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
let span_after_ident = item.span.with_lo(item.ident.span.hi());
if let ItemKind::Struct(var_data, _) = &item.kind
if let ItemKind::Struct(ident, var_data, _) = &item.kind
&& has_brackets(var_data)
&& let span_after_ident = item.span.with_lo(ident.span.hi())
&& has_no_fields(cx, var_data, span_after_ident)
{
span_lint_and_then(

View file

@ -119,7 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
cx,
BOXED_LOCAL,
node,
cx.tcx.hir().span(node),
cx.tcx.hir_span(node),
"local variable doesn't need to be boxed here",
);
}

View file

@ -51,7 +51,7 @@ declare_lint_pass!(FieldScopedVisibilityModifiers => [FIELD_SCOPED_VISIBILITY_MO
impl EarlyLintPass for FieldScopedVisibilityModifiers {
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
let ItemKind::Struct(ref st, _) = item.kind else {
let ItemKind::Struct(_, ref st, _) = item.kind else {
return;
};
for field in st.fields() {

View file

@ -5,7 +5,7 @@ use rustc_hir::hir_id::OwnerId;
use rustc_hir::{Impl, ImplItem, ImplItemKind, ImplItemRef, ItemKind, Node, TraitRef};
use rustc_lint::LateContext;
use rustc_span::Span;
use rustc_span::symbol::{Ident, Symbol, kw};
use rustc_span::symbol::{Ident, kw};
use super::RENAMED_FUNCTION_PARAMS;
@ -51,22 +51,31 @@ struct RenamedFnArgs(Vec<(Span, String)>);
impl RenamedFnArgs {
/// Comparing between an iterator of default names and one with current names,
/// then collect the ones that got renamed.
fn new<I, T>(default_names: &mut I, current_names: &mut T) -> Self
fn new<I1, I2>(default_idents: &mut I1, current_idents: &mut I2) -> Self
where
I: Iterator<Item = Ident>,
T: Iterator<Item = Ident>,
I1: Iterator<Item = Option<Ident>>,
I2: Iterator<Item = Option<Ident>>,
{
let mut renamed: Vec<(Span, String)> = vec![];
debug_assert!(default_names.size_hint() == current_names.size_hint());
while let (Some(def_name), Some(cur_name)) = (default_names.next(), current_names.next()) {
let current_name = cur_name.name;
let default_name = def_name.name;
if is_unused_or_empty_symbol(current_name) || is_unused_or_empty_symbol(default_name) {
continue;
}
if current_name != default_name {
renamed.push((cur_name.span, default_name.to_string()));
debug_assert!(default_idents.size_hint() == current_idents.size_hint());
while let (Some(default_ident), Some(current_ident)) = (default_idents.next(), current_idents.next()) {
let has_name_to_check = |ident: Option<Ident>| {
if let Some(ident) = ident
&& ident.name != kw::Underscore
&& !ident.name.as_str().starts_with('_')
{
Some(ident)
} else {
None
}
};
if let Some(default_ident) = has_name_to_check(default_ident)
&& let Some(current_ident) = has_name_to_check(current_ident)
&& default_ident.name != current_ident.name
{
renamed.push((current_ident.span, default_ident.to_string()));
}
}
@ -83,14 +92,6 @@ impl RenamedFnArgs {
}
}
fn is_unused_or_empty_symbol(symbol: Symbol) -> bool {
// FIXME: `body_param_names` currently returning empty symbols for `wild` as well,
// so we need to check if the symbol is empty first.
// Therefore the check of whether it's equal to [`kw::Underscore`] has no use for now,
// but it would be nice to keep it here just to be future-proof.
symbol.is_empty() || symbol == kw::Underscore || symbol.as_str().starts_with('_')
}
/// Get the [`trait_item_def_id`](ImplItemRef::trait_item_def_id) of a relevant impl item.
fn trait_item_def_id_of_impl(items: &[ImplItemRef], target: OwnerId) -> Option<DefId> {
items.iter().find_map(|item| {

View file

@ -248,7 +248,7 @@ impl<'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'_, 'tcx> {
{
use_info
.index_use
.push((index_value, cx.tcx.hir().span(parent_expr.hir_id)));
.push((index_value, cx.tcx.hir_span(parent_expr.hir_id)));
return;
}

View file

@ -189,7 +189,7 @@ fn check_fn_inner<'tcx>(
cx: &LateContext<'tcx>,
sig: &'tcx FnSig<'_>,
body: Option<BodyId>,
trait_sig: Option<&[Ident]>,
trait_sig: Option<&[Option<Ident>]>,
generics: &'tcx Generics<'_>,
span: Span,
report_extra_lifetimes: bool,
@ -264,7 +264,7 @@ fn could_use_elision<'tcx>(
cx: &LateContext<'tcx>,
func: &'tcx FnDecl<'_>,
body: Option<BodyId>,
trait_sig: Option<&[Ident]>,
trait_sig: Option<&[Option<Ident>]>,
named_generics: &'tcx [GenericParam<'_>],
msrv: Msrv,
) -> Option<(Vec<LocalDefId>, Vec<Lifetime>)> {
@ -300,8 +300,8 @@ fn could_use_elision<'tcx>(
let input_lts = input_visitor.lts;
let output_lts = output_visitor.lts;
if let Some(trait_sig) = trait_sig
&& non_elidable_self_type(cx, func, trait_sig.first().copied(), msrv)
if let Some(&[trait_sig]) = trait_sig
&& non_elidable_self_type(cx, func, trait_sig, msrv)
{
return None;
}

View file

@ -86,10 +86,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
&& let PlaceBase::Local(id) = cmt.place.base
{
if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));
self.span_low = Some(self.cx.tcx.hir_span(diag_expr_id));
}
if Some(id) == self.hir_id_high && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id));
self.span_high = Some(self.cx.tcx.hir_span(diag_expr_id));
}
}
}
@ -97,10 +97,10 @@ impl<'tcx> Delegate<'tcx> for MutatePairDelegate<'_, 'tcx> {
fn mutate(&mut self, cmt: &PlaceWithHirId<'tcx>, diag_expr_id: HirId) {
if let PlaceBase::Local(id) = cmt.place.base {
if Some(id) == self.hir_id_low && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
self.span_low = Some(self.cx.tcx.hir().span(diag_expr_id));
self.span_low = Some(self.cx.tcx.hir_span(diag_expr_id));
}
if Some(id) == self.hir_id_high && !BreakAfterExprVisitor::is_found(self.cx, diag_expr_id) {
self.span_high = Some(self.cx.tcx.hir().span(diag_expr_id));
self.span_high = Some(self.cx.tcx.hir_span(diag_expr_id));
}
}
}

View file

@ -262,7 +262,7 @@ impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe {
// Remove the syntax context to hide "in this macro invocation" in the diagnostic.
// The invocation doesn't matter. Also we want to dedupe by the unsafe block and not by anything
// related to the callsite.
let span = cx.tcx.hir().span(id);
let span = cx.tcx.hir_span(id);
(id, Span::new(span.lo(), span.hi(), SyntaxContext::root(), None))
})

View file

@ -246,7 +246,6 @@ fn emit_redundant_guards<'tcx>(
fn expr_can_be_pat(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
for_each_expr_without_closures(expr, |expr| {
if match expr.kind {
ExprKind::ConstBlock(..) => cx.tcx.features().inline_const_pat(),
ExprKind::Call(c, ..) if let ExprKind::Path(qpath) = c.kind => {
// Allow ctors
matches!(cx.qpath_res(&qpath, c.hir_id), Res::Def(DefKind::Ctor(..), ..))

View file

@ -39,7 +39,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, receiver: &Expr<'_
fn is_under_cfg(cx: &LateContext<'_>, id: HirId) -> bool {
cx.tcx
.hir_parent_id_iter(id)
.any(|id| cx.tcx.hir_attrs(id).iter().any(|attr| attr.has_name(sym::cfg)))
.any(|id| cx.tcx.hir_attrs(id).iter().any(|attr| attr.has_name(sym::cfg_trace)))
}
/// Similar to [`clippy_utils::expr_or_init`], but does not go up the chain if the initialization

View file

@ -329,7 +329,7 @@ fn used_underscore_binding<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
let name = ident.name.as_str();
if name.starts_with('_')
&& !name.starts_with("__")
&& let definition_span = cx.tcx.hir().span(definition_hir_id)
&& let definition_span = cx.tcx.hir_span(definition_hir_id)
&& !definition_span.from_expansion()
&& !fulfill_or_allowed(cx, USED_UNDERSCORE_BINDING, [expr.hir_id, definition_hir_id])
{

View file

@ -39,7 +39,7 @@ declare_lint_pass!(MultipleBoundLocations => [MULTIPLE_BOUND_LOCATIONS]);
impl EarlyLintPass for MultipleBoundLocations {
fn check_fn(&mut self, cx: &EarlyContext<'_>, kind: FnKind<'_>, _: Span, _: NodeId) {
if let FnKind::Fn(_, _, _, Fn { generics, .. }) = kind
if let FnKind::Fn(_, _, Fn { generics, .. }) = kind
&& !generics.params.is_empty()
&& !generics.where_clause.predicates.is_empty()
{

View file

@ -280,7 +280,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
diag.span_suggestion(
sp,
"consider changing to".to_string(),
format!("&{}", snippet(cx, cx.tcx.hir().span(inner_ty.ty.hir_id), "_"),),
format!("&{}", snippet(cx, cx.tcx.hir_span(inner_ty.ty.hir_id), "_"),),
Applicability::Unspecified,
);
if cx.effective_visibilities.is_exported(*fn_def_id) {

View file

@ -198,7 +198,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
// Dereference suggestion
let sugg = |diag: &mut Diag<'_, ()>| {
if let ty::Adt(def, ..) = ty.kind()
&& let Some(span) = cx.tcx.hir().span_if_local(def.did())
&& let Some(span) = cx.tcx.hir_span_if_local(def.did())
&& type_allowed_to_implement_copy(
cx.tcx,
cx.param_env,

View file

@ -97,14 +97,14 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
{
if self.impling_types.is_none() {
let mut impls = HirIdSet::default();
cx.tcx.for_each_impl(default_trait_id, |d| {
for &d in cx.tcx.local_trait_impls(default_trait_id) {
let ty = cx.tcx.type_of(d).instantiate_identity();
if let Some(ty_def) = ty.ty_adt_def()
&& let Some(local_def_id) = ty_def.did().as_local()
{
impls.insert(cx.tcx.local_def_id_to_hir_id(local_def_id));
}
});
}
self.impling_types = Some(impls);
}

View file

@ -354,7 +354,7 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
let body_owner_kind = cx.tcx.hir_body_owner_kind(body_owner_def_id);
if let hir::BodyOwnerKind::Const { .. } | hir::BodyOwnerKind::Static(_) = body_owner_kind {
let body_span = cx.tcx.hir().span_with_body(body_owner);
let body_span = cx.tcx.hir_span_with_body(body_owner);
if let Some(span) = self.const_span
&& span.contains(body_span)
{
@ -366,7 +366,7 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
fn check_body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
let body_owner = cx.tcx.hir_body_owner(body.id());
let body_span = cx.tcx.hir().span(body_owner);
let body_span = cx.tcx.hir_span(body_owner);
if let Some(span) = self.const_span
&& span.contains(body_span)
{

View file

@ -73,7 +73,7 @@ impl Context {
match cx.tcx.hir_body_owner_kind(body_owner_def_id) {
hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const { .. } => {
let body_span = cx.tcx.hir().span_with_body(body_owner);
let body_span = cx.tcx.hir_span_with_body(body_owner);
if let Some(span) = self.const_span
&& span.contains(body_span)
@ -88,7 +88,7 @@ impl Context {
pub fn body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
let body_owner = cx.tcx.hir_body_owner(body.id());
let body_span = cx.tcx.hir().span_with_body(body_owner);
let body_span = cx.tcx.hir_span_with_body(body_owner);
if let Some(span) = self.const_span
&& span.contains(body_span)

View file

@ -41,7 +41,7 @@ declare_lint_pass!(PartialPubFields => [PARTIAL_PUB_FIELDS]);
impl EarlyLintPass for PartialPubFields {
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) {
let ItemKind::Struct(ref st, _) = item.kind else {
let ItemKind::Struct(_, ref st, _) = item.kind else {
return;
};

View file

@ -125,29 +125,6 @@ declare_clippy_lint! {
"fns that create mutable refs from immutable ref args"
}
declare_clippy_lint! {
/// ### What it does
/// This lint checks for invalid usages of `ptr::null`.
///
/// ### Why is this bad?
/// This causes undefined behavior.
///
/// ### Example
/// ```ignore
/// // Undefined behavior
/// unsafe { std::slice::from_raw_parts(ptr::null(), 0); }
/// ```
///
/// Use instead:
/// ```ignore
/// unsafe { std::slice::from_raw_parts(NonNull::dangling().as_ptr(), 0); }
/// ```
#[clippy::version = "1.53.0"]
pub INVALID_NULL_PTR_USAGE,
correctness,
"invalid usage of a null pointer, suggesting `NonNull::dangling()` instead"
}
declare_clippy_lint! {
/// ### What it does
/// Use `std::ptr::eq` when applicable
@ -177,7 +154,7 @@ declare_clippy_lint! {
"use `std::ptr::eq` when comparing raw pointers"
}
declare_lint_pass!(Ptr => [PTR_ARG, CMP_NULL, MUT_FROM_REF, INVALID_NULL_PTR_USAGE, PTR_EQ]);
declare_lint_pass!(Ptr => [PTR_ARG, CMP_NULL, MUT_FROM_REF, PTR_EQ]);
impl<'tcx> LateLintPass<'tcx> for Ptr {
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
@ -301,54 +278,6 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
format!("{non_null_path_snippet}.is_null()"),
Applicability::MachineApplicable,
);
} else {
check_invalid_ptr_usage(cx, expr);
}
}
}
fn check_invalid_ptr_usage<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if let ExprKind::Call(fun, args) = expr.kind
&& let ExprKind::Path(ref qpath) = fun.kind
&& let Some(fun_def_id) = cx.qpath_res(qpath, fun.hir_id).opt_def_id()
&& let Some(name) = cx.tcx.get_diagnostic_name(fun_def_id)
{
// TODO: `ptr_slice_from_raw_parts` and its mutable variant should probably still be linted
// conditionally based on how the return value is used, but not universally like the other
// functions since there are valid uses for null slice pointers.
//
// See: https://github.com/rust-lang/rust-clippy/pull/13452/files#r1773772034
// `arg` positions where null would cause U.B.
let arg_indices: &[_] = match name {
sym::ptr_read
| sym::ptr_read_unaligned
| sym::ptr_read_volatile
| sym::ptr_replace
| sym::ptr_write
| sym::ptr_write_bytes
| sym::ptr_write_unaligned
| sym::ptr_write_volatile
| sym::slice_from_raw_parts
| sym::slice_from_raw_parts_mut => &[0],
sym::ptr_copy | sym::ptr_copy_nonoverlapping | sym::ptr_swap | sym::ptr_swap_nonoverlapping => &[0, 1],
_ => return,
};
for &arg_idx in arg_indices {
if let Some(arg) = args.get(arg_idx).filter(|arg| is_null_path(cx, arg))
&& let Some(std_or_core) = std_or_core(cx)
{
span_lint_and_sugg(
cx,
INVALID_NULL_PTR_USAGE,
arg.span,
"pointer must be non-null",
"change this to",
format!("{std_or_core}::ptr::NonNull::dangling().as_ptr()"),
Applicability::MachineApplicable,
);
}
}
}
}

View file

@ -231,7 +231,7 @@ fn lint_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, shadowed: HirId, span: Span)
},
};
span_lint_and_then(cx, lint, span, msg, |diag| {
diag.span_note(cx.tcx.hir().span(shadowed), "previous binding is here");
diag.span_note(cx.tcx.hir_span(shadowed), "previous binding is here");
});
}

View file

@ -79,10 +79,11 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
if apa.counter <= 1 || !apa.has_expensive_expr_after_last_attr {
continue;
}
let first_bind_ident = apa.first_bind_ident.unwrap();
span_lint_and_then(
cx,
SIGNIFICANT_DROP_TIGHTENING,
apa.first_bind_ident.span,
first_bind_ident.span,
"temporary with significant `Drop` can be early dropped",
|diag| {
match apa.counter {
@ -91,13 +92,13 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
let indent = " ".repeat(indent_of(cx, apa.last_stmt_span).unwrap_or(0));
let init_method = snippet(cx, apa.first_method_span, "..");
let usage_method = snippet(cx, apa.last_method_span, "..");
let stmt = if apa.last_bind_ident == Ident::empty() {
format!("\n{indent}{init_method}.{usage_method};")
} else {
let stmt = if let Some(last_bind_ident) = apa.last_bind_ident {
format!(
"\n{indent}let {} = {init_method}.{usage_method};",
snippet(cx, apa.last_bind_ident.span, ".."),
snippet(cx, last_bind_ident.span, ".."),
)
} else {
format!("\n{indent}{init_method}.{usage_method};")
};
diag.multipart_suggestion_verbose(
@ -113,7 +114,7 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
format!(
"\n{}drop({});",
" ".repeat(indent_of(cx, apa.last_stmt_span).unwrap_or(0)),
apa.first_bind_ident
first_bind_ident
),
Applicability::MaybeIncorrect,
);
@ -123,8 +124,7 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> {
diag.span_label(
apa.first_block_span,
format!(
"temporary `{}` is currently being dropped at the end of its contained scope",
apa.first_bind_ident
"temporary `{first_bind_ident}` is currently being dropped at the end of its contained scope"
),
);
},
@ -283,7 +283,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
let mut apa = AuxParamsAttr {
first_block_hir_id: self.ap.curr_block_hir_id,
first_block_span: self.ap.curr_block_span,
first_bind_ident: ident,
first_bind_ident: Some(ident),
first_method_span: {
let expr_or_init = expr_or_init(self.cx, expr);
if let hir::ExprKind::MethodCall(_, local_expr, _, span) = expr_or_init.kind {
@ -307,7 +307,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
match self.ap.curr_stmt.kind {
hir::StmtKind::Let(local) => {
if let hir::PatKind::Binding(_, _, ident, _) = local.pat.kind {
apa.last_bind_ident = ident;
apa.last_bind_ident = Some(ident);
}
if let Some(local_init) = local.init
&& let hir::ExprKind::MethodCall(_, _, _, span) = local_init.kind
@ -316,7 +316,7 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
}
},
hir::StmtKind::Semi(semi_expr) => {
if has_drop(semi_expr, &apa.first_bind_ident, self.cx) {
if has_drop(semi_expr, apa.first_bind_ident, self.cx) {
apa.has_expensive_expr_after_last_attr = false;
apa.last_stmt_span = DUMMY_SP;
return;
@ -373,7 +373,7 @@ struct AuxParamsAttr {
first_block_span: Span,
/// The binding or variable that references the initial construction of the type marked with
/// `#[has_significant_drop]`.
first_bind_ident: Ident,
first_bind_ident: Option<Ident>,
/// Similar to `init_bind_ident` but encompasses the right-hand method call.
first_method_span: Span,
/// Similar to `init_bind_ident` but encompasses the whole contained statement.
@ -381,7 +381,7 @@ struct AuxParamsAttr {
/// The last visited binding or variable span within a block that had any referenced inner type
/// marked with `#[has_significant_drop]`.
last_bind_ident: Ident,
last_bind_ident: Option<Ident>,
/// Similar to `last_bind_span` but encompasses the right-hand method call.
last_method_span: Span,
/// Similar to `last_bind_span` but encompasses the whole contained statement.
@ -395,10 +395,10 @@ impl Default for AuxParamsAttr {
has_expensive_expr_after_last_attr: false,
first_block_hir_id: HirId::INVALID,
first_block_span: DUMMY_SP,
first_bind_ident: Ident::empty(),
first_bind_ident: None,
first_method_span: DUMMY_SP,
first_stmt_span: DUMMY_SP,
last_bind_ident: Ident::empty(),
last_bind_ident: None,
last_method_span: DUMMY_SP,
last_stmt_span: DUMMY_SP,
}
@ -413,7 +413,7 @@ fn dummy_stmt_expr<'any>(expr: &'any hir::Expr<'any>) -> hir::Stmt<'any> {
}
}
fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Ident, lcx: &LateContext<'_>) -> bool {
fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: Option<Ident>, lcx: &LateContext<'_>) -> bool {
if let hir::ExprKind::Call(fun, [first_arg]) = expr.kind
&& let hir::ExprKind::Path(hir::QPath::Resolved(_, fun_path)) = &fun.kind
&& let Res::Def(DefKind::Fn, did) = fun_path.res
@ -422,7 +422,8 @@ fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Ident, lcx: &LateContext<'_
let has_ident = |local_expr: &hir::Expr<'_>| {
if let hir::ExprKind::Path(hir::QPath::Resolved(_, arg_path)) = &local_expr.kind
&& let [first_arg_ps, ..] = arg_path.segments
&& &first_arg_ps.ident == first_bind_ident
&& let Some(first_bind_ident) = first_bind_ident
&& first_arg_ps.ident == first_bind_ident
{
true
} else {

View file

@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for SingleCallFn {
for (&def_id, usage) in &self.def_id_to_usage {
if let CallState::Once { call_site } = *usage
&& let fn_hir_id = cx.tcx.local_def_id_to_hir_id(def_id)
&& let fn_span = cx.tcx.hir().span_with_body(fn_hir_id)
&& let fn_span = cx.tcx.hir_span_with_body(fn_hir_id)
&& !self.is_function_allowed(cx, def_id, fn_hir_id, fn_span)
{
span_lint_hir_and_then(

View file

@ -174,11 +174,11 @@ impl SingleComponentPathImports {
}
match &item.kind {
ItemKind::Mod(_, ModKind::Loaded(items, ..)) => {
ItemKind::Mod(_, _, ModKind::Loaded(items, ..)) => {
self.check_mod(items);
},
ItemKind::MacroDef(MacroDef { macro_rules: true, .. }) => {
macros.push(item.ident.name);
ItemKind::MacroDef(ident, MacroDef { macro_rules: true, .. }) => {
macros.push(ident.name);
},
ItemKind::Use(use_tree) => {
let segments = &use_tree.prefix.segments;

View file

@ -51,7 +51,7 @@ impl LateLintPass<'_> for UnneededStructPattern {
let variant = cx.tcx.adt_def(enum_did).variant_with_id(did);
let has_only_fields_brackets = variant.ctor.is_some() && variant.fields.is_empty();
let non_exhaustive_activated = !variant.def_id.is_local() && variant.is_field_list_non_exhaustive();
let non_exhaustive_activated = variant.field_list_has_applicable_non_exhaustive();
if !has_only_fields_brackets || non_exhaustive_activated {
return;
}

View file

@ -35,7 +35,7 @@ impl EarlyLintPass for ProduceIce {
fn is_trigger_fn(fn_kind: FnKind<'_>) -> bool {
match fn_kind {
FnKind::Fn(_, ident, ..) => ident.name.as_str() == "it_looks_like_you_are_trying_to_kill_clippy",
FnKind::Fn(_, _, func) => func.ident.name.as_str() == "it_looks_like_you_are_trying_to_kill_clippy",
FnKind::Closure(..) => false,
}
}

View file

@ -21,14 +21,19 @@ declare_lint_pass!(UnsortedClippyUtilsPaths => [UNSORTED_CLIPPY_UTILS_PATHS]);
impl EarlyLintPass for UnsortedClippyUtilsPaths {
fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &Crate) {
if let Some(utils) = krate.items.iter().find(|item| item.ident.name.as_str() == "utils")
&& let ItemKind::Mod(_, ModKind::Loaded(ref items, ..)) = utils.kind
&& let Some(paths) = items.iter().find(|item| item.ident.name.as_str() == "paths")
&& let ItemKind::Mod(_, ModKind::Loaded(ref items, ..)) = paths.kind
if let Some(utils) = krate
.items
.iter()
.find(|item| item.kind.ident().is_some_and(|i| i.name.as_str() == "utils"))
&& let ItemKind::Mod(_, _, ModKind::Loaded(ref items, ..)) = utils.kind
&& let Some(paths) = items
.iter()
.find(|item| item.kind.ident().is_some_and(|i| i.name.as_str() == "paths"))
&& let ItemKind::Mod(_, _, ModKind::Loaded(ref items, ..)) = paths.kind
{
let mut last_name: Option<&str> = None;
let mut last_name: Option<String> = None;
for item in items {
let name = item.ident.as_str();
let name = item.kind.ident().expect("const items have idents").to_string();
if let Some(last_name) = last_name
&& *last_name > *name
{

View file

@ -1,7 +1,7 @@
[package]
name = "clippy_utils"
# begin autogenerated version
version = "0.1.87"
version = "0.1.88"
# end autogenerated version
edition = "2024"
description = "Helpful tools for writing lints, provided as they are used in Clippy"

View file

@ -8,7 +8,7 @@ This crate is only guaranteed to build with this `nightly` toolchain:
<!-- begin autogenerated nightly -->
```
nightly-2025-03-20
nightly-2025-04-03
```
<!-- end autogenerated nightly -->

View file

@ -201,7 +201,8 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
(Loop(lt, ll, _), Loop(rt, rl, _)) => eq_label(ll.as_ref(), rl.as_ref()) && eq_block(lt, rt),
(Block(lb, ll), Block(rb, rl)) => eq_label(ll.as_ref(), rl.as_ref()) && eq_block(lb, rb),
(TryBlock(l), TryBlock(r)) => eq_block(l, r),
(Yield(l), Yield(r)) | (Ret(l), Ret(r)) => eq_expr_opt(l.as_ref(), r.as_ref()),
(Yield(l), Yield(r)) => eq_expr_opt(l.expr(), r.expr()) && l.same_kind(r),
(Ret(l), Ret(r)) => eq_expr_opt(l.as_ref(), r.as_ref()),
(Break(ll, le), Break(rl, re)) => eq_label(ll.as_ref(), rl.as_ref()) && eq_expr_opt(le.as_ref(), re.as_ref()),
(Continue(ll), Continue(rl)) => eq_label(ll.as_ref(), rl.as_ref()),
(Assign(l1, l2, _), Assign(r1, r2, _)) | (Index(l1, l2, _), Index(r1, r2, _)) => {
@ -320,47 +321,62 @@ pub fn eq_local_kind(l: &LocalKind, r: &LocalKind) -> bool {
}
pub fn eq_item<K>(l: &Item<K>, r: &Item<K>, mut eq_kind: impl FnMut(&K, &K) -> bool) -> bool {
eq_id(l.ident, r.ident) && over(&l.attrs, &r.attrs, eq_attr) && eq_vis(&l.vis, &r.vis) && eq_kind(&l.kind, &r.kind)
over(&l.attrs, &r.attrs, eq_attr) && eq_vis(&l.vis, &r.vis) && eq_kind(&l.kind, &r.kind)
}
#[expect(clippy::similar_names, clippy::too_many_lines)] // Just a big match statement
pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
use ItemKind::*;
match (l, r) {
(ExternCrate(l), ExternCrate(r)) => l == r,
(ExternCrate(ls, li), ExternCrate(rs, ri)) => ls == rs && eq_id(*li, *ri),
(Use(l), Use(r)) => eq_use_tree(l, r),
(
Static(box StaticItem {
ident: li,
ty: lt,
mutability: lm,
expr: le,
safety: ls,
define_opaque: _,
}),
Static(box StaticItem {
ident: ri,
ty: rt,
mutability: rm,
expr: re,
safety: rs,
define_opaque: _,
}),
) => lm == rm && ls == rs && eq_ty(lt, rt) && eq_expr_opt(le.as_ref(), re.as_ref()),
) => eq_id(*li, *ri) && lm == rm && ls == rs && eq_ty(lt, rt) && eq_expr_opt(le.as_ref(), re.as_ref()),
(
Const(box ConstItem {
defaultness: ld,
ident: li,
generics: lg,
ty: lt,
expr: le,
define_opaque: _,
}),
Const(box ConstItem {
defaultness: rd,
ident: ri,
generics: rg,
ty: rt,
expr: re,
define_opaque: _,
}),
) => eq_defaultness(*ld, *rd) && eq_generics(lg, rg) && eq_ty(lt, rt) && eq_expr_opt(le.as_ref(), re.as_ref()),
) => {
eq_defaultness(*ld, *rd)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& eq_ty(lt, rt)
&& eq_expr_opt(le.as_ref(), re.as_ref())
},
(
Fn(box ast::Fn {
defaultness: ld,
sig: lf,
ident: li,
generics: lg,
contract: lc,
body: lb,
@ -369,6 +385,7 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
Fn(box ast::Fn {
defaultness: rd,
sig: rf,
ident: ri,
generics: rg,
contract: rc,
body: rb,
@ -377,12 +394,14 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
) => {
eq_defaultness(*ld, *rd)
&& eq_fn_sig(lf, rf)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& eq_opt_fn_contract(lc, rc)
&& both(lb.as_ref(), rb.as_ref(), |l, r| eq_block(l, r))
},
(Mod(lu, lmk), Mod(ru, rmk)) => {
lu == ru
(Mod(ls, li, lmk), Mod(rs, ri, rmk)) => {
ls == rs
&& eq_id(*li, *ri)
&& match (lmk, rmk) {
(ModKind::Loaded(litems, linline, _, _), ModKind::Loaded(ritems, rinline, _, _)) => {
linline == rinline && over(litems, ritems, |l, r| eq_item(l, r, eq_item_kind))
@ -416,33 +435,40 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
&& over(lb, rb, eq_generic_bound)
&& both(lt.as_ref(), rt.as_ref(), |l, r| eq_ty(l, r))
},
(Enum(le, lg), Enum(re, rg)) => over(&le.variants, &re.variants, eq_variant) && eq_generics(lg, rg),
(Struct(lv, lg), Struct(rv, rg)) | (Union(lv, lg), Union(rv, rg)) => {
eq_variant_data(lv, rv) && eq_generics(lg, rg)
(Enum(li, le, lg), Enum(ri, re, rg)) => {
eq_id(*li, *ri) && over(&le.variants, &re.variants, eq_variant) && eq_generics(lg, rg)
},
(Struct(li, lv, lg), Struct(ri, rv, rg)) | (Union(li, lv, lg), Union(ri, rv, rg)) => {
eq_id(*li, *ri) && eq_variant_data(lv, rv) && eq_generics(lg, rg)
},
(
Trait(box ast::Trait {
is_auto: la,
safety: lu,
ident: li,
generics: lg,
bounds: lb,
items: li,
items: lis,
}),
Trait(box ast::Trait {
is_auto: ra,
safety: ru,
ident: ri,
generics: rg,
bounds: rb,
items: ri,
items: ris,
}),
) => {
la == ra
&& matches!(lu, Safety::Default) == matches!(ru, Safety::Default)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& over(lb, rb, eq_generic_bound)
&& over(li, ri, |l, r| eq_item(l, r, eq_assoc_item_kind))
&& over(lis, ris, |l, r| eq_item(l, r, eq_assoc_item_kind))
},
(TraitAlias(li, lg, lb), TraitAlias(ri, rg, rb)) => {
eq_id(*li, *ri) && eq_generics(lg, rg) && over(lb, rb, eq_generic_bound)
},
(TraitAlias(lg, lb), TraitAlias(rg, rb)) => eq_generics(lg, rg) && over(lb, rb, eq_generic_bound),
(
Impl(box ast::Impl {
safety: lu,
@ -475,7 +501,9 @@ pub fn eq_item_kind(l: &ItemKind, r: &ItemKind) -> bool {
&& over(li, ri, |l, r| eq_item(l, r, eq_assoc_item_kind))
},
(MacCall(l), MacCall(r)) => eq_mac_call(l, r),
(MacroDef(l), MacroDef(r)) => l.macro_rules == r.macro_rules && eq_delim_args(&l.body, &r.body),
(MacroDef(li, ld), MacroDef(ri, rd)) => {
eq_id(*li, *ri) && ld.macro_rules == rd.macro_rules && eq_delim_args(&ld.body, &rd.body)
},
_ => false,
}
}
@ -485,22 +513,27 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
match (l, r) {
(
Static(box StaticItem {
ident: li,
ty: lt,
mutability: lm,
expr: le,
safety: ls,
define_opaque: _,
}),
Static(box StaticItem {
ident: ri,
ty: rt,
mutability: rm,
expr: re,
safety: rs,
define_opaque: _,
}),
) => lm == rm && eq_ty(lt, rt) && eq_expr_opt(le.as_ref(), re.as_ref()) && ls == rs,
) => eq_id(*li, *ri) && eq_ty(lt, rt) && lm == rm && eq_expr_opt(le.as_ref(), re.as_ref()) && ls == rs,
(
Fn(box ast::Fn {
defaultness: ld,
sig: lf,
ident: li,
generics: lg,
contract: lc,
body: lb,
@ -509,6 +542,7 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
Fn(box ast::Fn {
defaultness: rd,
sig: rf,
ident: ri,
generics: rg,
contract: rc,
body: rb,
@ -517,6 +551,7 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
) => {
eq_defaultness(*ld, *rd)
&& eq_fn_sig(lf, rf)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& eq_opt_fn_contract(lc, rc)
&& both(lb.as_ref(), rb.as_ref(), |l, r| eq_block(l, r))
@ -524,20 +559,23 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
(
TyAlias(box ast::TyAlias {
defaultness: ld,
ident: li,
generics: lg,
where_clauses: _,
bounds: lb,
ty: lt,
..
}),
TyAlias(box ast::TyAlias {
defaultness: rd,
ident: ri,
generics: rg,
where_clauses: _,
bounds: rb,
ty: rt,
..
}),
) => {
eq_defaultness(*ld, *rd)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& over(lb, rb, eq_generic_bound)
&& both(lt.as_ref(), rt.as_ref(), |l, r| eq_ty(l, r))
@ -553,21 +591,32 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
(
Const(box ConstItem {
defaultness: ld,
ident: li,
generics: lg,
ty: lt,
expr: le,
define_opaque: _,
}),
Const(box ConstItem {
defaultness: rd,
ident: ri,
generics: rg,
ty: rt,
expr: re,
define_opaque: _,
}),
) => eq_defaultness(*ld, *rd) && eq_generics(lg, rg) && eq_ty(lt, rt) && eq_expr_opt(le.as_ref(), re.as_ref()),
) => {
eq_defaultness(*ld, *rd)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& eq_ty(lt, rt)
&& eq_expr_opt(le.as_ref(), re.as_ref())
},
(
Fn(box ast::Fn {
defaultness: ld,
sig: lf,
ident: li,
generics: lg,
contract: lc,
body: lb,
@ -576,6 +625,7 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
Fn(box ast::Fn {
defaultness: rd,
sig: rf,
ident: ri,
generics: rg,
contract: rc,
body: rb,
@ -584,6 +634,7 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
) => {
eq_defaultness(*ld, *rd)
&& eq_fn_sig(lf, rf)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& eq_opt_fn_contract(lc, rc)
&& both(lb.as_ref(), rb.as_ref(), |l, r| eq_block(l, r))
@ -591,20 +642,23 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
(
Type(box TyAlias {
defaultness: ld,
ident: li,
generics: lg,
where_clauses: _,
bounds: lb,
ty: lt,
..
}),
Type(box TyAlias {
defaultness: rd,
ident: ri,
generics: rg,
where_clauses: _,
bounds: rb,
ty: rt,
..
}),
) => {
eq_defaultness(*ld, *rd)
&& eq_id(*li, *ri)
&& eq_generics(lg, rg)
&& over(lb, rb, eq_generic_bound)
&& both(lt.as_ref(), rt.as_ref(), |l, r| eq_ty(l, r))

View file

@ -2691,7 +2691,7 @@ pub fn is_in_test_function(tcx: TyCtxt<'_>, id: HirId) -> bool {
/// use [`is_in_cfg_test`]
pub fn is_cfg_test(tcx: TyCtxt<'_>, id: HirId) -> bool {
tcx.hir_attrs(id).iter().any(|attr| {
if attr.has_name(sym::cfg)
if attr.has_name(sym::cfg_trace)
&& let Some(items) = attr.meta_item_list()
&& let [item] = &*items
&& item.has_name(sym::test)
@ -2715,11 +2715,11 @@ pub fn is_in_test(tcx: TyCtxt<'_>, hir_id: HirId) -> bool {
/// Checks if the item of any of its parents has `#[cfg(...)]` attribute applied.
pub fn inherits_cfg(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
tcx.has_attr(def_id, sym::cfg)
tcx.has_attr(def_id, sym::cfg_trace)
|| tcx
.hir_parent_iter(tcx.local_def_id_to_hir_id(def_id))
.flat_map(|(parent_id, _)| tcx.hir_attrs(parent_id))
.any(|attr| attr.has_name(sym::cfg))
.any(|attr| attr.has_name(sym::cfg_trace))
}
/// Walks up the HIR tree from the given expression in an attempt to find where the value is
@ -2982,7 +2982,7 @@ pub fn expr_use_ctxt<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> ExprU
{
adjustments = cx.typeck_results().expr_adjustments(e);
}
same_ctxt &= cx.tcx.hir().span(parent_id).ctxt() == ctxt;
same_ctxt &= cx.tcx.hir_span(parent_id).ctxt() == ctxt;
if let Node::Expr(e) = parent {
match e.kind {
ExprKind::If(e, _, _) | ExprKind::Match(e, _, _) if e.hir_id != child_id => {

View file

@ -178,7 +178,6 @@ pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option<
// get the parent node, possibly skipping over a statement
// if the parent is not found, it is sensible to return `Some(root)`
let hir = cx.tcx.hir();
let mut parent_iter = cx.tcx.hir_parent_iter(node.hir_id());
let (parent_id, _) = match parent_iter.next() {
None => return Some(ExpnId::root()),
@ -190,7 +189,7 @@ pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option<
};
// get the macro expansion of the parent node
let parent_span = hir.span(parent_id);
let parent_span = cx.tcx.hir_span(parent_id);
let Some(parent_macro_call) = macro_backtrace(parent_span).next() else {
// the parent node is not in a macro
return Some(ExpnId::root());

View file

@ -839,8 +839,7 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
fn borrow(&mut self, cmt: &PlaceWithHirId<'tcx>, _: HirId, _: ty::BorrowKind) {
if let PlaceBase::Local(id) = cmt.place.base {
let map = self.cx.tcx.hir();
let span = map.span(cmt.hir_id);
let span = self.cx.tcx.hir_span(cmt.hir_id);
let start_span = Span::new(self.next_pos, span.lo(), span.ctxt(), None);
let mut start_snip = snippet_with_applicability(self.cx, start_span, "..", &mut self.applicability);
@ -949,8 +948,8 @@ impl<'tcx> Delegate<'tcx> for DerefDelegate<'_, 'tcx> {
// i.e.: don't suggest `*sub[1..4].len()` for `|sub| sub[1..4].len() == 3`
if let ty::Ref(_, inner, _) = cmt.place.ty_before_projection(i).kind()
&& matches!(inner.kind(), ty::Ref(_, innermost, _) if innermost.is_array()) {
projections_handled = true;
}
projections_handled = true;
}
},
}
});

View file

@ -1,6 +1,6 @@
[toolchain]
# begin autogenerated nightly
channel = "nightly-2025-03-20"
channel = "nightly-2025-04-03"
# end autogenerated nightly
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]
profile = "minimal"

View file

@ -1,6 +1,6 @@
//@ check-pass
#![allow(dead_code, unused_variables)]
#![allow(dead_code, unused_variables, invalid_null_arguments)]
#![allow(clippy::unnecessary_cast, clippy::missing_transmute_annotations)]
/// Should not trigger an ICE in `SpanlessEq` / `consts::constant`

View file

@ -1,66 +0,0 @@
fn main() {
unsafe {
let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
let _slice: &[usize] = std::slice::from_raw_parts_mut(std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
std::ptr::copy::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
std::ptr::copy::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
std::ptr::copy_nonoverlapping::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
std::ptr::copy_nonoverlapping::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
struct A; // zero sized struct
assert_eq!(std::mem::size_of::<A>(), 0);
let _a: A = std::ptr::read(std::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read(std::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read_unaligned(std::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read_unaligned(std::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read_volatile(std::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read_volatile(std::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::replace(std::ptr::NonNull::dangling().as_ptr(), A);
//~^ invalid_null_ptr_usage
let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null_mut(), 0); // shouldn't lint
let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(std::ptr::null_mut(), 0);
std::ptr::swap::<A>(std::ptr::NonNull::dangling().as_ptr(), &mut A);
//~^ invalid_null_ptr_usage
std::ptr::swap::<A>(&mut A, std::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
std::ptr::swap_nonoverlapping::<A>(std::ptr::NonNull::dangling().as_ptr(), &mut A, 0);
//~^ invalid_null_ptr_usage
std::ptr::swap_nonoverlapping::<A>(&mut A, std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
std::ptr::write(std::ptr::NonNull::dangling().as_ptr(), A);
//~^ invalid_null_ptr_usage
std::ptr::write_unaligned(std::ptr::NonNull::dangling().as_ptr(), A);
//~^ invalid_null_ptr_usage
std::ptr::write_volatile(std::ptr::NonNull::dangling().as_ptr(), A);
//~^ invalid_null_ptr_usage
std::ptr::write_bytes::<usize>(std::ptr::NonNull::dangling().as_ptr(), 42, 0);
//~^ invalid_null_ptr_usage
}
}

View file

@ -1,66 +0,0 @@
fn main() {
unsafe {
let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null(), 0);
//~^ invalid_null_ptr_usage
let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
let _slice: &[usize] = std::slice::from_raw_parts_mut(std::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
std::ptr::copy::<usize>(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
std::ptr::copy::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
std::ptr::copy_nonoverlapping::<usize>(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
std::ptr::copy_nonoverlapping::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
struct A; // zero sized struct
assert_eq!(std::mem::size_of::<A>(), 0);
let _a: A = std::ptr::read(std::ptr::null());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read(std::ptr::null_mut());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read_unaligned(std::ptr::null());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read_unaligned(std::ptr::null_mut());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read_volatile(std::ptr::null());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::read_volatile(std::ptr::null_mut());
//~^ invalid_null_ptr_usage
let _a: A = std::ptr::replace(std::ptr::null_mut(), A);
//~^ invalid_null_ptr_usage
let _slice: *const [usize] = std::ptr::slice_from_raw_parts(std::ptr::null_mut(), 0); // shouldn't lint
let _slice: *const [usize] = std::ptr::slice_from_raw_parts_mut(std::ptr::null_mut(), 0);
std::ptr::swap::<A>(std::ptr::null_mut(), &mut A);
//~^ invalid_null_ptr_usage
std::ptr::swap::<A>(&mut A, std::ptr::null_mut());
//~^ invalid_null_ptr_usage
std::ptr::swap_nonoverlapping::<A>(std::ptr::null_mut(), &mut A, 0);
//~^ invalid_null_ptr_usage
std::ptr::swap_nonoverlapping::<A>(&mut A, std::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
std::ptr::write(std::ptr::null_mut(), A);
//~^ invalid_null_ptr_usage
std::ptr::write_unaligned(std::ptr::null_mut(), A);
//~^ invalid_null_ptr_usage
std::ptr::write_volatile(std::ptr::null_mut(), A);
//~^ invalid_null_ptr_usage
std::ptr::write_bytes::<usize>(std::ptr::null_mut(), 42, 0);
//~^ invalid_null_ptr_usage
}
}

View file

@ -1,136 +0,0 @@
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:3:59
|
LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null(), 0);
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
|
= note: `#[deny(clippy::invalid_null_ptr_usage)]` on by default
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:5:59
|
LL | let _slice: &[usize] = std::slice::from_raw_parts(std::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:8:63
|
LL | let _slice: &[usize] = std::slice::from_raw_parts_mut(std::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:11:33
|
LL | std::ptr::copy::<usize>(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0);
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:13:73
|
LL | std::ptr::copy::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:16:48
|
LL | std::ptr::copy_nonoverlapping::<usize>(std::ptr::null(), std::ptr::NonNull::dangling().as_ptr(), 0);
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:18:88
|
LL | std::ptr::copy_nonoverlapping::<usize>(std::ptr::NonNull::dangling().as_ptr(), std::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:24:36
|
LL | let _a: A = std::ptr::read(std::ptr::null());
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:26:36
|
LL | let _a: A = std::ptr::read(std::ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:29:46
|
LL | let _a: A = std::ptr::read_unaligned(std::ptr::null());
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:31:46
|
LL | let _a: A = std::ptr::read_unaligned(std::ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:34:45
|
LL | let _a: A = std::ptr::read_volatile(std::ptr::null());
| ^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:36:45
|
LL | let _a: A = std::ptr::read_volatile(std::ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:39:39
|
LL | let _a: A = std::ptr::replace(std::ptr::null_mut(), A);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:44:29
|
LL | std::ptr::swap::<A>(std::ptr::null_mut(), &mut A);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:46:37
|
LL | std::ptr::swap::<A>(&mut A, std::ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:49:44
|
LL | std::ptr::swap_nonoverlapping::<A>(std::ptr::null_mut(), &mut A, 0);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:51:52
|
LL | std::ptr::swap_nonoverlapping::<A>(&mut A, std::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:54:25
|
LL | std::ptr::write(std::ptr::null_mut(), A);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:57:35
|
LL | std::ptr::write_unaligned(std::ptr::null_mut(), A);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:60:34
|
LL | std::ptr::write_volatile(std::ptr::null_mut(), A);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage.rs:63:40
|
LL | std::ptr::write_bytes::<usize>(std::ptr::null_mut(), 42, 0);
| ^^^^^^^^^^^^^^^^^^^^ help: change this to: `std::ptr::NonNull::dangling().as_ptr()`
error: aborting due to 22 previous errors

View file

@ -1,79 +0,0 @@
#![no_std]
#![feature(lang_items)]
use core::panic::PanicInfo;
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
loop {}
}
fn main() {
unsafe {
let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
let _slice: &[usize] = core::slice::from_raw_parts_mut(core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
core::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
core::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
core::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
core::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
struct A; // zero sized struct
assert_eq!(core::mem::size_of::<A>(), 0);
let _a: A = core::ptr::read(core::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read(core::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read_unaligned(core::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read_unaligned(core::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read_volatile(core::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read_volatile(core::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::replace(core::ptr::NonNull::dangling().as_ptr(), A);
//~^ invalid_null_ptr_usage
let _slice: *const [usize] = core::ptr::slice_from_raw_parts(core::ptr::null_mut(), 0); // shouldn't lint
let _slice: *const [usize] = core::ptr::slice_from_raw_parts_mut(core::ptr::null_mut(), 0);
core::ptr::swap::<A>(core::ptr::NonNull::dangling().as_ptr(), &mut A);
//~^ invalid_null_ptr_usage
core::ptr::swap::<A>(&mut A, core::ptr::NonNull::dangling().as_ptr());
//~^ invalid_null_ptr_usage
core::ptr::swap_nonoverlapping::<A>(core::ptr::NonNull::dangling().as_ptr(), &mut A, 0);
//~^ invalid_null_ptr_usage
core::ptr::swap_nonoverlapping::<A>(&mut A, core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
core::ptr::write(core::ptr::NonNull::dangling().as_ptr(), A);
//~^ invalid_null_ptr_usage
core::ptr::write_unaligned(core::ptr::NonNull::dangling().as_ptr(), A);
//~^ invalid_null_ptr_usage
core::ptr::write_volatile(core::ptr::NonNull::dangling().as_ptr(), A);
//~^ invalid_null_ptr_usage
core::ptr::write_bytes::<usize>(core::ptr::NonNull::dangling().as_ptr(), 42, 0);
//~^ invalid_null_ptr_usage
}
}

View file

@ -1,79 +0,0 @@
#![no_std]
#![feature(lang_items)]
use core::panic::PanicInfo;
#[lang = "eh_personality"]
extern "C" fn eh_personality() {}
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
loop {}
}
fn main() {
unsafe {
let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::null(), 0);
//~^ invalid_null_ptr_usage
let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
let _slice: &[usize] = core::slice::from_raw_parts_mut(core::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
core::ptr::copy::<usize>(core::ptr::null(), core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
core::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
core::ptr::copy_nonoverlapping::<usize>(core::ptr::null(), core::ptr::NonNull::dangling().as_ptr(), 0);
//~^ invalid_null_ptr_usage
core::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
struct A; // zero sized struct
assert_eq!(core::mem::size_of::<A>(), 0);
let _a: A = core::ptr::read(core::ptr::null());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read(core::ptr::null_mut());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read_unaligned(core::ptr::null());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read_unaligned(core::ptr::null_mut());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read_volatile(core::ptr::null());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::read_volatile(core::ptr::null_mut());
//~^ invalid_null_ptr_usage
let _a: A = core::ptr::replace(core::ptr::null_mut(), A);
//~^ invalid_null_ptr_usage
let _slice: *const [usize] = core::ptr::slice_from_raw_parts(core::ptr::null_mut(), 0); // shouldn't lint
let _slice: *const [usize] = core::ptr::slice_from_raw_parts_mut(core::ptr::null_mut(), 0);
core::ptr::swap::<A>(core::ptr::null_mut(), &mut A);
//~^ invalid_null_ptr_usage
core::ptr::swap::<A>(&mut A, core::ptr::null_mut());
//~^ invalid_null_ptr_usage
core::ptr::swap_nonoverlapping::<A>(core::ptr::null_mut(), &mut A, 0);
//~^ invalid_null_ptr_usage
core::ptr::swap_nonoverlapping::<A>(&mut A, core::ptr::null_mut(), 0);
//~^ invalid_null_ptr_usage
core::ptr::write(core::ptr::null_mut(), A);
//~^ invalid_null_ptr_usage
core::ptr::write_unaligned(core::ptr::null_mut(), A);
//~^ invalid_null_ptr_usage
core::ptr::write_volatile(core::ptr::null_mut(), A);
//~^ invalid_null_ptr_usage
core::ptr::write_bytes::<usize>(core::ptr::null_mut(), 42, 0);
//~^ invalid_null_ptr_usage
}
}

View file

@ -1,136 +0,0 @@
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:16:60
|
LL | let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::null(), 0);
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
|
= note: `#[deny(clippy::invalid_null_ptr_usage)]` on by default
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:18:60
|
LL | let _slice: &[usize] = core::slice::from_raw_parts(core::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:21:64
|
LL | let _slice: &[usize] = core::slice::from_raw_parts_mut(core::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:24:34
|
LL | core::ptr::copy::<usize>(core::ptr::null(), core::ptr::NonNull::dangling().as_ptr(), 0);
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:26:75
|
LL | core::ptr::copy::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:29:49
|
LL | core::ptr::copy_nonoverlapping::<usize>(core::ptr::null(), core::ptr::NonNull::dangling().as_ptr(), 0);
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:31:90
|
LL | core::ptr::copy_nonoverlapping::<usize>(core::ptr::NonNull::dangling().as_ptr(), core::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:37:37
|
LL | let _a: A = core::ptr::read(core::ptr::null());
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:39:37
|
LL | let _a: A = core::ptr::read(core::ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:42:47
|
LL | let _a: A = core::ptr::read_unaligned(core::ptr::null());
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:44:47
|
LL | let _a: A = core::ptr::read_unaligned(core::ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:47:46
|
LL | let _a: A = core::ptr::read_volatile(core::ptr::null());
| ^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:49:46
|
LL | let _a: A = core::ptr::read_volatile(core::ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:52:40
|
LL | let _a: A = core::ptr::replace(core::ptr::null_mut(), A);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:57:30
|
LL | core::ptr::swap::<A>(core::ptr::null_mut(), &mut A);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:59:38
|
LL | core::ptr::swap::<A>(&mut A, core::ptr::null_mut());
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:62:45
|
LL | core::ptr::swap_nonoverlapping::<A>(core::ptr::null_mut(), &mut A, 0);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:64:53
|
LL | core::ptr::swap_nonoverlapping::<A>(&mut A, core::ptr::null_mut(), 0);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:67:26
|
LL | core::ptr::write(core::ptr::null_mut(), A);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:70:36
|
LL | core::ptr::write_unaligned(core::ptr::null_mut(), A);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:73:35
|
LL | core::ptr::write_volatile(core::ptr::null_mut(), A);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: pointer must be non-null
--> tests/ui/invalid_null_ptr_usage_no_std.rs:76:41
|
LL | core::ptr::write_bytes::<usize>(core::ptr::null_mut(), 42, 0);
| ^^^^^^^^^^^^^^^^^^^^^ help: change this to: `core::ptr::NonNull::dangling().as_ptr()`
error: aborting due to 22 previous errors

View file

@ -39,6 +39,7 @@
#![allow(invalid_reference_casting)]
#![allow(suspicious_double_ref_op)]
#![allow(invalid_nan_comparisons)]
#![allow(invalid_null_arguments)]
#![allow(double_negations)]
#![allow(drop_bounds)]
#![allow(dropping_copy_types)]
@ -104,6 +105,7 @@
#![warn(invalid_reference_casting)] //~ ERROR: lint `clippy::cast_ref_to_mut`
#![warn(suspicious_double_ref_op)] //~ ERROR: lint `clippy::clone_double_ref`
#![warn(invalid_nan_comparisons)] //~ ERROR: lint `clippy::cmp_nan`
#![warn(invalid_null_arguments)] //~ ERROR: lint `clippy::invalid_null_ptr_usage`
#![warn(double_negations)] //~ ERROR: lint `clippy::double_neg`
#![warn(drop_bounds)] //~ ERROR: lint `clippy::drop_bounds`
#![warn(dropping_copy_types)] //~ ERROR: lint `clippy::drop_copy`

View file

@ -39,6 +39,7 @@
#![allow(invalid_reference_casting)]
#![allow(suspicious_double_ref_op)]
#![allow(invalid_nan_comparisons)]
#![allow(invalid_null_arguments)]
#![allow(double_negations)]
#![allow(drop_bounds)]
#![allow(dropping_copy_types)]
@ -104,6 +105,7 @@
#![warn(clippy::cast_ref_to_mut)] //~ ERROR: lint `clippy::cast_ref_to_mut`
#![warn(clippy::clone_double_ref)] //~ ERROR: lint `clippy::clone_double_ref`
#![warn(clippy::cmp_nan)] //~ ERROR: lint `clippy::cmp_nan`
#![warn(clippy::invalid_null_ptr_usage)] //~ ERROR: lint `clippy::invalid_null_ptr_usage`
#![warn(clippy::double_neg)] //~ ERROR: lint `clippy::double_neg`
#![warn(clippy::drop_bounds)] //~ ERROR: lint `clippy::drop_bounds`
#![warn(clippy::drop_copy)] //~ ERROR: lint `clippy::drop_copy`

View file

@ -1,5 +1,5 @@
error: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range`
--> tests/ui/rename.rs:65:9
--> tests/ui/rename.rs:66:9
|
LL | #![warn(clippy::almost_complete_letter_range)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range`
@ -8,406 +8,412 @@ 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`
--> tests/ui/rename.rs:66:9
--> tests/ui/rename.rs:67: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`
--> tests/ui/rename.rs:67:9
--> tests/ui/rename.rs:68: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`
--> tests/ui/rename.rs:68:9
--> tests/ui/rename.rs:69: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`
--> tests/ui/rename.rs:69:9
--> tests/ui/rename.rs:70: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`
--> tests/ui/rename.rs:70:9
--> tests/ui/rename.rs:71: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`
--> tests/ui/rename.rs:71:9
--> tests/ui/rename.rs:72: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`
--> tests/ui/rename.rs:72:9
--> tests/ui/rename.rs:73: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`
--> tests/ui/rename.rs:73:9
--> tests/ui/rename.rs:74: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`
--> tests/ui/rename.rs:74:9
--> tests/ui/rename.rs:75: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`
--> tests/ui/rename.rs:75:9
--> tests/ui/rename.rs:76: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`
--> tests/ui/rename.rs:76:9
--> tests/ui/rename.rs:77:9
|
LL | #![warn(clippy::eval_order_dependence)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression`
error: lint `clippy::find_map` has been renamed to `clippy::manual_find_map`
--> tests/ui/rename.rs:77:9
--> tests/ui/rename.rs:78:9
|
LL | #![warn(clippy::find_map)]
| ^^^^^^^^^^^^^^^^ help: use the new name: `clippy::manual_find_map`
error: lint `clippy::filter_map` has been renamed to `clippy::manual_filter_map`
--> tests/ui/rename.rs:78:9
--> tests/ui/rename.rs:79:9
|
LL | #![warn(clippy::filter_map)]
| ^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::manual_filter_map`
error: lint `clippy::fn_address_comparisons` has been renamed to `unpredictable_function_pointer_comparisons`
--> tests/ui/rename.rs:79:9
--> tests/ui/rename.rs:80:9
|
LL | #![warn(clippy::fn_address_comparisons)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unpredictable_function_pointer_comparisons`
error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion`
--> tests/ui/rename.rs:80:9
--> tests/ui/rename.rs:81:9
|
LL | #![warn(clippy::identity_conversion)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion`
error: lint `clippy::if_let_redundant_pattern_matching` has been renamed to `clippy::redundant_pattern_matching`
--> tests/ui/rename.rs:81:9
--> tests/ui/rename.rs:82:9
|
LL | #![warn(clippy::if_let_redundant_pattern_matching)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_pattern_matching`
error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok`
--> tests/ui/rename.rs:82:9
--> tests/ui/rename.rs:83: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`
--> tests/ui/rename.rs:83:9
--> tests/ui/rename.rs:84: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`
--> tests/ui/rename.rs:84:9
--> tests/ui/rename.rs:85: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`
--> tests/ui/rename.rs:85:9
--> tests/ui/rename.rs:86: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`
--> tests/ui/rename.rs:86:9
--> tests/ui/rename.rs:87: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`
--> tests/ui/rename.rs:87:9
--> tests/ui/rename.rs:88: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`
--> tests/ui/rename.rs:88:9
--> tests/ui/rename.rs:89: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`
--> tests/ui/rename.rs:89:9
--> tests/ui/rename.rs:90: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`
--> tests/ui/rename.rs:90:9
--> tests/ui/rename.rs:91: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`
--> tests/ui/rename.rs:91:9
--> tests/ui/rename.rs:92: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`
--> tests/ui/rename.rs:92:9
--> tests/ui/rename.rs:93:9
|
LL | #![warn(clippy::option_unwrap_used)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used`
error: lint `clippy::overflow_check_conditional` has been renamed to `clippy::panicking_overflow_checks`
--> tests/ui/rename.rs:93:9
--> tests/ui/rename.rs:94:9
|
LL | #![warn(clippy::overflow_check_conditional)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::panicking_overflow_checks`
error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow`
--> tests/ui/rename.rs:94:9
--> tests/ui/rename.rs:95: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`
--> tests/ui/rename.rs:95:9
--> tests/ui/rename.rs:96: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`
--> tests/ui/rename.rs:96:9
--> tests/ui/rename.rs:97: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`
--> tests/ui/rename.rs:97:9
--> tests/ui/rename.rs:98: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`
--> tests/ui/rename.rs:98:9
--> tests/ui/rename.rs:99: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`
--> tests/ui/rename.rs:99:9
--> tests/ui/rename.rs:100:9
|
LL | #![warn(clippy::stutter)]
| ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions`
error: lint `clippy::thread_local_initializer_can_be_made_const` has been renamed to `clippy::missing_const_for_thread_local`
--> tests/ui/rename.rs:100:9
--> tests/ui/rename.rs:101:9
|
LL | #![warn(clippy::thread_local_initializer_can_be_made_const)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::missing_const_for_thread_local`
error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl`
--> tests/ui/rename.rs:101:9
--> tests/ui/rename.rs:102: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`
--> tests/ui/rename.rs:102:9
--> tests/ui/rename.rs:103: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`
--> tests/ui/rename.rs:103:9
--> tests/ui/rename.rs:104: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`
--> tests/ui/rename.rs:104:9
--> tests/ui/rename.rs:105: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`
--> tests/ui/rename.rs:105:9
--> tests/ui/rename.rs:106: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`
--> tests/ui/rename.rs:106:9
--> tests/ui/rename.rs:107:9
|
LL | #![warn(clippy::cmp_nan)]
| ^^^^^^^^^^^^^^^ help: use the new name: `invalid_nan_comparisons`
error: lint `clippy::invalid_null_ptr_usage` has been renamed to `invalid_null_arguments`
--> tests/ui/rename.rs:108:9
|
LL | #![warn(clippy::invalid_null_ptr_usage)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_null_arguments`
error: lint `clippy::double_neg` has been renamed to `double_negations`
--> tests/ui/rename.rs:107:9
--> tests/ui/rename.rs:109:9
|
LL | #![warn(clippy::double_neg)]
| ^^^^^^^^^^^^^^^^^^ help: use the new name: `double_negations`
error: lint `clippy::drop_bounds` has been renamed to `drop_bounds`
--> tests/ui/rename.rs:108:9
--> tests/ui/rename.rs:110: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`
--> tests/ui/rename.rs:109:9
--> tests/ui/rename.rs:111: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`
--> tests/ui/rename.rs:110:9
--> tests/ui/rename.rs:112: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`
--> tests/ui/rename.rs:111:9
--> tests/ui/rename.rs:113: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`
--> tests/ui/rename.rs:112:9
--> tests/ui/rename.rs:114: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`
--> tests/ui/rename.rs:113:9
--> tests/ui/rename.rs:115: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`
--> tests/ui/rename.rs:114:9
--> tests/ui/rename.rs:116: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`
--> tests/ui/rename.rs:115:9
--> tests/ui/rename.rs:117: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`
--> tests/ui/rename.rs:116:9
--> tests/ui/rename.rs:118: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`
--> tests/ui/rename.rs:117:9
--> tests/ui/rename.rs:119: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`
--> tests/ui/rename.rs:118:9
--> tests/ui/rename.rs:120: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`
--> tests/ui/rename.rs:119:9
--> tests/ui/rename.rs:121: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`
--> tests/ui/rename.rs:120:9
--> tests/ui/rename.rs:122: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`
--> tests/ui/rename.rs:121:9
--> tests/ui/rename.rs:123:9
|
LL | #![warn(clippy::let_underscore_drop)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop`
error: lint `clippy::maybe_misused_cfg` has been renamed to `unexpected_cfgs`
--> tests/ui/rename.rs:122:9
--> tests/ui/rename.rs:124:9
|
LL | #![warn(clippy::maybe_misused_cfg)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unexpected_cfgs`
error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums`
--> tests/ui/rename.rs:123:9
--> tests/ui/rename.rs:125:9
|
LL | #![warn(clippy::mem_discriminant_non_enum)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums`
error: lint `clippy::mismatched_target_os` has been renamed to `unexpected_cfgs`
--> tests/ui/rename.rs:124:9
--> tests/ui/rename.rs:126:9
|
LL | #![warn(clippy::mismatched_target_os)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unexpected_cfgs`
error: lint `clippy::panic_params` has been renamed to `non_fmt_panics`
--> tests/ui/rename.rs:125:9
--> tests/ui/rename.rs:127: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`
--> tests/ui/rename.rs:126:9
--> tests/ui/rename.rs:128: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 `dangling_pointers_from_temporaries`
--> tests/ui/rename.rs:127:9
--> tests/ui/rename.rs:129:9
|
LL | #![warn(clippy::temporary_cstring_as_ptr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `dangling_pointers_from_temporaries`
error: lint `clippy::undropped_manually_drops` has been renamed to `undropped_manually_drops`
--> tests/ui/rename.rs:128:9
--> tests/ui/rename.rs:130: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`
--> tests/ui/rename.rs:129:9
--> tests/ui/rename.rs:131: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`
--> tests/ui/rename.rs:130:9
--> tests/ui/rename.rs:132:9
|
LL | #![warn(clippy::unused_label)]
| ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels`
error: lint `clippy::vtable_address_comparisons` has been renamed to `ambiguous_wide_pointer_comparisons`
--> tests/ui/rename.rs:131:9
--> tests/ui/rename.rs:133:9
|
LL | #![warn(clippy::vtable_address_comparisons)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `ambiguous_wide_pointer_comparisons`
error: lint `clippy::reverse_range_loop` has been renamed to `clippy::reversed_empty_ranges`
--> tests/ui/rename.rs:132:9
--> tests/ui/rename.rs:134:9
|
LL | #![warn(clippy::reverse_range_loop)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::reversed_empty_ranges`
error: aborting due to 68 previous errors
error: aborting due to 69 previous errors