1
Fork 0

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)
This commit is contained in:
bors 2018-04-26 11:07:14 +00:00
commit 88cd36714c
5 changed files with 30 additions and 34 deletions

View file

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

View file

@ -96,6 +96,7 @@
#![feature(dropck_eyepatch)] #![feature(dropck_eyepatch)]
#![feature(exact_size_is_empty)] #![feature(exact_size_is_empty)]
#![feature(fmt_internals)] #![feature(fmt_internals)]
#![feature(fn_must_use)]
#![feature(from_ref)] #![feature(from_ref)]
#![feature(fundamental)] #![feature(fundamental)]
#![feature(lang_items)] #![feature(lang_items)]

View file

@ -207,6 +207,7 @@ impl str {
/// let s = "this is old"; /// let s = "this is old";
/// assert_eq!(s, s.replace("cookie monster", "little lamb")); /// assert_eq!(s, s.replace("cookie monster", "little lamb"));
/// ``` /// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[inline] #[inline]
pub fn replace<'a, P: Pattern<'a>>(&'a self, from: P, to: &str) -> String { pub fn replace<'a, P: Pattern<'a>>(&'a self, from: P, to: &str) -> String {
@ -246,6 +247,7 @@ impl str {
/// let s = "this is old"; /// let s = "this is old";
/// assert_eq!(s, s.replacen("cookie monster", "little lamb", 10)); /// assert_eq!(s, s.replacen("cookie monster", "little lamb", 10));
/// ``` /// ```
#[must_use]
#[stable(feature = "str_replacen", since = "1.16.0")] #[stable(feature = "str_replacen", since = "1.16.0")]
pub fn replacen<'a, P: Pattern<'a>>(&'a self, pat: P, to: &str, count: usize) -> String { pub fn replacen<'a, P: Pattern<'a>>(&'a self, pat: P, to: &str, count: usize) -> String {
// Hope to reduce the times of re-allocation // Hope to reduce the times of re-allocation

View file

@ -373,9 +373,10 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for EntryKind<'gcx> {
EntryKind::AssociatedType(associated_container) => { EntryKind::AssociatedType(associated_container) => {
associated_container.hash_stable(hcx, hasher); associated_container.hash_stable(hcx, hasher);
} }
EntryKind::AssociatedConst(associated_container, qualif, _) => { EntryKind::AssociatedConst(associated_container, qualif, ref const_data) => {
associated_container.hash_stable(hcx, hasher); associated_container.hash_stable(hcx, hasher);
qualif.hash_stable(hcx, hasher); qualif.hash_stable(hcx, hasher);
const_data.hash_stable(hcx, hasher);
} }
} }
} }

View file

@ -40,6 +40,8 @@
"union", "union",
"foreigntype"]; "foreigntype"];
var search_input = document.getElementsByClassName('search-input')[0];
// On the search screen, so you remain on the last tab you opened. // On the search screen, so you remain on the last tab you opened.
// //
// 0 for "In Names" // 0 for "In Names"
@ -411,8 +413,8 @@
// but only if the input bar is empty. This avoid the obnoxious issue // but only if the input bar is empty. This avoid the obnoxious issue
// where you start trying to do a search, and the index loads, and // where you start trying to do a search, and the index loads, and
// suddenly your search is gone! // suddenly your search is gone!
if (document.getElementsByClassName("search-input")[0].value === "") { if (search_input.value === "") {
document.getElementsByClassName("search-input")[0].value = params.search || ''; search_input.value = params.search || '';
} }
/** /**
@ -1118,7 +1120,6 @@
}); });
}); });
var search_input = document.getElementsByClassName('search-input')[0];
search_input.onkeydown = function(e) { search_input.onkeydown = function(e) {
// "actives" references the currently highlighted item in each search tab. // "actives" references the currently highlighted item in each search tab.
// Each array in "actives" represents a tab. // Each array in "actives" represents a tab.
@ -1169,7 +1170,7 @@
// Does nothing, it's just to avoid losing "focus" on the highlighted element. // Does nothing, it's just to avoid losing "focus" on the highlighted element.
} else if (e.which === 27) { // escape } else if (e.which === 27) { // escape
removeClass(actives[currentTab][0], 'highlighted'); removeClass(actives[currentTab][0], 'highlighted');
document.getElementsByClassName('search-input')[0].value = ''; search_input.value = '';
defocusSearchBar(); defocusSearchBar();
} else if (actives[currentTab].length > 0) { } else if (actives[currentTab].length > 0) {
removeClass(actives[currentTab][0], 'highlighted'); removeClass(actives[currentTab][0], 'highlighted');
@ -1206,7 +1207,6 @@
return; return;
} }
console.log(item);
shown.push(id_ty); shown.push(id_ty);
name = item.name; name = item.name;
type = itemTypes[item.ty]; type = itemTypes[item.ty];
@ -1268,7 +1268,7 @@
} }
function showResults(results) { function showResults(results) {
var output, query = getQuery(document.getElementsByClassName('search-input')[0].value); var output, query = getQuery(search_input.value);
currentResults = query.id; currentResults = query.id;
output = '<h1>Results for ' + escape(query.query) + output = '<h1>Results for ' + escape(query.query) +
@ -1375,14 +1375,13 @@
function search(e) { function search(e) {
var params = getQueryStringParams(); var params = getQueryStringParams();
var search_input = document.getElementsByClassName('search-input')[0];
var query = getQuery(search_input.value.trim()); var query = getQuery(search_input.value.trim());
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
} }
if (!query.query || query.id === currentResults) { if (query.query.length === 0 || query.id === currentResults) {
if (query.query.length > 0) { if (query.query.length > 0) {
putBackSearch(search_input); putBackSearch(search_input);
} }
@ -1468,9 +1467,6 @@
function startSearch() { function startSearch() {
var searchTimeout; var searchTimeout;
var callback = function() { var callback = function() {
var search_input = document.getElementsByClassName('search-input');
if (search_input.length < 1) { return; }
search_input = search_input[0];
clearTimeout(searchTimeout); clearTimeout(searchTimeout);
if (search_input.value.length === 0) { if (search_input.value.length === 0) {
if (browserSupportsHistoryApi()) { if (browserSupportsHistoryApi()) {
@ -1488,7 +1484,6 @@
searchTimeout = setTimeout(search, 500); searchTimeout = setTimeout(search, 500);
} }
}; };
var search_input = document.getElementsByClassName("search-input")[0];
search_input.onkeyup = callback; search_input.onkeyup = callback;
search_input.oninput = callback; search_input.oninput = callback;
document.getElementsByClassName("search-form")[0].onsubmit = function(e) { document.getElementsByClassName("search-form")[0].onsubmit = function(e) {
@ -1538,9 +1533,9 @@
// nothing there, which lets you really go back to a // nothing there, which lets you really go back to a
// previous state with nothing in the bar. // previous state with nothing in the bar.
if (params.search) { if (params.search) {
document.getElementsByClassName('search-input')[0].value = params.search; search_input.value = params.search;
} else { } else {
document.getElementsByClassName('search-input')[0].value = ''; search_input.value = '';
} }
// Some browsers fire 'onpopstate' for every page load // Some browsers fire 'onpopstate' for every page load
// (Chrome), while others fire the event only when actually // (Chrome), while others fire the event only when actually
@ -1950,28 +1945,14 @@
return wrapper; return wrapper;
} }
onEach(document.getElementById('main').getElementsByClassName('docblock'), function(e) {
if (e.parentNode.id === "main") {
var otherMessage;
if (hasClass(e, "type-decl")) {
otherMessage = '&nbsp;Show&nbsp;type&nbsp;declaration';
}
e.parentNode.insertBefore(createToggle(otherMessage), e);
if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {
collapseDocs(e.previousSibling.childNodes[0], "toggle");
}
}
});
onEach(document.getElementsByClassName('docblock'), function(e) { onEach(document.getElementsByClassName('docblock'), function(e) {
if (hasClass(e, 'autohide')) { if (hasClass(e, 'autohide')) {
var wrap = e.previousElementSibling; var wrap = e.previousElementSibling;
if (wrap && hasClass(wrap, 'toggle-wrapper')) { if (wrap && hasClass(wrap, 'toggle-wrapper')) {
var toggle = wrap.childNodes[0]; var toggle = wrap.childNodes[0];
var extra = false;
if (e.childNodes[0].tagName === 'H3') { if (e.childNodes[0].tagName === 'H3') {
onEach(toggle.getElementsByClassName('toggle-label'), function(i_e) { extra = true;
i_e.innerHTML = " Show " + e.childNodes[0].innerHTML;
});
} }
e.style.display = 'none'; e.style.display = 'none';
addClass(wrap, 'collapsed'); addClass(wrap, 'collapsed');
@ -1980,9 +1961,22 @@
}); });
onEach(toggle.getElementsByClassName('toggle-label'), function(e) { onEach(toggle.getElementsByClassName('toggle-label'), function(e) {
e.style.display = 'inline-block'; e.style.display = 'inline-block';
if (extra === true) {
i_e.innerHTML = " Show " + e.childNodes[0].innerHTML;
}
}); });
} }
} }
if (e.parentNode.id === "main") {
var otherMessage;
if (hasClass(e, "type-decl")) {
otherMessage = '&nbsp;Show&nbsp;type&nbsp;declaration';
}
e.parentNode.insertBefore(createToggle(otherMessage), e);
if (otherMessage && getCurrentValue('rustdoc-item-declarations') !== "false") {
collapseDocs(e.previousSibling.childNodes[0], "toggle");
}
}
}) })
autoCollapseAllImpls(getPageId()); autoCollapseAllImpls(getPageId());
@ -2088,8 +2082,6 @@
} }
} }
var search_input = document.getElementsByClassName("search-input")[0];
if (search_input) { if (search_input) {
search_input.onfocus = function() { search_input.onfocus = function() {
putBackSearch(this); putBackSearch(this);