Skip to content

Commit e119ab4

Browse files
committed
Auto merge of #4150 - rust-lang:rustup, r=oli-obk
Rustup to rustc 1.36.0-nightly (fa40a11 2019-05-27) changelog: none
2 parents 7b501f0 + 73d1830 commit e119ab4

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

clippy_lints/src/consts.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use std::cmp::PartialOrd;
1414
use std::convert::TryInto;
1515
use std::hash::{Hash, Hasher};
1616
use syntax::ast::{FloatTy, LitKind};
17-
use syntax_pos::symbol::{LocalInternedString, Symbol};
17+
use syntax_pos::symbol::Symbol;
1818

1919
/// A `LitKind`-like enum to fold constant `Expr`s into.
2020
#[derive(Debug, Clone)]
@@ -250,14 +250,18 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
250250
if let ExprKind::Path(qpath) = &callee.node;
251251
let res = self.tables.qpath_res(qpath, callee.hir_id);
252252
if let Some(def_id) = res.opt_def_id();
253-
let get_def_path = self.lcx.get_def_path(def_id);
253+
let get_def_path = self.lcx.get_def_path(def_id, );
254254
let def_path = get_def_path
255255
.iter()
256-
.map(LocalInternedString::get)
256+
.copied()
257+
.map(Symbol::as_str)
257258
.collect::<Vec<_>>();
258-
if let &["core", "num", impl_ty, "max_value"] = &def_path[..];
259+
if def_path[0] == "core";
260+
if def_path[1] == "num";
261+
if def_path[3] == "max_value";
262+
if def_path.len() == 4;
259263
then {
260-
let value = match impl_ty {
264+
let value = match &*def_path[2] {
261265
"<impl i8>" => i8::max_value() as u128,
262266
"<impl i16>" => i16::max_value() as u128,
263267
"<impl i32>" => i32::max_value() as u128,

clippy_lints/src/types.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use rustc_typeck::hir_ty_to_ty;
1818
use syntax::ast::{FloatTy, IntTy, UintTy};
1919
use syntax::errors::DiagnosticBuilder;
2020
use syntax::source_map::Span;
21+
use syntax::symbol::sym;
2122

2223
use crate::consts::{constant, Constant};
2324
use crate::utils::paths;
@@ -1091,7 +1092,7 @@ fn is_c_void(cx: &LateContext<'_, '_>, ty: Ty<'_>) -> bool {
10911092
if names.is_empty() {
10921093
return false;
10931094
}
1094-
if names[0] == "libc" || names[0] == "core" && *names.last().unwrap() == "c_void" {
1095+
if names[0] == sym!(libc) || names[0] == sym::core && *names.last().unwrap() == sym!(c_void) {
10951096
return true;
10961097
}
10971098
}

clippy_lints/src/utils/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1123,5 +1123,7 @@ mod test {
11231123
}
11241124

11251125
pub fn match_def_path<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, did: DefId, syms: &[&str]) -> bool {
1126+
// HACK: find a way to use symbols from clippy or just go fully to diagnostic items
1127+
let syms: Vec<_> = syms.iter().map(|sym| Symbol::intern(sym)).collect();
11261128
cx.match_def_path(did, &syms)
11271129
}

0 commit comments

Comments
 (0)