-// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-use crate::rustc::hir::intravisit::FnKind;
-use crate::rustc::hir::*;
-use crate::rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
-use crate::rustc::middle::expr_use_visitor as euv;
-use crate::rustc::middle::mem_categorization as mc;
-use crate::rustc::traits;
-use crate::rustc::ty::{self, RegionKind, TypeFoldable};
-use crate::rustc::{declare_tool_lint, lint_array};
-use crate::rustc_data_structures::fx::{FxHashMap, FxHashSet};
-use crate::rustc_errors::Applicability;
-use crate::rustc_target::spec::abi::Abi;
-use crate::syntax::ast::NodeId;
-use crate::syntax::errors::DiagnosticBuilder;
-use crate::syntax_pos::Span;
use crate::utils::ptr::get_spans;
use crate::utils::{
get_trait_def_id, implements_trait, in_macro, is_copy, is_self, match_type, multispan_sugg, paths, snippet,
};
use if_chain::if_chain;
use matches::matches;
+use rustc::hir::intravisit::FnKind;
+use rustc::hir::*;
+use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
+use rustc::middle::expr_use_visitor as euv;
+use rustc::middle::mem_categorization as mc;
+use rustc::traits;
+use rustc::ty::{self, RegionKind, TypeFoldable};
+use rustc::{declare_tool_lint, lint_array};
+use rustc_data_structures::fx::{FxHashMap, FxHashSet};
+use rustc_errors::Applicability;
+use rustc_target::spec::abi::Abi;
use std::borrow::Cow;
+use syntax::ast::NodeId;
+use syntax::errors::DiagnosticBuilder;
+use syntax_pos::Span;
/// **What it does:** Checks for functions taking arguments by value, but not
/// consuming them in its
}
// Exclude non-inherent impls
- if let Some(Node::Item(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(node_id)) {
+ if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(node_id)) {
if matches!(item.node, ItemKind::Impl(_, _, _, _, Some(_), _, _) |
ItemKind::Trait(..))
{
let sized_trait = need!(cx.tcx.lang_items().sized_trait());
- let fn_def_id = cx.tcx.hir.local_def_id(node_id);
+ let fn_def_id = cx.tcx.hir().local_def_id(node_id);
let preds = traits::elaborate_predicates(cx.tcx, cx.param_env.caller_bounds.to_vec())
.filter(|p| !p.is_global())
// Dereference suggestion
let sugg = |db: &mut DiagnosticBuilder<'_>| {
if let ty::Adt(def, ..) = ty.sty {
- if let Some(span) = cx.tcx.hir.span_if_local(def.did) {
+ if let Some(span) = cx.tcx.hir().span_if_local(def.did) {
if cx.param_env.can_type_implement_copy(cx.tcx, ty).is_ok() {
db.span_help(span, "consider marking this type as Copy");
}
if let mc::Categorization::Local(vid) = cmt.cat {
let mut id = matched_pat.id;
loop {
- let parent = self.cx.tcx.hir.get_parent_node(id);
+ let parent = self.cx.tcx.hir().get_parent_node(id);
if id == parent {
// no parent
return;
}
id = parent;
- if let Some(node) = self.cx.tcx.hir.find(id) {
+ if let Some(node) = self.cx.tcx.hir().find(id) {
match node {
Node::Expr(e) => {
// `match` and `if let`
Node::Stmt(s) => {
// `let <pat> = x;`
if_chain! {
- if let StmtKind::Decl(ref decl, _) = s.node;
- if let DeclKind::Local(ref local) = decl.node;
+ if let StmtKind::Local(ref local) = s.node;
then {
self.spans_need_deref
.entry(vid)