mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-12 16:45:37 +00:00
rustup
This commit is contained in:
parent
455fa0c40a
commit
b9f183d31f
@ -1028,7 +1028,7 @@ fn extract_first_expr(block: &Block) -> Option<&Expr> {
|
|||||||
/// Return true if expr contains a single break expr (maybe within a block).
|
/// Return true if expr contains a single break expr (maybe within a block).
|
||||||
fn is_break_expr(expr: &Expr) -> bool {
|
fn is_break_expr(expr: &Expr) -> bool {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
ExprBreak(None, _) => true,
|
ExprBreak(dest, _) if dest.ident.is_none() => true,
|
||||||
ExprBlock(ref b) => {
|
ExprBlock(ref b) => {
|
||||||
match extract_first_expr(b) {
|
match extract_first_expr(b) {
|
||||||
Some(subexpr) => is_break_expr(subexpr),
|
Some(subexpr) => is_break_expr(subexpr),
|
||||||
|
@ -69,9 +69,11 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedLabel {
|
|||||||
impl<'a, 'tcx: 'a> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> {
|
impl<'a, 'tcx: 'a> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> {
|
||||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||||
match expr.node {
|
match expr.node {
|
||||||
hir::ExprBreak(Some(label), _) |
|
hir::ExprBreak(destination, _) |
|
||||||
hir::ExprAgain(Some(label)) => {
|
hir::ExprAgain(destination) => {
|
||||||
self.labels.remove(&label.name.as_str());
|
if let Some(label) = destination.ident {
|
||||||
|
self.labels.remove(&label.node.name.as_str());
|
||||||
|
}
|
||||||
},
|
},
|
||||||
hir::ExprLoop(_, Some(label), _) |
|
hir::ExprLoop(_, Some(label), _) |
|
||||||
hir::ExprWhile(_, _, Some(label)) => {
|
hir::ExprWhile(_, _, Some(label)) => {
|
||||||
|
@ -68,7 +68,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
|||||||
|
|
||||||
match (&left.node, &right.node) {
|
match (&left.node, &right.node) {
|
||||||
(&ExprAddrOf(l_mut, ref le), &ExprAddrOf(r_mut, ref re)) => l_mut == r_mut && self.eq_expr(le, re),
|
(&ExprAddrOf(l_mut, ref le), &ExprAddrOf(r_mut, ref re)) => l_mut == r_mut && self.eq_expr(le, re),
|
||||||
(&ExprAgain(li), &ExprAgain(ri)) => both(&li, &ri, |l, r| l.name.as_str() == r.name.as_str()),
|
(&ExprAgain(li), &ExprAgain(ri)) => both(&li.ident, &ri.ident, |l, r| l.node.name.as_str() == r.node.name.as_str()),
|
||||||
(&ExprAssign(ref ll, ref lr), &ExprAssign(ref rl, ref rr)) => self.eq_expr(ll, rl) && self.eq_expr(lr, rr),
|
(&ExprAssign(ref ll, ref lr), &ExprAssign(ref rl, ref rr)) => self.eq_expr(ll, rl) && self.eq_expr(lr, rr),
|
||||||
(&ExprAssignOp(ref lo, ref ll, ref lr), &ExprAssignOp(ref ro, ref rl, ref rr)) => {
|
(&ExprAssignOp(ref lo, ref ll, ref lr), &ExprAssignOp(ref ro, ref rl, ref rr)) => {
|
||||||
lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
|
lo.node == ro.node && self.eq_expr(ll, rl) && self.eq_expr(lr, rr)
|
||||||
@ -81,7 +81,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
(&ExprBreak(li, ref le), &ExprBreak(ri, ref re)) => {
|
(&ExprBreak(li, ref le), &ExprBreak(ri, ref re)) => {
|
||||||
both(&li, &ri, |l, r| l.name.as_str() == r.name.as_str()) && both(le, re, |l, r| self.eq_expr(l, r))
|
both(&li.ident, &ri.ident, |l, r| l.node.name.as_str() == r.node.name.as_str()) && both(le, re, |l, r| self.eq_expr(l, r))
|
||||||
},
|
},
|
||||||
(&ExprBox(ref l), &ExprBox(ref r)) => self.eq_expr(l, r),
|
(&ExprBox(ref l), &ExprBox(ref r)) => self.eq_expr(l, r),
|
||||||
(&ExprCall(ref l_fun, ref l_args), &ExprCall(ref r_fun, ref r_args)) => {
|
(&ExprCall(ref l_fun, ref l_args), &ExprCall(ref r_fun, ref r_args)) => {
|
||||||
@ -310,8 +310,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
|||||||
ExprAgain(i) => {
|
ExprAgain(i) => {
|
||||||
let c: fn(_) -> _ = ExprAgain;
|
let c: fn(_) -> _ = ExprAgain;
|
||||||
c.hash(&mut self.s);
|
c.hash(&mut self.s);
|
||||||
if let Some(i) = i {
|
if let Some(i) = i.ident {
|
||||||
self.hash_name(&i.name);
|
self.hash_name(&i.node.name);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprAssign(ref l, ref r) => {
|
ExprAssign(ref l, ref r) => {
|
||||||
@ -342,8 +342,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
|||||||
ExprBreak(i, ref j) => {
|
ExprBreak(i, ref j) => {
|
||||||
let c: fn(_, _) -> _ = ExprBreak;
|
let c: fn(_, _) -> _ = ExprBreak;
|
||||||
c.hash(&mut self.s);
|
c.hash(&mut self.s);
|
||||||
if let Some(i) = i {
|
if let Some(i) = i.ident {
|
||||||
self.hash_name(&i.name);
|
self.hash_name(&i.node.name);
|
||||||
}
|
}
|
||||||
if let Some(ref j) = *j {
|
if let Some(ref j) = *j {
|
||||||
self.hash_expr(&*j);
|
self.hash_expr(&*j);
|
||||||
|
@ -900,7 +900,7 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {
|
|||||||
Def::AssociatedConst(id) |
|
Def::AssociatedConst(id) |
|
||||||
Def::Local(id) |
|
Def::Local(id) |
|
||||||
Def::Upvar(id, ..) |
|
Def::Upvar(id, ..) |
|
||||||
Def::Macro(id) => Some(id),
|
Def::Macro(id, _) => Some(id),
|
||||||
|
|
||||||
Def::Label(..) | Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => None,
|
Def::Label(..) | Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => None,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user