From 6528749083bb64a28aca6a8be2bf67458ce62147 Mon Sep 17 00:00:00 2001 From: Devon Hollowood Date: Sun, 7 Oct 2018 17:05:28 -0700 Subject: [PATCH] Fix items_after_statements for `use` statements --- clippy_lints/src/consts.rs | 4 +++- clippy_lints/src/write.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 4e09e039100c..3cf384407449 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -265,6 +265,8 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { /// lookup a possibly constant expression from a ExprKind::Path fn fetch_path(&mut self, qpath: &QPath, id: HirId) -> Option { + use crate::rustc::mir::interpret::GlobalId; + let def = self.tables.qpath_def(qpath, id); match def { Def::Const(def_id) | Def::AssociatedConst(def_id) => { @@ -279,7 +281,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> { instance, promoted: None, }; - use crate::rustc::mir::interpret::GlobalId; + let result = self.tcx.const_eval(self.param_env.and(gid)).ok()?; let ret = miri_to_const(self.tcx, result); if ret.is_some() { diff --git a/clippy_lints/src/write.rs b/clippy_lints/src/write.rs index a367a04b2bad..06575a264b32 100644 --- a/clippy_lints/src/write.rs +++ b/clippy_lints/src/write.rs @@ -246,6 +246,7 @@ impl EarlyLintPass for Pass { } fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) -> (Option, Option) { + use crate::fmt_macros::*; let tts = TokenStream::from(tts.clone()); let mut parser = parser::Parser::new(&cx.sess.parse_sess, tts, None, false, false); let mut expr: Option = None; @@ -264,7 +265,6 @@ fn check_tts<'a>(cx: &EarlyContext<'a>, tts: &ThinTokenStream, is_write: bool) - Ok(token) => token.0.to_string(), Err(_) => return (None, expr), }; - use crate::fmt_macros::*; let tmp = fmtstr.clone(); let mut args = vec![]; let mut fmt_parser = Parser::new(&tmp, None);