diff options
| author | bors <bors@rust-lang.org> | 2023-07-30 00:41:35 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-07-30 00:41:35 +0000 |
| commit | fb53384c94b87adebceb6048865c9fe305e71b92 (patch) | |
| tree | 2c209d5f667072db99e6df2ce23678e7ee958f3c /compiler | |
| parent | b969b830aa8cac0ded5cced9e4a47e124183a6ee (diff) | |
| parent | d4926b13aac4e61e9b46e32bcf0436589e589c07 (diff) | |
| download | rust-fb53384c94b87adebceb6048865c9fe305e71b92.tar.gz rust-fb53384c94b87adebceb6048865c9fe305e71b92.zip | |
Auto merge of #114226 - matthiaskrgr:rollup-wxdudsm, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #114129 (Rustdoc small cleanups) - #114152 ([rustc][data_structures] Simplify binary_search_slice.) - #114222 (Mark `lazy_type_alias` as incomplete) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_data_structures/src/binary_search_util/mod.rs | 38 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/active.rs | 2 |
2 files changed, 8 insertions, 32 deletions
diff --git a/compiler/rustc_data_structures/src/binary_search_util/mod.rs b/compiler/rustc_data_structures/src/binary_search_util/mod.rs index d40172a2e2f..bc8a6b9eac0 100644 --- a/compiler/rustc_data_structures/src/binary_search_util/mod.rs +++ b/compiler/rustc_data_structures/src/binary_search_util/mod.rs @@ -10,41 +10,17 @@ pub fn binary_search_slice<'d, E, K>(data: &'d [E], key_fn: impl Fn(&E) -> K, ke where K: Ord, { - let Ok(mid) = data.binary_search_by_key(key, &key_fn) else { + let size = data.len(); + let start = data.partition_point(|x| key_fn(x) < *key); + // At this point `start` either points at the first entry with equal or + // greater key or is equal to `size` in case all elements have smaller keys + if start == size || key_fn(&data[start]) != *key { return &[]; }; - let size = data.len(); - - // We get back *some* element with the given key -- so do - // a galloping search backwards to find the *first* one. - let mut start = mid; - let mut previous = mid; - let mut step = 1; - loop { - start = start.saturating_sub(step); - if start == 0 || key_fn(&data[start]) != *key { - break; - } - previous = start; - step *= 2; - } - step = previous - start; - while step > 1 { - let half = step / 2; - let mid = start + half; - if key_fn(&data[mid]) != *key { - start = mid; - } - step -= half; - } - // adjust by one if we have overshot - if start < size && key_fn(&data[start]) != *key { - start += 1; - } // Now search forward to find the *last* one. - let mut end = mid; - let mut previous = mid; + let mut end = start; + let mut previous = start; let mut step = 1; loop { end = end.saturating_add(step).min(size); diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 22380a52104..bbc3d291e20 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -449,7 +449,7 @@ declare_features! ( // Allows setting the threshold for the `large_assignments` lint. (active, large_assignments, "1.52.0", Some(83518), None), /// Allow to have type alias types for inter-crate use. - (active, lazy_type_alias, "1.72.0", Some(112792), None), + (incomplete, lazy_type_alias, "1.72.0", Some(112792), None), /// Allows `if/while p && let q = r && ...` chains. (active, let_chains, "1.37.0", Some(53667), None), /// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check. |
