Skip to content

Commit 9379bcd

Browse files
committed
Auto merge of #50033 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 4 pull requests Successful merges: - #49699 (Removed 'proc' from the reserved keywords list) - #49966 (Multiple query search) - #50013 (Remove no longer necessary comparison to Vec::splice.) - #50032 (rustdoc: Don't include private paths in all.html) Failed merges:
2 parents 881a7cd + 92d29c1 commit 9379bcd

File tree

8 files changed

+217
-158
lines changed

8 files changed

+217
-158
lines changed

src/liballoc/string.rs

-3
Original file line numberDiff line numberDiff line change
@@ -1521,9 +1521,6 @@ impl String {
15211521
/// and replaces it with the given string.
15221522
/// The given string doesn't need to be the same length as the range.
15231523
///
1524-
/// Note: Unlike [`Vec::splice`], the replacement happens eagerly, and this
1525-
/// method does not return the removed chars.
1526-
///
15271524
/// # Panics
15281525
///
15291526
/// Panics if the starting point or end point do not lie on a [`char`]

src/librustdoc/html/layout.rs

+110-122
Original file line numberDiff line numberDiff line change
@@ -37,128 +37,116 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
3737
-> io::Result<()>
3838
{
3939
write!(dst,
40-
r##"<!DOCTYPE html>
41-
<html lang="en">
42-
<head>
43-
<meta charset="utf-8">
44-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
45-
<meta name="generator" content="rustdoc">
46-
<meta name="description" content="{description}">
47-
<meta name="keywords" content="{keywords}">
48-
49-
<title>{title}</title>
50-
51-
<link rel="stylesheet" type="text/css" href="{root_path}normalize{suffix}.css">
52-
<link rel="stylesheet" type="text/css" href="{root_path}rustdoc{suffix}.css"
53-
id="mainThemeStyle">
54-
{themes}
55-
<link rel="stylesheet" type="text/css" href="{root_path}dark{suffix}.css">
56-
<link rel="stylesheet" type="text/css" href="{root_path}light{suffix}.css" id="themeStyle">
57-
<script src="{root_path}storage{suffix}.js"></script>
58-
{css_extension}
59-
60-
{favicon}
61-
{in_header}
62-
</head>
63-
<body class="rustdoc {css_class}">
64-
<!--[if lte IE 8]>
65-
<div class="warning">
66-
This old browser is unsupported and will most likely display funky
67-
things.
68-
</div>
69-
<![endif]-->
70-
71-
{before_content}
72-
73-
<nav class="sidebar">
74-
<div class="sidebar-menu">&#9776;</div>
75-
{logo}
76-
{sidebar}
77-
</nav>
78-
79-
<div class="theme-picker">
80-
<button id="theme-picker" aria-label="Pick another theme!">
81-
<img src="{root_path}brush{suffix}.svg" width="18" alt="Pick another theme!">
82-
</button>
83-
<div id="theme-choices"></div>
84-
</div>
85-
<script src="{root_path}theme{suffix}.js"></script>
86-
<nav class="sub">
87-
<form class="search-form js-only">
88-
<div class="search-container">
89-
<input class="search-input" name="search"
90-
autocomplete="off"
91-
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
92-
type="search">
93-
</div>
94-
</form>
95-
</nav>
96-
97-
<section id='main' class="content">{content}</section>
98-
<section id='search' class="content hidden"></section>
99-
100-
<section class="footer"></section>
101-
102-
<aside id="help" class="hidden">
103-
<div>
104-
<h1 class="hidden">Help</h1>
105-
106-
<div class="shortcuts">
107-
<h2>Keyboard Shortcuts</h2>
108-
109-
<dl>
110-
<dt><kbd>?</kbd></dt>
111-
<dd>Show this help dialog</dd>
112-
<dt><kbd>S</kbd></dt>
113-
<dd>Focus the search field</dd>
114-
<dt><kbd>↑</kbd></dt>
115-
<dd>Move up in search results</dd>
116-
<dt><kbd>↓</kbd></dt>
117-
<dd>Move down in search results</dd>
118-
<dt><kbd>↹</kbd></dt>
119-
<dd>Switch tab</dd>
120-
<dt><kbd>&#9166;</kbd></dt>
121-
<dd>Go to active search result</dd>
122-
<dt><kbd>+</kbd></dt>
123-
<dd>Expand all sections</dd>
124-
<dt><kbd>-</kbd></dt>
125-
<dd>Collapse all sections</dd>
126-
</dl>
127-
</div>
128-
129-
<div class="infos">
130-
<h2>Search Tricks</h2>
131-
132-
<p>
133-
Prefix searches with a type followed by a colon (e.g.
134-
<code>fn:</code>) to restrict the search to a given type.
135-
</p>
136-
137-
<p>
138-
Accepted types are: <code>fn</code>, <code>mod</code>,
139-
<code>struct</code>, <code>enum</code>,
140-
<code>trait</code>, <code>type</code>, <code>macro</code>,
141-
and <code>const</code>.
142-
</p>
143-
144-
<p>
145-
Search functions by type signature (e.g.
146-
<code>vec -> usize</code> or <code>* -> vec</code>)
147-
</p>
148-
</div>
149-
</div>
150-
</aside>
151-
152-
{after_content}
153-
154-
<script>
155-
window.rootPath = "{root_path}";
156-
window.currentCrate = "{krate}";
157-
</script>
158-
<script src="{root_path}main{suffix}.js"></script>
159-
<script defer src="{root_path}search-index.js"></script>
160-
</body>
161-
</html>"##,
40+
"<!DOCTYPE html>\
41+
<html lang=\"en\">\
42+
<head>\
43+
<meta charset=\"utf-8\">\
44+
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\
45+
<meta name=\"generator\" content=\"rustdoc\">\
46+
<meta name=\"description\" content=\"{description}\">\
47+
<meta name=\"keywords\" content=\"{keywords}\">\
48+
<title>{title}</title>\
49+
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}normalize{suffix}.css\">\
50+
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}rustdoc{suffix}.css\" \
51+
id=\"mainThemeStyle\">\
52+
{themes}\
53+
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}dark{suffix}.css\">\
54+
<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}light{suffix}.css\" \
55+
id=\"themeStyle\">\
56+
<script src=\"{root_path}storage{suffix}.js\"></script>\
57+
{css_extension}\
58+
{favicon}\
59+
{in_header}\
60+
</head>\
61+
<body class=\"rustdoc {css_class}\">\
62+
<!--[if lte IE 8]>\
63+
<div class=\"warning\">\
64+
This old browser is unsupported and will most likely display funky \
65+
things.\
66+
</div>\
67+
<![endif]-->\
68+
{before_content}\
69+
<nav class=\"sidebar\">\
70+
<div class=\"sidebar-menu\">&#9776;</div>\
71+
{logo}\
72+
{sidebar}\
73+
</nav>\
74+
<div class=\"theme-picker\">\
75+
<button id=\"theme-picker\" aria-label=\"Pick another theme!\">\
76+
<img src=\"{root_path}brush{suffix}.svg\" width=\"18\" alt=\"Pick another theme!\">\
77+
</button>\
78+
<div id=\"theme-choices\"></div>\
79+
</div>\
80+
<script src=\"{root_path}theme{suffix}.js\"></script>\
81+
<nav class=\"sub\">\
82+
<form class=\"search-form js-only\">\
83+
<div class=\"search-container\">\
84+
<input class=\"search-input\" name=\"search\" \
85+
autocomplete=\"off\" \
86+
placeholder=\"Click or press ‘S’ to search, ‘?’ for more options…\" \
87+
type=\"search\">\
88+
</div>\
89+
</form>\
90+
</nav>\
91+
<section id=\"main\" class=\"content\">{content}</section>\
92+
<section id=\"search\" class=\"content hidden\"></section>\
93+
<section class=\"footer\"></section>\
94+
<aside id=\"help\" class=\"hidden\">\
95+
<div>\
96+
<h1 class=\"hidden\">Help</h1>\
97+
<div class=\"shortcuts\">\
98+
<h2>Keyboard Shortcuts</h2>\
99+
<dl>\
100+
<dt><kbd>?</kbd></dt>\
101+
<dd>Show this help dialog</dd>\
102+
<dt><kbd>S</kbd></dt>\
103+
<dd>Focus the search field</dd>\
104+
<dt><kbd>↑</kbd></dt>\
105+
<dd>Move up in search results</dd>\
106+
<dt><kbd>↓</kbd></dt>\
107+
<dd>Move down in search results</dd>\
108+
<dt><kbd>↹</kbd></dt>\
109+
<dd>Switch tab</dd>\
110+
<dt><kbd>&#9166;</kbd></dt>\
111+
<dd>Go to active search result</dd>\
112+
<dt><kbd>+</kbd></dt>\
113+
<dd>Expand all sections</dd>\
114+
<dt><kbd>-</kbd></dt>\
115+
<dd>Collapse all sections</dd>\
116+
</dl>\
117+
</div>\
118+
<div class=\"infos\">\
119+
<h2>Search Tricks</h2>\
120+
<p>\
121+
Prefix searches with a type followed by a colon (e.g. \
122+
<code>fn:</code>) to restrict the search to a given type.\
123+
</p>\
124+
<p>\
125+
Accepted types are: <code>fn</code>, <code>mod</code>, \
126+
<code>struct</code>, <code>enum</code>, \
127+
<code>trait</code>, <code>type</code>, <code>macro</code>, \
128+
and <code>const</code>.\
129+
</p>\
130+
<p>\
131+
Search functions by type signature (e.g. \
132+
<code>vec -> usize</code> or <code>* -> vec</code>)\
133+
</p>\
134+
<p>\
135+
Search multiple things at once by splitting your query with comma (e.g. \
136+
<code>str,u8</code> or <code>String,struct:Vec,test</code>)\
137+
</p>\
138+
</div>\
139+
</div>\
140+
</aside>\
141+
{after_content}\
142+
<script>\
143+
window.rootPath = \"{root_path}\";\
144+
window.currentCrate = \"{krate}\";\
145+
</script>\
146+
<script src=\"{root_path}main{suffix}.js\"></script>\
147+
<script defer src=\"{root_path}search-index.js\"></script>\
148+
</body>\
149+
</html>",
162150
css_extension = if css_file_extension {
163151
format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{root_path}theme{suffix}.css\">",
164152
root_path = page.root_path,

src/librustdoc/html/render.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,9 @@ impl Context {
17281728
let mut dst = try_err!(File::create(&joint_dst), &joint_dst);
17291729
try_err!(dst.write_all(&buf), &joint_dst);
17301730

1731-
all.append(full_path(self, &item), &item_type);
1731+
if !self.render_redirect_pages {
1732+
all.append(full_path(self, &item), &item_type);
1733+
}
17321734
// Redirect from a sane URL using the namespace to Rustdoc's
17331735
// URL for the page.
17341736
let redir_name = format!("{}.{}.html", name, item_type.name_space());

src/librustdoc/html/static/main.js

+70-7
Original file line numberDiff line numberDiff line change
@@ -1299,14 +1299,78 @@
12991299
printTab(currentTab);
13001300
}
13011301

1302+
function execSearch(query, searchWords) {
1303+
var queries = query.raw.split(",");
1304+
var results = {
1305+
'in_args': [],
1306+
'returned': [],
1307+
'others': [],
1308+
};
1309+
1310+
for (var i = 0; i < queries.length; ++i) {
1311+
var query = queries[i].trim();
1312+
if (query.length !== 0) {
1313+
var tmp = execQuery(getQuery(query), searchWords);
1314+
1315+
results['in_args'].push(tmp['in_args']);
1316+
results['returned'].push(tmp['returned']);
1317+
results['others'].push(tmp['others']);
1318+
}
1319+
}
1320+
if (queries.length > 1) {
1321+
function getSmallest(arrays, positions) {
1322+
var start = null;
1323+
1324+
for (var it = 0; it < positions.length; ++it) {
1325+
if (arrays[it].length > positions[it] &&
1326+
(start === null || start > arrays[it][positions[it]].lev)) {
1327+
start = arrays[it][positions[it]].lev;
1328+
}
1329+
}
1330+
return start;
1331+
}
1332+
1333+
function mergeArrays(arrays) {
1334+
var ret = [];
1335+
var positions = [];
1336+
1337+
for (var x = 0; x < arrays.length; ++x) {
1338+
positions.push(0);
1339+
}
1340+
while (ret.length < MAX_RESULTS) {
1341+
var smallest = getSmallest(arrays, positions);
1342+
if (smallest === null) {
1343+
break;
1344+
}
1345+
for (x = 0; x < arrays.length && ret.length < MAX_RESULTS; ++x) {
1346+
if (arrays[x].length > positions[x] &&
1347+
arrays[x][positions[x]].lev === smallest) {
1348+
ret.push(arrays[x][positions[x]]);
1349+
positions[x] += 1;
1350+
}
1351+
}
1352+
}
1353+
return ret;
1354+
}
1355+
1356+
return {
1357+
'in_args': mergeArrays(results['in_args']),
1358+
'returned': mergeArrays(results['returned']),
1359+
'others': mergeArrays(results['others']),
1360+
};
1361+
} else {
1362+
return {
1363+
'in_args': results['in_args'][0],
1364+
'returned': results['returned'][0],
1365+
'others': results['others'][0],
1366+
};
1367+
}
1368+
}
1369+
13021370
function search(e) {
1303-
var query,
1304-
obj, i, len,
1305-
results = {"in_args": [], "returned": [], "others": []},
1306-
resultIndex;
13071371
var params = getQueryStringParams();
1372+
var query = getQuery(document.getElementsByClassName('search-input')[0].value);
13081373

1309-
query = getQuery(document.getElementsByClassName('search-input')[0].value);
13101374
if (e) {
13111375
e.preventDefault();
13121376
}
@@ -1328,8 +1392,7 @@
13281392
}
13291393
}
13301394

1331-
results = execQuery(query, index);
1332-
showResults(results);
1395+
showResults(execSearch(query, index));
13331396
}
13341397

13351398
function buildIndex(rawSearchIndex) {

src/libsyntax_pos/symbol.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -336,24 +336,23 @@ declare_keywords! {
336336
(46, Offsetof, "offsetof")
337337
(47, Override, "override")
338338
(48, Priv, "priv")
339-
(49, Proc, "proc")
340-
(50, Pure, "pure")
341-
(51, Sizeof, "sizeof")
342-
(52, Typeof, "typeof")
343-
(53, Unsized, "unsized")
344-
(54, Virtual, "virtual")
345-
(55, Yield, "yield")
339+
(49, Pure, "pure")
340+
(50, Sizeof, "sizeof")
341+
(51, Typeof, "typeof")
342+
(52, Unsized, "unsized")
343+
(53, Virtual, "virtual")
344+
(54, Yield, "yield")
346345

347346
// Special lifetime names
348-
(56, UnderscoreLifetime, "'_")
349-
(57, StaticLifetime, "'static")
347+
(55, UnderscoreLifetime, "'_")
348+
(56, StaticLifetime, "'static")
350349

351350
// Weak keywords, have special meaning only in specific contexts.
352-
(58, Auto, "auto")
353-
(59, Catch, "catch")
354-
(60, Default, "default")
355-
(61, Dyn, "dyn")
356-
(62, Union, "union")
351+
(57, Auto, "auto")
352+
(58, Catch, "catch")
353+
(59, Default, "default")
354+
(60, Dyn, "dyn")
355+
(61, Union, "union")
357356
}
358357

359358
// If an interner exists, return it. Otherwise, prepare a fresh one.

0 commit comments

Comments
 (0)