mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-05 11:33:04 +00:00
Import declared lints at the top of the file
This commit is contained in:
parent
2afa7df564
commit
bb8208da2b
@ -9,6 +9,8 @@ use if_chain::if_chain;
|
||||
|
||||
use crate::utils::{match_path, paths, snippet, span_lint_and_sugg};
|
||||
|
||||
use super::BORROWED_BOX;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, mut_ty: &MutTy<'_>) -> bool {
|
||||
match mut_ty.ty.kind {
|
||||
TyKind::Path(ref qpath) => {
|
||||
@ -61,7 +63,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m
|
||||
};
|
||||
span_lint_and_sugg(
|
||||
cx,
|
||||
super::BORROWED_BOX,
|
||||
BORROWED_BOX,
|
||||
hir_ty.span,
|
||||
"you seem to be trying to use `&Box<T>`. Consider using just `&T`",
|
||||
"try",
|
||||
|
@ -3,11 +3,13 @@ use rustc_lint::LateContext;
|
||||
|
||||
use crate::utils::{match_def_path, paths, span_lint_and_help};
|
||||
|
||||
use super::LINKEDLIST;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, def_id: DefId) -> bool {
|
||||
if match_def_path(cx, def_id, &paths::LINKED_LIST) {
|
||||
span_lint_and_help(
|
||||
cx,
|
||||
super::LINKEDLIST,
|
||||
LINKEDLIST,
|
||||
hir_ty.span,
|
||||
"you seem to be using a `LinkedList`! Perhaps you meant some other data structure?",
|
||||
None,
|
||||
|
@ -4,12 +4,14 @@ use rustc_span::symbol::sym;
|
||||
|
||||
use crate::utils::{is_ty_param_diagnostic_item, span_lint};
|
||||
|
||||
use super::OPTION_OPTION;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
|
||||
if cx.tcx.is_diagnostic_item(sym::option_type, def_id) {
|
||||
if is_ty_param_diagnostic_item(cx, qpath, sym::option_type).is_some() {
|
||||
span_lint(
|
||||
cx,
|
||||
super::OPTION_OPTION,
|
||||
OPTION_OPTION,
|
||||
hir_ty.span,
|
||||
"consider using `Option<T>` instead of `Option<Option<T>>` or a custom \
|
||||
enum if you need to distinguish all 3 cases",
|
||||
|
Loading…
Reference in New Issue
Block a user