Skip to content

Commit 7f84e3d

Browse files
committed
Rename lint
1 parent 149b372 commit 7f84e3d

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3021,7 +3021,7 @@ Released 2018-09-13
30213021
[`too_many_arguments`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
30223022
[`too_many_lines`]: https://rust-lang.github.io/rust-clippy/master/index.html#too_many_lines
30233023
[`toplevel_ref_arg`]: https://rust-lang.github.io/rust-clippy/master/index.html#toplevel_ref_arg
3024-
[`trailing_zero_sized_array_without_repr_c`]: https://rust-lang.github.io/rust-clippy/master/index.html#trailing_zero_sized_array_without_repr_c
3024+
[`trailing_zero_sized_array_without_repr`]: https://rust-lang.github.io/rust-clippy/master/index.html#trailing_zero_sized_array_without_repr
30253025
[`trait_duplication_in_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#trait_duplication_in_bounds
30263026
[`transmute_bytes_to_str`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_bytes_to_str
30273027
[`transmute_float_to_int`]: https://rust-lang.github.io/rust-clippy/master/index.html#transmute_float_to_int

clippy_lints/src/lib.register_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ store.register_lints(&[
443443
temporary_assignment::TEMPORARY_ASSIGNMENT,
444444
to_digit_is_some::TO_DIGIT_IS_SOME,
445445
to_string_in_display::TO_STRING_IN_DISPLAY,
446-
trailing_zero_sized_array_without_repr_c::TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C,
446+
trailing_zero_sized_array_without_repr::TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR,
447447
trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS,
448448
trait_bounds::TYPE_REPETITION_IN_BOUNDS,
449449
transmute::CROSSPOINTER_TRANSMUTE,

clippy_lints/src/lib.register_nursery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ store.register_group(true, "clippy::nursery", Some("clippy_nursery"), vec![
2525
LintId::of(regex::TRIVIAL_REGEX),
2626
LintId::of(strings::STRING_LIT_AS_BYTES),
2727
LintId::of(suspicious_operation_groupings::SUSPICIOUS_OPERATION_GROUPINGS),
28-
LintId::of(trailing_zero_sized_array_without_repr_c::TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C),
28+
LintId::of(trailing_zero_sized_array_without_repr::TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR),
2929
LintId::of(transmute::USELESS_TRANSMUTE),
3030
LintId::of(use_self::USE_SELF),
3131
])

clippy_lints/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ mod tabs_in_doc_comments;
356356
mod temporary_assignment;
357357
mod to_digit_is_some;
358358
mod to_string_in_display;
359-
mod trailing_zero_sized_array_without_repr_c;
359+
mod trailing_zero_sized_array_without_repr;
360360
mod trait_bounds;
361361
mod transmute;
362362
mod transmuting_null;
@@ -779,7 +779,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
779779
store.register_late_pass(move || Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::default()));
780780
store.register_late_pass(|| Box::new(match_str_case_mismatch::MatchStrCaseMismatch));
781781
store.register_late_pass(move || Box::new(format_args::FormatArgs));
782-
store.register_late_pass(|| Box::new(trailing_zero_sized_array_without_repr_c::TrailingZeroSizedArrayWithoutReprC));
782+
store.register_late_pass(|| Box::new(trailing_zero_sized_array_without_repr::TrailingZeroSizedArrayWithoutRepr));
783783

784784
}
785785

clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs renamed to clippy_lints/src/trailing_zero_sized_array_without_repr.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ use rustc_session::{declare_lint_pass, declare_tool_lint};
88

99
declare_clippy_lint! {
1010
/// ### What it does
11-
/// Displays a warning when a struct with a trailing zero-sized array is declared without the `repr(C)` attribute.
11+
/// Displays a warning when a struct with a trailing zero-sized array is declared without a `repr` attribute.
1212
///
1313
/// ### Why is this bad?
14-
/// 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.
14+
/// 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.
1515
///
1616
/// ### Example
1717
/// ```rust
@@ -29,13 +29,13 @@ declare_clippy_lint! {
2929
/// last: [SomeType; 0],
3030
/// }
3131
/// ```
32-
pub TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C,
32+
pub TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR,
3333
nursery,
3434
"struct with a trailing zero-sized array but without `repr(C)` or another `repr` attribute"
3535
}
36-
declare_lint_pass!(TrailingZeroSizedArrayWithoutReprC => [TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C]);
36+
declare_lint_pass!(TrailingZeroSizedArrayWithoutRepr => [TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR]);
3737

38-
impl<'tcx> LateLintPass<'tcx> for TrailingZeroSizedArrayWithoutReprC {
38+
impl<'tcx> LateLintPass<'tcx> for TrailingZeroSizedArrayWithoutRepr {
3939
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) {
4040
if is_struct_with_trailing_zero_sized_array(cx, item) {
4141
// 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 {
5252
if !has_repr_attr(cx, attrs) {
5353
span_lint_and_help(
5454
cx,
55-
TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR_C,
55+
TRAILING_ZERO_SIZED_ARRAY_WITHOUT_REPR,
5656
lint_span,
5757
"trailing zero-sized array in a struct which is not marked `#[repr(C)]`",
5858
None,
@@ -65,17 +65,17 @@ impl<'tcx> LateLintPass<'tcx> for TrailingZeroSizedArrayWithoutReprC {
6565

6666
fn is_struct_with_trailing_zero_sized_array(cx: &LateContext<'tcx>, item: &'tcx Item<'tcx>) -> bool {
6767
// TODO: when finalized, replace with an `if_chain`. I have it like this because my rust-analyzer
68-
// doesn't work when it's an `if_chain` First check if last field is an array
68+
// doesn't work when it's an `if_chain`.
69+
70+
// First check if last field is an array
6971
if let ItemKind::Struct(data, _) = &item.kind {
70-
let field_defs = data.fields();
71-
if let Some(last_field) = field_defs.last() {
72+
if let Some(last_field) = data.fields().last() {
7273
if let rustc_hir::TyKind::Array(_, length) = last_field.ty.kind {
7374
// Then check if that that array zero-sized
7475
let length_ldid = cx.tcx.hir().local_def_id(length.hir_id);
7576
let length = Const::from_anon_const(cx.tcx, length_ldid);
7677
let length = length.try_eval_usize(cx.tcx, cx.param_env);
77-
// if let Some((Constant::Int(length), _)) = length {
78-
if let Some(length) = length { length == 0 } else { false }
78+
length == Some(0)
7979
} else {
8080
false
8181
}

tests/ui/trailing_zero_sized_array_without_repr_c.rs renamed to tests/ui/trailing_zero_sized_array_without_repr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![warn(clippy::trailing_zero_sized_array_without_repr_c)]
1+
#![warn(clippy::trailing_zero_sized_array_without_repr)]
22
#![feature(const_generics_defaults)]
33

44
// Do lint:

0 commit comments

Comments
 (0)