remove unneccessary wrapping of return value of allow_unstable(), it would always return Some(thing)

This commit is contained in:
Matthias Krüger 2021-02-21 12:52:51 +01:00
parent ed58a2b03b
commit 4cb649bdb1

View File

@ -1036,21 +1036,21 @@ pub fn allow_internal_unstable<'a>(
sess: &'a Session, sess: &'a Session,
attrs: &'a [Attribute], attrs: &'a [Attribute],
) -> Option<impl Iterator<Item = Symbol> + 'a> { ) -> Option<impl Iterator<Item = Symbol> + 'a> {
allow_unstable(sess, attrs, sym::allow_internal_unstable) Some(allow_unstable(sess, attrs, sym::allow_internal_unstable))
} }
pub fn rustc_allow_const_fn_unstable<'a>( pub fn rustc_allow_const_fn_unstable<'a>(
sess: &'a Session, sess: &'a Session,
attrs: &'a [Attribute], attrs: &'a [Attribute],
) -> Option<impl Iterator<Item = Symbol> + 'a> { ) -> Option<impl Iterator<Item = Symbol> + 'a> {
allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable) Some(allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable))
} }
fn allow_unstable<'a>( fn allow_unstable<'a>(
sess: &'a Session, sess: &'a Session,
attrs: &'a [Attribute], attrs: &'a [Attribute],
symbol: Symbol, symbol: Symbol,
) -> Option<impl Iterator<Item = Symbol> + 'a> { ) -> impl Iterator<Item = Symbol> + 'a {
let attrs = sess.filter_by_name(attrs, symbol); let attrs = sess.filter_by_name(attrs, symbol);
let list = attrs let list = attrs
.filter_map(move |attr| { .filter_map(move |attr| {
@ -1064,7 +1064,7 @@ fn allow_unstable<'a>(
}) })
.flatten(); .flatten();
Some(list.into_iter().filter_map(move |it| { list.into_iter().filter_map(move |it| {
let name = it.ident().map(|ident| ident.name); let name = it.ident().map(|ident| ident.name);
if name.is_none() { if name.is_none() {
sess.diagnostic().span_err( sess.diagnostic().span_err(
@ -1073,5 +1073,5 @@ fn allow_unstable<'a>(
); );
} }
name name
})) })
} }