-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rustup to rustc 1.36.0-nightly (acc7e652f 2019-05-10) #4080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e7af60f
6289774
f40c77a
09a9329
da8b56d
69b1da4
c9ed92c
26ebc3e
5661e59
0499184
19cfb84
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ use rustc_data_structures::sync::Lrc; | |
use rustc_errors::Applicability; | ||
use syntax::ast::{self, LitKind}; | ||
use syntax::attr; | ||
use syntax::ext::hygiene::ExpnFormat; | ||
use syntax::source_map::{Span, DUMMY_SP}; | ||
use syntax::symbol::{keywords, Symbol}; | ||
|
||
|
@@ -90,7 +91,15 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool { | |
|
||
/// Returns `true` if this `expn_info` was expanded by any macro. | ||
pub fn in_macro(span: Span) -> bool { | ||
span.ctxt().outer().expn_info().is_some() | ||
if let Some(info) = span.ctxt().outer().expn_info() { | ||
if let ExpnFormat::CompilerDesugaring(..) = info.format { | ||
false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we actually want this in the macro check? As you can see it inadvertently fixed a bug in The nonminimal bool test fails without this because the visitor bails when it sees the if desugaring. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we may be able to do this more fine-grained in the future by passing in more than a span (e.g. a |
||
} else { | ||
true | ||
} | ||
} else { | ||
false | ||
} | ||
} | ||
|
||
// If the snippet is empty, it's an attribute that was inserted during macro | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#[allow(clippy::all)] | ||
|
||
fn main() { | ||
#[clippy::author] | ||
let _ = if true { | ||
1 == 1; | ||
} else { | ||
2 == 2; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
if_chain! { | ||
if let StmtKind::Local(ref local) = stmt.node; | ||
if let Some(ref init) = local.init; | ||
if let Some((ref cond, ref then, Some(else_))) = higher::if_block(&init); | ||
if let ExprKind::Block(ref block) = else_.node; | ||
if let StmtKind::Semi(ref e, _) = block.node | ||
if let ExprKind::Binary(ref op, ref left, ref right) = e.node; | ||
if BinOpKind::Eq == op.node; | ||
if let ExprKind::Lit(ref lit) = left.node; | ||
if let LitKind::Int(2, _) = lit.node; | ||
if let ExprKind::Lit(ref lit1) = right.node; | ||
if let LitKind::Int(2, _) = lit1.node; | ||
if let ExprKind::Lit(ref lit2) = cond.node; | ||
if let LitKind::Bool(true) = lit2.node; | ||
if let ExprKind::Block(ref block1) = then.node; | ||
if let StmtKind::Semi(ref e1, _) = block1.node | ||
if let ExprKind::Binary(ref op1, ref left1, ref right1) = e1.node; | ||
if BinOpKind::Eq == op1.node; | ||
if let ExprKind::Lit(ref lit3) = left1.node; | ||
if let LitKind::Int(1, _) = lit3.node; | ||
if let ExprKind::Lit(ref lit4) = right1.node; | ||
if let LitKind::Int(1, _) = lit4.node; | ||
if let PatKind::Wild = local.pat.node; | ||
then { | ||
// report your lint here | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diff is basically just me adding this if let and sticking the rest of the function in the else.