Skip to content

Commit 0cce3f6

Browse files
committed
Auto merge of #7504 - flip1995:rename-lints, r=flip1995
Rename two lints to comply with our lint naming convention self_named_constructor -> self_named_constructors append_instead_of_extend -> extend_with_drain We don't need to `register_renamed` those lints, since I'll backport them to beta, so the old names won't hit stable. changelog: none (I'll adapt the changelog before merging #7498)
2 parents 766f09f + 54e5391 commit 0cce3f6

15 files changed

+34
-34
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2423,7 +2423,6 @@ Released 2018-09-13
24232423
<!-- begin autogenerated links to lint list -->
24242424
[`absurd_extreme_comparisons`]: https://rust-lang.github.io/rust-clippy/master/index.html#absurd_extreme_comparisons
24252425
[`almost_swapped`]: https://rust-lang.github.io/rust-clippy/master/index.html#almost_swapped
2426-
[`append_instead_of_extend`]: https://rust-lang.github.io/rust-clippy/master/index.html#append_instead_of_extend
24272426
[`approx_constant`]: https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant
24282427
[`as_conversions`]: https://rust-lang.github.io/rust-clippy/master/index.html#as_conversions
24292428
[`assertions_on_constants`]: https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
@@ -2522,6 +2521,7 @@ Released 2018-09-13
25222521
[`explicit_iter_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_iter_loop
25232522
[`explicit_write`]: https://rust-lang.github.io/rust-clippy/master/index.html#explicit_write
25242523
[`extend_from_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_from_slice
2524+
[`extend_with_drain`]: https://rust-lang.github.io/rust-clippy/master/index.html#extend_with_drain
25252525
[`extra_unused_lifetimes`]: https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
25262526
[`fallible_impl_from`]: https://rust-lang.github.io/rust-clippy/master/index.html#fallible_impl_from
25272527
[`field_reassign_with_default`]: https://rust-lang.github.io/rust-clippy/master/index.html#field_reassign_with_default
@@ -2772,7 +2772,7 @@ Released 2018-09-13
27722772
[`same_item_push`]: https://rust-lang.github.io/rust-clippy/master/index.html#same_item_push
27732773
[`search_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#search_is_some
27742774
[`self_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_assignment
2775-
[`self_named_constructor`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_constructor
2775+
[`self_named_constructors`]: https://rust-lang.github.io/rust-clippy/master/index.html#self_named_constructors
27762776
[`semicolon_if_nothing_returned`]: https://rust-lang.github.io/rust-clippy/master/index.html#semicolon_if_nothing_returned
27772777
[`serde_api_misuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#serde_api_misuse
27782778
[`shadow_reuse`]: https://rust-lang.github.io/rust-clippy/master/index.html#shadow_reuse

clippy_lints/src/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ mod regex;
329329
mod repeat_once;
330330
mod returns;
331331
mod self_assignment;
332-
mod self_named_constructor;
332+
mod self_named_constructors;
333333
mod semicolon_if_nothing_returned;
334334
mod serde_api;
335335
mod shadow;
@@ -740,7 +740,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
740740
mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
741741
mem_replace::MEM_REPLACE_WITH_DEFAULT,
742742
mem_replace::MEM_REPLACE_WITH_UNINIT,
743-
methods::APPEND_INSTEAD_OF_EXTEND,
744743
methods::BIND_INSTEAD_OF_MAP,
745744
methods::BYTES_NTH,
746745
methods::CHARS_LAST_CMP,
@@ -751,6 +750,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
751750
methods::CLONE_ON_REF_PTR,
752751
methods::EXPECT_FUN_CALL,
753752
methods::EXPECT_USED,
753+
methods::EXTEND_WITH_DRAIN,
754754
methods::FILETYPE_IS_FILE,
755755
methods::FILTER_MAP_IDENTITY,
756756
methods::FILTER_MAP_NEXT,
@@ -900,7 +900,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
900900
returns::LET_AND_RETURN,
901901
returns::NEEDLESS_RETURN,
902902
self_assignment::SELF_ASSIGNMENT,
903-
self_named_constructor::SELF_NAMED_CONSTRUCTOR,
903+
self_named_constructors::SELF_NAMED_CONSTRUCTORS,
904904
semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED,
905905
serde_api::SERDE_API_MISUSE,
906906
shadow::SHADOW_REUSE,
@@ -1296,14 +1296,14 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
12961296
LintId::of(mem_replace::MEM_REPLACE_OPTION_WITH_NONE),
12971297
LintId::of(mem_replace::MEM_REPLACE_WITH_DEFAULT),
12981298
LintId::of(mem_replace::MEM_REPLACE_WITH_UNINIT),
1299-
LintId::of(methods::APPEND_INSTEAD_OF_EXTEND),
13001299
LintId::of(methods::BIND_INSTEAD_OF_MAP),
13011300
LintId::of(methods::BYTES_NTH),
13021301
LintId::of(methods::CHARS_LAST_CMP),
13031302
LintId::of(methods::CHARS_NEXT_CMP),
13041303
LintId::of(methods::CLONE_DOUBLE_REF),
13051304
LintId::of(methods::CLONE_ON_COPY),
13061305
LintId::of(methods::EXPECT_FUN_CALL),
1306+
LintId::of(methods::EXTEND_WITH_DRAIN),
13071307
LintId::of(methods::FILTER_MAP_IDENTITY),
13081308
LintId::of(methods::FILTER_NEXT),
13091309
LintId::of(methods::FLAT_MAP_IDENTITY),
@@ -1407,7 +1407,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
14071407
LintId::of(returns::LET_AND_RETURN),
14081408
LintId::of(returns::NEEDLESS_RETURN),
14091409
LintId::of(self_assignment::SELF_ASSIGNMENT),
1410-
LintId::of(self_named_constructor::SELF_NAMED_CONSTRUCTOR),
1410+
LintId::of(self_named_constructors::SELF_NAMED_CONSTRUCTORS),
14111411
LintId::of(serde_api::SERDE_API_MISUSE),
14121412
LintId::of(single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
14131413
LintId::of(size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT),
@@ -1561,7 +1561,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15611561
LintId::of(redundant_static_lifetimes::REDUNDANT_STATIC_LIFETIMES),
15621562
LintId::of(returns::LET_AND_RETURN),
15631563
LintId::of(returns::NEEDLESS_RETURN),
1564-
LintId::of(self_named_constructor::SELF_NAMED_CONSTRUCTOR),
1564+
LintId::of(self_named_constructors::SELF_NAMED_CONSTRUCTORS),
15651565
LintId::of(single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS),
15661566
LintId::of(tabs_in_doc_comments::TABS_IN_DOC_COMMENTS),
15671567
LintId::of(to_digit_is_some::TO_DIGIT_IS_SOME),
@@ -1762,8 +1762,8 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
17621762
LintId::of(large_enum_variant::LARGE_ENUM_VARIANT),
17631763
LintId::of(loops::MANUAL_MEMCPY),
17641764
LintId::of(loops::NEEDLESS_COLLECT),
1765-
LintId::of(methods::APPEND_INSTEAD_OF_EXTEND),
17661765
LintId::of(methods::EXPECT_FUN_CALL),
1766+
LintId::of(methods::EXTEND_WITH_DRAIN),
17671767
LintId::of(methods::ITER_NTH),
17681768
LintId::of(methods::MANUAL_STR_REPEAT),
17691769
LintId::of(methods::OR_FUN_CALL),
@@ -2104,7 +2104,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
21042104
let scripts = conf.allowed_scripts.clone();
21052105
store.register_early_pass(move || box disallowed_script_idents::DisallowedScriptIdents::new(&scripts));
21062106
store.register_late_pass(|| box strlen_on_c_strings::StrlenOnCStrings);
2107-
store.register_late_pass(move || box self_named_constructor::SelfNamedConstructor);
2107+
store.register_late_pass(move || box self_named_constructors::SelfNamedConstructors);
21082108
}
21092109

21102110
#[rustfmt::skip]

clippy_lints/src/methods/append_instead_of_extend.rs renamed to clippy_lints/src/methods/extend_with_drain.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_hir::{Expr, ExprKind, LangItem};
77
use rustc_lint::LateContext;
88
use rustc_span::symbol::sym;
99

10-
use super::APPEND_INSTEAD_OF_EXTEND;
10+
use super::EXTEND_WITH_DRAIN;
1111

1212
pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: &Expr<'_>) {
1313
let ty = cx.typeck_results().expr_ty(recv).peel_refs();
@@ -25,7 +25,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg:
2525
let mut applicability = Applicability::MachineApplicable;
2626
span_lint_and_sugg(
2727
cx,
28-
APPEND_INSTEAD_OF_EXTEND,
28+
EXTEND_WITH_DRAIN,
2929
expr.span,
3030
"use of `extend` instead of `append` for adding the full range of a second vector",
3131
"try this",

clippy_lints/src/methods/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
mod append_instead_of_extend;
21
mod bind_instead_of_map;
32
mod bytes_nth;
43
mod chars_cmp;
@@ -12,6 +11,7 @@ mod clone_on_ref_ptr;
1211
mod cloned_instead_of_copied;
1312
mod expect_fun_call;
1413
mod expect_used;
14+
mod extend_with_drain;
1515
mod filetype_is_file;
1616
mod filter_map;
1717
mod filter_map_identity;
@@ -1068,7 +1068,7 @@ declare_clippy_lint! {
10681068
/// // Good
10691069
/// a.append(&mut b);
10701070
/// ```
1071-
pub APPEND_INSTEAD_OF_EXTEND,
1071+
pub EXTEND_WITH_DRAIN,
10721072
perf,
10731073
"using vec.append(&mut vec) to move the full range of a vecor to another"
10741074
}
@@ -1821,7 +1821,7 @@ impl_lint_pass!(Methods => [
18211821
IMPLICIT_CLONE,
18221822
SUSPICIOUS_SPLITN,
18231823
MANUAL_STR_REPEAT,
1824-
APPEND_INSTEAD_OF_EXTEND
1824+
EXTEND_WITH_DRAIN
18251825
]);
18261826

18271827
/// Extracts a method call name, args, and `Span` of the method name.
@@ -2085,7 +2085,7 @@ fn check_methods<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, msrv: Optio
20852085
},
20862086
("extend", [arg]) => {
20872087
string_extend_chars::check(cx, expr, recv, arg);
2088-
append_instead_of_extend::check(cx, expr, recv, arg);
2088+
extend_with_drain::check(cx, expr, recv, arg);
20892089
},
20902090
("filter_map", [arg]) => {
20912091
unnecessary_filter_map::check(cx, expr, arg);

clippy_lints/src/self_named_constructor.rs renamed to clippy_lints/src/self_named_constructors.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ declare_clippy_lint! {
3232
/// }
3333
/// }
3434
/// ```
35-
pub SELF_NAMED_CONSTRUCTOR,
35+
pub SELF_NAMED_CONSTRUCTORS,
3636
style,
3737
"method should not have the same name as the type it is implemented for"
3838
}
3939

40-
declare_lint_pass!(SelfNamedConstructor => [SELF_NAMED_CONSTRUCTOR]);
40+
declare_lint_pass!(SelfNamedConstructors => [SELF_NAMED_CONSTRUCTORS]);
4141

42-
impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructor {
42+
impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors {
4343
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
4444
match impl_item.kind {
4545
ImplItemKind::Fn(ref sig, _) => {
@@ -80,7 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructor {
8080
then {
8181
span_lint(
8282
cx,
83-
SELF_NAMED_CONSTRUCTOR,
83+
SELF_NAMED_CONSTRUCTORS,
8484
impl_item.span,
8585
&format!("constructor `{}` has the same name as the type", impl_item.ident.name),
8686
);

tests/ui/append_instead_of_extend.fixed renamed to tests/ui/extend_with_drain.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![warn(clippy::append_instead_of_extend)]
2+
#![warn(clippy::extend_with_drain)]
33
use std::collections::BinaryHeap;
44
fn main() {
55
//gets linted

tests/ui/append_instead_of_extend.rs renamed to tests/ui/extend_with_drain.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-rustfix
2-
#![warn(clippy::append_instead_of_extend)]
2+
#![warn(clippy::extend_with_drain)]
33
use std::collections::BinaryHeap;
44
fn main() {
55
//gets linted

tests/ui/append_instead_of_extend.stderr renamed to tests/ui/extend_with_drain.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
error: use of `extend` instead of `append` for adding the full range of a second vector
2-
--> $DIR/append_instead_of_extend.rs:9:5
2+
--> $DIR/extend_with_drain.rs:9:5
33
|
44
LL | vec2.extend(vec1.drain(..));
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec2.append(&mut vec1)`
66
|
7-
= note: `-D clippy::append-instead-of-extend` implied by `-D warnings`
7+
= note: `-D clippy::extend-with-drain` implied by `-D warnings`
88

99
error: use of `extend` instead of `append` for adding the full range of a second vector
10-
--> $DIR/append_instead_of_extend.rs:14:5
10+
--> $DIR/extend_with_drain.rs:14:5
1111
|
1212
LL | vec4.extend(vec3.drain(..));
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec4.append(&mut vec3)`
1414

1515
error: use of `extend` instead of `append` for adding the full range of a second vector
16-
--> $DIR/append_instead_of_extend.rs:18:5
16+
--> $DIR/extend_with_drain.rs:18:5
1717
|
1818
LL | vec11.extend(return_vector().drain(..));
1919
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `vec11.append(&mut return_vector())`

tests/ui/needless_bool/fixable.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
clippy::no_effect,
88
clippy::if_same_then_else,
99
clippy::needless_return,
10-
clippy::self_named_constructor
10+
clippy::self_named_constructors
1111
)]
1212

1313
use std::cell::Cell;

tests/ui/needless_bool/fixable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
clippy::no_effect,
88
clippy::if_same_then_else,
99
clippy::needless_return,
10-
clippy::self_named_constructor
10+
clippy::self_named_constructors
1111
)]
1212

1313
use std::cell::Cell;

tests/ui/self_named_constructor.rs renamed to tests/ui/self_named_constructors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::self_named_constructor)]
1+
#![warn(clippy::self_named_constructors)]
22

33
struct ShouldSpawn;
44
struct ShouldNotSpawn;
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
error: constructor `should_spawn` has the same name as the type
2-
--> $DIR/self_named_constructor.rs:7:5
2+
--> $DIR/self_named_constructors.rs:7:5
33
|
44
LL | / pub fn should_spawn() -> ShouldSpawn {
55
LL | | ShouldSpawn
66
LL | | }
77
| |_____^
88
|
9-
= note: `-D clippy::self-named-constructor` implied by `-D warnings`
9+
= note: `-D clippy::self-named-constructors` implied by `-D warnings`
1010

1111
error: aborting due to previous error
1212

tests/ui/unit_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
clippy::unnecessary_wraps,
88
clippy::or_fun_call,
99
clippy::needless_question_mark,
10-
clippy::self_named_constructor
10+
clippy::self_named_constructors
1111
)]
1212

1313
use std::fmt::Debug;

tests/ui/use_self.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
clippy::should_implement_trait,
99
clippy::upper_case_acronyms,
1010
clippy::from_over_into,
11-
clippy::self_named_constructor
11+
clippy::self_named_constructors
1212
)]
1313

1414
#[macro_use]

tests/ui/use_self.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
clippy::should_implement_trait,
99
clippy::upper_case_acronyms,
1010
clippy::from_over_into,
11-
clippy::self_named_constructor
11+
clippy::self_named_constructors
1212
)]
1313

1414
#[macro_use]

0 commit comments

Comments
 (0)