Try to fix compilation error on rustc 1.19.0-nightly (4ed2edaaf
2017-06-01)
This commit is contained in:
parent
892cc2833c
commit
67cccc5c16
9 changed files with 20 additions and 39 deletions
|
@ -286,9 +286,7 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
||||||
match def {
|
match def {
|
||||||
Def::Const(def_id) |
|
Def::Const(def_id) |
|
||||||
Def::AssociatedConst(def_id) => {
|
Def::AssociatedConst(def_id) => {
|
||||||
let substs = self.tables
|
let substs = self.tables.node_substs(id);
|
||||||
.node_id_item_substs(id)
|
|
||||||
.unwrap_or_else(|| self.tcx.intern_substs(&[]));
|
|
||||||
let substs = if self.substs.is_empty() {
|
let substs = if self.substs.is_empty() {
|
||||||
substs
|
substs
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -160,14 +160,14 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
||||||
|
|
||||||
if let Categorization::Local(lid) = cmt.cat {
|
if let Categorization::Local(lid) = cmt.cat {
|
||||||
if self.set.contains(&lid) {
|
if self.set.contains(&lid) {
|
||||||
if let Some(&Adjust::DerefRef { autoderefs, .. }) =
|
if let Some(&Adjust::Deref(ref overloaded)) =
|
||||||
self.tables
|
self.tables
|
||||||
.adjustments
|
.adjustments
|
||||||
.get(&borrow_id)
|
.get(&borrow_id)
|
||||||
.map(|a| &a.kind) {
|
.map(|a| &a.kind) {
|
||||||
if LoanCause::AutoRef == loan_cause {
|
if LoanCause::AutoRef == loan_cause {
|
||||||
// x.foo()
|
// x.foo()
|
||||||
if autoderefs == 0 {
|
if overloaded == 0 {
|
||||||
self.set.remove(&lid); // Used without autodereffing (i.e. x.clone())
|
self.set.remove(&lid); // Used without autodereffing (i.e. x.clone())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -175,14 +175,14 @@ impl<'a, 'tcx: 'a> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
} else if LoanCause::AddrOf == loan_cause {
|
} else if LoanCause::AddrOf == loan_cause {
|
||||||
// &x
|
// &x
|
||||||
if let Some(&Adjust::DerefRef { autoderefs, .. }) =
|
if let Some(&Adjust::Deref(ref overloaded)) =
|
||||||
self.tables
|
self.tables
|
||||||
.adjustments
|
.adjustments
|
||||||
.get(&self.tcx
|
.get(&self.tcx
|
||||||
.hir
|
.hir
|
||||||
.get_parent_node(borrow_id))
|
.get_parent_node(borrow_id))
|
||||||
.map(|a| &a.kind) {
|
.map(|a| &a.kind) {
|
||||||
if autoderefs <= 1 {
|
if overloaded <= 1 {
|
||||||
// foo(&x) where no extra autoreffing is happening
|
// foo(&x) where no extra autoreffing is happening
|
||||||
self.set.remove(&lid);
|
self.set.remove(&lid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,11 +137,8 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprMethodCall(..) => {
|
ExprMethodCall(..) => {
|
||||||
let method_call = ty::MethodCall::expr(e.id);
|
|
||||||
let borrowed_table = self.cx.tables;
|
let borrowed_table = self.cx.tables;
|
||||||
let method_type = borrowed_table.method_map.get(&method_call).expect("This should never happen.");
|
if borrowed_table.expr_ty(e).is_never() {
|
||||||
let result_ty = method_type.ty.fn_ret();
|
|
||||||
if let ty::TyNever = self.cx.tcx.erase_late_bound_regions(&result_ty).sty {
|
|
||||||
self.report_diverging_sub_expr(e);
|
self.report_diverging_sub_expr(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -184,8 +184,8 @@ impl<'a, 'tcx> hir::intravisit::Visitor<'tcx> for DerefVisitor<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hir::ExprMethodCall(_, _, ref args) => {
|
hir::ExprMethodCall(_, _, ref args) => {
|
||||||
let method_call = ty::MethodCall::expr(expr.id);
|
let def_id = self.cx.tables.type_dependent_defs[&expr.id].def_id();
|
||||||
let base_type = self.cx.tables.method_map[&method_call].ty;
|
let base_type = self.cx.tcx.type_of(def_id);
|
||||||
|
|
||||||
if type_is_unsafe_function(base_type) {
|
if type_is_unsafe_function(base_type) {
|
||||||
for arg in args {
|
for arg in args {
|
||||||
|
|
|
@ -95,7 +95,7 @@ fn check_trait_items(cx: &LateContext, item: &Item, trait_items: &[TraitItemRef]
|
||||||
{
|
{
|
||||||
let did = cx.tcx.hir.local_def_id(item.id.node_id);
|
let did = cx.tcx.hir.local_def_id(item.id.node_id);
|
||||||
let impl_ty = cx.tcx.type_of(did);
|
let impl_ty = cx.tcx.type_of(did);
|
||||||
impl_ty.fn_args().skip_binder().len() == 1
|
impl_ty.fn_sig().inputs().skip_binder().len() == 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
@ -122,7 +122,7 @@ fn check_impl_items(cx: &LateContext, item: &Item, impl_items: &[ImplItemRef]) {
|
||||||
{
|
{
|
||||||
let did = cx.tcx.hir.local_def_id(item.id.node_id);
|
let did = cx.tcx.hir.local_def_id(item.id.node_id);
|
||||||
let impl_ty = cx.tcx.type_of(did);
|
let impl_ty = cx.tcx.type_of(did);
|
||||||
impl_ty.fn_args().skip_binder().len() == 1
|
impl_ty.fn_sig().inputs().skip_binder().len() == 1
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
@ -676,13 +676,8 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
|
||||||
lint_iter_method(cx, args, arg, &method_name);
|
lint_iter_method(cx, args, arg, &method_name);
|
||||||
}
|
}
|
||||||
} else if method_name == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) {
|
} else if method_name == "into_iter" && match_trait_method(cx, arg, &paths::INTO_ITERATOR) {
|
||||||
let method_call = ty::MethodCall::expr(arg.id);
|
let fn_ty = cx.tables.expr_ty(arg);
|
||||||
let fn_ty = cx.tables
|
let fn_arg_tys = fn_ty.fn_sig().inputs();
|
||||||
.method_map
|
|
||||||
.get(&method_call)
|
|
||||||
.map(|method_callee| method_callee.ty)
|
|
||||||
.expect("method calls need an entry in the method map");
|
|
||||||
let fn_arg_tys = fn_ty.fn_args();
|
|
||||||
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
|
assert_eq!(fn_arg_tys.skip_binder().len(), 1);
|
||||||
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
|
if fn_arg_tys.skip_binder()[0].is_region_ptr() {
|
||||||
lint_iter_method(cx, args, arg, &method_name);
|
lint_iter_method(cx, args, arg, &method_name);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use rustc::lint::*;
|
use rustc::lint::*;
|
||||||
use rustc::ty::{TypeAndMut, TypeVariants, MethodCall, TyS};
|
use rustc::ty::{TypeAndMut, TypeVariants, TyS};
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
use utils::span_lint;
|
use utils::span_lint;
|
||||||
|
|
||||||
|
@ -49,9 +49,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprMethodCall(ref name, _, ref arguments) => {
|
ExprMethodCall(ref name, _, ref arguments) => {
|
||||||
let method_call = MethodCall::expr(e.id);
|
let method_type = borrowed_table.expr_ty(e);
|
||||||
let method_type = borrowed_table.method_map.get(&method_call).expect("This should never happen.");
|
check_arguments(cx, arguments, method_type, &name.node.as_str())
|
||||||
check_arguments(cx, arguments, method_type.ty, &name.node.as_str())
|
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
|
||||||
}
|
}
|
||||||
if let ExprAddrOf(MutImmutable, ref inner) = e.node {
|
if let ExprAddrOf(MutImmutable, ref inner) = e.node {
|
||||||
if let ty::TyRef(..) = cx.tables.expr_ty(inner).sty {
|
if let ty::TyRef(..) = cx.tables.expr_ty(inner).sty {
|
||||||
if let Some(&ty::adjustment::Adjust::DerefRef { autoderefs, autoref, .. }) =
|
if let Some(&ty::adjustment::Adjust::Deref(ref overloaded)) =
|
||||||
cx.tables.adjustments.get(&e.id).map(|a| &a.kind) {
|
cx.tables.adjustments.get(&e.id).map(|a| &a.kind) {
|
||||||
if autoderefs > 1 && autoref.is_some() {
|
if autoderefs > 1 && autoref.is_some() {
|
||||||
span_lint(cx,
|
span_lint(cx,
|
||||||
|
|
|
@ -184,12 +184,8 @@ pub fn match_type(cx: &LateContext, ty: ty::Ty, path: &[&str]) -> bool {
|
||||||
|
|
||||||
/// Check if the method call given in `expr` belongs to given type.
|
/// Check if the method call given in `expr` belongs to given type.
|
||||||
pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
|
pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
|
||||||
let method_call = ty::MethodCall::expr(expr.id);
|
let method_call = cx.tables.type_dependent_defs[&expr.id];
|
||||||
|
let trt_id = cx.tcx.impl_of_method(method_call.def_id());
|
||||||
let trt_id = cx.tables
|
|
||||||
.method_map
|
|
||||||
.get(&method_call)
|
|
||||||
.and_then(|callee| cx.tcx.impl_of_method(callee.def_id));
|
|
||||||
if let Some(trt_id) = trt_id {
|
if let Some(trt_id) = trt_id {
|
||||||
match_def_path(cx.tcx, trt_id, path)
|
match_def_path(cx.tcx, trt_id, path)
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,12 +195,8 @@ pub fn match_impl_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
|
||||||
|
|
||||||
/// Check if the method call given in `expr` belongs to given trait.
|
/// Check if the method call given in `expr` belongs to given trait.
|
||||||
pub fn match_trait_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
|
pub fn match_trait_method(cx: &LateContext, expr: &Expr, path: &[&str]) -> bool {
|
||||||
let method_call = ty::MethodCall::expr(expr.id);
|
let method_call = cx.tables.type_dependent_defs[&expr.id];
|
||||||
|
let trt_id = cx.tcx.trait_of_item(method_call.def_id());
|
||||||
let trt_id = cx.tables
|
|
||||||
.method_map
|
|
||||||
.get(&method_call)
|
|
||||||
.and_then(|callee| cx.tcx.trait_of_item(callee.def_id));
|
|
||||||
if let Some(trt_id) = trt_id {
|
if let Some(trt_id) = trt_id {
|
||||||
match_def_path(cx.tcx, trt_id, path)
|
match_def_path(cx.tcx, trt_id, path)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue