Skip to content
Merged

Rustup #3945

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::convert::TryInto;
use std::hash::{Hash, Hasher};
use syntax::ast::{FloatTy, LitKind};
use syntax::ptr::P;
use syntax_pos::symbol::Symbol;
use syntax_pos::symbol::{LocalInternedString, Symbol};

/// A `LitKind`-like enum to fold constant `Expr`s into.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -249,7 +249,10 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
if let ExprKind::Path(qpath) = &callee.node;
let def = self.tables.qpath_def(qpath, callee.hir_id);
if let Some(def_id) = def.opt_def_id();
let def_path = get_def_path(self.tcx, def_id);
let def_path = get_def_path(self.tcx, def_id)
.iter()
.map(LocalInternedString::get)
.collect::<Vec<_>>();
if let &["core", "num", impl_ty, "max_value"] = &def_path[..];
then {
let value = match impl_ty {
Expand Down
9 changes: 2 additions & 7 deletions clippy_lints/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,8 @@ pub fn match_def_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, path
/// // The given `def_id` is that of an `Option` type
/// };
/// ```
pub fn get_def_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Vec<&'static str> {
AbsolutePathPrinter { tcx }
.print_def_path(def_id, &[])
.unwrap()
.iter()
.map(LocalInternedString::get)
.collect()
pub fn get_def_path<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Vec<LocalInternedString> {
AbsolutePathPrinter { tcx }.print_def_path(def_id, &[]).unwrap()
}

/// Checks if type is struct, enum or union type with the given def path.
Expand Down