Skip to content

Commit da9a588

Browse files
committed
remove redundant wrapping of return types of allow_internal_unstable() and rustc_allow_const_fn_unstable()
1 parent a9b90c0 commit da9a588

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

Diff for: compiler/rustc_attr/src/builtin.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1035,15 +1035,15 @@ pub fn find_transparency(
10351035
pub fn allow_internal_unstable<'a>(
10361036
sess: &'a Session,
10371037
attrs: &'a [Attribute],
1038-
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1039-
Some(allow_unstable(sess, attrs, sym::allow_internal_unstable))
1038+
) -> impl Iterator<Item = Symbol> + 'a {
1039+
allow_unstable(sess, attrs, sym::allow_internal_unstable)
10401040
}
10411041

10421042
pub fn rustc_allow_const_fn_unstable<'a>(
10431043
sess: &'a Session,
10441044
attrs: &'a [Attribute],
1045-
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1046-
Some(allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable))
1045+
) -> impl Iterator<Item = Symbol> + 'a {
1046+
allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable)
10471047
}
10481048

10491049
fn allow_unstable<'a>(

Diff for: compiler/rustc_expand/src/base.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ impl SyntaxExtension {
756756
name: Symbol,
757757
attrs: &[ast::Attribute],
758758
) -> SyntaxExtension {
759-
let allow_internal_unstable = attr::allow_internal_unstable(sess, &attrs)
760-
.map(|features| features.collect::<Vec<Symbol>>().into());
759+
let allow_internal_unstable =
760+
Some(attr::allow_internal_unstable(sess, &attrs).collect::<Vec<Symbol>>().into());
761761

762762
let mut local_inner_macros = false;
763763
if let Some(macro_export) = sess.find_by_name(attrs, sym::macro_export) {

Diff for: compiler/rustc_mir/src/transform/check_consts/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ pub fn rustc_allow_const_fn_unstable(
8585
feature_gate: Symbol,
8686
) -> bool {
8787
let attrs = tcx.get_attrs(def_id);
88-
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs)
89-
.map_or(false, |mut features| features.any(|name| name == feature_gate))
88+
attr::rustc_allow_const_fn_unstable(&tcx.sess, attrs).any(|name| name == feature_gate)
9089
}
9190

9291
// Returns `true` if the given `const fn` is "const-stable".

Diff for: compiler/rustc_passes/src/check_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'tcx> CheckConstVisitor<'tcx> {
106106
// However, we cannot allow stable `const fn`s to use unstable features without an explicit
107107
// opt-in via `rustc_allow_const_fn_unstable`.
108108
attr::rustc_allow_const_fn_unstable(&tcx.sess, &tcx.get_attrs(def_id))
109-
.map_or(false, |mut features| features.any(|name| name == feature_gate))
109+
.any(|name| name == feature_gate)
110110
};
111111

112112
match required_gates {

0 commit comments

Comments
 (0)