Skip to content

Commit

Permalink
Merge pull request #1 from humanenginuity/fix-strictly-aligned-types-…
Browse files Browse the repository at this point in the history
…cast-messages

Corrected messaging to warn against less- to more-strictly aligned
  • Loading branch information
Xandkeeper authored Apr 23, 2018
2 parents 79e8182 + 1969d42 commit efdd00d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,10 +679,10 @@ declare_clippy_lint! {
"cast to the same type, e.g. `x as i32` where `x: i32`"
}

/// **What it does:** Checks for casts from a more-strictly-aligned pointer to a
/// less-strictly-aligned pointer
/// **What it does:** Checks for casts from a less-strictly-aligned pointer to a
/// more-strictly-aligned pointer
///
/// **Why is this bad?** Dereferencing the resulting pointer is undefined
/// **Why is this bad?** Dereferencing the resulting pointer may be undefined
/// behavior.
///
/// **Known problems:** None.
Expand All @@ -695,7 +695,7 @@ declare_clippy_lint! {
declare_clippy_lint! {
pub CAST_PTR_ALIGNMENT,
correctness,
"cast from a pointer to a less-strictly-aligned pointer"
"cast from a pointer to a more-strictly-aligned pointer"
}

/// Returns the size in bits of an integral type.
Expand Down Expand Up @@ -986,7 +986,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CastPass {
cx,
CAST_PTR_ALIGNMENT,
expr.span,
&format!("casting from `{}` to a less-strictly-aligned pointer (`{}`)", cast_from, cast_to)
&format!("casting from `{}` to a more-strictly-aligned pointer (`{}`)", cast_from, cast_to)
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/cast_alignment.stderr
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
error: casting from `*const u8` to a less-strictly-aligned pointer (`*const u16`)
error: casting from `*const u8` to a more-strictly-aligned pointer (`*const u16`)
--> $DIR/cast_alignment.rs:9:5
|
9 | (&1u8 as *const u8) as *const u16;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D cast-ptr-alignment` implied by `-D warnings`

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

0 comments on commit efdd00d

Please sign in to comment.