Skip to content

Commit 88cd367

Browse files
committed
Auto merge of #50245 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 4 pull requests Successful merges: - #50177 (mark std::str::replace(,n) as #[must_use]) - #50207 (Hash EntryKind::AssociatedConst const data) - #50214 (Js improvements) - #50219 (Added missing `.` in docs.) Failed merges: - #50229 (Add setting to go to item if there is only one result)
2 parents 3eca70a + 438f3ca commit 88cd367

File tree

5 files changed

+30
-34
lines changed

5 files changed

+30
-34
lines changed

src/liballoc/arc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const MAX_REFCOUNT: usize = (isize::MAX) as usize;
6060
/// ## Thread Safety
6161
///
6262
/// Unlike [`Rc<T>`], `Arc<T>` uses atomic operations for its reference
63-
/// counting This means that it is thread-safe. The disadvantage is that
63+
/// counting. This means that it is thread-safe. The disadvantage is that
6464
/// atomic operations are more expensive than ordinary memory accesses. If you
6565
/// are not sharing reference-counted values between threads, consider using
6666
/// [`Rc<T>`] for lower overhead. [`Rc<T>`] is a safe default, because the

src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
#![feature(dropck_eyepatch)]
9797
#![feature(exact_size_is_empty)]
9898
#![feature(fmt_internals)]
99+
#![feature(fn_must_use)]
99100
#![feature(from_ref)]
100101
#![feature(fundamental)]
101102
#![feature(lang_items)]

src/liballoc/str.rs

+2
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ impl str {
207207
/// let s = "this is old";
208208
/// assert_eq!(s, s.replace("cookie monster", "little lamb"));
209209
/// ```
210+
#[must_use]
210211
#[stable(feature = "rust1", since = "1.0.0")]
211212
#[inline]
212213
pub fn replace<'a, P: Pattern<'a>>(&'a self, from: P, to: &str) -> String {
@@ -246,6 +247,7 @@ impl str {
246247
/// let s = "this is old";
247248
/// assert_eq!(s, s.replacen("cookie monster", "little lamb", 10));
248249
/// ```
250+
#[must_use]
249251
#[stable(feature = "str_replacen", since = "1.16.0")]
250252
pub fn replacen<'a, P: Pattern<'a>>(&'a self, pat: P, to: &str, count: usize) -> String {
251253
// Hope to reduce the times of re-allocation

src/librustc_metadata/schema.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,10 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for EntryKind<'gcx> {
373373
EntryKind::AssociatedType(associated_container) => {
374374
associated_container.hash_stable(hcx, hasher);
375375
}
376-
EntryKind::AssociatedConst(associated_container, qualif, _) => {
376+
EntryKind::AssociatedConst(associated_container, qualif, ref const_data) => {
377377
associated_container.hash_stable(hcx, hasher);
378378
qualif.hash_stable(hcx, hasher);
379+
const_data.hash_stable(hcx, hasher);
379380
}
380381
}
381382
}

src/librustdoc/html/static/main.js

+24-32
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
"union",
4141
"foreigntype"];
4242

43+
var search_input = document.getElementsByClassName('search-input')[0];
44+
4345
// On the search screen, so you remain on the last tab you opened.
4446
//
4547
// 0 for "In Names"
@@ -411,8 +413,8 @@
411413
// but only if the input bar is empty. This avoid the obnoxious issue
412414
// where you start trying to do a search, and the index loads, and
413415
// suddenly your search is gone!
414-
if (document.getElementsByClassName("search-input")[0].value === "") {
415-
document.getElementsByClassName("search-input")[0].value = params.search || '';
416+
if (search_input.value === "") {
417+
search_input.value = params.search || '';
416418
}
417419

418420
/**
@@ -1118,7 +1120,6 @@
11181120
});
11191121
});
11201122

1121-
var search_input = document.getElementsByClassName('search-input')[0];
11221123
search_input.onkeydown = function(e) {
11231124
// "actives" references the currently highlighted item in each search tab.
11241125
// Each array in "actives" represents a tab.
@@ -1169,7 +1170,7 @@
11691170
// Does nothing, it's just to avoid losing "focus" on the highlighted element.
11701171
} else if (e.which === 27) { // escape
11711172
removeClass(actives[currentTab][0], 'highlighted');
1172-
document.getElementsByClassName('search-input')[0].value = '';
1173+
search_input.value = '';
11731174
defocusSearchBar();
11741175
} else if (actives[currentTab].length > 0) {
11751176
removeClass(actives[currentTab][0], 'highlighted');
@@ -1206,7 +1207,6 @@
12061207
return;
12071208
}
12081209

1209-
console.log(item);
12101210
shown.push(id_ty);
12111211
name = item.name;
12121212
type = itemTypes[item.ty];
@@ -1268,7 +1268,7 @@
12681268
}
12691269

12701270
function showResults(results) {
1271-
var output, query = getQuery(document.getElementsByClassName('search-input')[0].value);
1271+
var output, query = getQuery(search_input.value);
12721272

12731273
currentResults = query.id;
12741274
output = '<h1>Results for ' + escape(query.query) +
@@ -1375,14 +1375,13 @@
13751375

13761376
function search(e) {
13771377
var params = getQueryStringParams();
1378-
var search_input = document.getElementsByClassName('search-input')[0];
13791378
var query = getQuery(search_input.value.trim());
13801379

13811380
if (e) {
13821381
e.preventDefault();
13831382
}
13841383

1385-
if (!query.query || query.id === currentResults) {
1384+
if (query.query.length === 0 || query.id === currentResults) {
13861385
if (query.query.length > 0) {
13871386
putBackSearch(search_input);
13881387
}
@@ -1468,9 +1467,6 @@
14681467
function startSearch() {
14691468
var searchTimeout;
14701469
var callback = function() {
1471-
var search_input = document.getElementsByClassName('search-input');
1472-
if (search_input.length < 1) { return; }
1473-
search_input = search_input[0];
14741470
clearTimeout(searchTimeout);
14751471
if (search_input.value.length === 0) {
14761472
if (browserSupportsHistoryApi()) {
@@ -1488,7 +1484,6 @@
14881484
searchTimeout = setTimeout(search, 500);
14891485
}
14901486
};
1491-
var search_input = document.getElementsByClassName("search-input")[0];
14921487
search_input.onkeyup = callback;
14931488
search_input.oninput = callback;
14941489
document.getElementsByClassName("search-form")[0].onsubmit = function(e) {
@@ -1538,9 +1533,9 @@
15381533
// nothing there, which lets you really go back to a
15391534
// previous state with nothing in the bar.
15401535
if (params.search) {
1541-
document.getElementsByClassName('search-input')[0].value = params.search;
1536+
search_input.value = params.search;
15421537
} else {
1543-
document.getElementsByClassName('search-input')[0].value = '';
1538+
search_input.value = '';
15441539
}
15451540
// Some browsers fire 'onpopstate' for every page load
15461541
// (Chrome), while others fire the event only when actually
@@ -1950,28 +1945,14 @@
19501945
return wrapper;
19511946
}
19521947

1953-
onEach(document.getElementById('main').getElementsByClassName('docblock'), function(e) {
1954-
if (e.parentNode.id === "main") {
1955-
var otherMessage;
1956-
if (hasClass(e, "type-decl")) {
1957-
otherMessage = '&nbsp;Show&nbsp;type&nbsp;declaration';
1958-
}
1959-
e.parentNode.insertBefore(createToggle(otherMessage), e);
1960-
if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {
1961-
collapseDocs(e.previousSibling.childNodes[0], "toggle");
1962-
}
1963-
}
1964-
});
1965-
19661948
onEach(document.getElementsByClassName('docblock'), function(e) {
19671949
if (hasClass(e, 'autohide')) {
19681950
var wrap = e.previousElementSibling;
19691951
if (wrap && hasClass(wrap, 'toggle-wrapper')) {
19701952
var toggle = wrap.childNodes[0];
1953+
var extra = false;
19711954
if (e.childNodes[0].tagName === 'H3') {
1972-
onEach(toggle.getElementsByClassName('toggle-label'), function(i_e) {
1973-
i_e.innerHTML = " Show " + e.childNodes[0].innerHTML;
1974-
});
1955+
extra = true;
19751956
}
19761957
e.style.display = 'none';
19771958
addClass(wrap, 'collapsed');
@@ -1980,9 +1961,22 @@
19801961
});
19811962
onEach(toggle.getElementsByClassName('toggle-label'), function(e) {
19821963
e.style.display = 'inline-block';
1964+
if (extra === true) {
1965+
i_e.innerHTML = " Show " + e.childNodes[0].innerHTML;
1966+
}
19831967
});
19841968
}
19851969
}
1970+
if (e.parentNode.id === "main") {
1971+
var otherMessage;
1972+
if (hasClass(e, "type-decl")) {
1973+
otherMessage = '&nbsp;Show&nbsp;type&nbsp;declaration';
1974+
}
1975+
e.parentNode.insertBefore(createToggle(otherMessage), e);
1976+
if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {
1977+
collapseDocs(e.previousSibling.childNodes[0], "toggle");
1978+
}
1979+
}
19861980
})
19871981

19881982
autoCollapseAllImpls(getPageId());
@@ -2088,8 +2082,6 @@
20882082
}
20892083
}
20902084

2091-
var search_input = document.getElementsByClassName("search-input")[0];
2092-
20932085
if (search_input) {
20942086
search_input.onfocus = function() {
20952087
putBackSearch(this);

0 commit comments

Comments
 (0)