Skip to content

Commit 713aab1

Browse files
committed
Import declared lints at the top of the file
1 parent 260a29a commit 713aab1

File tree

7 files changed

+23
-17
lines changed

7 files changed

+23
-17
lines changed

clippy_lints/src/types/borrowed_box.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use if_chain::if_chain;
99

1010
use crate::utils::{match_path, paths, snippet, span_lint_and_sugg};
1111

12+
use super::BORROWED_BOX;
13+
1214
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, mut_ty: &MutTy<'_>) -> bool {
1315
match mut_ty.ty.kind {
1416
TyKind::Path(ref qpath) => {
@@ -61,7 +63,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m
6163
};
6264
span_lint_and_sugg(
6365
cx,
64-
super::BORROWED_BOX,
66+
BORROWED_BOX,
6567
hir_ty.span,
6668
"you seem to be trying to use `&Box<T>`. Consider using just `&T`",
6769
"try",

clippy_lints/src/types/box_vec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ use rustc_lint::LateContext;
33

44
use crate::utils::{paths, span_lint_and_help};
55

6-
use super::utils;
6+
use super::{utils, BOX_VEC};
77

88
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
99
if Some(def_id) == cx.tcx.lang_items().owned_box() {
1010
if utils::match_type_parameter(cx, qpath, &paths::VEC).is_some() {
1111
span_lint_and_help(
1212
cx,
13-
super::BOX_VEC,
13+
BOX_VEC,
1414
hir_ty.span,
1515
"you seem to be trying to use `Box<Vec<T>>`. Consider using just `Vec<T>`",
1616
None,

clippy_lints/src/types/linked_list.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ use rustc_lint::LateContext;
33

44
use crate::utils::{match_def_path, paths, span_lint_and_help};
55

6+
use super::LINKEDLIST;
7+
68
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, def_id: DefId) -> bool {
79
if match_def_path(cx, def_id, &paths::LINKED_LIST) {
810
span_lint_and_help(
911
cx,
10-
super::LINKEDLIST,
12+
LINKEDLIST,
1113
hir_ty.span,
1214
"I see you're using a LinkedList! Perhaps you meant some other data structure?",
1315
None,

clippy_lints/src/types/option_option.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ use rustc_span::symbol::sym;
44

55
use crate::utils::{paths, span_lint};
66

7-
use super::utils;
7+
use super::{utils, OPTION_OPTION};
88

99
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
1010
if cx.tcx.is_diagnostic_item(sym::option_type, def_id) {
1111
if utils::match_type_parameter(cx, qpath, &paths::OPTION).is_some() {
1212
span_lint(
1313
cx,
14-
super::OPTION_OPTION,
14+
OPTION_OPTION,
1515
hir_ty.span,
1616
"consider using `Option<T>` instead of `Option<Option<T>>` or a custom \
1717
enum if you need to distinguish all 3 cases",

clippy_lints/src/types/rc_buffer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ use rustc_span::symbol::sym;
55

66
use crate::utils::{last_path_segment, paths, snippet_with_applicability, span_lint_and_sugg};
77

8-
use super::utils;
8+
use super::{utils, RC_BUFFER};
99

1010
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
1111
if cx.tcx.is_diagnostic_item(sym::Rc, def_id) {
1212
if let Some(alternate) = match_buffer_type(cx, qpath) {
1313
span_lint_and_sugg(
1414
cx,
15-
super::RC_BUFFER,
15+
RC_BUFFER,
1616
hir_ty.span,
1717
"usage of `Rc<T>` when T is a buffer type",
1818
"try",
@@ -35,7 +35,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
3535
let mut applicability = Applicability::MachineApplicable;
3636
span_lint_and_sugg(
3737
cx,
38-
super::RC_BUFFER,
38+
RC_BUFFER,
3939
hir_ty.span,
4040
"usage of `Rc<T>` when T is a buffer type",
4141
"try",
@@ -51,7 +51,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
5151
if let Some(alternate) = match_buffer_type(cx, qpath) {
5252
span_lint_and_sugg(
5353
cx,
54-
super::RC_BUFFER,
54+
RC_BUFFER,
5555
hir_ty.span,
5656
"usage of `Arc<T>` when T is a buffer type",
5757
"try",
@@ -73,7 +73,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
7373
let mut applicability = Applicability::MachineApplicable;
7474
span_lint_and_sugg(
7575
cx,
76-
super::RC_BUFFER,
76+
RC_BUFFER,
7777
hir_ty.span,
7878
"usage of `Arc<T>` when T is a buffer type",
7979
"try",

clippy_lints/src/types/redundant_allocation.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use rustc_span::symbol::sym;
55

66
use crate::utils::{last_path_segment, paths, snippet_with_applicability, span_lint_and_sugg};
77

8-
use super::utils;
8+
use super::{utils, REDUNDANT_ALLOCATION};
99

1010
pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_>, def_id: DefId) -> bool {
1111
if Some(def_id) == cx.tcx.lang_items().owned_box() {
1212
if let Some(span) = utils::match_borrows_parameter(cx, qpath) {
1313
let mut applicability = Applicability::MachineApplicable;
1414
span_lint_and_sugg(
1515
cx,
16-
super::REDUNDANT_ALLOCATION,
16+
REDUNDANT_ALLOCATION,
1717
hir_ty.span,
1818
"usage of `Box<&T>`",
1919
"try",
@@ -30,7 +30,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
3030
let mut applicability = Applicability::MachineApplicable;
3131
span_lint_and_sugg(
3232
cx,
33-
super::REDUNDANT_ALLOCATION,
33+
REDUNDANT_ALLOCATION,
3434
hir_ty.span,
3535
"usage of `Rc<Rc<T>>`",
3636
"try",
@@ -55,7 +55,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
5555

5656
span_lint_and_sugg(
5757
cx,
58-
super::REDUNDANT_ALLOCATION,
58+
REDUNDANT_ALLOCATION,
5959
hir_ty.span,
6060
"usage of `Rc<Box<T>>`",
6161
"try",
@@ -70,7 +70,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, qpath: &QPath<'_
7070
let mut applicability = Applicability::MachineApplicable;
7171
span_lint_and_sugg(
7272
cx,
73-
super::REDUNDANT_ALLOCATION,
73+
REDUNDANT_ALLOCATION,
7474
hir_ty.span,
7575
"usage of `Rc<&T>`",
7676
"try",

clippy_lints/src/types/vec_box.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use if_chain::if_chain;
1010

1111
use crate::utils::{last_path_segment, snippet, span_lint_and_sugg};
1212

13+
use super::VEC_BOX;
14+
1315
pub(super) fn check(
1416
cx: &LateContext<'_>,
1517
hir_ty: &hir::Ty<'_>,
@@ -44,7 +46,7 @@ pub(super) fn check(
4446
then {
4547
span_lint_and_sugg(
4648
cx,
47-
super::VEC_BOX,
49+
VEC_BOX,
4850
hir_ty.span,
4951
"`Vec<T>` is already on the heap, the boxing is unnecessary.",
5052
"try",

0 commit comments

Comments
 (0)