Skip to content

Commit edef6c5

Browse files
committed
Continue work on rustup
1 parent 67cccc5 commit edef6c5

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

clippy_lints/src/escape.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
8181
let fn_def_id = cx.tcx.hir.local_def_id(node_id);
8282
let region_maps = &cx.tcx.region_maps(fn_def_id);
8383
{
84-
let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx);
84+
let def_id = cx.tcx.hir.body_owner_def_id(body.id());
85+
let param_env = cx.tcx.param_env(def_id);
86+
let mut vis = ExprUseVisitor::new(&mut v, region_maps, &infcx, param_env);
8587
vis.consume_body(body);
8688
}
8789

@@ -205,7 +207,7 @@ impl<'a, 'tcx: 'a> EscapeDelegate<'a, 'tcx> {
205207
// overflows.
206208
if ty.is_box() {
207209
let inner = ty.boxed_ty();
208-
self.tcx.infer_ctxt((), Reveal::All).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
210+
self.tcx.infer_ctxt(()).enter(|infcx| if let Ok(layout) = inner.layout(&infcx) {
209211
let size = layout.size(&self.target);
210212
size.bytes() > self.too_large_for_stack
211213
} else {

clippy_lints/src/mut_reference.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
4949
}
5050
},
5151
ExprMethodCall(ref name, _, ref arguments) => {
52-
let method_type = borrowed_table.expr_ty(e);
52+
let def_id = borrowed_table.type_dependent_defs[&e.id].def_id();
53+
let method_type = cx.tcx.type_of(def_id);
5354
check_arguments(cx, arguments, method_type, &name.node.as_str())
5455
},
5556
_ => (),
@@ -70,7 +71,7 @@ fn check_arguments(cx: &LateContext, arguments: &[Expr], type_definition: &TyS,
7071
span_lint(cx,
7172
UNNECESSARY_MUT_PASSED,
7273
argument.span,
73-
&format!("The function/method \"{}\" doesn't need a mutable reference", name));
74+
&format!("The function/method `{}` doesn't need a mutable reference", name));
7475
}
7576
},
7677
_ => (),

clippy_lints/src/needless_borrow.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessBorrow {
4141
}
4242
if let ExprAddrOf(MutImmutable, ref inner) = e.node {
4343
if let ty::TyRef(..) = cx.tables.expr_ty(inner).sty {
44-
if let Some(&ty::adjustment::Adjust::Deref(ref overloaded)) =
44+
if let Some(&ty::adjustment::Adjust::Deref(Some(_))) =
4545
cx.tables.adjustments.get(&e.id).map(|a| &a.kind) {
46-
if autoderefs > 1 && autoref.is_some() {
47-
span_lint(cx,
48-
NEEDLESS_BORROW,
49-
e.span,
50-
"this expression borrows a reference that is immediately dereferenced by the \
51-
compiler");
52-
}
46+
span_lint(cx,
47+
NEEDLESS_BORROW,
48+
e.span,
49+
"this expression borrows a reference that is immediately dereferenced by the \
50+
compiler");
5351
}
5452
}
5553
}

clippy_lints/src/utils/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ pub fn match_path_ast(path: &ast::Path, segments: &[&str]) -> bool {
259259
}
260260

261261
/// Get the definition associated to a path.
262-
/// TODO: investigate if there is something more efficient for that.
263262
pub fn path_to_def(cx: &LateContext, path: &[&str]) -> Option<def::Def> {
264263
let cstore = &cx.tcx.sess.cstore;
265264

@@ -319,9 +318,9 @@ pub fn implements_trait<'a, 'tcx>(
319318
) -> bool {
320319
let ty = cx.tcx.erase_regions(&ty);
321320
let mut b = if let Some(id) = parent_node_id {
322-
cx.tcx.infer_ctxt(BodyId { node_id: id }, Reveal::All)
321+
cx.tcx.infer_ctxt(BodyId { node_id: id })
323322
} else {
324-
cx.tcx.infer_ctxt((), Reveal::All)
323+
cx.tcx.infer_ctxt(())
325324
};
326325
b.enter(|infcx| {
327326
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>(
780779
parameter_item: DefId
781780
) -> bool {
782781
let parameter_env = cx.tcx.param_env(parameter_item);
783-
cx.tcx.infer_ctxt(parameter_env, Reveal::All).enter(|infcx| {
782+
cx.tcx.infer_ctxt(parameter_env).enter(|infcx| {
784783
let substs = Substs::identity_for_item(cx.tcx, parameter_item);
785784
let new_a = a.subst(infcx.tcx, substs);
786785
let new_b = b.subst(infcx.tcx, substs);
@@ -963,6 +962,6 @@ pub fn is_try(expr: &Expr) -> Option<&Expr> {
963962

964963
pub fn type_size<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: ty::Ty<'tcx>) -> Option<u64> {
965964
cx.tcx
966-
.infer_ctxt((), Reveal::All)
965+
.infer_ctxt(())
967966
.enter(|infcx| ty.layout(&infcx).ok().map(|lay| lay.size(&TargetDataLayout::parse(cx.sess())).bytes()))
968967
}

0 commit comments

Comments
 (0)