aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2016-04-08 06:38:21 +0530
committerManish Goregaokar <manishsmail@gmail.com>2016-04-08 06:44:57 +0530
commitefa84862af9ba2659120fa16687c8d3b294a88e2 (patch)
tree608e5341cc0a8dbf6036584a16d5300db15e1e70
parentc0aa049b0aaf39df979234dff1ed01ff5d9aa5c5 (diff)
downloadservo-efa84862af9ba2659120fa16687c8d3b294a88e2.tar.gz
servo-efa84862af9ba2659120fa16687c8d3b294a88e2.zip
Remove str_to_string lint
Specialization makes all of the options equally efficient.
-rw-r--r--components/plugins/lib.rs1
-rw-r--r--components/plugins/lints/mod.rs1
-rw-r--r--components/plugins/lints/str_to_string.rs48
-rw-r--r--components/util/opts.rs1
4 files changed, 0 insertions, 51 deletions
diff --git a/components/plugins/lib.rs b/components/plugins/lib.rs
index b949d516b52..c4e21c0ad4e 100644
--- a/components/plugins/lib.rs
+++ b/components/plugins/lib.rs
@@ -70,5 +70,4 @@ fn register_clippy(reg: &mut Registry) {
}
#[cfg(not(feature = "clippy"))]
fn register_clippy(reg: &mut Registry) {
- reg.register_late_lint_pass(box lints::str_to_string::StrToStringPass);
}
diff --git a/components/plugins/lints/mod.rs b/components/plugins/lints/mod.rs
index 45a3c6a7eda..31c6b90737b 100644
--- a/components/plugins/lints/mod.rs
+++ b/components/plugins/lints/mod.rs
@@ -5,6 +5,5 @@
pub mod ban;
pub mod inheritance_integrity;
pub mod privatize;
-pub mod str_to_string;
pub mod transmute_type;
pub mod unrooted_must_root;
diff --git a/components/plugins/lints/str_to_string.rs b/components/plugins/lints/str_to_string.rs
deleted file mode 100644
index 8a1f1530898..00000000000
--- a/components/plugins/lints/str_to_string.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext};
-use rustc::ty;
-use rustc_front::hir;
-
-declare_lint!(STR_TO_STRING, Deny,
- "Warn when a String could use to_owned() instead of to_string()");
-
-/// Prefer str.to_owned() over str.to_string()
-///
-/// The latter creates a `Formatter` and is 5x slower than the former
-pub struct StrToStringPass;
-
-impl LintPass for StrToStringPass {
- fn get_lints(&self) -> LintArray {
- lint_array!(STR_TO_STRING)
- }
-}
-
-impl LateLintPass for StrToStringPass {
- fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
- match expr.node {
- hir::ExprMethodCall(ref method, _, ref args)
- if method.node.as_str() == "to_string"
- && is_str(cx, &*args[0]) => {
- cx.span_lint(STR_TO_STRING, expr.span,
- "str.to_owned() is more efficient than str.to_string(), please use it instead");
- },
- _ => ()
- }
-
- fn is_str(cx: &LateContext, expr: &hir::Expr) -> bool {
- fn walk_ty<'t>(ty: ty::Ty<'t>) -> ty::Ty<'t> {
- match ty.sty {
- ty::TyRef(_, ref tm) | ty::TyRawPtr(ref tm) => walk_ty(tm.ty),
- _ => ty
- }
- }
- match walk_ty(cx.tcx.expr_ty(expr)).sty {
- ty::TyStr => true,
- _ => false
- }
- }
- }
-}
diff --git a/components/util/opts.rs b/components/util/opts.rs
index 40309515435..9b5dea10f9c 100644
--- a/components/util/opts.rs
+++ b/components/util/opts.rs
@@ -518,7 +518,6 @@ pub fn default_opts() -> Opts {
}
}
-#[allow(str_to_string)]
pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
let (app_name, args) = args.split_first().unwrap();