@@ -32,7 +32,7 @@ use rustc_session::impl_lint_pass;
3232
3333declare_clippy_lint ! {
3434 /// ### What it does
35- /// Checks for casts from any numerical to a float type where
35+ /// Checks for casts from any numeric type to a float type where
3636 /// the receiving type cannot store all values from the original type without
3737 /// rounding errors. This possible rounding is to be expected, so this lint is
3838 /// `Allow` by default.
@@ -58,14 +58,14 @@ declare_clippy_lint! {
5858
5959declare_clippy_lint ! {
6060 /// ### What it does
61- /// Checks for casts from a signed to an unsigned numerical
61+ /// Checks for casts from a signed to an unsigned numeric
6262 /// type. In this case, negative values wrap around to large positive values,
63- /// which can be quite surprising in practice. However, as the cast works as
63+ /// which can be quite surprising in practice. However, since the cast works as
6464 /// defined, this lint is `Allow` by default.
6565 ///
6666 /// ### Why is this bad?
6767 /// Possibly surprising results. You can activate this lint
68- /// as a one-time check to see where numerical wrapping can arise.
68+ /// as a one-time check to see where numeric wrapping can arise.
6969 ///
7070 /// ### Example
7171 /// ```no_run
@@ -80,7 +80,7 @@ declare_clippy_lint! {
8080
8181declare_clippy_lint ! {
8282 /// ### What it does
83- /// Checks for casts between numerical types that may
83+ /// Checks for casts between numeric types that may
8484 /// truncate large values. This is expected behavior, so the cast is `Allow` by
8585 /// default. It suggests user either explicitly ignore the lint,
8686 /// or use `try_from()` and handle the truncation, default, or panic explicitly.
@@ -120,17 +120,16 @@ declare_clippy_lint! {
120120declare_clippy_lint ! {
121121 /// ### What it does
122122 /// Checks for casts from an unsigned type to a signed type of
123- /// the same size, or possibly smaller due to target dependent integers.
124- /// Performing such a cast is a ' no-op' for the compiler, i.e. , nothing is
125- /// changed at the bit level, and the binary representation of the value is
123+ /// the same size, or possibly smaller due to target- dependent integers.
124+ /// Performing such a cast is a no-op for the compiler (that is , nothing is
125+ /// changed at the bit level) , and the binary representation of the value is
126126 /// reinterpreted. This can cause wrapping if the value is too big
127127 /// for the target signed type. However, the cast works as defined, so this lint
128128 /// is `Allow` by default.
129129 ///
130130 /// ### Why is this bad?
131131 /// While such a cast is not bad in itself, the results can
132- /// be surprising when this is not the intended behavior, as demonstrated by the
133- /// example below.
132+ /// be surprising when this is not the intended behavior:
134133 ///
135134 /// ### Example
136135 /// ```no_run
@@ -144,16 +143,16 @@ declare_clippy_lint! {
144143
145144declare_clippy_lint ! {
146145 /// ### What it does
147- /// Checks for casts between numerical types that may
148- /// be replaced by safe conversion functions.
146+ /// Checks for casts between numeric types that can be replaced by safe
147+ /// conversion functions.
149148 ///
150149 /// ### Why is this bad?
151- /// Rust's `as` keyword will perform many kinds of
152- /// conversions, including silently lossy conversions. Conversion functions such
153- /// as `i32::from` will only perform lossless conversions. Using the conversion
154- /// functions prevents conversions from turning into silent lossy conversions if
155- /// the types of the input expressions ever change, and make it easier for
156- /// people reading the code to know that the conversion is lossless.
150+ /// Rust's `as` keyword will perform many kinds of conversions, including
151+ /// silently lossy conversions. Conversion functions such as `i32::from`
152+ /// will only perform lossless conversions. Using the conversion functions
153+ /// prevents conversions from becoming silently lossy if the input types
154+ /// ever change, and makes it clear for people reading the code that the
155+ /// conversion is lossless.
157156 ///
158157 /// ### Example
159158 /// ```no_run
@@ -177,19 +176,21 @@ declare_clippy_lint! {
177176
178177declare_clippy_lint ! {
179178 /// ### What it does
180- /// Checks for casts to the same type, casts of int literals to integer types, casts of float
181- /// literals to float types and casts between raw pointers without changing type or constness.
179+ /// Checks for casts to the same type, casts of int literals to integer
180+ /// types, casts of float literals to float types, and casts between raw
181+ /// pointers that don't change type or constness.
182182 ///
183183 /// ### Why is this bad?
184184 /// It's just unnecessary.
185185 ///
186186 /// ### Known problems
187- /// When the expression on the left is a function call, the lint considers the return type to be
188- /// a type alias if it's aliased through a `use` statement
189- /// (like `use std::io::Result as IoResult`). It will not lint such cases.
187+ /// When the expression on the left is a function call, the lint considers
188+ /// the return type to be a type alias if it's aliased through a `use`
189+ /// statement (like `use std::io::Result as IoResult`). It will not lint
190+ /// such cases.
190191 ///
191- /// This check is also rather primitive. It will only work on primitive types without any
192- /// intermediate references, raw pointers and trait objects may or may not work.
192+ /// This check will only work on primitive types without any intermediate
193+ /// references: raw pointers and trait objects may or may not work.
193194 ///
194195 /// ### Example
195196 /// ```no_run
@@ -211,17 +212,17 @@ declare_clippy_lint! {
211212
212213declare_clippy_lint ! {
213214 /// ### What it does
214- /// Checks for casts, using `as` or `pointer::cast`,
215- /// from a less- strictly- aligned pointer to a more- strictly- aligned pointer
215+ /// Checks for casts, using `as` or `pointer::cast`, from a
216+ /// less strictly aligned pointer to a more strictly aligned pointer.
216217 ///
217218 /// ### Why is this bad?
218- /// Dereferencing the resulting pointer may be undefined
219- /// behavior.
219+ /// Dereferencing the resulting pointer may be undefined behavior.
220220 ///
221221 /// ### Known problems
222- /// Using `std::ptr::read_unaligned` and `std::ptr::write_unaligned` or similar
223- /// on the resulting pointer is fine. Is over-zealous: Casts with manual alignment checks or casts like
224- /// u64-> u8 -> u16 can be fine. Miri is able to do a more in-depth analysis.
222+ /// Using [`std::ptr::read_unaligned`] and [`std::ptr::write_unaligned`] or
223+ /// similar on the resulting pointer is fine. Is over-zealous: casts with
224+ /// manual alignment checks or casts like `u64` -> `u8` -> `u16` can be
225+ /// fine. Miri is able to do a more in-depth analysis.
225226 ///
226227 /// ### Example
227228 /// ```no_run
@@ -234,20 +235,21 @@ declare_clippy_lint! {
234235 #[ clippy:: version = "pre 1.29.0" ]
235236 pub CAST_PTR_ALIGNMENT ,
236237 pedantic,
237- "cast from a pointer to a more- strictly- aligned pointer"
238+ "cast from a pointer to a more strictly aligned pointer"
238239}
239240
240241declare_clippy_lint ! {
241242 /// ### What it does
242- /// Checks for casts of function pointers to something other than usize
243+ /// Checks for casts of function pointers to something other than ` usize`.
243244 ///
244245 /// ### Why is this bad?
245- /// Casting a function pointer to anything other than usize/ isize is not portable across
246- /// architectures, because you end up losing bits if the target type is too small or end up with a
247- /// bunch of extra bits that waste space and add more instructions to the final binary than
248- /// strictly necessary for the problem
246+ /// Casting a function pointer to anything other than ` usize`/` isize` is
247+ /// not portable across architectures. It either loses bits if the target
248+ /// type is too small, or creates extra bits that waste space and bloat the
249+ /// resulting binary.
249250 ///
250- /// Casting to isize also doesn't make sense since there are no signed addresses.
251+ /// Casting to `isize` also doesn't make sense, since addresses are never
252+ /// signed.
251253 ///
252254 /// ### Example
253255 /// ```no_run
@@ -263,17 +265,17 @@ declare_clippy_lint! {
263265 #[ clippy:: version = "pre 1.29.0" ]
264266 pub FN_TO_NUMERIC_CAST ,
265267 style,
266- "casting a function pointer to a numeric type other than usize"
268+ "casting a function pointer to a numeric type other than ` usize` "
267269}
268270
269271declare_clippy_lint ! {
270272 /// ### What it does
271273 /// Checks for casts of a function pointer to a numeric type not wide enough to
272- /// store address.
274+ /// store an address.
273275 ///
274276 /// ### Why is this bad?
275277 /// Such a cast discards some bits of the function's address. If this is intended, it would be more
276- /// clearly expressed by casting to usize first, then casting the usize to the intended type (with
278+ /// clearly expressed by casting to ` usize` first, then casting the ` usize` to the intended type (with
277279 /// a comment) to perform the truncation.
278280 ///
279281 /// ### Example
@@ -306,7 +308,7 @@ declare_clippy_lint! {
306308 /// ### Why restrict this?
307309 /// Casting a function pointer to an integer can have surprising results and can occur
308310 /// accidentally if parentheses are omitted from a function call. If you aren't doing anything
309- /// low-level with function pointers then you can opt- out of casting functions to integers in
311+ /// low-level with function pointers then you can opt out of casting functions to integers in
310312 /// order to avoid mistakes. Alternatively, you can use this lint to audit all uses of function
311313 /// pointer casts in your code.
312314 ///
@@ -349,8 +351,8 @@ declare_clippy_lint! {
349351 /// ### Why is this bad?
350352 /// In general, casting values to smaller types is
351353 /// error-prone and should be avoided where possible. In the particular case of
352- /// converting a character literal to u8 , it is easy to avoid by just using a
353- /// byte literal instead. As an added bonus, `b'a'` is even slightly shorter
354+ /// converting a character literal to `u8` , it is easy to avoid by just using a
355+ /// byte literal instead. As an added bonus, `b'a'` is also slightly shorter
354356 /// than `'a' as u8`.
355357 ///
356358 /// ### Example
@@ -371,12 +373,13 @@ declare_clippy_lint! {
371373
372374declare_clippy_lint ! {
373375 /// ### What it does
374- /// Checks for `as` casts between raw pointers without changing its mutability,
375- /// namely `*const T` to `*const U` and `*mut T` to `*mut U`.
376+ /// Checks for `as` casts on a raw pointer that don't change its
377+ /// mutability, namely `*const T` to `*const U` and `*mut T` to `*mut U`.
376378 ///
377379 /// ### Why is this bad?
378- /// Though `as` casts between raw pointers are not terrible, `pointer::cast` is safer because
379- /// it cannot accidentally change the pointer's mutability nor cast the pointer to other types like `usize`.
380+ /// Though `as` casts between raw pointers are not terrible,
381+ /// `pointer::cast` is safer because it cannot accidentally change the
382+ /// pointer's mutability, nor cast the pointer to other types like `usize`.
380383 ///
381384 /// ### Example
382385 /// ```no_run
@@ -395,12 +398,12 @@ declare_clippy_lint! {
395398 #[ clippy:: version = "1.51.0" ]
396399 pub PTR_AS_PTR ,
397400 pedantic,
398- "casting using `as` from and to raw pointers that doesn't change its mutability, where `pointer::cast` could take the place of `as`"
401+ "casting using `as` on a raw pointer that doesn't change its mutability, where `pointer::cast` could take the place of `as`"
399402}
400403
401404declare_clippy_lint ! {
402405 /// ### What it does
403- /// Checks for `as` casts between raw pointers which change its constness, namely `*const T` to
406+ /// Checks for `as` casts on a raw pointer that change its constness, namely `*const T` to
404407 /// `*mut T` and `*mut T` to `*const T`.
405408 ///
406409 /// ### Why is this bad?
@@ -423,12 +426,12 @@ declare_clippy_lint! {
423426 #[ clippy:: version = "1.72.0" ]
424427 pub PTR_CAST_CONSTNESS ,
425428 pedantic,
426- "casting using `as` from and to raw pointers to change constness when specialized methods apply"
429+ "casting using `as` on raw pointers to change constness when specialized methods apply"
427430}
428431
429432declare_clippy_lint ! {
430433 /// ### What it does
431- /// Checks for casts from an enum type to an integral type which will definitely truncate the
434+ /// Checks for casts from an enum type to an integral type that will definitely truncate the
432435 /// value.
433436 ///
434437 /// ### Why is this bad?
@@ -442,7 +445,7 @@ declare_clippy_lint! {
442445 #[ clippy:: version = "1.61.0" ]
443446 pub CAST_ENUM_TRUNCATION ,
444447 suspicious,
445- "casts from an enum type to an integral type which will truncate the value"
448+ "casts from an enum type to an integral type that will truncate the value"
446449}
447450
448451declare_clippy_lint ! {
@@ -621,7 +624,7 @@ declare_clippy_lint! {
621624
622625declare_clippy_lint ! {
623626 /// ### What it does
624- /// Checks for the result of a `&self`-taking `as_ptr` being cast to a mutable pointer
627+ /// Checks for the result of a `&self`-taking `as_ptr` being cast to a mutable pointer.
625628 ///
626629 /// ### Why is this bad?
627630 /// Since `as_ptr` takes a `&self`, the pointer won't have write permissions unless interior
0 commit comments