From 0ec14089a9b62b9e3cda6e84f6ac598ea3778933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 2 Mar 2020 00:09:17 +0100 Subject: [PATCH] Don't convert Results to Options just for matching. --- src/librustc_resolve/imports.rs | 4 ++-- src/libstd/net/addr.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/imports.rs b/src/librustc_resolve/imports.rs index 1d502e52de4..73bc038ea15 100644 --- a/src/librustc_resolve/imports.rs +++ b/src/librustc_resolve/imports.rs @@ -1252,7 +1252,7 @@ fn finalize_import( // this may resolve to either a value or a type, but for documentation // purposes it's good enough to just favor one over the other. self.r.per_ns(|this, ns| { - if let Some(binding) = source_bindings[ns].get().ok() { + if let Ok(binding) = source_bindings[ns].get() { this.import_res_map.entry(directive.id).or_default()[ns] = Some(binding.res()); } }); @@ -1293,7 +1293,7 @@ fn check_for_redundant_imports( let mut redundant_span = PerNS { value_ns: None, type_ns: None, macro_ns: None }; self.r.per_ns(|this, ns| { - if let Some(binding) = source_bindings[ns].get().ok() { + if let Ok(binding) = source_bindings[ns].get() { if binding.res() == Res::Err { return; } diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index a59d7f0263b..57cba6b1f7a 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -901,7 +901,7 @@ impl ToSocketAddrs for str { type Iter = vec::IntoIter; fn to_socket_addrs(&self) -> io::Result> { // try to parse as a regular SocketAddr first - if let Some(addr) = self.parse().ok() { + if let Ok(addr) = self.parse() { return Ok(vec![addr].into_iter()); }