mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-12 16:45:37 +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 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);
|
||||
}
|
||||
|
||||
@ -205,7 +207,7 @@ impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> {
|
||||
// overflows.
|
||||
if ty.is_box() {
|
||||
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);
|
||||
size.bytes() > self.too_large_for_stack
|
||||
} else {
|
||||
|
@ -49,7 +49,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
|
||||
}
|
||||
},
|
||||
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())
|
||||
},
|
||||
_ => (),
|
||||
@ -70,7 +71,7 @@ fn check_arguments(cx: &LateContext, arguments: &[Expr], type_definition: &TyS,
|
||||
span_lint(cx,
|
||||
UNNECESSARY_MUT_PASSED,
|
||||
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 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) {
|
||||
if autoderefs > 1 && autoref.is_some() {
|
||||
span_lint(cx,
|
||||
NEEDLESS_BORROW,
|
||||
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) {
|
||||
if in_macro(pat.span) {
|
||||
return;
|
||||
|
@ -259,7 +259,6 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
|
||||
}
|
||||
|
||||
/// 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> {
|
||||
let cstore = &cx.tcx.sess.cstore;
|
||||
|
||||
@ -319,9 +318,9 @@ pub fn implements_trait<'a, 'tcx>(
|
||||
) -> bool {
|
||||
let ty = cx.tcx.erase_regions(&ty);
|
||||
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 {
|
||||
cx.tcx.infer_ctxt((), Reveal::All)
|
||||
cx.tcx.infer_ctxt(())
|
||||
};
|
||||
b.enter(|infcx| {
|
||||
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
|
||||
) -> bool {
|
||||
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 new_a = a.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> {
|
||||
cx.tcx
|
||||
.infer_ctxt((), Reveal::All)
|
||||
.infer_ctxt(())
|
||||
.enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes()))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user