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)]
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::<Vec<_>>();
- 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] {
"<impl i8>" => i8::max_value() as u128,
"<impl i16>" => i16::max_value() as u128,
"<impl i32>" => i32::max_value() as u128,
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;
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;
}
}
}
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)
}