From da9a588d4fda02c2fe6d52db651ec4c83b2b3e49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Feb 2021 18:11:27 +0100 Subject: [PATCH] remove redundant wrapping of return types of allow_internal_unstable() and rustc_allow_const_fn_unstable() --- compiler/rustc_attr/src/builtin.rs | 8 ++++---- compiler/rustc_expand/src/base.rs | 4 ++-- compiler/rustc_mir/src/transform/check_consts/mod.rs | 3 +-- compiler/rustc_passes/src/check_const.rs | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_attr/src/builtin.rs b/compiler/rustc_attr/src/builtin.rs index 378911f0c4e..24da75114a6 100644 --- a/compiler/rustc_attr/src/builtin.rs +++ b/compiler/rustc_attr/src/builtin.rs @@ -1035,15 +1035,15 @@ pub fn find_transparency( pub fn allow_internal_unstable<'a>( sess: &'a Session, attrs: &'a [Attribute], -) -> Option + 'a> { - Some(allow_unstable(sess, attrs, sym::allow_internal_unstable)) +) -> impl Iterator + 'a { + allow_unstable(sess, attrs, sym::allow_internal_unstable) } pub fn rustc_allow_const_fn_unstable<'a>( sess: &'a Session, attrs: &'a [Attribute], -) -> Option + 'a> { - Some(allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable)) +) -> impl Iterator + 'a { + allow_unstable(sess, attrs, sym::rustc_allow_const_fn_unstable) } fn allow_unstable<'a>( diff --git a/compiler/rustc_expand/src/base.rs b/compiler/rustc_expand/src/base.rs index e3dc793a7fa..ca304c05cdc 100644 --- a/compiler/rustc_expand/src/base.rs +++ b/compiler/rustc_expand/src/base.rs @@ -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::>().into()); + let allow_internal_unstable = + Some(attr::allow_internal_unstable(sess, &attrs).collect::>().into()); let mut local_inner_macros = false; if let Some(macro_export) = sess.find_by_name(attrs, sym::macro_export) { diff --git a/compiler/rustc_mir/src/transform/check_consts/mod.rs b/compiler/rustc_mir/src/transform/check_consts/mod.rs index ba7bea4ac54..19aee033a69 100644 --- a/compiler/rustc_mir/src/transform/check_consts/mod.rs +++ b/compiler/rustc_mir/src/transform/check_consts/mod.rs @@ -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". diff --git a/compiler/rustc_passes/src/check_const.rs b/compiler/rustc_passes/src/check_const.rs index 9328f7cd9ec..da713566c31 100644 --- a/compiler/rustc_passes/src/check_const.rs +++ b/compiler/rustc_passes/src/check_const.rs @@ -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 {