mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Track msrv
attribute for manual_bits
and borrow_as_prt
This commit is contained in:
parent
9e7858545a
commit
1afeb71065
5 changed files with 25 additions and 6 deletions
|
@ -5,7 +5,7 @@ use clippy_utils::{meets_msrv, msrvs};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, TyKind};
|
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, TyKind};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||||
use rustc_semver::RustcVersion;
|
use rustc_semver::RustcVersion;
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
|
|
||||||
|
@ -94,4 +94,6 @@ impl<'tcx> LateLintPass<'tcx> for BorrowAsPtr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extract_msrv_attr!(LateContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use clippy_utils::{match_def_path, meets_msrv, msrvs, paths};
|
||||||
use rustc_ast::ast::LitKind;
|
use rustc_ast::ast::LitKind;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
use rustc_hir::{BinOpKind, Expr, ExprKind, GenericArg, QPath};
|
use rustc_hir::{BinOpKind, Expr, ExprKind, GenericArg, QPath};
|
||||||
use rustc_lint::{LateContext, LateLintPass};
|
use rustc_lint::{LateContext, LateLintPass, LintContext};
|
||||||
use rustc_middle::ty::{self, Ty};
|
use rustc_middle::ty::{self, Ty};
|
||||||
use rustc_semver::RustcVersion;
|
use rustc_semver::RustcVersion;
|
||||||
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
use rustc_session::{declare_tool_lint, impl_lint_pass};
|
||||||
|
@ -72,6 +72,8 @@ impl<'tcx> LateLintPass<'tcx> for ManualBits {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extract_msrv_attr!(LateContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_one_size_of_ty<'tcx>(
|
fn get_one_size_of_ty<'tcx>(
|
||||||
|
|
|
@ -156,7 +156,7 @@ define_Conf! {
|
||||||
///
|
///
|
||||||
/// Suppress lints whenever the suggested change would cause breakage for other crates.
|
/// Suppress lints whenever the suggested change would cause breakage for other crates.
|
||||||
(avoid_breaking_exported_api: bool = true),
|
(avoid_breaking_exported_api: bool = true),
|
||||||
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE.
|
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS.
|
||||||
///
|
///
|
||||||
/// The minimum rust version that the project supports
|
/// The minimum rust version that the project supports
|
||||||
(msrv: Option<String> = None),
|
(msrv: Option<String> = None),
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#![allow(clippy::redundant_clone)]
|
#![allow(clippy::redundant_clone, clippy::unnecessary_operation)]
|
||||||
#![warn(clippy::manual_non_exhaustive)]
|
#![warn(clippy::manual_non_exhaustive, clippy::borrow_as_ptr, clippy::manual_bits)]
|
||||||
|
|
||||||
|
use std::mem::{size_of, size_of_val};
|
||||||
use std::ops::Deref;
|
use std::ops::Deref;
|
||||||
|
|
||||||
mod enums {
|
mod enums {
|
||||||
|
@ -73,6 +74,19 @@ fn map_clone_suggest_copied() {
|
||||||
let _: Option<u64> = Some(&16).map(|b| *b);
|
let _: Option<u64> = Some(&16).map(|b| *b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn borrow_as_ptr() {
|
||||||
|
let val = 1;
|
||||||
|
let _p = &val as *const i32;
|
||||||
|
|
||||||
|
let mut val_mut = 1;
|
||||||
|
let _p_mut = &mut val_mut as *mut i32;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn manual_bits() {
|
||||||
|
size_of::<i8>() * 8;
|
||||||
|
size_of_val(&0u32) * 8;
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
option_as_ref_deref();
|
option_as_ref_deref();
|
||||||
match_like_matches();
|
match_like_matches();
|
||||||
|
@ -80,4 +94,5 @@ fn main() {
|
||||||
match_same_arms2();
|
match_same_arms2();
|
||||||
manual_strip_msrv();
|
manual_strip_msrv();
|
||||||
check_index_refutable_slice();
|
check_index_refutable_slice();
|
||||||
|
borrow_as_ptr();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error: you are using an explicit closure for copying elements
|
error: you are using an explicit closure for copying elements
|
||||||
--> $DIR/min_rust_version.rs:73:26
|
--> $DIR/min_rust_version.rs:74:26
|
||||||
|
|
|
|
||||||
LL | let _: Option<u64> = Some(&16).map(|b| *b);
|
LL | let _: Option<u64> = Some(&16).map(|b| *b);
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `Some(&16).cloned()`
|
| ^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `Some(&16).cloned()`
|
||||||
|
|
Loading…
Reference in a new issue