mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-13 17:13:48 +00:00
Continue work on rustup
This commit is contained in:
parent
67cccc5c16
commit
edef6c53c0
@ -81,7 +81,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
|
|||||||
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 region_maps = &cx.tcx.region_maps(fn_def_id);
|
let region_maps = &cx.tcx.region_maps(fn_def_id);
|
||||||
{
|
{
|
||||||
let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx);
|
let def_id = cx.tcx.hir.body_owner_def_id(body.id());
|
||||||
|
let param_env = cx.tcx.param_env(def_id);
|
||||||
|
let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx, param_env);
|
||||||
vis.consume_body(body);
|
vis.consume_body(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +207,7 @@ impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> {
|
|||||||
// overflows.
|
// overflows.
|
||||||
if ty.is_box() {
|
if ty.is_box() {
|
||||||
let inner = ty.boxed_ty();
|
let inner = ty.boxed_ty();
|
||||||
self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
|
self.tcx.infer_ctxt(()).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
|
||||||
let size = layout.size(&self.target);
|
let size = layout.size(&self.target);
|
||||||
size.bytes() > self.too_large_for_stack
|
size.bytes() > self.too_large_for_stack
|
||||||
} else {
|
} else {
|
||||||
|
@ -49,7 +49,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprMethodCall(ref name, _, ref arguments) => {
|
ExprMethodCall(ref name, _, ref arguments) => {
|
||||||
let method_type = borrowed_table.expr_ty(e);
|
let def_id = borrowed_table.type_dependent_defs[&e.id].def_id();
|
||||||
|
let method_type = cx.tcx.type_of(def_id);
|
||||||
check_arguments(cx, arguments, method_type, &name.node.as_str())
|
check_arguments(cx, arguments, method_type, &name.node.as_str())
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
@ -70,7 +71,7 @@ fn check_arguments(cx: &LateContext, arguments: &[Expr], type_definition: &TyS,
|
|||||||
span_lint(cx,
|
span_lint(cx,
|
||||||
UNNECESSARY_MUT_PASSED,
|
UNNECESSARY_MUT_PASSED,
|
||||||
argument.span,
|
argument.span,
|
||||||
&format!("The function/method \"{}\" doesn't need a mutable reference", name));
|
&format!("The function/method `{}` doesn't need a mutable reference", name));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => (),
|
_ => (),
|
||||||
|
@ -41,9 +41,8 @@ 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::Deref(ref overloaded)) =
|
if let Some(&ty::adjustment::Adjust::Deref(Some(_))) =
|
||||||
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() {
|
|
||||||
span_lint(cx,
|
span_lint(cx,
|
||||||
NEEDLESS_BORROW,
|
NEEDLESS_BORROW,
|
||||||
e.span,
|
e.span,
|
||||||
@ -53,7 +52,6 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
|
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
|
||||||
if in_macro(pat.span) {
|
if in_macro(pat.span) {
|
||||||
return;
|
return;
|
||||||
|
@ -259,7 +259,6 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get the definition associated to a path.
|
/// Get the definition associated to a path.
|
||||||
/// TODO: investigate if there is something more efficient for that.
|
|
||||||
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
|
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
|
||||||
let cstore = &cx.tcx.sess.cstore;
|
let cstore = &cx.tcx.sess.cstore;
|
||||||
|
|
||||||
@ -319,9 +318,9 @@ pub fn implements_trait<'a, 'tcx>(
|
|||||||
) -> bool {
|
) -> bool {
|
||||||
let ty = cx.tcx.erase_regions(&ty);
|
let ty = cx.tcx.erase_regions(&ty);
|
||||||
let mut b = if let Some(id) = parent_node_id {
|
let mut b = if let Some(id) = parent_node_id {
|
||||||
cx.tcx.infer_ctxt(BodyId { node_id: id }, Reveal::All)
|
cx.tcx.infer_ctxt(BodyId { node_id: id })
|
||||||
} else {
|
} else {
|
||||||
cx.tcx.infer_ctxt((), Reveal::All)
|
cx.tcx.infer_ctxt(())
|
||||||
};
|
};
|
||||||
b.enter(|infcx| {
|
b.enter(|infcx| {
|
||||||
let obligation = cx.tcx.predicate_for_trait_def(traits::ObligationCause::dummy(), trait_id, 0, ty, ty_params);
|
let obligation = cx.tcx.predicate_for_trait_def(traits::ObligationCause::dummy(), trait_id, 0, ty, ty_params);
|
||||||
@ -780,7 +779,7 @@ pub fn same_tys<'a, 'tcx>(
|
|||||||
parameter_item: DefId
|
parameter_item: DefId
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let parameter_env = cx.tcx.param_env(parameter_item);
|
let parameter_env = cx.tcx.param_env(parameter_item);
|
||||||
cx.tcx.infer_ctxt(parameter_env, Reveal::All).enter(|infcx| {
|
cx.tcx.infer_ctxt(parameter_env).enter(|infcx| {
|
||||||
let substs = Substs::identity_for_item(cx.tcx, parameter_item);
|
let substs = Substs::identity_for_item(cx.tcx, parameter_item);
|
||||||
let new_a = a.subst(infcx.tcx, substs);
|
let new_a = a.subst(infcx.tcx, substs);
|
||||||
let new_b = b.subst(infcx.tcx, substs);
|
let new_b = b.subst(infcx.tcx, substs);
|
||||||
@ -963,6 +962,6 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> {
|
|||||||
|
|
||||||
pub fn type_size<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>) -> Option<u64> {
|
pub fn type_size<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>) -> Option<u64> {
|
||||||
cx.tcx
|
cx.tcx
|
||||||
.infer_ctxt((), Reveal::All)
|
.infer_ctxt(())
|
||||||
.enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes()))
|
.enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes()))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user