Skip to content

Commit 088bb8f

Browse files
committed
fixup! New large_enum_variants linter
1 parent 4a0e6c8 commit 088bb8f

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ All notable changes to this project will be documented in this file.
193193
[`empty_loop`]: https://github.com/Manishearth/rust-clippy/wiki#empty_loop
194194
[`enum_clike_unportable_variant`]: https://github.com/Manishearth/rust-clippy/wiki#enum_clike_unportable_variant
195195
[`enum_glob_use`]: https://github.com/Manishearth/rust-clippy/wiki#enum_glob_use
196-
[`enum_large_variant`]: https://github.com/Manishearth/rust-clippy/wiki#enum_large_variant
197196
[`enum_variant_names`]: https://github.com/Manishearth/rust-clippy/wiki#enum_variant_names
198197
[`eq_op`]: https://github.com/Manishearth/rust-clippy/wiki#eq_op
199198
[`eval_order_dependence`]: https://github.com/Manishearth/rust-clippy/wiki#eval_order_dependence
@@ -221,6 +220,7 @@ All notable changes to this project will be documented in this file.
221220
[`items_after_statements`]: https://github.com/Manishearth/rust-clippy/wiki#items_after_statements
222221
[`iter_next_loop`]: https://github.com/Manishearth/rust-clippy/wiki#iter_next_loop
223222
[`iter_nth`]: https://github.com/Manishearth/rust-clippy/wiki#iter_nth
223+
[`large_enum_variant`]: https://github.com/Manishearth/rust-clippy/wiki#large_enum_variant
224224
[`len_without_is_empty`]: https://github.com/Manishearth/rust-clippy/wiki#len_without_is_empty
225225
[`len_zero`]: https://github.com/Manishearth/rust-clippy/wiki#len_zero
226226
[`let_and_return`]: https://github.com/Manishearth/rust-clippy/wiki#let_and_return

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ name
5555
[empty_loop](https://github.com/Manishearth/rust-clippy/wiki#empty_loop) | warn | empty `loop {}`, which should block or sleep
5656
[enum_clike_unportable_variant](https://github.com/Manishearth/rust-clippy/wiki#enum_clike_unportable_variant) | warn | C-like enums that are `repr(isize/usize)` and have values that don't fit into an `i32`
5757
[enum_glob_use](https://github.com/Manishearth/rust-clippy/wiki#enum_glob_use) | allow | use items that import all variants of an enum
58-
[enum_large_variant](https://github.com/Manishearth/rust-clippy/wiki#enum_large_variant) | warn | large variants on an enum
5958
[enum_variant_names](https://github.com/Manishearth/rust-clippy/wiki#enum_variant_names) | warn | enums where all variants share a prefix/postfix
6059
[eq_op](https://github.com/Manishearth/rust-clippy/wiki#eq_op) | warn | equal operands on both sides of a comparison or bitwise combination (e.g. `x == x`)
6160
[eval_order_dependence](https://github.com/Manishearth/rust-clippy/wiki#eval_order_dependence) | warn | whether a variable read occurs before a write depends on sub-expression evaluation order
@@ -83,6 +82,7 @@ name
8382
[items_after_statements](https://github.com/Manishearth/rust-clippy/wiki#items_after_statements) | allow | blocks where an item comes after a statement
8483
[iter_next_loop](https://github.com/Manishearth/rust-clippy/wiki#iter_next_loop) | warn | for-looping over `_.next()` which is probably not intended
8584
[iter_nth](https://github.com/Manishearth/rust-clippy/wiki#iter_nth) | warn | using `.iter().nth()` on a standard library type with O(1) element access
85+
[large_enum_variant](https://github.com/Manishearth/rust-clippy/wiki#large_enum_variant) | warn | large variants on an enum
8686
[len_without_is_empty](https://github.com/Manishearth/rust-clippy/wiki#len_without_is_empty) | warn | traits and impls that have `.len()` but not `.is_empty()`
8787
[len_zero](https://github.com/Manishearth/rust-clippy/wiki#len_zero) | warn | checking `.len() == 0` or `.len() > 0` (or similar) when `.is_empty()` could be used instead
8888
[let_and_return](https://github.com/Manishearth/rust-clippy/wiki#let_and_return) | warn | creating a let-binding and then immediately returning it like `let x = expr; x` at the end of a block

clippy_lints/src/enum_large_variant.rs renamed to clippy_lints/src/large_enum_variant.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,31 @@ use rustc::ty::layout::TargetDataLayout;
2020
/// }
2121
/// ```
2222
declare_lint! {
23-
pub ENUM_LARGE_VARIANT,
23+
pub LARGE_ENUM_VARIANT,
2424
Warn,
2525
"large variants on an enum"
2626
}
2727

2828
#[derive(Copy,Clone)]
29-
pub struct EnumLargeVariant {
29+
pub struct LargeEnumVariant {
3030
maximum_variant_size_allowed: u64,
3131
}
3232

33-
impl EnumLargeVariant {
33+
impl LargeEnumVariant {
3434
pub fn new(maximum_variant_size_allowed: u64) -> Self {
35-
EnumLargeVariant {
35+
LargeEnumVariant {
3636
maximum_variant_size_allowed: maximum_variant_size_allowed,
3737
}
3838
}
3939
}
4040

41-
impl LintPass for EnumLargeVariant {
41+
impl LintPass for LargeEnumVariant {
4242
fn get_lints(&self) -> LintArray {
43-
lint_array!(ENUM_LARGE_VARIANT)
43+
lint_array!(LARGE_ENUM_VARIANT)
4444
}
4545
}
4646

47-
impl LateLintPass for EnumLargeVariant {
47+
impl LateLintPass for LargeEnumVariant {
4848
fn check_variant(&mut self, cx: &LateContext, variant: &Variant, _ :&Generics) {
4949
let data_layout = TargetDataLayout::parse(cx.sess());
5050
let param_env = cx.tcx.empty_parameter_environment();
@@ -61,7 +61,7 @@ impl LateLintPass for EnumLargeVariant {
6161
if variant_size > self.maximum_variant_size_allowed {
6262
span_help_and_lint(
6363
cx,
64-
ENUM_LARGE_VARIANT,
64+
LARGE_ENUM_VARIANT,
6565
variant.span,
6666
&format!("large enum variant found on variant `{}`", variant.node.name),
6767
"consider boxing the large branches to reduce the total size of the enum",

clippy_lints/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ pub mod drop_ref;
7474
pub mod entry;
7575
pub mod enum_clike;
7676
pub mod enum_glob_use;
77-
pub mod enum_large_variant;
7877
pub mod enum_variants;
7978
pub mod eq_op;
8079
pub mod escape;
@@ -86,6 +85,7 @@ pub mod functions;
8685
pub mod identity_op;
8786
pub mod if_not_else;
8887
pub mod items_after_statements;
88+
pub mod large_enum_variant;
8989
pub mod len_zero;
9090
pub mod let_if_seq;
9191
pub mod lifetimes;
@@ -261,7 +261,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
261261
reg.register_late_lint_pass(box assign_ops::AssignOps);
262262
reg.register_late_lint_pass(box let_if_seq::LetIfSeq);
263263
reg.register_late_lint_pass(box eval_order_dependence::EvalOrderDependence);
264-
reg.register_late_lint_pass(box enum_large_variant::EnumLargeVariant::new(conf.enum_variant_size_threshold));
264+
reg.register_late_lint_pass(box large_enum_variant::LargeEnumVariant::new(conf.enum_variant_size_threshold));
265265

266266
reg.register_lint_group("clippy_restrictions", vec![
267267
arithmetic::FLOAT_ARITHMETIC,
@@ -328,7 +328,6 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
328328
drop_ref::DROP_REF,
329329
entry::MAP_ENTRY,
330330
enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
331-
enum_large_variant::ENUM_LARGE_VARIANT,
332331
enum_variants::ENUM_VARIANT_NAMES,
333332
eq_op::EQ_OP,
334333
escape::BOXED_LOCAL,
@@ -340,6 +339,7 @@ pub fn register_plugins(reg: &mut rustc_plugin::Registry) {
340339
functions::NOT_UNSAFE_PTR_ARG_DEREF,
341340
functions::TOO_MANY_ARGUMENTS,
342341
identity_op::IDENTITY_OP,
342+
large_enum_variant::LARGE_ENUM_VARIANT,
343343
len_zero::LEN_WITHOUT_IS_EMPTY,
344344
len_zero::LEN_ZERO,
345345
let_if_seq::USELESS_LET_IF_SEQ,

tests/compile-fail/enum_large_variant.rs renamed to tests/compile-fail/large_enum_variant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#![allow(dead_code)]
55
#![allow(unused_variables)]
6-
#![deny(enum_large_variant)]
6+
#![deny(large_enum_variant)]
77

88
enum LargeEnum {
99
A(i32),

0 commit comments

Comments
 (0)