Skip to content

Commit

Permalink
remove redundant wrapping of return types of allow_internal_unstable(…
Browse files Browse the repository at this point in the history
…) and rustc_allow_const_fn_unstable()
  • Loading branch information
matthiaskrgr committed Feb 21, 2021
1 parent a9b90c0 commit da9a588
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,8 @@ impl SyntaxExtension {
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) {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_mir/src/transform/check_consts/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_passes/src/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
// 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 {
Expand Down

0 comments on commit da9a588

Please sign in to comment.