From: bors Date: Mon, 27 May 2019 19:59:33 +0000 (+0000) Subject: Auto merge of #4150 - rust-lang:rustup, r=oli-obk X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=e119ab402fca139e0973f176a9e4b8e49727a3f7;hp=7b501f0f6af678aa0a081ea1c32d3afa7d1bd641;p=rust.git Auto merge of #4150 - rust-lang:rustup, r=oli-obk Rustup to rustc 1.36.0-nightly (fa40a111f 2019-05-27) changelog: none --- diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index 8f18102101d..fff02915589 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -14,7 +14,7 @@ use std::convert::TryInto; use std::hash::{Hash, Hasher}; use syntax::ast::{FloatTy, LitKind}; -use syntax_pos::symbol::{LocalInternedString, Symbol}; +use syntax_pos::symbol::Symbol; /// A `LitKind`-like enum to fold constant `Expr`s into. #[derive(Debug, Clone)] @@ -250,14 +250,18 @@ pub fn expr(&mut self, e: &Expr) -> Option { if let ExprKind::Path(qpath) = &callee.node; let res = self.tables.qpath_res(qpath, callee.hir_id); if let Some(def_id) = res.opt_def_id(); - let get_def_path = self.lcx.get_def_path(def_id); + let get_def_path = self.lcx.get_def_path(def_id, ); let def_path = get_def_path .iter() - .map(LocalInternedString::get) + .copied() + .map(Symbol::as_str) .collect::>(); - if let &["core", "num", impl_ty, "max_value"] = &def_path[..]; + if def_path[0] == "core"; + if def_path[1] == "num"; + if def_path[3] == "max_value"; + if def_path.len() == 4; then { - let value = match impl_ty { + let value = match &*def_path[2] { "" => i8::max_value() as u128, "" => i16::max_value() as u128, "" => i32::max_value() as u128, diff --git a/clippy_lints/src/types.rs b/clippy_lints/src/types.rs index 7bce42369dc..7b41bea4ff4 100644 --- a/clippy_lints/src/types.rs +++ b/clippy_lints/src/types.rs @@ -18,6 +18,7 @@ use syntax::ast::{FloatTy, IntTy, UintTy}; use syntax::errors::DiagnosticBuilder; use syntax::source_map::Span; +use syntax::symbol::sym; use crate::consts::{constant, Constant}; use crate::utils::paths; @@ -1091,7 +1092,7 @@ fn is_c_void(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool { if names.is_empty() { return false; } - if names[0] == "libc" || names[0] == "core" && *names.last().unwrap() == "c_void" { + if names[0] == sym!(libc) || names[0] == sym::core && *names.last().unwrap() == sym!(c_void) { return true; } } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index 179e006ed05..a812b1709bb 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -1123,5 +1123,7 @@ fn test_without_block_comments_lines_without_block_comments() { } pub fn match_def_path<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, did: DefId, syms: &[&str]) -> bool { + // HACK: find a way to use symbols from clippy or just go fully to diagnostic items + let syms: Vec<_> = syms.iter().map(|sym| Symbol::intern(sym)).collect(); cx.match_def_path(did, &syms) }