Rollup merge of #59419 - frewsxcv:frewsxcv-qu, r=varkor

Utilize `?` instead of `return None`.

None
This commit is contained in:
Mazdak Farrokhzad
2019-03-26 09:05:53 +01:00
committed by GitHub
3 changed files with 4 additions and 13 deletions
+2 -4
View File
@@ -239,10 +239,8 @@ pub fn write(&self, out: &mut [u8]) -> Option<usize> {
let mut written = self.sign.len();
for part in self.parts {
match part.write(&mut out[written..]) {
Some(len) => { written += len; }
None => { return None; }
}
let len = part.write(&mut out[written..])?;
written += len;
}
Some(written)
}
+1 -5
View File
@@ -292,11 +292,7 @@ impl<'cx, 'gcx, 'tcx> Iterator for SupertraitDefIds<'cx, 'gcx, 'tcx> {
type Item = DefId;
fn next(&mut self) -> Option<DefId> {
let def_id = match self.stack.pop() {
Some(def_id) => def_id,
None => { return None; }
};
let def_id = self.stack.pop()?;
let predicates = self.tcx.super_predicates_of(def_id);
let visited = &mut self.visited;
self.stack.extend(
+1 -4
View File
@@ -5318,10 +5318,7 @@ fn could_remove_semicolon(
) -> Option<Span> {
// Be helpful when the user wrote `{... expr;}` and
// taking the `;` off is enough to fix the error.
let last_stmt = match blk.stmts.last() {
Some(s) => s,
None => return None,
};
let last_stmt = blk.stmts.last()?;
let last_expr = match last_stmt.node {
hir::StmtKind::Semi(ref e) => e,
_ => return None,