Skip to content

Commit

Permalink
Rollup merge of rust-lang#102556 - WaffleLapkin:implied_by_btree_new,…
Browse files Browse the repository at this point in the history
… 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 rust-lang#102197

cc ``@davidtwco`` it seems like tidy doesn't check `implied_by`, should it?
  • Loading branch information
Dylan-DPC authored Oct 2, 2022
2 parents 3dde014 + da78c1f commit a260d63
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
12 changes: 10 additions & 2 deletions library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2392,7 +2392,11 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
/// ```
#[must_use]
#[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 {
self.length
}
Expand All @@ -2413,7 +2417,11 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
/// ```
#[must_use]
#[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 {
self.len() == 0
}
Expand Down
12 changes: 10 additions & 2 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,11 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// ```
#[must_use]
#[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 {
self.map.len()
}
Expand All @@ -1193,7 +1197,11 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// ```
#[must_use]
#[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 {
self.len() == 0
}
Expand Down
4 changes: 3 additions & 1 deletion src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,9 @@ fn map_lib_features(
becoming_feature = None;
if line.contains("rustc_const_unstable(") {
// `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,
None => err!("malformed stability attribute: missing `feature` key"),
};
Expand Down

0 comments on commit a260d63

Please sign in to comment.