Skip to content

Commit 715c19e

Browse files
committed
Refactor get_word_attr to return only Option
1 parent a118ee2 commit 715c19e

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/librustdoc/clean/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2163,7 +2163,8 @@ fn clean_use_statement(
21632163
return Vec::new();
21642164
}
21652165

2166-
let (doc_meta_item, please_inline) = import.attrs.lists(sym::doc).get_word_attr(sym::inline);
2166+
let doc_meta_item = import.attrs.lists(sym::doc).get_word_attr(sym::inline);
2167+
let please_inline = doc_meta_item.is_some();
21672168
let pub_underscore = import.vis.node.is_pub() && name == kw::Underscore;
21682169

21692170
if pub_underscore && please_inline {

src/librustdoc/clean/types.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ impl AttributesExt for [ast::Attribute] {
438438
crate trait NestedAttributesExt {
439439
/// Returns `true` if the attribute list contains a specific `Word`
440440
fn has_word(self, word: Symbol) -> bool;
441-
fn get_word_attr(self, word: Symbol) -> (Option<ast::NestedMetaItem>, bool);
441+
fn get_word_attr(self, word: Symbol) -> Option<ast::NestedMetaItem>;
442442
}
443443

444444
impl<I: Iterator<Item = ast::NestedMetaItem> + IntoIterator<Item = ast::NestedMetaItem>>
@@ -448,11 +448,8 @@ impl<I: Iterator<Item = ast::NestedMetaItem> + IntoIterator<Item = ast::NestedMe
448448
self.into_iter().any(|attr| attr.is_word() && attr.has_name(word))
449449
}
450450

451-
fn get_word_attr(mut self, word: Symbol) -> (Option<ast::NestedMetaItem>, bool) {
452-
match self.find(|attr| attr.is_word() && attr.has_name(word)) {
453-
Some(a) => (Some(a), true),
454-
None => (None, false),
455-
}
451+
fn get_word_attr(mut self, word: Symbol) -> Option<ast::NestedMetaItem> {
452+
self.find(|attr| attr.is_word() && attr.has_name(word))
456453
}
457454
}
458455

0 commit comments

Comments
 (0)