Skip to content

Commit eebdfb5

Browse files
committed
Auto merge of #108228 - Dylan-DPC:rollup-i9t13qu, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #104659 (reflow the stack size story) - #106933 (Update documentation of select_nth_unstable and select_nth_unstable_by to state O(n^2) complexity) - #107783 (rustdoc: simplify DOM for `.item-table`) - #107951 (resolve: Fix doc links referring to other crates when documenting proc macro crates directly) - #108130 ("Basic usage" is redundant for there is just one example) - #108146 (rustdoc: hide `reference` methods in search index) - #108189 (Fix some more `non_lifetime_binders` stuff with higher-ranked trait bounds) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 73f4019 + c5d5c57 commit eebdfb5

File tree

35 files changed

+275
-161
lines changed

35 files changed

+275
-161
lines changed

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -418,10 +418,15 @@ impl<'cx, 'tcx> TypeFolder<TyCtxt<'tcx>> for Canonicalizer<'cx, 'tcx> {
418418
bug!("encountered a fresh type during canonicalization")
419419
}
420420

421-
ty::Placeholder(placeholder) => self.canonicalize_ty_var(
422-
CanonicalVarInfo { kind: CanonicalVarKind::PlaceholderTy(placeholder) },
423-
t,
424-
),
421+
ty::Placeholder(mut placeholder) => {
422+
if !self.canonicalize_mode.preserve_universes() {
423+
placeholder.universe = ty::UniverseIndex::ROOT;
424+
}
425+
self.canonicalize_ty_var(
426+
CanonicalVarInfo { kind: CanonicalVarKind::PlaceholderTy(placeholder) },
427+
t,
428+
)
429+
}
425430

426431
ty::Bound(debruijn, _) => {
427432
if debruijn >= self.binder_index {

compiler/rustc_middle/src/ty/print/pretty.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,10 @@ pub trait PrettyPrinter<'tcx>:
735735
p!(print(data))
736736
}
737737
}
738-
ty::Placeholder(placeholder) => p!(write("Placeholder({:?})", placeholder)),
738+
ty::Placeholder(placeholder) => match placeholder.name {
739+
ty::BoundTyKind::Anon(_) => p!(write("Placeholder({:?})", placeholder)),
740+
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
741+
},
739742
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
740743
// We use verbose printing in 'NO_QUERIES' mode, to
741744
// avoid needing to call `predicates_of`. This should

compiler/rustc_resolve/src/late.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -4211,7 +4211,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
42114211
if let Some(res) = res
42124212
&& let Some(def_id) = res.opt_def_id()
42134213
&& !def_id.is_local()
4214-
&& self.r.session.crate_types().contains(&CrateType::ProcMacro) {
4214+
&& self.r.session.crate_types().contains(&CrateType::ProcMacro)
4215+
&& matches!(self.r.session.opts.resolve_doc_links, ResolveDocLinks::ExportedMetadata) {
42154216
// Encoding foreign def ids in proc macro crate metadata will ICE.
42164217
return None;
42174218
}
@@ -4281,6 +4282,10 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
42814282
.filter_map(|tr| {
42824283
if !tr.def_id.is_local()
42834284
&& self.r.session.crate_types().contains(&CrateType::ProcMacro)
4285+
&& matches!(
4286+
self.r.session.opts.resolve_doc_links,
4287+
ResolveDocLinks::ExportedMetadata
4288+
)
42844289
{
42854290
// Encoding foreign def ids in proc macro crate metadata will ICE.
42864291
return None;

compiler/rustc_trait_selection/src/traits/select/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -2148,12 +2148,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
21482148
}))
21492149
}
21502150

2151-
ty::Alias(..) | ty::Param(_) => None,
2151+
ty::Alias(..) | ty::Param(_) | ty::Placeholder(..) => None,
21522152
ty::Infer(ty::TyVar(_)) => Ambiguous,
21532153

2154-
ty::Placeholder(..)
2155-
| ty::Bound(..)
2156-
| ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
2154+
// We can make this an ICE if/once we actually instantiate the trait obligation.
2155+
ty::Bound(..) => None,
2156+
2157+
ty::Infer(ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_)) => {
21572158
bug!("asked to assemble builtin bounds of unexpected type: {:?}", self_ty);
21582159
}
21592160
}

library/core/src/result.rs

-42
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,6 @@ impl<T, E> Result<T, E> {
525525
///
526526
/// # Examples
527527
///
528-
/// Basic usage:
529-
///
530528
/// ```
531529
/// let x: Result<i32, &str> = Ok(-3);
532530
/// assert_eq!(x.is_ok(), true);
@@ -572,8 +570,6 @@ impl<T, E> Result<T, E> {
572570
///
573571
/// # Examples
574572
///
575-
/// Basic usage:
576-
///
577573
/// ```
578574
/// let x: Result<i32, &str> = Ok(-3);
579575
/// assert_eq!(x.is_err(), false);
@@ -627,8 +623,6 @@ impl<T, E> Result<T, E> {
627623
///
628624
/// # Examples
629625
///
630-
/// Basic usage:
631-
///
632626
/// ```
633627
/// let x: Result<u32, &str> = Ok(2);
634628
/// assert_eq!(x.ok(), Some(2));
@@ -658,8 +652,6 @@ impl<T, E> Result<T, E> {
658652
///
659653
/// # Examples
660654
///
661-
/// Basic usage:
662-
///
663655
/// ```
664656
/// let x: Result<u32, &str> = Ok(2);
665657
/// assert_eq!(x.err(), None);
@@ -693,8 +685,6 @@ impl<T, E> Result<T, E> {
693685
///
694686
/// # Examples
695687
///
696-
/// Basic usage:
697-
///
698688
/// ```
699689
/// let x: Result<u32, &str> = Ok(2);
700690
/// assert_eq!(x.as_ref(), Ok(&2));
@@ -716,8 +706,6 @@ impl<T, E> Result<T, E> {
716706
///
717707
/// # Examples
718708
///
719-
/// Basic usage:
720-
///
721709
/// ```
722710
/// fn mutate(r: &mut Result<i32, i32>) {
723711
/// match r.as_mut() {
@@ -812,8 +800,6 @@ impl<T, E> Result<T, E> {
812800
///
813801
/// # Examples
814802
///
815-
/// Basic usage:
816-
///
817803
/// ```
818804
/// let k = 21;
819805
///
@@ -841,8 +827,6 @@ impl<T, E> Result<T, E> {
841827
///
842828
/// # Examples
843829
///
844-
/// Basic usage:
845-
///
846830
/// ```
847831
/// fn stringify(x: u32) -> String { format!("error code: {x}") }
848832
///
@@ -968,8 +952,6 @@ impl<T, E> Result<T, E> {
968952
///
969953
/// # Examples
970954
///
971-
/// Basic usage:
972-
///
973955
/// ```
974956
/// let x: Result<u32, &str> = Ok(7);
975957
/// assert_eq!(x.iter().next(), Some(&7));
@@ -989,8 +971,6 @@ impl<T, E> Result<T, E> {
989971
///
990972
/// # Examples
991973
///
992-
/// Basic usage:
993-
///
994974
/// ```
995975
/// let mut x: Result<u32, &str> = Ok(7);
996976
/// match x.iter_mut().next() {
@@ -1031,8 +1011,6 @@ impl<T, E> Result<T, E> {
10311011
///
10321012
/// # Examples
10331013
///
1034-
/// Basic usage:
1035-
///
10361014
/// ```should_panic
10371015
/// let x: Result<u32, &str> = Err("emergency failure");
10381016
/// x.expect("Testing expect"); // panics with `Testing expect: emergency failure`
@@ -1160,8 +1138,6 @@ impl<T, E> Result<T, E> {
11601138
///
11611139
/// # Examples
11621140
///
1163-
/// Basic usage:
1164-
///
11651141
/// ```should_panic
11661142
/// let x: Result<u32, &str> = Ok(10);
11671143
/// x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10`
@@ -1222,8 +1198,6 @@ impl<T, E> Result<T, E> {
12221198
///
12231199
/// # Examples
12241200
///
1225-
/// Basic usage:
1226-
///
12271201
/// ```
12281202
/// # #![feature(never_type)]
12291203
/// # #![feature(unwrap_infallible)]
@@ -1259,8 +1233,6 @@ impl<T, E> Result<T, E> {
12591233
///
12601234
/// # Examples
12611235
///
1262-
/// Basic usage:
1263-
///
12641236
/// ```
12651237
/// # #![feature(never_type)]
12661238
/// # #![feature(unwrap_infallible)]
@@ -1298,8 +1270,6 @@ impl<T, E> Result<T, E> {
12981270
///
12991271
/// # Examples
13001272
///
1301-
/// Basic usage:
1302-
///
13031273
/// ```
13041274
/// let x: Result<u32, &str> = Ok(2);
13051275
/// let y: Result<&str, &str> = Err("late error");
@@ -1383,8 +1353,6 @@ impl<T, E> Result<T, E> {
13831353
///
13841354
/// # Examples
13851355
///
1386-
/// Basic usage:
1387-
///
13881356
/// ```
13891357
/// let x: Result<u32, &str> = Ok(2);
13901358
/// let y: Result<u32, &str> = Err("late error");
@@ -1426,8 +1394,6 @@ impl<T, E> Result<T, E> {
14261394
///
14271395
/// # Examples
14281396
///
1429-
/// Basic usage:
1430-
///
14311397
/// ```
14321398
/// fn sq(x: u32) -> Result<u32, u32> { Ok(x * x) }
14331399
/// fn err(x: u32) -> Result<u32, u32> { Err(x) }
@@ -1456,8 +1422,6 @@ impl<T, E> Result<T, E> {
14561422
///
14571423
/// # Examples
14581424
///
1459-
/// Basic usage:
1460-
///
14611425
/// ```
14621426
/// let default = 2;
14631427
/// let x: Result<u32, &str> = Ok(9);
@@ -1487,8 +1451,6 @@ impl<T, E> Result<T, E> {
14871451
///
14881452
/// # Examples
14891453
///
1490-
/// Basic usage:
1491-
///
14921454
/// ```
14931455
/// fn count(x: &str) -> usize { x.len() }
14941456
///
@@ -1752,8 +1714,6 @@ impl<T, E> Result<Result<T, E>, E> {
17521714
///
17531715
/// # Examples
17541716
///
1755-
/// Basic usage:
1756-
///
17571717
/// ```
17581718
/// #![feature(result_flattening)]
17591719
/// let x: Result<Result<&'static str, u32>, u32> = Ok(Ok("hello"));
@@ -1842,8 +1802,6 @@ impl<T, E> IntoIterator for Result<T, E> {
18421802
///
18431803
/// # Examples
18441804
///
1845-
/// Basic usage:
1846-
///
18471805
/// ```
18481806
/// let x: Result<u32, &str> = Ok(5);
18491807
/// let v: Vec<u32> = x.into_iter().collect();

library/core/src/slice/mod.rs

+14-6
Original file line numberDiff line numberDiff line change
@@ -2730,8 +2730,10 @@ impl<T> [T] {
27302730
/// This reordering has the additional property that any value at position `i < index` will be
27312731
/// less than or equal to any value at a position `j > index`. Additionally, this reordering is
27322732
/// unstable (i.e. any number of equal elements may end up at position `index`), in-place
2733-
/// (i.e. does not allocate), and *O*(*n*) worst-case. This function is also/ known as "kth
2734-
/// element" in other libraries. It returns a triplet of the following from the reordered slice:
2733+
/// (i.e. does not allocate), and *O*(*n*) on average. The worst-case performance is *O*(*n* log *n*).
2734+
/// This function is also known as "kth element" in other libraries.
2735+
///
2736+
/// It returns a triplet of the following from the reordered slice:
27352737
/// the subslice prior to `index`, the element at `index`, and the subslice after `index`;
27362738
/// accordingly, the values in those two subslices will respectively all be less-than-or-equal-to
27372739
/// and greater-than-or-equal-to the value of the element at `index`.
@@ -2777,8 +2779,11 @@ impl<T> [T] {
27772779
/// This reordering has the additional property that any value at position `i < index` will be
27782780
/// less than or equal to any value at a position `j > index` using the comparator function.
27792781
/// Additionally, this reordering is unstable (i.e. any number of equal elements may end up at
2780-
/// position `index`), in-place (i.e. does not allocate), and *O*(*n*) worst-case. This function
2781-
/// is also known as "kth element" in other libraries. It returns a triplet of the following from
2782+
/// position `index`), in-place (i.e. does not allocate), and *O*(*n*) on average.
2783+
/// The worst-case performance is *O*(*n* log *n*). This function is also known as
2784+
/// "kth element" in other libraries.
2785+
///
2786+
/// It returns a triplet of the following from
27822787
/// the slice reordered according to the provided comparator function: the subslice prior to
27832788
/// `index`, the element at `index`, and the subslice after `index`; accordingly, the values in
27842789
/// those two subslices will respectively all be less-than-or-equal-to and greater-than-or-equal-to
@@ -2829,8 +2834,11 @@ impl<T> [T] {
28292834
/// This reordering has the additional property that any value at position `i < index` will be
28302835
/// less than or equal to any value at a position `j > index` using the key extraction function.
28312836
/// Additionally, this reordering is unstable (i.e. any number of equal elements may end up at
2832-
/// position `index`), in-place (i.e. does not allocate), and *O*(*n*) worst-case. This function
2833-
/// is also known as "kth element" in other libraries. It returns a triplet of the following from
2837+
/// position `index`), in-place (i.e. does not allocate), and *O*(*n*) on average.
2838+
/// The worst-case performance is *O*(*n* log *n*).
2839+
/// This function is also known as "kth element" in other libraries.
2840+
///
2841+
/// It returns a triplet of the following from
28342842
/// the slice reordered according to the provided key extraction function: the subslice prior to
28352843
/// `index`, the element at `index`, and the subslice after `index`; accordingly, the values in
28362844
/// those two subslices will respectively all be less-than-or-equal-to and greater-than-or-equal-to

library/std/src/thread/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,10 @@
124124
//!
125125
//! ## Stack size
126126
//!
127-
//! The default stack size is platform-dependent and subject to change. Currently it is 2MB on all
128-
//! Tier-1 platforms. There are two ways to manually specify the stack size for spawned threads:
127+
//! The default stack size is platform-dependent and subject to change.
128+
//! Currently, it is 2 MiB on all Tier-1 platforms.
129+
//!
130+
//! There are two ways to manually specify the stack size for spawned threads:
129131
//!
130132
//! * Build the thread with [`Builder`] and pass the desired stack size to [`Builder::stack_size`].
131133
//! * Set the `RUST_MIN_STACK` environment variable to an integer representing the desired stack

src/librustdoc/formats/cache.rs

+10
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> {
287287
} else {
288288
let last = self.cache.parent_stack.last().expect("parent_stack is empty 2");
289289
let did = match &*last {
290+
ParentStackItem::Impl {
291+
// impl Trait for &T { fn method(self); }
292+
//
293+
// When generating a function index with the above shape, we want it
294+
// associated with `T`, not with the primitive reference type. It should
295+
// show up as `T::method`, rather than `reference::method`, in the search
296+
// results page.
297+
for_: clean::Type::BorrowedRef { type_, .. },
298+
..
299+
} => type_.def_id(&self.cache),
290300
ParentStackItem::Impl { for_, .. } => for_.def_id(&self.cache),
291301
ParentStackItem::Type(item_id) => item_id.as_def_id(),
292302
};

src/librustdoc/html/render/print_item.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ use crate::html::{highlight, static_files};
3939
use askama::Template;
4040
use itertools::Itertools;
4141

42-
const ITEM_TABLE_OPEN: &str = "<div class=\"item-table\">";
43-
const ITEM_TABLE_CLOSE: &str = "</div>";
44-
const ITEM_TABLE_ROW_OPEN: &str = "<div class=\"item-row\">";
45-
const ITEM_TABLE_ROW_CLOSE: &str = "</div>";
42+
const ITEM_TABLE_OPEN: &str = "<ul class=\"item-table\">";
43+
const ITEM_TABLE_CLOSE: &str = "</ul>";
44+
const ITEM_TABLE_ROW_OPEN: &str = "<li>";
45+
const ITEM_TABLE_ROW_CLOSE: &str = "</li>";
4646

4747
// A component in a `use` path, like `string` in std::string::ToString
4848
struct PathComponent {
@@ -338,14 +338,14 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
338338
match *src {
339339
Some(src) => write!(
340340
w,
341-
"<div class=\"item-left\"><code>{}extern crate {} as {};",
341+
"<div class=\"item-name\"><code>{}extern crate {} as {};",
342342
visibility_print_with_space(myitem.visibility(tcx), myitem.item_id, cx),
343343
anchor(myitem.item_id.expect_def_id(), src, cx),
344344
myitem.name.unwrap(),
345345
),
346346
None => write!(
347347
w,
348-
"<div class=\"item-left\"><code>{}extern crate {};",
348+
"<div class=\"item-name\"><code>{}extern crate {};",
349349
visibility_print_with_space(myitem.visibility(tcx), myitem.item_id, cx),
350350
anchor(myitem.item_id.expect_def_id(), myitem.name.unwrap(), cx),
351351
),
@@ -384,11 +384,11 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
384384
let (stab_tags_before, stab_tags_after) = if stab_tags.is_empty() {
385385
("", "")
386386
} else {
387-
("<div class=\"item-right docblock-short\">", "</div>")
387+
("<div class=\"desc docblock-short\">", "</div>")
388388
};
389389
write!(
390390
w,
391-
"<div class=\"item-left\"{id}>\
391+
"<div class=\"item-name\"{id}>\
392392
<code>{vis}{imp}</code>\
393393
</div>\
394394
{stab_tags_before}{stab_tags}{stab_tags_after}",
@@ -426,11 +426,11 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
426426
let (docs_before, docs_after) = if docs.is_empty() {
427427
("", "")
428428
} else {
429-
("<div class=\"item-right docblock-short\">", "</div>")
429+
("<div class=\"desc docblock-short\">", "</div>")
430430
};
431431
write!(
432432
w,
433-
"<div class=\"item-left\">\
433+
"<div class=\"item-name\">\
434434
<a class=\"{class}\" href=\"{href}\" title=\"{title}\">{name}</a>\
435435
{visibility_emoji}\
436436
{unsafety_flag}\

0 commit comments

Comments
 (0)