Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit eb5487e

Browse files
committedAug 13, 2024·
rustdoc-search: simplify rules for generics and type params
This commit is a response to feedback on the displayed type signatures results, by making type params looser and generics act stricter. Type params are loosened by allowing a single function type param to match multiple query params. In other words, the relationship is loosened to N:1 instead of the older 1:1 rule. This change also allows a type param to be unboxed in one spot and matched in another. Generics are tightened by making order significant. This means `Vec<Allocator>` now matches only with a true vector of allocators, instead of matching the second type param. It also makes unboxing within generics stricter, so `Result<A, B>` only matches if `B` is in the error type and `A` is in the success type. The top level of the function search is unaffected. Find the discussion on: * <https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.202024-07-08/near/449965149> * <#124544 (comment)>
1 parent 36e26ab commit eb5487e

38 files changed

+580
-208
lines changed
 

Diff for: ‎compiler/rustc_ast_passes/src/feature_gate.rs

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
217217
"meant for internal use only" {
218218
keyword => rustdoc_internals
219219
fake_variadic => rustdoc_internals
220+
search_unbox => rustdoc_internals
220221
}
221222
);
222223
}

Diff for: ‎compiler/rustc_passes/messages.ftl

+3
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ passes_doc_masked_only_extern_crate =
226226
passes_doc_rust_logo =
227227
the `#[doc(rust_logo)]` attribute is used for Rust branding
228228
229+
passes_doc_search_unbox_invalid =
230+
`#[doc(search_unbox)]` should be used on generic structs and enums
231+
229232
passes_doc_test_literal = `#![doc(test(...)]` does not take a literal
230233
231234
passes_doc_test_takes_list =

Diff for: ‎compiler/rustc_passes/src/check_attr.rs

+25-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ use rustc_feature::{AttributeDuplicates, AttributeType, BuiltinAttribute, BUILTI
1616
use rustc_hir::def_id::LocalModDefId;
1717
use rustc_hir::intravisit::{self, Visitor};
1818
use rustc_hir::{
19-
self as hir, self, FnSig, ForeignItem, HirId, Item, ItemKind, MethodKind, Safety, Target,
20-
TraitItem, CRATE_HIR_ID, CRATE_OWNER_ID,
19+
self as hir, self, AssocItemKind, FnSig, ForeignItem, HirId, Item, ItemKind, MethodKind,
20+
Safety, Target, TraitItem, CRATE_HIR_ID, CRATE_OWNER_ID,
2121
};
2222
use rustc_macros::LintDiagnostic;
2323
use rustc_middle::hir::nested_filter;
@@ -962,6 +962,23 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
962962
}
963963
}
964964

965+
fn check_doc_search_unbox(&self, meta: &NestedMetaItem, hir_id: HirId) {
966+
let hir::Node::Item(item) = self.tcx.hir_node(hir_id) else {
967+
self.dcx().emit_err(errors::DocSearchUnboxInvalid { span: meta.span() });
968+
return;
969+
};
970+
match item.kind {
971+
ItemKind::Enum(_, generics) | ItemKind::Struct(_, generics)
972+
if generics.params.len() != 0 => {}
973+
ItemKind::Trait(_, _, generics, _, items)
974+
if generics.params.len() != 0
975+
|| items.iter().any(|item| matches!(item.kind, AssocItemKind::Type)) => {}
976+
_ => {
977+
self.dcx().emit_err(errors::DocSearchUnboxInvalid { span: meta.span() });
978+
}
979+
}
980+
}
981+
965982
/// Checks `#[doc(inline)]`/`#[doc(no_inline)]` attributes.
966983
///
967984
/// A doc inlining attribute is invalid if it is applied to a non-`use` item, or
@@ -1180,6 +1197,12 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
11801197
}
11811198
}
11821199

1200+
sym::search_unbox => {
1201+
if self.check_attr_not_crate_level(meta, hir_id, "fake_variadic") {
1202+
self.check_doc_search_unbox(meta, hir_id);
1203+
}
1204+
}
1205+
11831206
sym::html_favicon_url
11841207
| sym::html_logo_url
11851208
| sym::html_playground_url

Diff for: ‎compiler/rustc_passes/src/errors.rs

+7
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ pub struct DocKeywordOnlyImpl {
230230
pub span: Span,
231231
}
232232

233+
#[derive(Diagnostic)]
234+
#[diag(passes_doc_search_unbox_invalid)]
235+
pub struct DocSearchUnboxInvalid {
236+
#[primary_span]
237+
pub span: Span,
238+
}
239+
233240
#[derive(Diagnostic)]
234241
#[diag(passes_doc_inline_conflict)]
235242
#[help]

Diff for: ‎compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1704,6 +1704,7 @@ symbols! {
17041704
saturating_add,
17051705
saturating_div,
17061706
saturating_sub,
1707+
search_unbox,
17071708
select_unpredictable,
17081709
self_in_typedefs,
17091710
self_struct_ctor,

Diff for: ‎library/alloc/src/boxed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ mod thin;
230230
#[lang = "owned_box"]
231231
#[fundamental]
232232
#[stable(feature = "rust1", since = "1.0.0")]
233+
#[cfg_attr(not(bootstrap), doc(search_unbox))]
233234
// The declaration of the `Box` struct must be kept in sync with the
234235
// compiler or ICEs will happen.
235236
pub struct Box<

Diff for: ‎library/core/src/future/future.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::task::{Context, Poll};
2525
/// [`async`]: ../../std/keyword.async.html
2626
/// [`Waker`]: crate::task::Waker
2727
#[doc(notable_trait)]
28+
#[cfg_attr(not(bootstrap), doc(search_unbox))]
2829
#[must_use = "futures do nothing unless you `.await` or poll them"]
2930
#[stable(feature = "futures_api", since = "1.36.0")]
3031
#[lang = "future_trait"]

Diff for: ‎library/core/src/option.rs

+1
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ use crate::{cmp, convert, hint, mem, slice};
568568
#[lang = "Option"]
569569
#[stable(feature = "rust1", since = "1.0.0")]
570570
#[allow(clippy::derived_hash_with_manual_eq)] // PartialEq is manually implemented equivalently
571+
#[cfg_attr(not(bootstrap), doc(search_unbox))]
571572
pub enum Option<T> {
572573
/// No value.
573574
#[lang = "None"]

Diff for: ‎library/core/src/result.rs

+1
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,7 @@ use crate::{convert, fmt, hint};
524524
#[must_use = "this `Result` may be an `Err` variant, which should be handled"]
525525
#[rustc_diagnostic_item = "Result"]
526526
#[stable(feature = "rust1", since = "1.0.0")]
527+
#[cfg_attr(not(bootstrap), doc(search_unbox))]
527528
pub enum Result<T, E> {
528529
/// Contains the success value
529530
#[lang = "Ok"]

Diff for: ‎src/doc/rustdoc/src/read-documentation/search.md

+7-5
Original file line numberDiff line numberDiff line change
@@ -130,29 +130,31 @@ pub trait MyTrait {
130130
/// This function can be found using the following search queries:
131131
///
132132
/// MyTrait<First=u8, Second=u32> -> bool
133-
/// MyTrait<u32, First=u8> -> bool
134133
/// MyTrait<Second=u32> -> bool
135-
/// MyTrait<u32, u8> -> bool
136134
///
137135
/// The following queries, however, will *not* match it:
138136
///
139137
/// MyTrait<First=u32> -> bool
140138
/// MyTrait<u32, u32> -> bool
139+
/// MyTrait<u32, First=u8> -> bool
140+
/// MyTrait<u32, u8> -> bool
141141
pub fn my_fn(x: impl MyTrait<First=u8, Second=u32>) -> bool { true }
142142
```
143143

144-
Generics and function parameters are order-agnostic, but sensitive to nesting
144+
Function parameters are order-agnostic, but sensitive to nesting
145145
and number of matches. For example, a function with the signature
146146
`fn read_all(&mut self: impl Read) -> Result<Vec<u8>, Error>`
147147
will match these queries:
148148

149149
* `&mut Read -> Result<Vec<u8>, Error>`
150150
* `Read -> Result<Vec<u8>, Error>`
151-
* `Read -> Result<Error, Vec>`
152151
* `Read -> Result<Vec<u8>>`
153152
* `Read -> u8`
154153

155-
But it *does not* match `Result<Vec, u8>` or `Result<u8<Vec>>`.
154+
But it *does not* match `Result<Vec, u8>` or `Result<u8<Vec>>`,
155+
because those are nested incorrectly, and it does not match
156+
`Result<Error, Vec<u8>>` or `Result<Error>`, because those are
157+
in the wrong order.
156158

157159
To search for a function that accepts a function as a parameter,
158160
like `Iterator::all`, wrap the nested signature in parenthesis,

Diff for: ‎src/librustdoc/html/render/search_index.rs

+62-12
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use rustc_span::symbol::{kw, Symbol};
1212
use serde::ser::{Serialize, SerializeSeq, SerializeStruct, Serializer};
1313
use thin_vec::ThinVec;
1414

15-
use crate::clean;
1615
use crate::clean::types::{Function, Generics, ItemId, Type, WherePredicate};
16+
use crate::clean::{self, utils};
1717
use crate::formats::cache::{Cache, OrphanImplItem};
1818
use crate::formats::item_type::ItemType;
1919
use crate::html::format::join_with_double_colon;
@@ -64,7 +64,7 @@ pub(crate) fn build_index<'tcx>(
6464
let mut associated_types = FxHashMap::default();
6565

6666
// item type, display path, re-exported internal path
67-
let mut crate_paths: Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)> = vec![];
67+
let mut crate_paths: Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>, bool)> = vec![];
6868

6969
// Attach all orphan items to the type's definition if the type
7070
// has since been learned.
@@ -130,10 +130,11 @@ pub(crate) fn build_index<'tcx>(
130130
map: &mut FxHashMap<F, isize>,
131131
itemid: F,
132132
lastpathid: &mut isize,
133-
crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)>,
133+
crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>, bool)>,
134134
item_type: ItemType,
135135
path: &[Symbol],
136136
exact_path: Option<&[Symbol]>,
137+
search_unbox: bool,
137138
) -> RenderTypeId {
138139
match map.entry(itemid) {
139140
Entry::Occupied(entry) => RenderTypeId::Index(*entry.get()),
@@ -145,6 +146,7 @@ pub(crate) fn build_index<'tcx>(
145146
item_type,
146147
path.to_vec(),
147148
exact_path.map(|path| path.to_vec()),
149+
search_unbox,
148150
));
149151
RenderTypeId::Index(pathid)
150152
}
@@ -158,9 +160,21 @@ pub(crate) fn build_index<'tcx>(
158160
primitives: &mut FxHashMap<Symbol, isize>,
159161
associated_types: &mut FxHashMap<Symbol, isize>,
160162
lastpathid: &mut isize,
161-
crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)>,
163+
crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>, bool)>,
164+
tcx: TyCtxt<'_>,
162165
) -> Option<RenderTypeId> {
166+
use crate::clean::PrimitiveType;
163167
let Cache { ref paths, ref external_paths, ref exact_paths, .. } = *cache;
168+
let search_unbox = match id {
169+
RenderTypeId::Mut => false,
170+
RenderTypeId::DefId(defid) => utils::has_doc_flag(tcx, defid, sym::search_unbox),
171+
RenderTypeId::Primitive(PrimitiveType::Reference | PrimitiveType::Tuple) => true,
172+
RenderTypeId::Primitive(..) => false,
173+
RenderTypeId::AssociatedType(..) => false,
174+
// this bool is only used by `insert_into_map`, so it doesn't matter what we set here
175+
// because Index means we've already inserted into the map
176+
RenderTypeId::Index(_) => false,
177+
};
164178
match id {
165179
RenderTypeId::Mut => Some(insert_into_map(
166180
primitives,
@@ -170,6 +184,7 @@ pub(crate) fn build_index<'tcx>(
170184
ItemType::Keyword,
171185
&[kw::Mut],
172186
None,
187+
search_unbox,
173188
)),
174189
RenderTypeId::DefId(defid) => {
175190
if let Some(&(ref fqp, item_type)) =
@@ -193,6 +208,7 @@ pub(crate) fn build_index<'tcx>(
193208
item_type,
194209
fqp,
195210
exact_fqp.map(|x| &x[..]).filter(|exact_fqp| exact_fqp != fqp),
211+
search_unbox,
196212
))
197213
} else {
198214
None
@@ -208,6 +224,7 @@ pub(crate) fn build_index<'tcx>(
208224
ItemType::Primitive,
209225
&[sym],
210226
None,
227+
search_unbox,
211228
))
212229
}
213230
RenderTypeId::Index(_) => Some(id),
@@ -219,6 +236,7 @@ pub(crate) fn build_index<'tcx>(
219236
ItemType::AssocType,
220237
&[sym],
221238
None,
239+
search_unbox,
222240
)),
223241
}
224242
}
@@ -230,7 +248,8 @@ pub(crate) fn build_index<'tcx>(
230248
primitives: &mut FxHashMap<Symbol, isize>,
231249
associated_types: &mut FxHashMap<Symbol, isize>,
232250
lastpathid: &mut isize,
233-
crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)>,
251+
crate_paths: &mut Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>, bool)>,
252+
tcx: TyCtxt<'_>,
234253
) {
235254
if let Some(generics) = &mut ty.generics {
236255
for item in generics {
@@ -242,6 +261,7 @@ pub(crate) fn build_index<'tcx>(
242261
associated_types,
243262
lastpathid,
244263
crate_paths,
264+
tcx,
245265
);
246266
}
247267
}
@@ -255,6 +275,7 @@ pub(crate) fn build_index<'tcx>(
255275
associated_types,
256276
lastpathid,
257277
crate_paths,
278+
tcx,
258279
);
259280
let Some(converted_associated_type) = converted_associated_type else {
260281
return false;
@@ -269,6 +290,7 @@ pub(crate) fn build_index<'tcx>(
269290
associated_types,
270291
lastpathid,
271292
crate_paths,
293+
tcx,
272294
);
273295
}
274296
true
@@ -286,6 +308,7 @@ pub(crate) fn build_index<'tcx>(
286308
associated_types,
287309
lastpathid,
288310
crate_paths,
311+
tcx,
289312
);
290313
}
291314
if let Some(search_type) = &mut item.search_type {
@@ -298,6 +321,7 @@ pub(crate) fn build_index<'tcx>(
298321
&mut associated_types,
299322
&mut lastpathid,
300323
&mut crate_paths,
324+
tcx,
301325
);
302326
}
303327
for item in &mut search_type.output {
@@ -309,6 +333,7 @@ pub(crate) fn build_index<'tcx>(
309333
&mut associated_types,
310334
&mut lastpathid,
311335
&mut crate_paths,
336+
tcx,
312337
);
313338
}
314339
for constraint in &mut search_type.where_clause {
@@ -321,6 +346,7 @@ pub(crate) fn build_index<'tcx>(
321346
&mut associated_types,
322347
&mut lastpathid,
323348
&mut crate_paths,
349+
tcx,
324350
);
325351
}
326352
}
@@ -348,7 +374,12 @@ pub(crate) fn build_index<'tcx>(
348374
.filter(|exact_fqp| {
349375
exact_fqp.last() == Some(&item.name) && *exact_fqp != fqp
350376
});
351-
crate_paths.push((short, fqp.clone(), exact_fqp.cloned()));
377+
crate_paths.push((
378+
short,
379+
fqp.clone(),
380+
exact_fqp.cloned(),
381+
utils::has_doc_flag(tcx, defid, sym::search_unbox),
382+
));
352383
Some(pathid)
353384
} else {
354385
None
@@ -429,7 +460,7 @@ pub(crate) fn build_index<'tcx>(
429460

430461
struct CrateData<'a> {
431462
items: Vec<&'a IndexItem>,
432-
paths: Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>)>,
463+
paths: Vec<(ItemType, Vec<Symbol>, Option<Vec<Symbol>>, bool)>,
433464
// The String is alias name and the vec is the list of the elements with this alias.
434465
//
435466
// To be noted: the `usize` elements are indexes to `items`.
@@ -448,6 +479,7 @@ pub(crate) fn build_index<'tcx>(
448479
name: Symbol,
449480
path: Option<usize>,
450481
exact_path: Option<usize>,
482+
search_unbox: bool,
451483
}
452484

453485
impl Serialize for Paths {
@@ -465,6 +497,15 @@ pub(crate) fn build_index<'tcx>(
465497
assert!(self.path.is_some());
466498
seq.serialize_element(path)?;
467499
}
500+
if self.search_unbox {
501+
if self.path.is_none() {
502+
seq.serialize_element(&None::<u8>)?;
503+
}
504+
if self.exact_path.is_none() {
505+
seq.serialize_element(&None::<u8>)?;
506+
}
507+
seq.serialize_element(&1)?;
508+
}
468509
seq.end()
469510
}
470511
}
@@ -487,9 +528,15 @@ pub(crate) fn build_index<'tcx>(
487528
mod_paths.insert(&item.path, index);
488529
}
489530
let mut paths = Vec::with_capacity(self.paths.len());
490-
for (ty, path, exact) in &self.paths {
531+
for &(ty, ref path, ref exact, search_unbox) in &self.paths {
491532
if path.len() < 2 {
492-
paths.push(Paths { ty: *ty, name: path[0], path: None, exact_path: None });
533+
paths.push(Paths {
534+
ty,
535+
name: path[0],
536+
path: None,
537+
exact_path: None,
538+
search_unbox,
539+
});
493540
continue;
494541
}
495542
let full_path = join_with_double_colon(&path[..path.len() - 1]);
@@ -515,10 +562,11 @@ pub(crate) fn build_index<'tcx>(
515562
});
516563
if let Some(index) = mod_paths.get(&full_path) {
517564
paths.push(Paths {
518-
ty: *ty,
565+
ty,
519566
name: *path.last().unwrap(),
520567
path: Some(*index),
521568
exact_path,
569+
search_unbox,
522570
});
523571
continue;
524572
}
@@ -530,10 +578,11 @@ pub(crate) fn build_index<'tcx>(
530578
match extra_paths.entry(full_path.clone()) {
531579
Entry::Occupied(entry) => {
532580
paths.push(Paths {
533-
ty: *ty,
581+
ty,
534582
name: *path.last().unwrap(),
535583
path: Some(*entry.get()),
536584
exact_path,
585+
search_unbox,
537586
});
538587
}
539588
Entry::Vacant(entry) => {
@@ -542,10 +591,11 @@ pub(crate) fn build_index<'tcx>(
542591
revert_extra_paths.insert(index, full_path);
543592
}
544593
paths.push(Paths {
545-
ty: *ty,
594+
ty,
546595
name: *path.last().unwrap(),
547596
path: Some(index),
548597
exact_path,
598+
search_unbox,
549599
});
550600
}
551601
}

Diff for: ‎src/librustdoc/html/static/js/search.js

+239-69
Large diffs are not rendered by default.

Diff for: ‎tests/rustdoc-gui/search-about-this-result.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ assert-count: ("#search-tabs button", 1)
1111
assert-count: (".search-results > a", 1)
1212

1313
assert: "//div[@class='type-signature']/strong[text()='Iterator']"
14-
assert: "//div[@class='type-signature']/strong[text()='(']"
15-
assert: "//div[@class='type-signature']/strong[text()=')']"
14+
assert: "//div[@class='type-signature']/strong[text()='(B']"
15+
assert: "//div[@class='type-signature']/strong[text()='B)']"
1616

1717
assert: "//div[@class='type-signature']/div[@class='where']/strong[text()='FnMut']"
1818
assert: "//div[@class='type-signature']/div[@class='where']/strong[text()='Iterator::Item']"

Diff for: ‎tests/rustdoc-js-std/bufread-fill-buf.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22

33
const EXPECTED = [
44
{
5-
'query': 'bufread -> result<u8>',
5+
'query': 'bufread -> result<[u8]>',
66
'others': [
7-
{ 'path': 'std::io::Split', 'name': 'next' },
87
{ 'path': 'std::boxed::Box', 'name': 'fill_buf' },
9-
{ 'path': 'std::io::Chain', 'name': 'fill_buf' },
10-
{ 'path': 'std::io::Take', 'name': 'fill_buf' },
8+
],
9+
},
10+
{
11+
'query': 'split<bufread> -> option<result<vec<u8>>>',
12+
'others': [
13+
{ 'path': 'std::io::Split', 'name': 'next' },
1114
],
1215
},
1316
];

Diff for: ‎tests/rustdoc-js-std/option-type-signatures.js

+6-25
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,6 @@ const EXPECTED = [
8080
'name': 'and',
8181
'displayType': '`Option`<`T`>, `Option`<`U`> -> `Option`<`U`>',
8282
},
83-
{
84-
'path': 'std::option::Option',
85-
'name': 'zip',
86-
'displayType': '`Option`<`T`>, `Option`<`U`> -> `Option`<(T, `U`)>',
87-
},
8883
],
8984
},
9085
{
@@ -103,12 +98,12 @@ const EXPECTED = [
10398
],
10499
},
105100
{
106-
'query': 'option<t>, option<u> -> option<t, u>',
101+
'query': 'option<t>, option<u> -> option<(t, u)>',
107102
'others': [
108103
{
109104
'path': 'std::option::Option',
110105
'name': 'zip',
111-
'displayType': '`Option`<`T`>, `Option`<`U`> -> `Option`<(`T`, `U`)>',
106+
'displayType': '`Option`<`T`>, `Option`<`U`> -> `Option`<`(T`, `U)`>',
112107
},
113108
],
114109
},
@@ -174,37 +169,23 @@ const EXPECTED = [
174169
'path': 'std::option::Option',
175170
'name': 'map',
176171
'displayType': '`Option`<`T`>, F -> `Option`<U>',
177-
'displayMappedNames': `T = t, U = u`,
172+
'displayMappedNames': `t = T, u = U`,
178173
'displayWhereClause': "F: `FnOnce` (T) -> `U`",
179174
},
180175
{
181176
'path': 'std::option::Option',
182177
'name': 'and_then',
183178
'displayType': '`Option`<`T`>, F -> `Option`<U>',
184-
'displayMappedNames': `T = t, U = u`,
179+
'displayMappedNames': `t = T, u = U`,
185180
'displayWhereClause': "F: `FnOnce` (T) -> Option<`U`>",
186181
},
187182
{
188183
'path': 'std::option::Option',
189184
'name': 'zip_with',
190185
'displayType': 'Option<T>, `Option`<`U`>, F -> `Option`<R>',
191-
'displayMappedNames': `U = t, R = u`,
186+
'displayMappedNames': `t = U, u = R`,
192187
'displayWhereClause': "F: `FnOnce` (T, U) -> `R`",
193188
},
194-
{
195-
'path': 'std::task::Poll',
196-
'name': 'map_ok',
197-
'displayType': 'Poll<`Option`<Result<`T`, E>>>, F -> Poll<`Option`<Result<U, E>>>',
198-
'displayMappedNames': `T = t, U = u`,
199-
'displayWhereClause': "F: `FnOnce` (T) -> `U`",
200-
},
201-
{
202-
'path': 'std::task::Poll',
203-
'name': 'map_err',
204-
'displayType': 'Poll<`Option`<Result<`T`, E>>>, F -> Poll<`Option`<Result<T, U>>>',
205-
'displayMappedNames': `T = t, U = u`,
206-
'displayWhereClause': "F: `FnOnce` (E) -> `U`",
207-
},
208189
],
209190
},
210191
{
@@ -214,7 +195,7 @@ const EXPECTED = [
214195
'path': 'std::option::Option',
215196
'name': 'and_then',
216197
'displayType': '`Option`<`T`>, F -> `Option`<U>',
217-
'displayMappedNames': `T = t, U = u`,
198+
'displayMappedNames': `t = T, u = U`,
218199
'displayWhereClause': "F: `FnOnce` (T) -> `Option`<`U`>",
219200
},
220201
],

Diff for: ‎tests/rustdoc-js-std/vec-type-signatures.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ const EXPECTED = [
2020
],
2121
},
2222
{
23-
'query': 'vec<Allocator> -> Box<[T]>',
23+
'query': 'vec<T, Allocator> -> Box<[T]>',
2424
'others': [
2525
{
2626
'path': 'std::boxed::Box',
2727
'name': 'from',
28-
'displayType': '`Vec`<T, `A`> -> `Box`<`[T]`, A>',
28+
'displayType': '`Vec`<`T`, `A`> -> `Box`<`[T]`, A>',
2929
'displayMappedNames': `T = T`,
3030
'displayWhereClause': 'A: `Allocator`',
3131
},

Diff for: ‎tests/rustdoc-js/assoc-type-backtrack.js

+40-17
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,26 @@ const EXPECTED = [
66
'correction': null,
77
'others': [
88
{ 'path': 'assoc_type_backtrack::MyTrait', 'name': 'fold' },
9-
{ 'path': 'assoc_type_backtrack::Cloned', 'name': 'fold' },
109
],
1110
},
1211
{
1312
'query': 'mytrait<U>, mytrait2 -> T',
1413
'correction': null,
1514
'others': [
1615
{ 'path': 'assoc_type_backtrack::MyTrait', 'name': 'fold' },
16+
],
17+
},
18+
{
19+
'query': 'cloned<mytrait>, mytrait2 -> T',
20+
'correction': null,
21+
'others': [
22+
{ 'path': 'assoc_type_backtrack::Cloned', 'name': 'fold' },
23+
],
24+
},
25+
{
26+
'query': 'cloned<mytrait<U>>, mytrait2 -> T',
27+
'correction': null,
28+
'others': [
1729
{ 'path': 'assoc_type_backtrack::Cloned', 'name': 'fold' },
1830
],
1931
},
@@ -22,7 +34,6 @@ const EXPECTED = [
2234
'correction': null,
2335
'others': [
2436
{ 'path': 'assoc_type_backtrack::MyTrait', 'name': 'fold' },
25-
{ 'path': 'assoc_type_backtrack::Cloned', 'name': 'fold' },
2637
],
2738
},
2839
{
@@ -50,14 +61,14 @@ const EXPECTED = [
5061
],
5162
},
5263
{
53-
'query': 'mytrait<U> -> Option<T>',
64+
'query': 'cloned<mytrait<U>> -> Option<T>',
5465
'correction': null,
5566
'others': [
5667
{ 'path': 'assoc_type_backtrack::Cloned', 'name': 'next' },
5768
],
5869
},
5970
{
60-
'query': 'mytrait<Item=U> -> Option<T>',
71+
'query': 'cloned<mytrait<Item=U>> -> Option<T>',
6172
'correction': null,
6273
'others': [
6374
{ 'path': 'assoc_type_backtrack::Cloned', 'name': 'next' },
@@ -89,19 +100,21 @@ const EXPECTED = [
89100
],
90101
},
91102
{
92-
'query': 'myintofuture<myfuture<t>> -> myfuture<t>',
103+
'query': 'myintofuture<t, myfuture<t>> -> myfuture<t>',
93104
'correction': null,
94105
'others': [
95106
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future' },
96107
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
97108
],
98109
},
99-
// Invalid unboxing of the one-argument case.
100-
// If you unbox one of the myfutures, you need to unbox both of them.
110+
// Unboxings of the one-argument case.
101111
{
102112
'query': 'myintofuture<fut=t> -> myfuture<t>',
103113
'correction': null,
104-
'others': [],
114+
'others': [
115+
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future' },
116+
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
117+
],
105118
},
106119
// Unboxings of the two-argument case.
107120
{
@@ -119,7 +132,7 @@ const EXPECTED = [
119132
],
120133
},
121134
{
122-
'query': 'myintofuture<myfuture>, myintofuture<myfuture> -> myfuture',
135+
'query': 'myintofuture<t, myfuture>, myintofuture<t, myfuture> -> myfuture',
123136
'correction': null,
124137
'others': [
125138
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
@@ -132,32 +145,42 @@ const EXPECTED = [
132145
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
133146
],
134147
},
135-
// Invalid unboxings of the two-argument case.
136-
// If you unbox one of the myfutures, you need to unbox all of them.
148+
// If you unbox one of the myfutures, you don't need to unbox all of them.
137149
{
138150
'query': 'myintofuture<fut=t>, myintofuture<fut=myfuture<t>> -> myfuture<t>',
139151
'correction': null,
140-
'others': [],
152+
'others': [
153+
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
154+
],
141155
},
142156
{
143157
'query': 'myintofuture<fut=myfuture<t>>, myintofuture<fut=t> -> myfuture<t>',
144158
'correction': null,
145-
'others': [],
159+
'others': [
160+
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
161+
],
146162
},
147163
{
148164
'query': 'myintofuture<fut=myfuture<t>>, myintofuture<fut=myfuture<t>> -> t',
149165
'correction': null,
150-
'others': [],
166+
'others': [
167+
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
168+
],
151169
},
152-
// different generics don't match up either
170+
// different generics will match up (didn't used to, but does now)
153171
{
154172
'query': 'myintofuture<fut=myfuture<u>>, myintofuture<fut=myfuture<t>> -> myfuture<t>',
155173
'correction': null,
156-
'others': [],
174+
'others': [
175+
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
176+
],
157177
},
158178
{
159179
'query': 'myintofuture<output=t> -> myfuture<tt>',
160180
'correction': null,
161-
'others': [],
181+
'others': [
182+
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future' },
183+
{ 'path': 'assoc_type_backtrack::MyIntoFuture', 'name': 'into_future_2' },
184+
],
162185
},
163186
];

Diff for: ‎tests/rustdoc-js/assoc-type-backtrack.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(rustdoc_internals)]
2+
13
pub trait MyTrait2<X> {
24
type Output;
35
}
@@ -31,10 +33,12 @@ where
3133
}
3234
}
3335

36+
#[doc(search_unbox)]
3437
pub trait MyFuture {
3538
type Output;
3639
}
3740

41+
#[doc(search_unbox)]
3842
pub trait MyIntoFuture {
3943
type Output;
4044
type Fut: MyFuture<Output = Self::Output>;

Diff for: ‎tests/rustdoc-js/assoc-type-unbound.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const EXPECTED = [
1313
'path': 'assoc_type_unbound::MyIter',
1414
'name': 'next',
1515
'displayType': '&mut `MyIter` -> `Option`<`MyIter::Item`>',
16-
'displayMappedNames': 'MyIter::Item = T',
16+
'displayMappedNames': 'T = MyIter::Item',
1717
'displayWhereClause': '',
1818
},
1919
],
@@ -26,7 +26,7 @@ const EXPECTED = [
2626
'path': 'assoc_type_unbound::MyIter',
2727
'name': 'next',
2828
'displayType': '&mut `MyIter` -> `Option`<`MyIter::Item`>',
29-
'displayMappedNames': 'MyIter::Item = T',
29+
'displayMappedNames': 'T = MyIter::Item',
3030
'displayWhereClause': '',
3131
},
3232
],

Diff for: ‎tests/rustdoc-js/assoc-type.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
pub fn my_fn<X: Iterator<Item = Something>>(_x: X) -> u32 {
1+
#![feature(rustdoc_internals)]
2+
3+
pub fn my_fn<X: other::Iterator<Item = Something>>(_x: X) -> u32 {
24
3
35
}
46

57
pub struct Something;
68

79
pub mod my {
10+
#[doc(search_unbox)]
811
pub trait Iterator<T> {}
912
pub fn other_fn<X: Iterator<crate::Something>>(_: X) -> u32 {
1013
3
1114
}
1215
}
16+
17+
pub mod other {
18+
#[doc(search_unbox)]
19+
pub trait Iterator {
20+
type Item;
21+
}
22+
}

Diff for: ‎tests/rustdoc-js/generics-impl.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const EXPECTED = [
1414
],
1515
},
1616
{
17-
'query': 'Aaaaaaa -> usize',
17+
'query': 'Aaaaaaa -> Result<usize>',
1818
'others': [
1919
{ 'path': 'generics_impl::Aaaaaaa', 'name': 'read' },
2020
],
@@ -23,14 +23,18 @@ const EXPECTED = [
2323
'query': 'Read -> u64',
2424
'others': [
2525
{ 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' },
26+
],
27+
},
28+
{
29+
'query': 'Ddddddd<Read> -> u64',
30+
'others': [
2631
{ 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' },
2732
],
2833
},
2934
{
3035
'query': 'trait:Read -> u64',
3136
'others': [
3237
{ 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' },
33-
{ 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' },
3438
],
3539
},
3640
{

Diff for: ‎tests/rustdoc-js/generics-impl.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::io::{Read, Result as IoResult};
1+
use std::io::{self, Read};
22

33
pub struct Aaaaaaa;
44

@@ -12,7 +12,7 @@ impl Aaaaaaa {
1212
}
1313

1414
impl Read for Aaaaaaa {
15-
fn read(&mut self, out: &mut [u8]) -> IoResult<usize> {
15+
fn read(&mut self, out: &mut [u8]) -> io::Result<usize> {
1616
Ok(out.len())
1717
}
1818
}
+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// ignore-order
2+
// exact-check
3+
4+
// Make sure that results are order-agnostic, even when there's search items that only differ
5+
// by generics.
6+
7+
const EXPECTED = [
8+
{
9+
'query': 'Wrap',
10+
'in_args': [
11+
{ 'path': 'generics_match_ambiguity', 'name': 'bar' },
12+
{ 'path': 'generics_match_ambiguity', 'name': 'foo' },
13+
],
14+
},
15+
{
16+
'query': 'Wrap<i32>',
17+
'in_args': [
18+
{ 'path': 'generics_match_ambiguity', 'name': 'bar' },
19+
{ 'path': 'generics_match_ambiguity', 'name': 'foo' },
20+
],
21+
},
22+
{
23+
'query': 'Wrap<i32>, Wrap<i32, u32>',
24+
'others': [
25+
{ 'path': 'generics_match_ambiguity', 'name': 'bar' },
26+
{ 'path': 'generics_match_ambiguity', 'name': 'foo' },
27+
],
28+
},
29+
{
30+
'query': 'Wrap<i32, u32>, Wrap<i32>',
31+
'others': [
32+
{ 'path': 'generics_match_ambiguity', 'name': 'bar' },
33+
{ 'path': 'generics_match_ambiguity', 'name': 'foo' },
34+
],
35+
},
36+
{
37+
'query': 'W3<i32>, W3<i32, u32>',
38+
'others': [
39+
{ 'path': 'generics_match_ambiguity', 'name': 'baaa' },
40+
{ 'path': 'generics_match_ambiguity', 'name': 'baab' },
41+
],
42+
},
43+
{
44+
'query': 'W3<i32, u32>, W3<i32>',
45+
'others': [
46+
{ 'path': 'generics_match_ambiguity', 'name': 'baaa' },
47+
{ 'path': 'generics_match_ambiguity', 'name': 'baab' },
48+
],
49+
},
50+
{
51+
// strict generics matching; W2<i32, u32> doesn't match W2<W3<i32, u32>>,
52+
// even though W2<i32> works just fine (ignoring the W3)
53+
'query': 'W2<i32>, W2<i32, u32>',
54+
'others': [],
55+
},
56+
{
57+
'query': 'W2<i32, u32>, W2<i32>',
58+
'others': [],
59+
},
60+
{
61+
'query': 'W2<i32>, W3<i32, u32>',
62+
'others': [],
63+
},
64+
{
65+
'query': 'W2<i32>, W2<i32>',
66+
'others': [],
67+
},
68+
];
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#![crate_name = "generics_match_ambiguity"]
2+
3+
pub struct Wrap<T, U = ()>(pub T, pub U);
4+
5+
pub fn foo(a: Wrap<i32>, b: Wrap<i32, u32>) {}
6+
pub fn bar(a: Wrap<i32, u32>, b: Wrap<i32>) {}
7+
8+
pub struct W2<T>(pub T);
9+
pub struct W3<T, U = ()>(pub T, pub U);
10+
11+
pub fn baaa(a: W3<i32>, b: W3<i32, u32>) {}
12+
pub fn baab(a: W3<i32, u32>, b: W3<i32>) {}
13+
pub fn baac(a: W2<W3<i32>>, b: W3<i32, u32>) {}
14+
pub fn baad(a: W2<W3<i32, u32>>, b: W3<i32>) {}
15+
pub fn baae(a: W3<i32>, b: W2<W3<i32, u32>>) {}
16+
pub fn baaf(a: W3<i32, u32>, b: W2<W3<i32>>) {}
17+
pub fn baag(a: W2<W3<i32>>, b: W2<W3<i32, u32>>) {}
18+
pub fn baah(a: W2<W3<i32, u32>>, b: W2<W3<i32>>) {}

Diff for: ‎tests/rustdoc-js/generics-match-ambiguity.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,14 @@ const EXPECTED = [
6060
],
6161
},
6262
{
63+
// strict generics matching; W2<i32, u32> doesn't match W2<W3<i32, u32>>,
64+
// even though W2<i32> works just fine (ignoring the W3)
6365
'query': 'W2<i32>, W2<i32, u32>',
64-
'others': [
65-
{ 'path': 'generics_match_ambiguity', 'name': 'baag' },
66-
{ 'path': 'generics_match_ambiguity', 'name': 'baah' },
67-
],
66+
'others': [],
6867
},
6968
{
7069
'query': 'W2<i32, u32>, W2<i32>',
71-
'others': [
72-
{ 'path': 'generics_match_ambiguity', 'name': 'baag' },
73-
{ 'path': 'generics_match_ambiguity', 'name': 'baah' },
74-
],
70+
'others': [],
7571
},
7672
{
7773
'query': 'W2<i32>, W3<i32, u32>',

Diff for: ‎tests/rustdoc-js/generics-match-ambiguity.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
#![feature(rustdoc_internals)]
2+
3+
#[doc(search_unbox)]
14
pub struct Wrap<T, U = ()>(pub T, pub U);
25

36
pub fn foo(a: Wrap<i32>, b: Wrap<i32, u32>) {}
47
pub fn bar(a: Wrap<i32, u32>, b: Wrap<i32>) {}
58

9+
#[doc(search_unbox)]
610
pub struct W2<T>(pub T);
11+
#[doc(search_unbox)]
712
pub struct W3<T, U = ()>(pub T, pub U);
813

914
pub fn baaa(a: W3<i32>, b: W3<i32, u32>) {}
@@ -14,4 +19,3 @@ pub fn baae(a: W3<i32>, b: W2<W3<i32, u32>>) {}
1419
pub fn baaf(a: W3<i32, u32>, b: W2<W3<i32>>) {}
1520
pub fn baag(a: W2<W3<i32>>, b: W2<W3<i32, u32>>) {}
1621
pub fn baah(a: W2<W3<i32, u32>>, b: W2<W3<i32>>) {}
17-
//

Diff for: ‎tests/rustdoc-js/generics-nested.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ const EXPECTED = [
1818
],
1919
},
2020
{
21+
// can't put generics out of order
2122
'query': '-> Out<Second, First>',
22-
'others': [
23-
{ 'path': 'generics_nested', 'name': 'bet' },
24-
],
23+
'others': [],
2524
},
2625
];

Diff for: ‎tests/rustdoc-js/generics-unbox.js

-4
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,24 @@ const EXPECTED = [
1111
'query': 'Inside<T> -> Out3<T>',
1212
'others': [
1313
{ 'path': 'generics_unbox', 'name': 'beta' },
14-
{ 'path': 'generics_unbox', 'name': 'gamma' },
1514
],
1615
},
1716
{
1817
'query': 'Inside<T> -> Out4<T>',
1918
'others': [
20-
{ 'path': 'generics_unbox', 'name': 'beta' },
2119
{ 'path': 'generics_unbox', 'name': 'gamma' },
2220
],
2321
},
2422
{
2523
'query': 'Inside<T> -> Out3<U, T>',
2624
'others': [
27-
{ 'path': 'generics_unbox', 'name': 'beta' },
2825
{ 'path': 'generics_unbox', 'name': 'gamma' },
2926
],
3027
},
3128
{
3229
'query': 'Inside<T> -> Out4<U, T>',
3330
'others': [
3431
{ 'path': 'generics_unbox', 'name': 'beta' },
35-
{ 'path': 'generics_unbox', 'name': 'gamma' },
3632
],
3733
},
3834
];

Diff for: ‎tests/rustdoc-js/generics-unbox.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,34 @@
1+
#![feature(rustdoc_internals)]
2+
3+
#[doc(search_unbox)]
14
pub struct Out<A, B = ()> {
25
a: A,
36
b: B,
47
}
58

9+
#[doc(search_unbox)]
610
pub struct Out1<A, const N: usize> {
711
a: [A; N],
812
}
913

14+
#[doc(search_unbox)]
1015
pub struct Out2<A, const N: usize> {
1116
a: [A; N],
1217
}
1318

19+
#[doc(search_unbox)]
1420
pub struct Out3<A, B> {
1521
a: A,
1622
b: B,
1723
}
1824

25+
#[doc(search_unbox)]
1926
pub struct Out4<A, B> {
2027
a: A,
2128
b: B,
2229
}
2330

31+
#[doc(search_unbox)]
2432
pub struct Inside<T>(T);
2533

2634
pub fn alpha<const N: usize, T>(_: Inside<T>) -> Out<Out1<T, N>, Out2<T, N>> {

Diff for: ‎tests/rustdoc-js/generics.js

+2-15
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,8 @@ const EXPECTED = [
3030
'others': [
3131
{ 'path': 'generics', 'name': 'P' },
3232
],
33-
'returned': [
34-
{ 'path': 'generics', 'name': 'alef' },
35-
],
36-
'in_args': [
37-
{ 'path': 'generics', 'name': 'alpha' },
38-
],
39-
},
40-
{
41-
'query': 'P',
42-
'returned': [
43-
{ 'path': 'generics', 'name': 'alef' },
44-
],
45-
'in_args': [
46-
{ 'path': 'generics', 'name': 'alpha' },
47-
],
33+
'returned': [],
34+
'in_args': [],
4835
},
4936
{
5037
'query': '"ExtraCreditStructMulti"<ExtraCreditInnerMulti, ExtraCreditInnerMulti>',

Diff for: ‎tests/rustdoc-js/hof.js

+11-14
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ const EXPECTED = [
99

1010
// ML-style higher-order function notation
1111
{
12-
'query': 'bool, (u32 -> !) -> ()',
12+
'query': 'bool, (first<u32> -> !) -> ()',
1313
'others': [
1414
{"path": "hof", "name": "fn_ptr"},
1515
],
1616
},
1717
{
18-
'query': 'u8, (u32 -> !) -> ()',
18+
'query': 'u8, (second<u32> -> !) -> ()',
1919
'others': [
2020
{"path": "hof", "name": "fn_once"},
2121
],
2222
},
2323
{
24-
'query': 'i8, (u32 -> !) -> ()',
24+
'query': 'i8, (third<u32> -> !) -> ()',
2525
'others': [
2626
{"path": "hof", "name": "fn_mut"},
2727
],
@@ -54,9 +54,6 @@ const EXPECTED = [
5454
'query': '(u32 -> !) -> ()',
5555
'others': [
5656
{"path": "hof", "name": "fn_"},
57-
{"path": "hof", "name": "fn_ptr"},
58-
{"path": "hof", "name": "fn_mut"},
59-
{"path": "hof", "name": "fn_once"},
6057
],
6158
},
6259
{
@@ -95,30 +92,30 @@ const EXPECTED = [
9592

9693
// Rust-style higher-order function notation
9794
{
98-
'query': 'bool, fn(u32) -> ! -> ()',
95+
'query': 'bool, fn(first<u32>) -> ! -> ()',
9996
'others': [
10097
{"path": "hof", "name": "fn_ptr"},
10198
],
10299
},
103100
{
104-
'query': 'u8, fnonce(u32) -> ! -> ()',
101+
'query': 'u8, fnonce(second<u32>) -> ! -> ()',
105102
'others': [
106103
{"path": "hof", "name": "fn_once"},
107104
],
108105
},
109106
{
110-
'query': 'u8, fn(u32) -> ! -> ()',
107+
'query': 'u8, fn(second<u32>) -> ! -> ()',
111108
// fnonce != fn
112109
'others': [],
113110
},
114111
{
115-
'query': 'i8, fnmut(u32) -> ! -> ()',
112+
'query': 'i8, fnmut(third<u32>) -> ! -> ()',
116113
'others': [
117114
{"path": "hof", "name": "fn_mut"},
118115
],
119116
},
120117
{
121-
'query': 'i8, fn(u32) -> ! -> ()',
118+
'query': 'i8, fn(third<u32>) -> ! -> ()',
122119
// fnmut != fn
123120
'others': [],
124121
},
@@ -152,22 +149,22 @@ const EXPECTED = [
152149
],
153150
},
154151
{
155-
'query': 'fn(u32) -> ! -> ()',
152+
'query': 'fn() -> ! -> ()',
156153
'others': [
157154
// fn matches primitive:fn and trait:Fn
158155
{"path": "hof", "name": "fn_"},
159156
{"path": "hof", "name": "fn_ptr"},
160157
],
161158
},
162159
{
163-
'query': 'trait:fn(u32) -> ! -> ()',
160+
'query': 'trait:fn() -> ! -> ()',
164161
'others': [
165162
// fn matches primitive:fn and trait:Fn
166163
{"path": "hof", "name": "fn_"},
167164
],
168165
},
169166
{
170-
'query': 'primitive:fn(u32) -> ! -> ()',
167+
'query': 'primitive:fn() -> ! -> ()',
171168
'others': [
172169
// fn matches primitive:fn and trait:Fn
173170
{"path": "hof", "name": "fn_ptr"},

Diff for: ‎tests/rustdoc-js/looks-like-rustc-interner.js

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
const EXPECTED = {
55
'query': 'canonicalvarinfo, intoiterator -> intoiterator',
6+
'others': [],
7+
'query': '[canonicalvarinfo], interner<tys=intoiterator> -> intoiterator',
68
'others': [
79
{ 'path': 'looks_like_rustc_interner::Interner', 'name': 'mk_canonical_var_infos' },
810
],

Diff for: ‎tests/rustdoc-js/nested-unboxed.js

+3-6
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@ const EXPECTED = [
3333
},
3434
{
3535
'query': '-> Result<i32, u32, bool>',
36-
'others': [
37-
{ 'path': 'nested_unboxed', 'name': 'something' },
38-
],
36+
// can't put nested generics out of order
37+
'others': [],
3938
},
4039
{
4140
'query': '-> Result<Object<i32>, bool>',
@@ -45,9 +44,7 @@ const EXPECTED = [
4544
},
4645
{
4746
'query': '-> Result<Object<u32>, bool>',
48-
'others': [
49-
{ 'path': 'nested_unboxed', 'name': 'something' },
50-
],
47+
'others': [],
5148
},
5249
{
5350
'query': '-> Result<Object<i32>, u32, bool>',

Diff for: ‎tests/rustdoc-js/nested-unboxed.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#![feature(rustdoc_internals)]
2+
3+
#[doc(search_unbox)]
14
pub struct Object<T, U>(T, U);
25

36
pub fn something() -> Result<Object<i32, u32>, bool> {

Diff for: ‎tests/rustdoc-js/reference.js

+6-9
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ const EXPECTED = [
7979
},
8080
{
8181
'query': 'reference<ring>, reference<ring> -> ()',
82-
'others': [
83-
{ 'path': 'reference::Ring', 'name': 'wear' },
84-
],
82+
// can't leave out the `mut`, because can't reorder like that
83+
'others': [],
8584
},
8685
{
8786
'query': 'reference<mut, ring>, reference<ring> -> ()',
@@ -102,9 +101,8 @@ const EXPECTED = [
102101
},
103102
{
104103
'query': 'reference<middle>, reference<middle> -> ()',
105-
'others': [
106-
{ 'path': 'reference', 'name': 'show' },
107-
],
104+
// can't leave out the mut
105+
'others': [],
108106
},
109107
{
110108
'query': 'reference<mut, middle>, reference<mut, middle> -> ()',
@@ -203,9 +201,8 @@ const EXPECTED = [
203201
// middle with shorthand
204202
{
205203
'query': '&middle, &middle -> ()',
206-
'others': [
207-
{ 'path': 'reference', 'name': 'show' },
208-
],
204+
// can't leave out the mut
205+
'others': [],
209206
},
210207
{
211208
'query': '&mut middle, &mut middle -> ()',

Diff for: ‎tests/rustdoc-js/tuple-unit.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const EXPECTED = [
5757
'in_args': [],
5858
},
5959
{
60-
'query': '(Q, ())',
60+
'query': '(Q, R<()>)',
6161
'returned': [
6262
{ 'path': 'tuple_unit', 'name': 'nest' },
6363
],
@@ -71,7 +71,7 @@ const EXPECTED = [
7171
'in_args': [],
7272
},
7373
{
74-
'query': '(u32)',
74+
'query': 'R<(u32)>',
7575
'returned': [
7676
{ 'path': 'tuple_unit', 'name': 'nest' },
7777
],

Diff for: ‎tests/ui/feature-gates/feature-gate-rustdoc_internals.rs

+4
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,8 @@ trait Mine {}
77
#[doc(fake_variadic)] //~ ERROR: `#[doc(fake_variadic)]` is meant for internal use only
88
impl<T> Mine for (T,) {}
99

10+
11+
#[doc(search_unbox)] //~ ERROR: `#[doc(search_unbox)]` is meant for internal use only
12+
struct Wrap<T> (T);
13+
1014
fn main() {}

Diff for: ‎tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr

+11-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ LL | #[doc(fake_variadic)]
1818
= help: add `#![feature(rustdoc_internals)]` to the crate attributes to enable
1919
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
2020

21-
error: aborting due to 2 previous errors
21+
error[E0658]: `#[doc(search_unbox)]` is meant for internal use only
22+
--> $DIR/feature-gate-rustdoc_internals.rs:11:1
23+
|
24+
LL | #[doc(search_unbox)]
25+
| ^^^^^^^^^^^^^^^^^^^^
26+
|
27+
= note: see issue #90418 <https://github.com/rust-lang/rust/issues/90418> for more information
28+
= help: add `#![feature(rustdoc_internals)]` to the crate attributes to enable
29+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
30+
31+
error: aborting due to 3 previous errors
2232

2333
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)
Please sign in to comment.