@@ -219,13 +219,16 @@ declare_clippy_lint! {
219219 ///
220220 /// ### Example
221221 /// ```rust
222- /// // Bad
223222 /// fn fun() -> i32 { 1 }
224- /// let a = fun as i64;
223+ /// # let _ =
224+ /// fun as i64;
225+ /// ```
225226 ///
226- /// // Good
227- /// fn fun2() -> i32 { 1 }
228- /// let a = fun2 as usize;
227+ /// Use instead:
228+ /// ```rust
229+ /// # fn fun() -> i32 { 1 }
230+ /// # let _ =
231+ /// fun as usize;
229232 /// ```
230233 #[ clippy:: version = "pre 1.29.0" ]
231234 pub FN_TO_NUMERIC_CAST ,
@@ -245,17 +248,20 @@ declare_clippy_lint! {
245248 ///
246249 /// ### Example
247250 /// ```rust
248- /// // Bad
249251 /// fn fn1() -> i16 {
250252 /// 1
251253 /// };
252- /// let _ = fn1 as i32;
254+ /// # let _ =
255+ /// fn1 as i32;
256+ /// ```
253257 ///
254- /// // Better: Cast to usize first, then comment with the reason for the truncation
255- /// fn fn2() -> i16 {
258+ /// Use instead:
259+ /// ```rust
260+ /// // Cast to usize first, then comment with the reason for the truncation
261+ /// fn fn1() -> i16 {
256262 /// 1
257263 /// };
258- /// let fn_ptr = fn2 as usize;
264+ /// let fn_ptr = fn1 as usize;
259265 /// let fn_ptr_truncated = fn_ptr as i32;
260266 /// ```
261267 #[ clippy:: version = "pre 1.29.0" ]
@@ -277,23 +283,31 @@ declare_clippy_lint! {
277283 ///
278284 /// ### Example
279285 /// ```rust
280- /// // Bad: fn1 is cast as `usize`
286+ /// // fn1 is cast as `usize`
281287 /// fn fn1() -> u16 {
282288 /// 1
283289 /// };
284- /// let _ = fn1 as usize;
290+ /// # let _ =
291+ /// fn1 as usize;
292+ /// ```
285293 ///
286- /// // Good: maybe you intended to call the function?
294+ /// Use instead:
295+ /// ```rust
296+ /// // maybe you intended to call the function?
287297 /// fn fn2() -> u16 {
288298 /// 1
289299 /// };
290- /// let _ = fn2() as usize;
300+ /// # let _ =
301+ /// fn2() as usize;
302+ ///
303+ /// // or
291304 ///
292- /// // Good: maybe you intended to cast it to a function type?
305+ /// // maybe you intended to cast it to a function type?
293306 /// fn fn3() -> u16 {
294307 /// 1
295308 /// }
296- /// let _ = fn3 as fn() -> u16;
309+ /// # let _ =
310+ /// fn3 as fn() -> u16;
297311 /// ```
298312 #[ clippy:: version = "1.58.0" ]
299313 pub FN_TO_NUMERIC_CAST_ANY ,
0 commit comments