Skip to content

Commit ecae6e4

Browse files
committed
use question mark operator in a few places.
1 parent 9381e81 commit ecae6e4

File tree

4 files changed

+6
-15
lines changed

4 files changed

+6
-15
lines changed

src/libcore/iter/adapters/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1894,9 +1894,7 @@ where
18941894
let to_skip = self.n;
18951895
self.n = 0;
18961896
// nth(n) skips n+1
1897-
if self.iter.nth(to_skip - 1).is_none() {
1898-
return None;
1899-
}
1897+
self.iter.nth(to_skip - 1)?;
19001898
}
19011899
self.iter.nth(n)
19021900
}
@@ -1916,9 +1914,7 @@ where
19161914
fn last(mut self) -> Option<I::Item> {
19171915
if self.n > 0 {
19181916
// nth(n) skips n+1
1919-
if self.iter.nth(self.n - 1).is_none() {
1920-
return None;
1921-
}
1917+
self.iter.nth(self.n - 1)?;
19221918
}
19231919
self.iter.last()
19241920
}

src/librustc/hir/map/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,8 @@ impl<'hir> Map<'hir> {
338338
Node::Variant(_) => DefKind::Variant,
339339
Node::Ctor(variant_data) => {
340340
// FIXME(eddyb) is this even possible, if we have a `Node::Ctor`?
341-
if variant_data.ctor_hir_id().is_none() {
342-
return None;
343-
}
341+
variant_data.ctor_hir_id()?;
342+
344343
let ctor_of = match self.find(self.get_parent_node(hir_id)) {
345344
Some(Node::Item(..)) => def::CtorOf::Struct,
346345
Some(Node::Variant(..)) => def::CtorOf::Variant,

src/librustc/ty/instance.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ impl<'tcx> Instance<'tcx> {
115115
}
116116

117117
// If this a non-generic instance, it cannot be a shared monomorphization.
118-
if self.substs.non_erasable_generics().next().is_none() {
119-
return None;
120-
}
118+
self.substs.non_erasable_generics().next()?;
121119

122120
match self.def {
123121
InstanceDef::Item(def_id) => tcx

src/librustc_incremental/persist/work_product.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ pub fn copy_cgu_workproducts_to_incr_comp_cache_dir(
1313
files: &[(WorkProductFileKind, PathBuf)],
1414
) -> Option<(WorkProductId, WorkProduct)> {
1515
debug!("copy_cgu_workproducts_to_incr_comp_cache_dir({:?},{:?})", cgu_name, files);
16-
if sess.opts.incremental.is_none() {
17-
return None;
18-
}
16+
sess.opts.incremental.as_ref()?;
1917

2018
let saved_files = files
2119
.iter()

0 commit comments

Comments
 (0)