]> git.lizzy.rs Git - rust.git/blobdiff - clippy_lints/src/option_env_unwrap.rs
Rollup merge of #83092 - petrochenkov:qspan, r=estebank
[rust.git] / clippy_lints / src / option_env_unwrap.rs
index e84a7dd2db04c09ab92fae13feae7f54f2231552..fd653044a1bcb9fb6442041c6e2b4e1f39d90c21 100644 (file)
@@ -1,9 +1,8 @@
 use crate::utils::{is_direct_expn_of, span_lint_and_help};
 use if_chain::if_chain;
-use rustc::lint::in_external_macro;
+use rustc_ast::ast::{Expr, ExprKind};
 use rustc_lint::{EarlyContext, EarlyLintPass};
 use rustc_session::{declare_lint_pass, declare_tool_lint};
-use syntax::ast::*;
 
 declare_clippy_lint! {
     /// **What it does:** Checks for usage of `option_env!(...).unwrap()` and
@@ -36,8 +35,7 @@
 impl EarlyLintPass for OptionEnvUnwrap {
     fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
         if_chain! {
-            if !in_external_macro(cx.sess, expr.span);
-            if let ExprKind::MethodCall(path_segment, args) = &expr.kind;
+            if let ExprKind::MethodCall(path_segment, args, _) = &expr.kind;
             let method_name = path_segment.ident.as_str();
             if method_name == "expect" || method_name == "unwrap";
             if let ExprKind::Call(caller, _) = &args[0].kind;
@@ -48,6 +46,7 @@ fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) {
                     OPTION_ENV_UNWRAP,
                     expr.span,
                     "this will panic at run-time if the environment variable doesn't exist at compile-time",
+                    None,
                     "consider using the `env!` macro instead"
                 );
             }