about summary refs log tree commit diff
path: root/clippy_lints/src/explicit_write.rs
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2019-05-14 01:34:08 +0200
committerOliver Scherer <github35764891676564198441@oli-obk.de>2019-05-14 10:33:42 +0200
commitb2dbda4d480a9256975448155d39b3b62653a4cf (patch)
tree98b5a6bbfc801ef022706f089e8d6bcce6890178 /clippy_lints/src/explicit_write.rs
parent42480fd0313028c40b103700dcb03da25f248685 (diff)
Use symbols instead of strings
Diffstat (limited to 'clippy_lints/src/explicit_write.rs')
-rw-r--r--clippy_lints/src/explicit_write.rs15
1 files changed, 8 insertions, 7 deletions
diff --git a/clippy_lints/src/explicit_write.rs b/clippy_lints/src/explicit_write.rs
index a29b1380006..3790b8ef337 100644
--- a/clippy_lints/src/explicit_write.rs
+++ b/clippy_lints/src/explicit_write.rs
@@ -1,4 +1,5 @@
-use crate::utils::{is_expn_of, resolve_node, span_lint, span_lint_and_sugg};
+use crate::utils::{is_expn_of, resolve_node, span_lint, span_lint_and_sugg, match_def_path};
+use crate::utils::sym;
 use if_chain::if_chain;
 use rustc::hir::*;
 use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
@@ -31,21 +32,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitWrite {
         if_chain! {
             // match call to unwrap
             if let ExprKind::MethodCall(ref unwrap_fun, _, ref unwrap_args) = expr.node;
-            if unwrap_fun.ident.name == "unwrap";
+            if unwrap_fun.ident.name == *sym::unwrap;
             // match call to write_fmt
             if unwrap_args.len() > 0;
             if let ExprKind::MethodCall(ref write_fun, _, ref write_args) =
                 unwrap_args[0].node;
-            if write_fun.ident.name == "write_fmt";
+            if write_fun.ident.name == *sym::write_fmt;
             // match calls to std::io::stdout() / std::io::stderr ()
             if write_args.len() > 0;
             if let ExprKind::Call(ref dest_fun, _) = write_args[0].node;
             if let ExprKind::Path(ref qpath) = dest_fun.node;
             if let Some(dest_fun_id) =
                 resolve_node(cx, qpath, dest_fun.hir_id).opt_def_id();
-            if let Some(dest_name) = if cx.match_def_path(dest_fun_id, &["std", "io", "stdio", "stdout"]) {
+            if let Some(dest_name) = if match_def_path(cx, dest_fun_id, &[*sym::std, *sym::io, *sym::stdio, *sym::stdout]) {
                 Some("stdout")
-            } else if cx.match_def_path(dest_fun_id, &["std", "io", "stdio", "stderr"]) {
+            } else if match_def_path(cx, dest_fun_id, &[*sym::std, *sym::io, *sym::stdio, *sym::stderr]) {
                 Some("stderr")
             } else {
                 None
@@ -54,9 +55,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for ExplicitWrite {
                 let write_span = unwrap_args[0].span;
                 let calling_macro =
                     // ordering is important here, since `writeln!` uses `write!` internally
-                    if is_expn_of(write_span, "writeln").is_some() {
+                    if is_expn_of(write_span, *sym::writeln).is_some() {
                         Some("writeln")
-                    } else if is_expn_of(write_span, "write").is_some() {
+                    } else if is_expn_of(write_span, *sym::write).is_some() {
                         Some("write")
                     } else {
                         None