aboutsummaryrefslogtreecommitdiffstats
path: root/components/plugins/lints/str_to_string.rs
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-09-21 13:12:01 +0530
committerMs2ger <Ms2ger@gmail.com>2015-09-23 14:44:59 +0200
commit3c969b346a02928abeea2796a0ec92a072f70b6e (patch)
treefbf7b015edf85032dd2327dde6867da2c568b594 /components/plugins/lints/str_to_string.rs
parent8f1469eb08a437bcc6cfb510334be2b6430b4a8f (diff)
downloadservo-3c969b346a02928abeea2796a0ec92a072f70b6e.tar.gz
servo-3c969b346a02928abeea2796a0ec92a072f70b6e.zip
Upgrade rust to f93ab64d4a1a7ee91759a1594ab2a426b6cc657e/rustc-1.5.0-dev.
Diffstat (limited to 'components/plugins/lints/str_to_string.rs')
-rw-r--r--components/plugins/lints/str_to_string.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/components/plugins/lints/str_to_string.rs b/components/plugins/lints/str_to_string.rs
index 431a161e999..80a16841323 100644
--- a/components/plugins/lints/str_to_string.rs
+++ b/components/plugins/lints/str_to_string.rs
@@ -2,9 +2,9 @@
* 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::{Context, LintPass, LintArray};
+use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext};
use rustc::middle::ty;
-use syntax::ast;
+use rustc_front::hir;
declare_lint!(STR_TO_STRING, Deny,
"Warn when a String could use to_owned() instead of to_string()");
@@ -18,10 +18,12 @@ impl LintPass for StrToStringPass {
fn get_lints(&self) -> LintArray {
lint_array!(STR_TO_STRING)
}
+}
- fn check_expr(&mut self, cx: &Context, expr: &ast::Expr) {
+impl LateLintPass for StrToStringPass {
+ fn check_expr(&mut self, cx: &LateContext, expr: &hir::Expr) {
match expr.node {
- ast::ExprMethodCall(ref method, _, ref args)
+ hir::ExprMethodCall(ref method, _, ref args)
if method.node.name.as_str() == "to_string"
&& is_str(cx, &*args[0]) => {
cx.span_lint(STR_TO_STRING, expr.span,
@@ -30,7 +32,7 @@ impl LintPass for StrToStringPass {
_ => ()
}
- fn is_str(cx: &Context, expr: &ast::Expr) -> bool {
+ 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),