-
Notifications
You must be signed in to change notification settings - Fork 1.7k
replace if_let_chain with if_chain #2154
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
Conversation
The tests don't get very far on my machine due to some procedural macro BS, so I figured travis could have a crack at it. |
Rebased on #2153 temporarily. |
4ceccc4
to
8550397
Compare
I merged #2153, can you rebase over master? |
if_chain! { | ||
if let Some(inner) = expr_block(then); | ||
if let ast::ExprKind::If(ref check_inner, ref content, None) = inner.node; | ||
then { |
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.
I think I'd prefer it if we didn't have to use an additional indentation level. Maybe use something like
if_chain! {
...
then {
...
}}
Opinions?
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.
I went with the indentation used in the crate's examples: https://docs.rs/if_chain/0.1.2/if_chain/
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.
Ok, I can get behind staying with the official style
Rebased. |
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.
You lost all comments in the chains. Are they not supported?
I think I can fix that. At least for line comments it should be easy... |
I recovered the comments and linebreaks. And my frankenstein untry learned to handle nested chains. |
@@ -117,40 +117,41 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NewWithoutDefault { | |||
if decl.inputs.is_empty() && name == "new" && cx.access_levels.is_reachable(id) { | |||
let self_ty = cx.tcx | |||
.type_of(cx.tcx.hir.local_def_id(cx.tcx.hir.get_parent(id))); | |||
if_let_chain!{[ | |||
same_tys(cx, self_ty, return_ty(cx, id)), |
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.
Indentation is wrong here, but I didn't cause that...
Awesome! Another code duplication bites the dust |
Fixes #2150. Done mostly mechanically with a hacked-up version of @japaric's untry.