Rollup merge of #102556 - WaffleLapkin:implied_by_btree_new, r=Mark-Simulacrum

Make `feature(const_btree_len)` implied by `feature(const_btree_new)`

...this should fix code that used the old feature that was changed in #102197

cc ```@davidtwco``` it seems like tidy doesn't check `implied_by`, should it?
This commit is contained in:
Dylan DPC 2022-10-02 20:42:22 +05:30 committed by GitHub
commit 890a327c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 5 deletions

View File

@ -2392,7 +2392,11 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
/// ``` /// ```
#[must_use] #[must_use]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_btree_len", issue = "71835")] #[rustc_const_unstable(
feature = "const_btree_len",
issue = "71835",
implied_by = "const_btree_new"
)]
pub const fn len(&self) -> usize { pub const fn len(&self) -> usize {
self.length self.length
} }
@ -2413,7 +2417,11 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
/// ``` /// ```
#[must_use] #[must_use]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_btree_len", issue = "71835")] #[rustc_const_unstable(
feature = "const_btree_len",
issue = "71835",
implied_by = "const_btree_new"
)]
pub const fn is_empty(&self) -> bool { pub const fn is_empty(&self) -> bool {
self.len() == 0 self.len() == 0
} }

View File

@ -1174,7 +1174,11 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// ``` /// ```
#[must_use] #[must_use]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_btree_len", issue = "71835")] #[rustc_const_unstable(
feature = "const_btree_len",
issue = "71835",
implied_by = "const_btree_new"
)]
pub const fn len(&self) -> usize { pub const fn len(&self) -> usize {
self.map.len() self.map.len()
} }
@ -1193,7 +1197,11 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// ``` /// ```
#[must_use] #[must_use]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_btree_len", issue = "71835")] #[rustc_const_unstable(
feature = "const_btree_len",
issue = "71835",
implied_by = "const_btree_new"
)]
pub const fn is_empty(&self) -> bool { pub const fn is_empty(&self) -> bool {
self.len() == 0 self.len() == 0
} }

View File

@ -538,7 +538,9 @@ fn map_lib_features(
becoming_feature = None; becoming_feature = None;
if line.contains("rustc_const_unstable(") { if line.contains("rustc_const_unstable(") {
// `const fn` features are handled specially. // `const fn` features are handled specially.
let feature_name = match find_attr_val(line, "feature") { let feature_name = match find_attr_val(line, "feature").or_else(|| {
iter_lines.peek().and_then(|next| find_attr_val(next.1, "feature"))
}) {
Some(name) => name, Some(name) => name,
None => err!("malformed stability attribute: missing `feature` key"), None => err!("malformed stability attribute: missing `feature` key"),
}; };