prefer if let
to match with None => ()
arm in some places
Casual grepping revealed some places in the codebase (some of which
antedated `if let`'s December 2014 stabilization in c200ae5a
) where we
were using a match with a `None => ()` arm where (in the present
author's opinion) an `if let` conditional would be more readable. (Other
places where matching to the unit value did seem to better express the
intent were left alone.)
It's likely that we don't care about making such trivial,
non-functional, sheerly æsthetic changes.
But if we do, this is a patch.
This commit is contained in:
parent
6551acc8e5
commit
8531d58104
11 changed files with 98 additions and 136 deletions
|
@ -5430,18 +5430,15 @@ impl<'a> Parser<'a> {
|
|||
name: String,
|
||||
id_sp: Span) -> PResult<'a, (ast::ItemKind, Vec<ast::Attribute> )> {
|
||||
let mut included_mod_stack = self.sess.included_mod_stack.borrow_mut();
|
||||
match included_mod_stack.iter().position(|p| *p == path) {
|
||||
Some(i) => {
|
||||
let mut err = String::from("circular modules: ");
|
||||
let len = included_mod_stack.len();
|
||||
for p in &included_mod_stack[i.. len] {
|
||||
err.push_str(&p.to_string_lossy());
|
||||
err.push_str(" -> ");
|
||||
}
|
||||
err.push_str(&path.to_string_lossy());
|
||||
return Err(self.span_fatal(id_sp, &err[..]));
|
||||
if let Some(i) = included_mod_stack.iter().position(|p| *p == path) {
|
||||
let mut err = String::from("circular modules: ");
|
||||
let len = included_mod_stack.len();
|
||||
for p in &included_mod_stack[i.. len] {
|
||||
err.push_str(&p.to_string_lossy());
|
||||
err.push_str(" -> ");
|
||||
}
|
||||
None => ()
|
||||
err.push_str(&path.to_string_lossy());
|
||||
return Err(self.span_fatal(id_sp, &err[..]));
|
||||
}
|
||||
included_mod_stack.push(path.clone());
|
||||
drop(included_mod_stack);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue