]> git.lizzy.rs Git - rust.git/blobdiff - src/transmute.rs
Merge pull request #523 from sanxiyn/escape-arg
[rust.git] / src / transmute.rs
index ab1397ea7fe4b0ca70ebed679104864dbe06e422..24af45bc68d1232877f94a100b5cdfd00c631c16 100644 (file)
@@ -2,6 +2,13 @@
 use rustc_front::hir::*;
 use utils;
 
+/// **What it does:** This lint checks for transmutes to the original type of the object. It is `Warn` by default.
+///
+/// **Why is this bad?** Readability. The code tricks people into thinking that the original value was of some other type.
+///
+/// **Known problems:** None.
+///
+/// **Example:** `core::intrinsics::transmute(t)` where the result type is the same as `t`'s.
 declare_lint! {
     pub USELESS_TRANSMUTE,
     Warn,
@@ -27,7 +34,8 @@ fn check_expr(&mut self, cx: &LateContext, e: &Expr) {
                     let to_ty = cx.tcx.expr_ty(e);
 
                     if from_ty == to_ty {
-                        cx.span_lint(USELESS_TRANSMUTE, e.span,
+                        cx.span_lint(USELESS_TRANSMUTE,
+                                     e.span,
                                      &format!("transmute from a type (`{}`) to itself", from_ty));
                     }
                 }