Skip to content

Fix compilation failures caused by changes in the compiler #1510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 3 additions & 3 deletions clippy_lints/src/assign_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AssignOps {
return; // useless if the trait doesn't exist
};
// check that we are not inside an `impl AssignOp` of this exact operation
let parent_fn = cx.tcx.map.get_parent(e.id);
let parent_impl = cx.tcx.map.get_parent(parent_fn);
let parent_fn = cx.tcx.hir.get_parent(e.id);
let parent_impl = cx.tcx.hir.get_parent(parent_fn);
// the crate node is the only one that is not in the map
if_let_chain!{[
parent_impl != ast::CRATE_NODE_ID,
let hir::map::Node::NodeItem(item) = cx.tcx.map.get(parent_impl),
let hir::map::Node::NodeItem(item) = cx.tcx.hir.get(parent_impl),
let hir::Item_::ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node,
trait_ref.path.def.def_id() == trait_id
], { return; }}
Expand Down
10 changes: 5 additions & 5 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {

fn is_relevant_item(tcx: ty::TyCtxt, item: &Item) -> bool {
if let ItemFn(_, _, _, _, _, eid) = item.node {
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.map.body(eid).value)
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
} else {
false
}
}

fn is_relevant_impl(tcx: ty::TyCtxt, item: &ImplItem) -> bool {
match item.node {
ImplItemKind::Method(_, eid) => is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.map.body(eid).value),
ImplItemKind::Method(_, eid) => is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value),
_ => false,
}
}
Expand All @@ -175,13 +175,13 @@ fn is_relevant_trait(tcx: ty::TyCtxt, item: &TraitItem) -> bool {
match item.node {
TraitItemKind::Method(_, TraitMethod::Required(_)) => true,
TraitItemKind::Method(_, TraitMethod::Provided(eid)) => {
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.map.body(eid).value)
is_relevant_expr(tcx, tcx.body_tables(eid), &tcx.hir.body(eid).value)
},
_ => false,
}
}

fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::Tables, block: &Block) -> bool {
fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::TypeckTables, block: &Block) -> bool {
for stmt in &block.stmts {
match stmt.node {
StmtDecl(_, _) => return true,
Expand All @@ -194,7 +194,7 @@ fn is_relevant_block(tcx: ty::TyCtxt, tables: &ty::Tables, block: &Block) -> boo
block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e))
}

fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::Tables, expr: &Expr) -> bool {
fn is_relevant_expr(tcx: ty::TyCtxt, tables: &ty::TypeckTables, expr: &Expr) -> bool {
match expr.node {
ExprBlock(ref block) => is_relevant_block(tcx, tables, block),
ExprRet(Some(ref e)) => is_relevant_expr(tcx, tables, e),
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/block_in_if_condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct ExVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
fn visit_expr(&mut self, expr: &'tcx Expr) {
if let ExprClosure(_, _, eid, _) = expr.node {
let body = self.cx.tcx.map.body(eid);
let body = self.cx.tcx.hir.body(eid);
let ex = &body.value;
if matches!(ex.node, ExprBlock(_)) {
self.found_block = Some(ex);
Expand All @@ -67,7 +67,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
ExprRepeat(ref value, number_id) => {
if let Some(lcx) = self.lcx {
self.binop_apply(value,
&lcx.tcx.map.body(number_id).value,
&lcx.tcx.hir.body(number_id).value,
|v, n| Some(Constant::Repeat(Box::new(v), n.as_u64() as usize)))
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/cyclomatic_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for CyclomaticComplexity {
span: Span,
node_id: NodeId
) {
let def_id = cx.tcx.map.local_def_id(node_id);
let def_id = cx.tcx.hir.local_def_id(node_id);
if !cx.tcx.has_attr(def_id, "test") {
self.check(cx, &body.value, span);
}
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl LintPass for Derive {
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Derive {
fn check_item(&mut self, cx: &LateContext<'a, 'tcx>, item: &'tcx Item) {
if let ItemImpl(_, _, _, Some(ref trait_ref), _, _) = item.node {
let ty = cx.tcx.item_type(cx.tcx.map.local_def_id(item.id));
let ty = cx.tcx.item_type(cx.tcx.hir.local_def_id(item.id));
let is_automatically_derived = is_automatically_derived(&*item.attrs);

check_hash_peq(cx, item.span, trait_ref, ty, is_automatically_derived);
Expand Down Expand Up @@ -122,9 +122,9 @@ fn check_hash_peq<'a, 'tcx>(
cx, DERIVE_HASH_XOR_EQ, span,
mess,
|db| {
if let Some(node_id) = cx.tcx.map.as_local_node_id(impl_id) {
if let Some(node_id) = cx.tcx.hir.as_local_node_id(impl_id) {
db.span_note(
cx.tcx.map.span(node_id),
cx.tcx.hir.span(node_id),
"`PartialEq` implemented here"
);
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,6 @@ impl<'a, 'tcx, 'b> Visitor<'tcx> for InsertVisitor<'a, 'tcx, 'b> {
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}
2 changes: 1 addition & 1 deletion clippy_lints/src/enum_clike.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnportableVariant {
if let Some(body_id) = variant.disr_expr {
use rustc_const_eval::*;
let constcx = ConstContext::new(cx.tcx, body_id);
let bad = match constcx.eval(&cx.tcx.map.body(body_id).value, EvalHint::ExprTypeChecked) {
let bad = match constcx.eval(&cx.tcx.hir.body(body_id).value, EvalHint::ExprTypeChecked) {
Ok(ConstVal::Integral(Usize(Us64(i)))) => i as u32 as u64 != i,
Ok(ConstVal::Integral(Isize(Is64(i)))) => i as i32 as i64 != i,
_ => false,
Expand Down
13 changes: 7 additions & 6 deletions clippy_lints/src/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ declare_lint! {

fn is_non_trait_box(ty: ty::Ty) -> bool {
match ty.sty {
ty::TyBox(inner) => !inner.is_trait(),
ty::TyAdt(_, substs) if ty.is_box() => !substs.type_at(0).is_trait(),
_ => false,
}
}

struct EscapeDelegate<'a, 'tcx: 'a> {
set: NodeSet,
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
tables: &'a ty::Tables<'tcx>,
tables: &'a ty::TypeckTables<'tcx>,
target: TargetDataLayout,
too_large_for_stack: u64,
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
for node in v.set {
span_lint(cx,
BOXED_LOCAL,
cx.tcx.map.span(node),
cx.tcx.hir.span(node),
"local variable doesn't need to be boxed here");
}
}
Expand All @@ -108,7 +108,7 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
}
fn matched_pat(&mut self, _: &Pat, _: cmt<'tcx>, _: MatchMode) {}
fn consume_pat(&mut self, consume_pat: &Pat, cmt: cmt<'tcx>, _: ConsumeMode) {
let map = &self.tcx.map;
let map = &self.tcx.hir;
if map.is_argument(consume_pat.id) {
// Skip closure arguments
if let Some(NodeExpr(..)) = map.find(map.get_parent_node(consume_pat.id)) {
Expand Down Expand Up @@ -180,7 +180,7 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
self.tables
.adjustments
.get(&self.tcx
.map
.hir
.get_parent_node(borrow_id))
.map(|a| &a.kind) {
if autoderefs <= 1 {
Expand All @@ -205,7 +205,8 @@ impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> {
// Large types need to be boxed to avoid stack
// overflows.
match ty.sty {
ty::TyBox(inner) => {
ty::TyAdt(_, substs) if ty.is_box() => {
let inner = substs.type_at(0);
self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
let size = layout.size(&self.target);
size.bytes() > self.too_large_for_stack
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for EtaPass {

fn check_closure(cx: &LateContext, expr: &Expr) {
if let ExprClosure(_, ref decl, eid, _) = expr.node {
let body = cx.tcx.map.body(eid);
let body = cx.tcx.hir.body(eid);
let ex = &body.value;
if let ExprCall(ref caller, ref args) = ex.node {
if args.len() != decl.inputs.len() {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/eval_order_dependence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
// don't continue over blocks, LateLintPass already does that
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand All @@ -176,7 +176,7 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
///
/// When such a read is found, the lint is triggered.
fn check_for_unsequenced_reads(vis: &mut ReadVisitor) {
let map = &vis.cx.tcx.map;
let map = &vis.cx.tcx.hir;
let mut cur_id = vis.write_expr.id;
loop {
let parent_id = map.get_parent_node(cur_id);
Expand Down Expand Up @@ -342,7 +342,7 @@ impl<'a, 'tcx> Visitor<'tcx> for ReadVisitor<'a, 'tcx> {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ pub fn get_argument_fmtstr_parts<'a, 'b>(cx: &LateContext<'a, 'b>, expr: &'a Exp
block.stmts.len() == 1,
let StmtDecl(ref decl, _) = block.stmts[0].node,
let DeclItem(ref decl) = decl.node,
let Some(NodeItem(decl)) = cx.tcx.map.find(decl.id),
let Some(NodeItem(decl)) = cx.tcx.hir.find(decl.id),
&*decl.name.as_str() == "__STATIC_FMTSTR",
let ItemStatic(_, _, ref expr) = decl.node,
let ExprAddrOf(_, ref expr) = cx.tcx.map.body(*expr).value.node, // &["…", "…", …]
let ExprAddrOf(_, ref expr) = cx.tcx.hir.body(*expr).value.node, // &["…", "…", …]
let ExprArray(ref exprs) = expr.node,
], {
let mut result = Vec::new();
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
) {
use rustc::hir::map::Node::*;

let is_impl = if let Some(NodeItem(item)) = cx.tcx.map.find(cx.tcx.map.get_parent_node(nodeid)) {
let is_impl = if let Some(NodeItem(item)) = cx.tcx.hir.find(cx.tcx.hir.get_parent_node(nodeid)) {
matches!(item.node, hir::ItemImpl(_, _, _, Some(_), _, _) | hir::ItemDefaultImpl(..))
} else {
false
Expand Down Expand Up @@ -113,7 +113,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Functions {
}

if let hir::TraitMethod::Provided(eid) = *eid {
let body = cx.tcx.map.body(eid);
let body = cx.tcx.hir.body(eid);
self.check_raw_ptr(cx, sig.unsafety, &sig.decl, body, item.id);
}
}
Expand Down Expand Up @@ -200,7 +200,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
hir::intravisit::walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
intravisit::NestedVisitorMap::All(&self.cx.tcx.map)
intravisit::NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/large_enum_variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl LintPass for LargeEnumVariant {

impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LargeEnumVariant {
fn check_item(&mut self, cx: &LateContext, item: &Item) {
let did = cx.tcx.map.local_def_id(item.id);
let did = cx.tcx.hir.local_def_id(item.id);
if let ItemEnum(ref def, _) = item.node {
let ty = cx.tcx.item_type(did);
let adt = ty.ty_adt_def().expect("already checked whether this is an enum");
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/len_zero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItemRef]
if let AssociatedItemKind::Method { has_self } = item.kind {
has_self &&
{
let did = cx.tcx.map.local_def_id(item.id.node_id);
let did = cx.tcx.hir.local_def_id(item.id.node_id);
let impl_ty = cx.tcx.item_type(did);
impl_ty.fn_args().skip_binder().len() == 1
}
Expand All @@ -120,7 +120,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
if let AssociatedItemKind::Method { has_self } = item.kind {
has_self &&
{
let did = cx.tcx.map.local_def_id(item.id.node_id);
let did = cx.tcx.hir.local_def_id(item.id.node_id);
let impl_ty = cx.tcx.item_type(did);
impl_ty.fn_args().skip_binder().len() == 1
}
Expand All @@ -141,7 +141,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {

if let Some(i) = impl_items.iter().find(|i| is_named_self(cx, i, "len")) {
if cx.access_levels.is_exported(i.id.node_id) {
let def_id = cx.tcx.map.local_def_id(item.id);
let def_id = cx.tcx.hir.local_def_id(item.id);
let ty = cx.tcx.item_type(def_id);

span_lint(cx,
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/let_if_seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
hir::intravisit::walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> hir::intravisit::NestedVisitorMap<'this, 'tcx> {
hir::intravisit::NestedVisitorMap::All(&self.cx.tcx.map)
hir::intravisit::NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand Down
1 change: 0 additions & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(stmt_expr_attributes)]
#![feature(repeat_str)]
#![feature(conservative_impl_trait)]
#![feature(collections_bound)]

Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {

fn visit_ty(&mut self, ty: &'tcx Ty) {
match ty.node {
TyRptr(None, _) => {
TyRptr(lifetime, _) if lifetime.is_elided() => {
self.record(&None);
},
TyPath(ref path) => {
Expand Down
16 changes: 8 additions & 8 deletions clippy_lints/src/loops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ fn check_for_loop_explicit_counter<'a, 'tcx>(

// For each candidate, check the parent block to see if
// it's initialized to zero at the start of the loop.
let map = &cx.tcx.map;
let map = &cx.tcx.hir;
let parent_scope = map.get_enclosing_scope(expr.id).and_then(|id| map.get_enclosing_scope(id));
if let Some(parent_id) = parent_scope {
if let NodeBlock(block) = map.get(parent_id) {
Expand Down Expand Up @@ -794,7 +794,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand Down Expand Up @@ -822,7 +822,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
match def {
Def::Local(..) | Def::Upvar(..) => {
let def_id = def.def_id();
let node_id = self.cx.tcx.map.as_local_node_id(def_id).unwrap();
let node_id = self.cx.tcx.hir.as_local_node_id(def_id).unwrap();

let extent = self.cx.tcx.region_maps.var_scope(node_id);
self.indexed.insert(seqvar.segments[0].name, Some(extent));
Expand All @@ -844,7 +844,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarVisitor<'a, 'tcx> {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand Down Expand Up @@ -886,7 +886,7 @@ impl<'a, 'tcx> Visitor<'tcx> for VarUsedAfterLoopVisitor<'a, 'tcx> {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand Down Expand Up @@ -1029,7 +1029,7 @@ impl<'a, 'tcx> Visitor<'tcx> for IncrementVisitor<'a, 'tcx> {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

Expand Down Expand Up @@ -1116,15 +1116,15 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
NestedVisitorMap::All(&self.cx.tcx.map)
NestedVisitorMap::All(&self.cx.tcx.hir)
}
}

fn var_def_id(cx: &LateContext, expr: &Expr) -> Option<NodeId> {
if let ExprPath(ref qpath) = expr.node {
let path_res = cx.tables.qpath_def(qpath, expr.id);
if let Def::Local(def_id) = path_res {
let node_id = cx.tcx.map.as_local_node_id(def_id).expect("That DefId should be valid");
let node_id = cx.tcx.hir.as_local_node_id(def_id).expect("That DefId should be valid");
return Some(node_id);
}
}
Expand Down
Loading