diff options
| author | bors <bors@rust-lang.org> | 2016-07-04 02:18:46 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-04 02:18:46 -0700 |
| commit | d508de6cf7c7bb9b5057ee63432dbbc899209101 (patch) | |
| tree | 972fd7fd823fc411d3d3a175bbae46dee2f6d71b /src/librustdoc/html | |
| parent | d98da85c5cfd2546ac711701cecc05b093242a26 (diff) | |
| parent | d37edef9dd088d953c5e272db37686a338c31778 (diff) | |
| download | rust-d508de6cf7c7bb9b5057ee63432dbbc899209101.tar.gz rust-d508de6cf7c7bb9b5057ee63432dbbc899209101.zip | |
Auto merge of #34638 - zackmdavis:if_let_over_none_empty_block_arm, r=jseyfried
prefer `if let` to match with `None => {}` arm in some places
This is a spiritual succesor to #34268 / 8531d581, in which we replaced a
number of matches of None to the unit value with `if let` conditionals
where it was judged that this made for clearer/simpler code (as would be
recommended by Manishearth/rust-clippy's `single_match` lint). The same
rationale applies to matches of None to the empty block.
----
r? @jseyfried
Diffstat (limited to 'src/librustdoc/html')
| -rw-r--r-- | src/librustdoc/html/format.rs | 20 | ||||
| -rw-r--r-- | src/librustdoc/html/highlight.rs | 5 | ||||
| -rw-r--r-- | src/librustdoc/html/render.rs | 36 |
3 files changed, 25 insertions, 36 deletions
diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 760e84622cf..77c4a0f8174 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -131,9 +131,8 @@ impl fmt::Display for clean::Generics { write!(f, ": {}", TyParamBounds(&tp.bounds))?; } - match tp.default { - Some(ref ty) => { write!(f, " = {}", ty)?; }, - None => {} + if let Some(ref ty) = tp.default { + write!(f, " = {}", ty)?; }; } } @@ -401,15 +400,12 @@ fn primitive_link(f: &mut fmt::Formatter, } (_, render::Unknown) => None, }; - match loc { - Some(root) => { - write!(f, "<a class='primitive' href='{}{}/primitive.{}.html'>", - root, - path.0.first().unwrap(), - prim.to_url_str())?; - needs_termination = true; - } - None => {} + if let Some(root) = loc { + write!(f, "<a class='primitive' href='{}{}/primitive.{}.html'>", + root, + path.0.first().unwrap(), + prim.to_url_str())?; + needs_termination = true; } } None => {} diff --git a/src/librustdoc/html/highlight.rs b/src/librustdoc/html/highlight.rs index 2e2f9989773..84e98a67391 100644 --- a/src/librustdoc/html/highlight.rs +++ b/src/librustdoc/html/highlight.rs @@ -352,9 +352,8 @@ fn write_header(class: Option<&str>, out: &mut Write) -> io::Result<()> { write!(out, "<pre ")?; - match id { - Some(id) => write!(out, "id='{}' ", id)?, - None => {} + if let Some(id) = id { + write!(out, "id='{}' ", id)?; } write!(out, "class='rust {}'>\n", class.unwrap_or("")) } diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 9f2b33c0282..acf867561a6 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -589,19 +589,16 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> String { // Attach all orphan methods to the type's definition if the type // has since been learned. for &(did, ref item) in orphan_methods { - match paths.get(&did) { - Some(&(ref fqp, _)) => { - search_index.push(IndexItem { - ty: shortty(item), - name: item.name.clone().unwrap(), - path: fqp[..fqp.len() - 1].join("::"), - desc: Escape(&shorter(item.doc_value())).to_string(), - parent: Some(did), - parent_idx: None, - search_type: get_index_search_type(&item), - }); - }, - None => {} + if let Some(&(ref fqp, _)) = paths.get(&did) { + search_index.push(IndexItem { + ty: shortty(item), + name: item.name.clone().unwrap(), + path: fqp[..fqp.len() - 1].join("::"), + desc: Escape(&shorter(item.doc_value())).to_string(), + parent: Some(did), + parent_idx: None, + search_type: get_index_search_type(&item), + }); } } @@ -2093,15 +2090,12 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, <h2 id='implementors'>Implementors</h2> <ul class='item-list' id='implementors-list'> ")?; - match cache.implementors.get(&it.def_id) { - Some(implementors) => { - for i in implementors { - write!(w, "<li><code>")?; - fmt_impl_for_trait_page(&i.impl_, w)?; - writeln!(w, "</code></li>")?; - } + if let Some(implementors) = cache.implementors.get(&it.def_id) { + for i in implementors { + write!(w, "<li><code>")?; + fmt_impl_for_trait_page(&i.impl_, w)?; + writeln!(w, "</code></li>")?; } - None => {} } write!(w, "</ul>")?; write!(w, r#"<script type="text/javascript" async |
