diff options
| author | Colin Wallace <colin@mooooo.ooo> | 2018-07-23 22:05:45 -0700 |
|---|---|---|
| committer | Colin Wallace <colin@mooooo.ooo> | 2018-07-23 22:05:45 -0700 |
| commit | 10d82137b3fe45a3b0f0c1bd9080ee46b5259ac1 (patch) | |
| tree | e619e8f0758072b4bd16293c0ac8cdacd53d4efc | |
| parent | 727bd7de7e6332482ee2765d46bfd00d89386d4b (diff) | |
| download | rust-10d82137b3fe45a3b0f0c1bd9080ee46b5259ac1.tar.gz rust-10d82137b3fe45a3b0f0c1bd9080ee46b5259ac1.zip | |
librustc: Prefer `Option::map`/etc over `match` where applicable
| -rw-r--r-- | src/librustc/traits/on_unimplemented.rs | 9 | ||||
| -rw-r--r-- | src/librustc/ty/mod.rs | 13 | ||||
| -rw-r--r-- | src/librustc_metadata/locator.rs | 17 |
3 files changed, 16 insertions, 23 deletions
diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index 925d3504f75..e1395c3fa44 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -190,11 +190,10 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { for command in self.subcommands.iter().chain(Some(self)).rev() { if let Some(ref condition) = command.condition { if !attr::eval_condition(condition, &tcx.sess.parse_sess, &mut |c| { - options.contains(&(c.name().as_str().to_string(), - match c.value_str().map(|s| s.as_str().to_string()) { - Some(s) => Some(s), - None => None - })) + options.contains(&( + c.name().as_str().to_string(), + c.value_str().map(|s| s.as_str().to_string()) + )) }) { debug!("evaluate: skipping {:?} due to condition", command); continue diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index bd24b93f029..c2795bae010 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2697,15 +2697,12 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.opt_associated_item(def_id) }; - match item { - Some(trait_item) => { - match trait_item.container { - TraitContainer(_) => None, - ImplContainer(def_id) => Some(def_id), - } + item.and_then(|trait_item| + match trait_item.container { + TraitContainer(_) => None, + ImplContainer(def_id) => Some(def_id), } - None => None - } + ) } /// Looks up the span of `impl_did` if the impl is local; otherwise returns `Err` diff --git a/src/librustc_metadata/locator.rs b/src/librustc_metadata/locator.rs index b747624338c..42af5db8294 100644 --- a/src/librustc_metadata/locator.rs +++ b/src/librustc_metadata/locator.rs @@ -824,17 +824,14 @@ impl<'a> Context<'a> { if rlib.is_none() && rmeta.is_none() && dylib.is_none() { return None; } - match slot { - Some((_, metadata)) => { - Some(Library { - dylib, - rlib, - rmeta, - metadata, - }) + slot.map(|(_, metadata)| + Library { + dylib, + rlib, + rmeta, + metadata, } - None => None, - } + ) } } |
