From 4ae43b10f0b48bca95efa6dd830bb7281f52f05e Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 13 Dec 2015 09:08:58 +0530 Subject: [PATCH] Add wiki note for escape analysis --- src/escape.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/escape.rs b/src/escape.rs index fbd545acc96..1df19bcf548 100644 --- a/src/escape.rs +++ b/src/escape.rs @@ -14,6 +14,20 @@ use utils::span_lint; pub struct EscapePass; +/// **What it does:** This lint checks for usage of `Box` where an unboxed `T` would work fine +/// +/// **Why is this bad?** This is an unnecessary allocation, and bad for performance +/// +/// It is only necessary to allocate if you wish to move the box into something. +/// +/// **Example:** +/// +/// ```rust +/// fn main() { +/// let x = Box::new(1); +/// foo(*x); +/// println!("{}", *x); +/// } declare_lint!(pub BOXED_LOCAL, Warn, "using Box where unnecessary"); struct EscapeDelegate<'a, 'tcx: 'a> {