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).
|
||||
fn is_break_expr(expr: &Expr) -> bool {
|
||||
match expr.node {
|
||||
ExprBreak(None, _) => true,
|
||||
ExprBreak(dest, _) if dest.ident.is_none() => true,
|
||||
ExprBlock(ref b) => {
|
||||
match extract_first_expr(b) {
|
||||
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> {
|
||||
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
|
||||
match expr.node {
|
||||
hir::ExprBreak(Some(label), _) |
|
||||
hir::ExprAgain(Some(label)) => {
|
||||
self.labels.remove(&label.name.as_str());
|
||||
hir::ExprBreak(destination, _) |
|
||||
hir::ExprAgain(destination) => {
|
||||
if let Some(label) = destination.ident {
|
||||
self.labels.remove(&label.node.name.as_str());
|
||||
}
|
||||
},
|
||||
hir::ExprLoop(_, Some(label), _) |
|
||||
hir::ExprWhile(_, _, Some(label)) => {
|
||||
|
@ -68,7 +68,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
||||
|
||||
match (&left.node, &right.node) {
|
||||
(&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),
|
||||
(&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)
|
||||
@ -81,7 +81,7 @@ impl<'a, 'tcx: 'a> SpanlessEq<'a, 'tcx> {
|
||||
})
|
||||
},
|
||||
(&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),
|
||||
(&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) => {
|
||||
let c: fn(_) -> _ = ExprAgain;
|
||||
c.hash(&mut self.s);
|
||||
if let Some(i) = i {
|
||||
self.hash_name(&i.name);
|
||||
if let Some(i) = i.ident {
|
||||
self.hash_name(&i.node.name);
|
||||
}
|
||||
},
|
||||
ExprAssign(ref l, ref r) => {
|
||||
@ -342,8 +342,8 @@ impl<'a, 'tcx: 'a> SpanlessHash<'a, 'tcx> {
|
||||
ExprBreak(i, ref j) => {
|
||||
let c: fn(_, _) -> _ = ExprBreak;
|
||||
c.hash(&mut self.s);
|
||||
if let Some(i) = i {
|
||||
self.hash_name(&i.name);
|
||||
if let Some(i) = i.ident {
|
||||
self.hash_name(&i.node.name);
|
||||
}
|
||||
if let Some(ref j) = *j {
|
||||
self.hash_expr(&*j);
|
||||
|
@ -900,7 +900,7 @@ pub fn opt_def_id(def: Def) -> Option<DefId> {
|
||||
Def::AssociatedConst(id) |
|
||||
Def::Local(id) |
|
||||
Def::Upvar(id, ..) |
|
||||
Def::Macro(id) => Some(id),
|
||||
Def::Macro(id, _) => Some(id),
|
||||
|
||||
Def::Label(..) | Def::PrimTy(..) | Def::SelfTy(..) | Def::Err => None,
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user