]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/unwrap_in_result.rs
Merge remote-tracking branch 'upstream/master' into rustup
[rust.git] / clippy_lints / src / unwrap_in_result.rs
index 0f8797243eca316ae24c9512246239b8c376fccd..fde3102933098415d2aece0bc10df6aac083f302 100644 (file)
@@ -5,7 +5,7 @@
 use rustc_middle::hir::map::Map;
 use rustc_middle::ty;
 use rustc_session::{declare_lint_pass, declare_tool_lint};
-use rustc_span::Span;
+use rustc_span::{sym, Span};
 
 declare_clippy_lint! {
     /// **What it does:** Checks for functions of type Result that contain `expect()` or `unwrap()`
@@ -57,8 +57,8 @@ fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::Impl
             // first check if it's a method or function
             if let hir::ImplItemKind::Fn(ref _signature, _) = impl_item.kind;
             // checking if its return type is `result` or `option`
-            if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id), sym!(result_type))
-                || is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id), sym!(option_type));
+            if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id), sym::result_type)
+                || is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id), sym::option_type);
             then {
                 lint_impl_body(cx, impl_item.span, impl_item);
             }
@@ -82,8 +82,8 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
         // check for `expect`
         if let Some(arglists) = method_chain_args(expr, &["expect"]) {
             let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs();
-            if is_type_diagnostic_item(self.lcx, reciever_ty, sym!(option_type))
-                || is_type_diagnostic_item(self.lcx, reciever_ty, sym!(result_type))
+            if is_type_diagnostic_item(self.lcx, reciever_ty, sym::option_type)
+                || is_type_diagnostic_item(self.lcx, reciever_ty, sym::result_type)
             {
                 self.result.push(expr.span);
             }
@@ -92,8 +92,8 @@ fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
         // check for `unwrap`
         if let Some(arglists) = method_chain_args(expr, &["unwrap"]) {
             let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs();
-            if is_type_diagnostic_item(self.lcx, reciever_ty, sym!(option_type))
-                || is_type_diagnostic_item(self.lcx, reciever_ty, sym!(result_type))
+            if is_type_diagnostic_item(self.lcx, reciever_ty, sym::option_type)
+                || is_type_diagnostic_item(self.lcx, reciever_ty, sym::result_type)
             {
                 self.result.push(expr.span);
             }