Skip to content

Utilize ? instead of return None. #59419

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

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/libcore/num/flt2dec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,8 @@ impl<'a> Formatted<'a> {

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)
}
Expand Down
6 changes: 1 addition & 5 deletions src/librustc/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5318,10 +5318,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
) -> 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,
Expand Down