Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fb53384

Browse files
committed
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
2 parents b969b83 + d4926b1 commit fb53384

File tree

13 files changed

+145
-141
lines changed

13 files changed

+145
-141
lines changed

‎compiler/rustc_data_structures/src/binary_search_util/mod.rs‎

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,17 @@ pub fn binary_search_slice<'d, E, K>(data: &'d [E], key_fn: impl Fn(&E) -> K, ke
1010
where
1111
K: Ord,
1212
{
13-
let Ok(mid) = data.binary_search_by_key(key, &key_fn) else {
13+
let size = data.len();
14+
let start = data.partition_point(|x| key_fn(x) < *key);
15+
// At this point `start` either points at the first entry with equal or
16+
// greater key or is equal to `size` in case all elements have smaller keys
17+
if start == size || key_fn(&data[start]) != *key {
1418
return &[];
1519
};
16-
let size = data.len();
17-
18-
// We get back *some* element with the given key -- so do
19-
// a galloping search backwards to find the *first* one.
20-
let mut start = mid;
21-
let mut previous = mid;
22-
let mut step = 1;
23-
loop {
24-
start = start.saturating_sub(step);
25-
if start == 0 || key_fn(&data[start]) != *key {
26-
break;
27-
}
28-
previous = start;
29-
step *= 2;
30-
}
31-
step = previous - start;
32-
while step > 1 {
33-
let half = step / 2;
34-
let mid = start + half;
35-
if key_fn(&data[mid]) != *key {
36-
start = mid;
37-
}
38-
step -= half;
39-
}
40-
// adjust by one if we have overshot
41-
if start < size && key_fn(&data[start]) != *key {
42-
start += 1;
43-
}
4420

4521
// Now search forward to find the *last* one.
46-
let mut end = mid;
47-
let mut previous = mid;
22+
let mut end = start;
23+
let mut previous = start;
4824
let mut step = 1;
4925
loop {
5026
end = end.saturating_add(step).min(size);

‎compiler/rustc_feature/src/active.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ declare_features! (
449449
// Allows setting the threshold for the `large_assignments` lint.
450450
(active, large_assignments, "1.52.0", Some(83518), None),
451451
/// Allow to have type alias types for inter-crate use.
452-
(active, lazy_type_alias, "1.72.0", Some(112792), None),
452+
(incomplete, lazy_type_alias, "1.72.0", Some(112792), None),
453453
/// Allows `if/while p && let q = r && ...` chains.
454454
(active, let_chains, "1.37.0", Some(53667), None),
455455
/// Allows using `reason` in lint attributes and the `#[expect(lint)]` lint check.

‎src/librustdoc/clean/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2809,7 +2809,7 @@ fn clean_use_statement_inner<'tcx>(
28092809
cx: &mut DocContext<'tcx>,
28102810
inlined_names: &mut FxHashSet<(ItemType, Symbol)>,
28112811
) -> Vec<Item> {
2812-
if letRes::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..) = path.res {
2812+
if should_ignore_res(path.res) {
28132813
return Vec::new();
28142814
}
28152815
// We need this comparison because some imports (for std types for example)

‎src/librustdoc/clean/utils.rs‎

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_ast as ast;
1313
use rustc_ast::tokenstream::TokenTree;
1414
use rustc_hir as hir;
1515
use rustc_hir::def::{DefKind, Res};
16-
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
16+
use rustc_hir::def_id::{DefId, LocalDefId,LOCAL_CRATE};
1717
use rustc_middle::mir;
1818
use rustc_middle::mir::interpret::ConstValue;
1919
use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, TyCtxt};
@@ -629,3 +629,35 @@ pub(super) fn display_macro_source(
629629
}
630630
}
631631
}
632+
633+
pub(crate) fn inherits_doc_hidden(
634+
tcx: TyCtxt<'_>,
635+
mut def_id: LocalDefId,
636+
stop_at: Option<LocalDefId>,
637+
) -> bool {
638+
let hir = tcx.hir();
639+
while let Some(id) = tcx.opt_local_parent(def_id) {
640+
if let Some(stop_at) = stop_at && id == stop_at {
641+
return false;
642+
}
643+
def_id = id;
644+
if tcx.is_doc_hidden(def_id.to_def_id()) {
645+
return true;
646+
} else if let Some(node) = hir.find_by_def_id(def_id) &&
647+
matches!(
648+
node,
649+
hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(_), .. }),
650+
)
651+
{
652+
// `impl` blocks stand a bit on their own: unless they have `#[doc(hidden)]` directly
653+
// on them, they don't inherit it from the parent context.
654+
return false;
655+
}
656+
}
657+
false
658+
}
659+
660+
#[inline]
661+
pub(crate) fn should_ignore_res(res: Res) -> bool {
662+
matches!(res, Res::Def(DefKind::Ctor(..), _) | Res::SelfCtor(..))
663+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /