about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNathaniel Hamovitz <18648574+nhamovitz@users.noreply.github.com>2021-10-18 03:45:08 -0700
committerNathaniel Hamovitz <18648574+nhamovitz@users.noreply.github.com>2021-10-18 03:45:08 -0700
commit7f84e3d791846fb462eb39d05bbec029b68d97af (patch)
tree55ebe13712b29ca5de1c66c781fdf2bd7043fb0c
parent149b3728732169cbd6684dfb5e17242924a506a7 (diff)
downloadrust-7f84e3d791846fb462eb39d05bbec029b68d97af.tar.gz
rust-7f84e3d791846fb462eb39d05bbec029b68d97af.zip
Rename lint
-rw-r--r--CHANGELOG.md2
-rw-r--r--clippy_lints/src/lib.register_lints.rs2
-rw-r--r--clippy_lints/src/lib.register_nursery.rs2
-rw-r--r--clippy_lints/src/lib.rs4
-rw-r--r--clippy_lints/src/trailing_zero_sized_array_without_repr.rs (renamed from clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs)22
-rw-r--r--tests/ui/trailing_zero_sized_array_without_repr.rs (renamed from tests/ui/trailing_zero_sized_array_without_repr_c.rs)2
6 files changed, 17 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a124bebe924..0cf19a6f0f1 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3021,7 +3021,7 @@ Released 2018-09-13
 [`too_many_arguments`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
 [`too_many_lines`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
 [`toplevel_ref_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg
-[`trailing_zero_sized_array_without_repr_c`]: https://rust-lang.github.io/rust-clippy/master/index.html#trailing_zero_sized_array_without_repr_c
+[`trailing_zero_sized_array_without_repr`]: https://rust-lang.github.io/rust-clippy/master/index.html#trailing_zero_sized_array_without_repr
 [`trait_duplication_in_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds
 [`transmute_bytes_to_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_bytes_to_str
 [`transmute_float_to_int`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_float_to_int
diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs
index 34b87002fa3..af0629beb36 100644
--- a/clippy_lints/src/lib.register_lints.rs
+++ b/clippy_lints/src/lib.register_lints.rs
@@ -443,7 +443,7 @@ store.register_lints(&[
     temporary_assignment::TEMPORARY_ASSIGNMENT,
     to_digit_is_some::TO_DIGIT_IS_SOME,
     to_string_in_display::TO_STRING_IN_DISPLAY,
-    trailing_zero_sized_array_without_repr_c::TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C,
+    trailing_zero_sized_array_without_repr::TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR,
     trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS,
     trait_bounds::TYPE_REPETITION_IN_BOUNDS,
     transmute::CROSSPOINTER_TRANSMUTE,
diff --git a/clippy_lints/src/lib.register_nursery.rs b/clippy_lints/src/lib.register_nursery.rs
index 325706746db..eab0e5b90f1 100644
--- a/clippy_lints/src/lib.register_nursery.rs
+++ b/clippy_lints/src/lib.register_nursery.rs
@@ -25,7 +25,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
     LintId::of(regex::TRIVIAL_REGEX),
     LintId::of(strings::STRING_LIT_AS_BYTES),
     LintId::of(suspicious_operation_groupings::SUSPICIOUS_OPERATION_GROUPINGS),
-    LintId::of(trailing_zero_sized_array_without_repr_c::TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C),
+    LintId::of(trailing_zero_sized_array_without_repr::TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR),
     LintId::of(transmute::USELESS_TRANSMUTE),
     LintId::of(use_self::USE_SELF),
 ])
diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs
index 72636146d7c..1473a2f3095 100644
--- a/clippy_lints/src/lib.rs
+++ b/clippy_lints/src/lib.rs
@@ -356,7 +356,7 @@ mod tabs_in_doc_comments;
 mod temporary_assignment;
 mod to_digit_is_some;
 mod to_string_in_display;
-mod trailing_zero_sized_array_without_repr_c;
+mod trailing_zero_sized_array_without_repr;
 mod trait_bounds;
 mod transmute;
 mod transmuting_null;
@@ -779,7 +779,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
     store.register_late_pass(move || Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::default()));
     store.register_late_pass(|| Box::new(match_str_case_mismatch::MatchStrCaseMismatch));
     store.register_late_pass(move || Box::new(format_args::FormatArgs));
-    store.register_late_pass(|| Box::new(trailing_zero_sized_array_without_repr_c::TrailingZeroSizedArrayWithoutReprC));
+    store.register_late_pass(|| Box::new(trailing_zero_sized_array_without_repr::TrailingZeroSizedArrayWithoutRepr));
 
 }
 
diff --git a/clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs b/clippy_lints/src/trailing_zero_sized_array_without_repr.rs
index 6cba18146b1..0267f7bdf0e 100644
--- a/clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs
+++ b/clippy_lints/src/trailing_zero_sized_array_without_repr.rs
@@ -8,10 +8,10 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
 
 declare_clippy_lint! {
     /// ### What it does
-    /// Displays a warning when a struct with a trailing zero-sized array is declared without the `repr(C)` attribute.
+    /// Displays a warning when a struct with a trailing zero-sized array is declared without a `repr` attribute.
     ///
     /// ### Why is this bad?
-    /// Zero-sized arrays aren't very useful in Rust itself, so such a struct is likely being created to pass to C code (or in conjuction with manual allocation to make it easy to compute the offset of the array). Either way, `#[repr(C)]` is needed.
+    /// Zero-sized arrays aren't very useful in Rust itself, so such a struct is likely being created to pass to C code or in some other situation where control over memory layout matters (for example, in conjuction with manual allocation to make it easy to compute the offset of the array). Either way, `#[repr(C)]` (or another `repr` attribute) is needed.
     ///
     /// ### Example
     /// ```rust
@@ -29,13 +29,13 @@ declare_clippy_lint! {
     ///     last: [SomeType; 0],
     /// }
     /// ```
-    pub TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C,
+    pub TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR,
     nursery,
     "struct with a trailing zero-sized array but without `repr(C)` or another `repr` attribute"
 }
-declare_lint_pass!(TrailingZeroSizedArrayWithoutReprC => [TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C]);
+declare_lint_pass!(TrailingZeroSizedArrayWithoutRepr => [TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR]);
 
-impl<'tcx> LateLintPass<'tcx> for TrailingZeroSizedArrayWithoutReprC {
+impl<'tcx> LateLintPass<'tcx> for TrailingZeroSizedArrayWithoutRepr {
     fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
         if is_struct_with_trailing_zero_sized_array(cx, item) {
             // NOTE: This is to include attributes on the definition when we print the lint. If the convention
@@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for TrailingZeroSizedArrayWithoutReprC {
             if !has_repr_attr(cx, attrs) {
                 span_lint_and_help(
                     cx,
-                    TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C,
+                    TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR,
                     lint_span,
                     "trailing zero-sized array in a struct which is not marked `#[repr(C)]`",
                     None,
@@ -65,17 +65,17 @@ impl<'tcx> LateLintPass<'tcx> for TrailingZeroSizedArrayWithoutReprC {
 
 fn is_struct_with_trailing_zero_sized_array(cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) -> bool {
     // TODO: when finalized, replace with an `if_chain`. I have it like this because my rust-analyzer
-    // doesn't work when it's an `if_chain` First check if last field is an array
+    // doesn't work when it's an `if_chain`.
+
+    // First check if last field is an array
     if let ItemKind::Struct(data, _) = &item.kind {
-        let field_defs = data.fields();
-        if let Some(last_field) = field_defs.last() {
+        if let Some(last_field) = data.fields().last() {
             if let rustc_hir::TyKind::Array(_, length) = last_field.ty.kind {
                 // Then check if that that array zero-sized
                 let length_ldid = cx.tcx.hir().local_def_id(length.hir_id);
                 let length = Const::from_anon_const(cx.tcx, length_ldid);
                 let length = length.try_eval_usize(cx.tcx, cx.param_env);
-                // if let Some((Constant::Int(length), _)) = length {
-                if let Some(length) = length { length == 0 } else { false }
+                length == Some(0)
             } else {
                 false
             }
diff --git a/tests/ui/trailing_zero_sized_array_without_repr_c.rs b/tests/ui/trailing_zero_sized_array_without_repr.rs
index c6ee36e9685..6ac124c8b34 100644
--- a/tests/ui/trailing_zero_sized_array_without_repr_c.rs
+++ b/tests/ui/trailing_zero_sized_array_without_repr.rs
@@ -1,4 +1,4 @@
-#![warn(clippy::trailing_zero_sized_array_without_repr_c)]
+#![warn(clippy::trailing_zero_sized_array_without_repr)]
 #![feature(const_generics_defaults)]
 
 // Do lint: