Skip to content

Commit efdd00d

Browse files
authored
Merge pull request #1 from humanenginuity/fix-strictly-aligned-types-cast-messages
Corrected messaging to warn against less- to more-strictly aligned
2 parents 79e8182 + 1969d42 commit efdd00d

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

clippy_lints/src/types.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,10 @@ declare_clippy_lint! {
679679
"cast to the same type, e.g. `x as i32` where `x: i32`"
680680
}
681681

682-
/// **What it does:** Checks for casts from a more-strictly-aligned pointer to a
683-
/// less-strictly-aligned pointer
682+
/// **What it does:** Checks for casts from a less-strictly-aligned pointer to a
683+
/// more-strictly-aligned pointer
684684
///
685-
/// **Why is this bad?** Dereferencing the resulting pointer is undefined
685+
/// **Why is this bad?** Dereferencing the resulting pointer may be undefined
686686
/// behavior.
687687
///
688688
/// **Known problems:** None.
@@ -695,7 +695,7 @@ declare_clippy_lint! {
695695
declare_clippy_lint! {
696696
pub CAST_PTR_ALIGNMENT,
697697
correctness,
698-
"cast from a pointer to a less-strictly-aligned pointer"
698+
"cast from a pointer to a more-strictly-aligned pointer"
699699
}
700700

701701
/// Returns the size in bits of an integral type.
@@ -986,7 +986,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
986986
cx,
987987
CAST_PTR_ALIGNMENT,
988988
expr.span,
989-
&format!("casting from `{}` to a less-strictly-aligned pointer (`{}`)", cast_from, cast_to)
989+
&format!("casting from `{}` to a more-strictly-aligned pointer (`{}`)", cast_from, cast_to)
990990
);
991991
}
992992
}

tests/ui/cast_alignment.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
error: casting from `*const u8` to a less-strictly-aligned pointer (`*const u16`)
1+
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
22
--> $DIR/cast_alignment.rs:9:5
33
|
44
9 | (&1u8 as *const u8) as *const u16;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= note: `-D cast-ptr-alignment` implied by `-D warnings`
88

9-
error: casting from `*mut u8` to a less-strictly-aligned pointer (`*mut u16`)
9+
error: casting from `*mut u8` to a more-strictly-aligned pointer (`*mut u16`)
1010
--> $DIR/cast_alignment.rs:10:5
1111
|
1212
10 | (&mut 1u8 as *mut u8) as *mut u16;

0 commit comments

Comments
 (0)