mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 13:13:34 +00:00
Rustup to rustc 1.36.0-nightly (fa40a111f 2019-05-27)
This commit is contained in:
parent
7b501f0f6a
commit
73d1830812
3 changed files with 13 additions and 6 deletions
|
@ -14,7 +14,7 @@ use std::cmp::PartialOrd;
|
|||
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 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
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,
|
||||
|
|
|
@ -18,6 +18,7 @@ use rustc_typeck::hir_ty_to_ty;
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1123,5 +1123,7 @@ mod test {
|
|||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue