remove redundant wrapping of return types of allow_internal_unstable() and rustc_allow_const_fn_unstable()

This commit is contained in:
Matthias Krüger 2021-02-21 18:11:27 +01:00
parent a9b90c02a2
commit da9a588d4f
4 changed files with 8 additions and 9 deletions

View File

@ -1035,15 +1035,15 @@ pub fn find_transparency(
pub fn allow_internal_unstable<'a>(
sess: &'a Session,
attrs: &'a [Attribute],
) -> Option<impl Iterator<Item = Symbol> + 'a> {
Some(allow_unstable(sess, attrs, sym::allow_internal_unstable))
) -> impl Iterator<Item = Symbol> + 'a {
allow_unstable(sess, attrs, sym::allow_internal_unstable)
}
pub fn rustc_allow_const_fn_unstable<'a>(
sess: &'a Session,
attrs: &'a [Attribute],
) -> Option<impl Iterator<Item = Symbol> + 'a> {
Some(allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable))
) -> impl Iterator<Item = Symbol> + 'a {
allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable)
}
fn allow_unstable<'a>(

View File

@ -756,8 +756,8 @@ pub fn new(
name: Symbol,
attrs: &[ast::Attribute],
) -> SyntaxExtension {
let allow_internal_unstable = attr::allow_internal_unstable(sess, &attrs)
.map(|features| features.collect::<Vec<Symbol>>().into());
let allow_internal_unstable =
Some(attr::allow_internal_unstable(sess, &attrs).collect::<Vec<Symbol>>().into());
let mut local_inner_macros = false;
if let Some(macro_export) = sess.find_by_name(attrs, sym::macro_export) {

View File

@ -85,8 +85,7 @@ pub fn rustc_allow_const_fn_unstable(
feature_gate: Symbol,
) -> bool {
let attrs = tcx.get_attrs(def_id);
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs)
.map_or(false, |mut features| features.any(|name| name == feature_gate))
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs).any(|name| name == feature_gate)
}
// Returns `true` if the given `const fn` is "const-stable".

View File

@ -106,7 +106,7 @@ fn const_check_violated(&self, expr: NonConstExpr, span: Span) {
// However, we cannot allow stable `const fn`s to use unstable features without an explicit
// opt-in via `rustc_allow_const_fn_unstable`.
attr::rustc_allow_const_fn_unstable(&tcx.sess, &tcx.get_attrs(def_id))
.map_or(false, |mut features| features.any(|name| name == feature_gate))
.any(|name| name == feature_gate)
};
match required_gates {