walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
// 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.hir)
+ NestedVisitorMap::None
}
}
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
hir::intravisit::walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
- intravisit::NestedVisitorMap::All(&self.cx.tcx.hir)
+ intravisit::NestedVisitorMap::None
}
}
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.hir)
+ hir::intravisit::NestedVisitorMap::None
}
}
let (new_pat_span, kind, ty, mutbl) = match cx.tables.expr_ty(arg).sty {
ty::TyRef(_, ref tam) => {
match (&pat[0].node, &pat[1].node) {
- (key, _) if pat_is_wild(cx, key, body) => (pat[1].span, "value", tam.ty, tam.mutbl),
- (_, value) if pat_is_wild(cx, value, body) => (pat[0].span, "key", tam.ty, MutImmutable),
+ (key, _) if pat_is_wild(key, body) => (pat[1].span, "value", tam.ty, tam.mutbl),
+ (_, value) if pat_is_wild(value, body) => (pat[0].span, "key", tam.ty, MutImmutable),
_ => return,
}
},
}
/// Return true if the pattern is a `PatWild` or an ident prefixed with `'_'`.
-fn pat_is_wild<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, pat: &'tcx PatKind, body: &'tcx Expr) -> bool {
+fn pat_is_wild<'tcx>(pat: &'tcx PatKind, body: &'tcx Expr) -> bool {
match *pat {
PatKind::Wild => true,
PatKind::Binding(_, _, ident, None) if ident.node.as_str().starts_with('_') => {
let mut visitor = UsedVisitor {
var: ident.node,
used: false,
- cx: cx,
};
walk_expr(&mut visitor, body);
!visitor.used
}
}
-struct UsedVisitor<'a, 'tcx: 'a> {
+struct UsedVisitor {
var: ast::Name, // var to look for
used: bool, // has the var been used otherwise?
- cx: &'a LateContext<'a, 'tcx>,
}
-impl<'a, 'tcx: 'a> Visitor<'tcx> for UsedVisitor<'a, 'tcx> {
+impl<'tcx> Visitor<'tcx> for UsedVisitor {
fn visit_expr(&mut self, expr: &'tcx Expr) {
if let ExprPath(QPath::Resolved(None, ref path)) = expr.node {
if path.segments.len() == 1 && path.segments[0].name == self.var {
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
walk_expr(self, expr);
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
intravisit::walk_ty(self, ty);
}
fn nested_visit_map<'this>(&'this mut self) -> intravisit::NestedVisitorMap<'this, 'tcx> {
- intravisit::NestedVisitorMap::All(&self.cx.tcx.hir)
+ intravisit::NestedVisitorMap::None
}
}
snippet(cx, pattern_span, "_"),
snippet(cx, expr.span, "..")),
|db| { db.span_note(prev_span, "previous binding is here"); });
- } else if contains_self(cx, name, expr) {
+ } else if contains_self(name, expr) {
span_lint_and_then(cx,
SHADOW_REUSE,
pattern_span,
!path.is_global() && path.segments.len() == 1 && path.segments[0].name.as_str() == name.as_str()
}
-struct ContainsSelf<'a, 'tcx: 'a> {
+struct ContainsSelf {
name: Name,
result: bool,
- cx: &'a LateContext<'a, 'tcx>,
}
-impl<'a, 'tcx: 'a> Visitor<'tcx> for ContainsSelf<'a, 'tcx> {
+impl<'tcx> Visitor<'tcx> for ContainsSelf {
fn visit_name(&mut self, _: Span, name: Name) {
if self.name == name {
self.result = true;
}
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
-fn contains_self<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, name: Name, expr: &'tcx Expr) -> bool {
+fn contains_self(name: Name, expr: &Expr) -> bool {
let mut cs = ContainsSelf {
name: name,
result: false,
- cx: cx,
};
cs.visit_expr(expr);
cs.result
}
}
- fn check_type(&self, cx: &LateContext<'a, 'tcx>, ty: &'tcx Ty) {
+ fn check_type(&self, cx: &LateContext, ty: &Ty) {
if in_macro(ty.span) {
return;
}
let mut visitor = TypeComplexityVisitor {
score: 0,
nest: 1,
- cx: cx,
};
visitor.visit_ty(ty);
visitor.score
}
/// Walks a type and assigns a complexity score to it.
-struct TypeComplexityVisitor<'a, 'tcx: 'a> {
+struct TypeComplexityVisitor{
/// total complexity score of the type
score: u64,
/// current nesting level
nest: u64,
- cx: &'a LateContext<'a, 'tcx>,
}
-impl<'a, 'tcx: 'a> Visitor<'tcx> for TypeComplexityVisitor<'a, 'tcx> {
+impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
fn visit_ty(&mut self, ty: &'tcx Ty) {
let (add_score, sub_nest) = match ty.node {
// _, &x and *x have only small overhead; don't mess with nesting level
self.nest -= sub_nest;
}
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'tcx> {
- NestedVisitorMap::All(&self.cx.tcx.hir)
+ NestedVisitorMap::None
}
}
--- /dev/null
+#![feature(plugin)]
+#![plugin(clippy)]
+
+pub fn foo(bar: *const u8) {
+ println!("{:#p}", bar);
+}
+
+fn main() {}
--- /dev/null
+
+// this used to ICE
+fubar!();
+
+fn main() {}
--- /dev/null
+error: cannot find macro `fubar!` in this scope
+ --> $DIR/ices.rs:3:1
+ |
+3 | fubar!();
+ | ^^^^^
+
+error: aborting due to previous error
+