Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit f09fb48

Browse files
committedJan 19, 2021
Auto merge of rust-lang#81186 - GuillaumeGomez:rollup-y2d04g9, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - rust-lang#80382 (Improve search result tab handling) - rust-lang#81112 (Remove unused alloc::std::ops re-export.) - rust-lang#81115 (BTreeMap: prefer bulk_steal functions over specialized ones) - rust-lang#81147 (Fix structured suggestion for explicit `drop` call) - rust-lang#81161 (Remove inline script tags) - rust-lang#81164 (Fix typo in simplify.rs) - rust-lang#81166 (remove some outdated comments regarding debug assertions) - rust-lang#81168 (Fixes rust-lang#81109 - Typo in pointer::wrapping_sub) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 47121d6 + dcb7479 commit f09fb48

File tree

27 files changed

+166
-182
lines changed

27 files changed

+166
-182
lines changed
 

‎compiler/rustc_mir_build/src/build/matches/simplify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
5555
// * the bindings from the previous iteration of the loop is prepended to the bindings from
5656
// the current iteration (in the implementation this is done by mem::swap and extend)
5757
// * after all iterations, these new bindings are then appended to the bindings that were
58-
// prexisting (i.e. `candidate.binding` when the function was called).
58+
// preexisting (i.e. `candidate.binding` when the function was called).
5959
//
6060
// example:
6161
// candidate.bindings = [1, 2, 3]

‎compiler/rustc_typeck/src/check/callee.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,24 @@ pub fn check_legal_trait_for_method_call(
2525
tcx: TyCtxt<'_>,
2626
span: Span,
2727
receiver: Option<Span>,
28+
expr_span: Span,
2829
trait_id: DefId,
2930
) {
3031
if tcx.lang_items().drop_trait() == Some(trait_id) {
3132
let mut err = struct_span_err!(tcx.sess, span, E0040, "explicit use of destructor method");
3233
err.span_label(span, "explicit destructor calls not allowed");
3334

34-
let snippet = receiver
35+
let (sp, suggestion) = receiver
3536
.and_then(|s| tcx.sess.source_map().span_to_snippet(s).ok())
36-
.unwrap_or_default();
37-
38-
let suggestion =
39-
if snippet.is_empty() { "drop".to_string() } else { format!("drop({})", snippet) };
37+
.filter(|snippet| !snippet.is_empty())
38+
.map(|snippet| (expr_span, format!("drop({})", snippet)))
39+
.unwrap_or_else(|| (span, "drop".to_string()));
4040

4141
err.span_suggestion(
42-
span,
43-
&format!("consider using `drop` function: `{}`", suggestion),
44-
String::new(),
45-
Applicability::Unspecified,
42+
sp,
43+
"consider using `drop` function",
44+
suggestion,
45+
Applicability::MaybeIncorrect,
4646
);
4747

4848
err.emit();

‎compiler/rustc_typeck/src/check/fn_ctxt/_impl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11631163
debug!("instantiate_value_path: def_id={:?} container={:?}", def_id, container);
11641164
match container {
11651165
ty::TraitContainer(trait_did) => {
1166-
callee::check_legal_trait_for_method_call(tcx, span, None, trait_did)
1166+
callee::check_legal_trait_for_method_call(tcx, span, None, span, trait_did)
11671167
}
11681168
ty::ImplContainer(impl_def_id) => {
11691169
if segments.len() == 1 {

‎compiler/rustc_typeck/src/check/method/confirm.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
508508
self.tcx,
509509
self.span,
510510
Some(self.self_expr.span),
511+
self.call_expr.span,
511512
trait_def_id,
512513
),
513514
ty::ImplContainer(..) => {}

‎library/alloc/src/collections/btree/node.rs

Lines changed: 4 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,6 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Leaf> {
592592
self.val_area_mut(idx).write(val);
593593
}
594594
}
595-
596-
/// Adds a key-value pair to the beginning of the node.
597-
fn push_front(&mut self, key: K, val: V) {
598-
let new_len = self.len() + 1;
599-
assert!(new_len <= CAPACITY);
600-
unsafe {
601-
slice_insert(self.key_area_mut(..new_len), 0, key);
602-
slice_insert(self.val_area_mut(..new_len), 0, val);
603-
*self.len_mut() = new_len as u16;
604-
}
605-
}
606595
}
607596

608597
impl<'a, K, V> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
@@ -638,88 +627,6 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
638627
Handle::new_edge(self.reborrow_mut(), idx + 1).correct_parent_link();
639628
}
640629
}
641-
642-
/// Adds a key-value pair, and an edge to go to the left of that pair,
643-
/// to the beginning of the node.
644-
fn push_front(&mut self, key: K, val: V, edge: Root<K, V>) {
645-
let new_len = self.len() + 1;
646-
assert!(edge.height == self.height - 1);
647-
assert!(new_len <= CAPACITY);
648-
649-
unsafe {
650-
slice_insert(self.key_area_mut(..new_len), 0, key);
651-
slice_insert(self.val_area_mut(..new_len), 0, val);
652-
slice_insert(self.edge_area_mut(..new_len + 1), 0, edge.node);
653-
*self.len_mut() = new_len as u16;
654-
}
655-
656-
self.correct_all_childrens_parent_links();
657-
}
658-
}
659-
660-
impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal> {
661-
/// Removes a key-value pair from the end of the node and returns the pair.
662-
/// Also removes the edge that was to the right of that pair and, if the node
663-
/// is internal, returns the orphaned subtree that this edge owned.
664-
///
665-
/// # Safety
666-
/// The node must not be empty.
667-
unsafe fn pop(&mut self) -> (K, V, Option<Root<K, V>>) {
668-
debug_assert!(self.len() > 0);
669-
670-
let idx = self.len() - 1;
671-
672-
unsafe {
673-
let key = self.key_area_mut(idx).assume_init_read();
674-
let val = self.val_area_mut(idx).assume_init_read();
675-
let edge = match self.reborrow_mut().force() {
676-
ForceResult::Leaf(_) => None,
677-
ForceResult::Internal(mut internal) => {
678-
let node = internal.edge_area_mut(idx + 1).assume_init_read();
679-
let mut edge = Root { node, height: internal.height - 1, _marker: PhantomData };
680-
// Currently, clearing the parent link is superfluous, because we will
681-
// insert the node elsewhere and set its parent link again.
682-
edge.clear_parent_link();
683-
Some(edge)
684-
}
685-
};
686-
687-
*self.len_mut() -= 1;
688-
(key, val, edge)
689-
}
690-
}
691-
692-
/// Removes a key-value pair from the beginning of the node and returns the pair.
693-
/// Also removes the edge that was to the left of that pair and, if the node is
694-
/// internal, returns the orphaned subtree that this edge owned.
695-
fn pop_front(&mut self) -> (K, V, Option<Root<K, V>>) {
696-
debug_assert!(self.len() > 0);
697-
698-
let old_len = self.len();
699-
700-
unsafe {
701-
let key = slice_remove(self.key_area_mut(..old_len), 0);
702-
let val = slice_remove(self.val_area_mut(..old_len), 0);
703-
let edge = match self.reborrow_mut().force() {
704-
ForceResult::Leaf(_) => None,
705-
ForceResult::Internal(mut internal) => {
706-
let node = slice_remove(internal.edge_area_mut(..old_len + 1), 0);
707-
let mut edge = Root { node, height: internal.height - 1, _marker: PhantomData };
708-
// Currently, clearing the parent link is superfluous, because we will
709-
// insert the node elsewhere and set its parent link again.
710-
edge.clear_parent_link();
711-
712-
internal.correct_childrens_parent_links(0..old_len);
713-
714-
Some(edge)
715-
}
716-
};
717-
718-
*self.len_mut() -= 1;
719-
720-
(key, val, edge)
721-
}
722-
}
723630
}
724631

725632
impl<BorrowType, K, V> NodeRef<BorrowType, K, V, marker::LeafOrInternal> {
@@ -1399,18 +1306,8 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> {
13991306
mut self,
14001307
track_right_edge_idx: usize,
14011308
) -> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::Edge> {
1402-
unsafe {
1403-
let (k, v, edge) = self.left_child.pop();
1404-
1405-
let (k, v) = self.parent.replace_kv(k, v);
1406-
1407-
match self.right_child.reborrow_mut().force() {
1408-
ForceResult::Leaf(mut leaf) => leaf.push_front(k, v),
1409-
ForceResult::Internal(mut internal) => internal.push_front(k, v, edge.unwrap()),
1410-
}
1411-
1412-
Handle::new_edge(self.right_child, 1 + track_right_edge_idx)
1413-
}
1309+
self.bulk_steal_left(1);
1310+
unsafe { Handle::new_edge(self.right_child, 1 + track_right_edge_idx) }
14141311
}
14151312

14161313
/// Removes a key-value pair from the right child and places it in the key-value storage
@@ -1421,18 +1318,8 @@ impl<'a, K: 'a, V: 'a> BalancingContext<'a, K, V> {
14211318
mut self,
14221319
track_left_edge_idx: usize,
14231320
) -> Handle<NodeRef<marker::Mut<'a>, K, V, marker::LeafOrInternal>, marker::Edge> {
1424-
unsafe {
1425-
let (k, v, edge) = self.right_child.pop_front();
1426-
1427-
let (k, v) = self.parent.replace_kv(k, v);
1428-
1429-
match self.left_child.reborrow_mut().force() {
1430-
ForceResult::Leaf(mut leaf) => leaf.push(k, v),
1431-
ForceResult::Internal(mut internal) => internal.push(k, v, edge.unwrap()),
1432-
}
1433-
1434-
Handle::new_edge(self.left_child, track_left_edge_idx)
1435-
}
1321+
self.bulk_steal_right(1);
1322+
unsafe { Handle::new_edge(self.left_child, track_left_edge_idx) }
14361323
}
14371324

14381325
/// This does stealing similar to `steal_left` but steals multiple elements at once.

‎library/alloc/src/collections/btree/remove.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,25 @@ impl<'a, K: 'a, V: 'a> NodeRef<marker::Mut<'a>, K, V, marker::Internal> {
121121
self,
122122
) -> Option<NodeRef<marker::Mut<'a>, K, V, marker::Internal>> {
123123
match self.forget_type().choose_parent_kv() {
124-
Ok(Left(left_parent_kv)) => {
124+
Ok(Left(mut left_parent_kv)) => {
125125
debug_assert_eq!(left_parent_kv.right_child_len(), MIN_LEN - 1);
126126
if left_parent_kv.can_merge() {
127127
let parent = left_parent_kv.merge_tracking_parent();
128128
Some(parent)
129129
} else {
130130
debug_assert!(left_parent_kv.left_child_len() > MIN_LEN);
131-
left_parent_kv.steal_left(0);
131+
left_parent_kv.bulk_steal_left(1);
132132
None
133133
}
134134
}
135-
Ok(Right(right_parent_kv)) => {
135+
Ok(Right(mut right_parent_kv)) => {
136136
debug_assert_eq!(right_parent_kv.left_child_len(), MIN_LEN - 1);
137137
if right_parent_kv.can_merge() {
138138
let parent = right_parent_kv.merge_tracking_parent();
139139
Some(parent)
140140
} else {
141141
debug_assert!(right_parent_kv.right_child_len() > MIN_LEN);
142-
right_parent_kv.steal_right(0);
142+
right_parent_kv.bulk_steal_right(1);
143143
None
144144
}
145145
}

‎library/alloc/src/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,6 @@ pub mod task;
185185
mod tests;
186186
pub mod vec;
187187

188-
#[cfg(not(test))]
189-
mod std {
190-
pub use core::ops; // RangeFull
191-
}
192-
193188
#[doc(hidden)]
194189
#[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")]
195190
pub mod __export {

‎library/core/src/ptr/const_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ impl<T: ?Sized> *const T {
633633
}
634634

635635
/// Calculates the offset from a pointer using wrapping arithmetic.
636-
/// (convenience for `.wrapping_offset((count as isize).wrapping_sub())`)
636+
/// (convenience for `.wrapping_offset((count as isize).wrapping_neg())`)
637637
///
638638
/// `count` is in units of T; e.g., a `count` of 3 represents a pointer
639639
/// offset of `3 * size_of::<T>()` bytes.

‎library/core/src/ptr/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ pub unsafe fn replace<T>(dst: *mut T, mut src: T) -> T {
687687
#[stable(feature = "rust1", since = "1.0.0")]
688688
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
689689
pub const unsafe fn read<T>(src: *const T) -> T {
690-
// `copy_nonoverlapping` takes care of debug_assert.
691690
let mut tmp = MaybeUninit::<T>::uninit();
692691
// SAFETY: the caller must guarantee that `src` is valid for reads.
693692
// `src` cannot overlap `tmp` because `tmp` was just allocated on
@@ -787,7 +786,6 @@ pub const unsafe fn read<T>(src: *const T) -> T {
787786
#[stable(feature = "ptr_unaligned", since = "1.17.0")]
788787
#[rustc_const_unstable(feature = "const_ptr_read", issue = "80377")]
789788
pub const unsafe fn read_unaligned<T>(src: *const T) -> T {
790-
// `copy_nonoverlapping` takes care of debug_assert.
791789
let mut tmp = MaybeUninit::<T>::uninit();
792790
// SAFETY: the caller must guarantee that `src` is valid for reads.
793791
// `src` cannot overlap `tmp` because `tmp` was just allocated on
@@ -988,7 +986,6 @@ pub unsafe fn write_unaligned<T>(dst: *mut T, src: T) {
988986
// `dst` cannot overlap `src` because the caller has mutable access
989987
// to `dst` while `src` is owned by this function.
990988
unsafe {
991-
// `copy_nonoverlapping` takes care of debug_assert.
992989
copy_nonoverlapping(&src as *const T as *const u8, dst as *mut u8, mem::size_of::<T>());
993990
}
994991
mem::forget(src);

‎library/core/src/ptr/mut_ptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ impl<T: ?Sized> *mut T {
740740
}
741741

742742
/// Calculates the offset from a pointer using wrapping arithmetic.
743-
/// (convenience for `.wrapping_offset((count as isize).wrapping_sub())`)
743+
/// (convenience for `.wrapping_offset((count as isize).wrapping_neg())`)
744744
///
745745
/// `count` is in units of T; e.g., a `count` of 3 represents a pointer
746746
/// offset of `3 * size_of::<T>()` bytes.

‎src/librustdoc/html/layout.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,7 @@ crate fn render<T: Print, S: Print>(
111111
<section id=\"search\" class=\"content hidden\"></section>\
112112
<section class=\"footer\"></section>\
113113
{after_content}\
114-
<script>\
115-
window.rootPath = \"{root_path}\";\
116-
window.currentCrate = \"{krate}\";\
117-
</script>\
114+
<div id=\"rustdoc-vars\" data-root-path=\"{root_path}\" data-current-crate=\"{krate}\"></div>
118115
<script src=\"{static_root_path}main{suffix}.js\"></script>\
119116
{static_extra_scripts}\
120117
{extra_scripts}\

‎src/librustdoc/html/markdown.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,8 @@ fn init_id_map() -> FxHashMap<String, usize> {
13131313
map.insert("toggle-all-docs".to_owned(), 1);
13141314
map.insert("all-types".to_owned(), 1);
13151315
map.insert("default-settings".to_owned(), 1);
1316+
map.insert("rustdoc-vars".to_owned(), 1);
1317+
map.insert("sidebar-vars".to_owned(), 1);
13161318
// This is the list of IDs used by rustdoc sections.
13171319
map.insert("fields".to_owned(), 1);
13181320
map.insert("variants".to_owned(), 1);

‎src/librustdoc/html/render/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4216,11 +4216,8 @@ fn print_sidebar(cx: &Context<'_>, it: &clean::Item, buffer: &mut Buffer, cache:
42164216
let relpath = if it.is_mod() { "../" } else { "" };
42174217
write!(
42184218
buffer,
4219-
"<script>window.sidebarCurrent = {{\
4220-
name: \"{name}\", \
4221-
ty: \"{ty}\", \
4222-
relpath: \"{path}\"\
4223-
}};</script>",
4219+
"<div id=\"sidebar-vars\" data-name=\"{name}\" data-ty=\"{ty}\" data-relpath=\"{path}\">\
4220+
</div>",
42244221
name = it.name.unwrap_or(kw::Empty),
42254222
ty = it.type_(),
42264223
path = relpath

‎src/librustdoc/html/static/main.js

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// From rust:
2-
/* global ALIASES, currentCrate, rootPath */
2+
/* global ALIASES */
33

44
// Local js definitions:
55
/* global addClass, getCurrentValue, hasClass */
@@ -40,6 +40,21 @@ if (!DOMTokenList.prototype.remove) {
4040
};
4141
}
4242

43+
(function () {
44+
var rustdocVars = document.getElementById("rustdoc-vars");
45+
if (rustdocVars) {
46+
window.rootPath = rustdocVars.attributes["data-root-path"].value;
47+
window.currentCrate = rustdocVars.attributes["data-current-crate"].value;
48+
}
49+
var sidebarVars = document.getElementById("sidebar-vars");
50+
if (sidebarVars) {
51+
window.sidebarCurrent = {
52+
name: sidebarVars.attributes["data-name"].value,
53+
ty: sidebarVars.attributes["data-ty"].value,
54+
relpath: sidebarVars.attributes["data-relpath"].value,
55+
};
56+
}
57+
}());
4358

4459
// Gets the human-readable string for the virtual-key code of the
4560
// given KeyboardEvent, ev.
@@ -565,7 +580,7 @@ function defocusSearchBar() {
565580
var i, match,
566581
url = document.location.href,
567582
stripped = "",
568-
len = rootPath.match(/\.\.\//g).length + 1;
583+
len = window.rootPath.match(/\.\.\//g).length + 1;
569584

570585
for (i = 0; i < len; ++i) {
571586
match = url.match(/\/[^\/]*$/);
@@ -1504,15 +1519,15 @@ function defocusSearchBar() {
15041519

15051520
if (type === "mod") {
15061521
displayPath = path + "::";
1507-
href = rootPath + path.replace(/::/g, "/") + "/" +
1522+
href = window.rootPath + path.replace(/::/g, "/") + "/" +
15081523
name + "/index.html";
15091524
} else if (type === "primitive" || type === "keyword") {
15101525
displayPath = "";
1511-
href = rootPath + path.replace(/::/g, "/") +
1526+
href = window.rootPath + path.replace(/::/g, "/") +
15121527
"/" + type + "." + name + ".html";
15131528
} else if (type === "externcrate") {
15141529
displayPath = "";
1515-
href = rootPath + name + "/index.html";
1530+
href = window.rootPath + name + "/index.html";
15161531
} else if (item.parent !== undefined) {
15171532
var myparent = item.parent;
15181533
var anchor = "#" + type + "." + name;
@@ -1535,13 +1550,13 @@ function defocusSearchBar() {
15351550
} else {
15361551
displayPath = path + "::" + myparent.name + "::";
15371552
}
1538-
href = rootPath + path.replace(/::/g, "/") +
1553+
href = window.rootPath + path.replace(/::/g, "/") +
15391554
"/" + pageType +
15401555
"." + pageName +
15411556
".html" + anchor;
15421557
} else {
15431558
displayPath = item.path + "::";
1544-
href = rootPath + item.path.replace(/::/g, "/") +
1559+
href = window.rootPath + item.path.replace(/::/g, "/") +
15451560
"/" + type + "." + name + ".html";
15461561
}
15471562
return [displayPath, href];
@@ -1650,6 +1665,21 @@ function defocusSearchBar() {
16501665
var ret_in_args = addTab(results.in_args, query, false);
16511666
var ret_returned = addTab(results.returned, query, false);
16521667

1668+
// Navigate to the relevant tab if the current tab is empty, like in case users search
1669+
// for "-> String". If they had selected another tab previously, they have to click on
1670+
// it again.
1671+
if ((currentTab === 0 && ret_others[1] === 0) ||
1672+
(currentTab === 1 && ret_in_args[1] === 0) ||
1673+
(currentTab === 2 && ret_returned[1] === 0)) {
1674+
if (ret_others[1] !== 0) {
1675+
currentTab = 0;
1676+
} else if (ret_in_args[1] !== 0) {
1677+
currentTab = 1;
1678+
} else if (ret_returned[1] !== 0) {
1679+
currentTab = 2;
1680+
}
1681+
}
1682+
16531683
var output = "<h1>Results for " + escape(query.query) +
16541684
(query.type ? " (type: " + escape(query.type) + ")" : "") + "</h1>" +
16551685
"<div id=\"titles\">" +
@@ -1973,7 +2003,7 @@ function defocusSearchBar() {
19732003
startSearch();
19742004

19752005
// Draw a convenient sidebar of known crates if we have a listing
1976-
if (rootPath === "../" || rootPath === "./") {
2006+
if (window.rootPath === "../" || window.rootPath === "./") {
19772007
var sidebar = document.getElementsByClassName("sidebar-elems")[0];
19782008
if (sidebar) {
19792009
var div = document.createElement("div");
@@ -1992,11 +2022,11 @@ function defocusSearchBar() {
19922022
crates.sort();
19932023
for (var i = 0; i < crates.length; ++i) {
19942024
var klass = "crate";
1995-
if (rootPath !== "./" && crates[i] === window.currentCrate) {
2025+
if (window.rootPath !== "./" && crates[i] === window.currentCrate) {
19962026
klass += " current";
19972027
}
19982028
var link = document.createElement("a");
1999-
link.href = rootPath + crates[i] + "/index.html";
2029+
link.href = window.rootPath + crates[i] + "/index.html";
20002030
// The summary in the search index has HTML, so we need to
20012031
// dynamically render it as plaintext.
20022032
link.title = convertHTMLToPlaintext(rawSearchIndex[crates[i]].doc);
@@ -2118,7 +2148,7 @@ function defocusSearchBar() {
21182148

21192149
var libs = Object.getOwnPropertyNames(imp);
21202150
for (var i = 0, llength = libs.length; i < llength; ++i) {
2121-
if (libs[i] === currentCrate) { continue; }
2151+
if (libs[i] === window.currentCrate) { continue; }
21222152
var structs = imp[libs[i]];
21232153

21242154
struct_loop:
@@ -2143,7 +2173,7 @@ function defocusSearchBar() {
21432173
var href = elem.getAttribute("href");
21442174

21452175
if (href && href.indexOf("http") !== 0) {
2146-
elem.setAttribute("href", rootPath + href);
2176+
elem.setAttribute("href", window.rootPath + href);
21472177
}
21482178
});
21492179

‎src/test/ui/error-codes/E0040.fixed

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// run-rustfix
2+
struct Foo {
3+
x: i32,
4+
}
5+
6+
impl Drop for Foo {
7+
fn drop(&mut self) {
8+
println!("kaboom");
9+
}
10+
}
11+
12+
fn main() {
13+
let mut x = Foo { x: -7 };
14+
x.x = 0;
15+
println!("{}", x.x);
16+
drop(x);
17+
//~^ ERROR E0040
18+
}

‎src/test/ui/error-codes/E0040.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// run-rustfix
12
struct Foo {
23
x: i32,
34
}
@@ -10,6 +11,8 @@ impl Drop for Foo {
1011

1112
fn main() {
1213
let mut x = Foo { x: -7 };
14+
x.x = 0;
15+
println!("{}", x.x);
1316
x.drop();
1417
//~^ ERROR E0040
1518
}

‎src/test/ui/error-codes/E0040.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0040]: explicit use of destructor method
2-
--> $DIR/E0040.rs:13:7
2+
--> $DIR/E0040.rs:16:7
33
|
44
LL | x.drop();
5-
| ^^^^
6-
| |
7-
| explicit destructor calls not allowed
8-
| help: consider using `drop` function: `drop(x)`
5+
| --^^^^--
6+
| | |
7+
| | explicit destructor calls not allowed
8+
| help: consider using `drop` function: `drop(x)`
99

1010
error: aborting due to previous error
1111

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// run-rustfix
2+
struct Foo {
3+
x: isize
4+
}
5+
6+
impl Drop for Foo {
7+
fn drop(&mut self) {
8+
println!("kaboom");
9+
}
10+
}
11+
12+
fn main() {
13+
let x = Foo { x: 3 };
14+
println!("{}", x.x);
15+
drop(x); //~ ERROR explicit use of destructor method
16+
}

‎src/test/ui/explicit/explicit-call-to-dtor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// run-rustfix
12
struct Foo {
23
x: isize
34
}
@@ -10,5 +11,6 @@ impl Drop for Foo {
1011

1112
fn main() {
1213
let x = Foo { x: 3 };
14+
println!("{}", x.x);
1315
x.drop(); //~ ERROR explicit use of destructor method
1416
}

‎src/test/ui/explicit/explicit-call-to-dtor.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0040]: explicit use of destructor method
2-
--> $DIR/explicit-call-to-dtor.rs:13:7
2+
--> $DIR/explicit-call-to-dtor.rs:15:7
33
|
44
LL | x.drop();
5-
| ^^^^
6-
| |
7-
| explicit destructor calls not allowed
8-
| help: consider using `drop` function: `drop(x)`
5+
| --^^^^--
6+
| | |
7+
| | explicit destructor calls not allowed
8+
| help: consider using `drop` function: `drop(x)`
99

1010
error: aborting due to previous error
1111

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// run-rustfix
2+
struct Foo {
3+
x: isize
4+
}
5+
6+
#[allow(drop_bounds)]
7+
trait Bar: Drop {
8+
fn blah(&self);
9+
}
10+
11+
impl Drop for Foo {
12+
fn drop(&mut self) {
13+
println!("kaboom");
14+
}
15+
}
16+
17+
impl Bar for Foo {
18+
fn blah(&self) {
19+
drop(self); //~ ERROR explicit use of destructor method
20+
}
21+
}
22+
23+
fn main() {
24+
let x = Foo { x: 3 };
25+
println!("{}", x.x);
26+
}

‎src/test/ui/explicit/explicit-call-to-supertrait-dtor.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// run-rustfix
12
struct Foo {
23
x: isize
34
}
45

5-
trait Bar : Drop {
6+
#[allow(drop_bounds)]
7+
trait Bar: Drop {
68
fn blah(&self);
79
}
810

@@ -20,4 +22,5 @@ impl Bar for Foo {
2022

2123
fn main() {
2224
let x = Foo { x: 3 };
25+
println!("{}", x.x);
2326
}

‎src/test/ui/explicit/explicit-call-to-supertrait-dtor.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0040]: explicit use of destructor method
2-
--> $DIR/explicit-call-to-supertrait-dtor.rs:17:14
2+
--> $DIR/explicit-call-to-supertrait-dtor.rs:19:14
33
|
44
LL | self.drop();
5-
| ^^^^
6-
| |
7-
| explicit destructor calls not allowed
8-
| help: consider using `drop` function: `drop(self)`
5+
| -----^^^^--
6+
| | |
7+
| | explicit destructor calls not allowed
8+
| help: consider using `drop` function: `drop(self)`
99

1010
error: aborting due to previous error
1111

‎src/test/ui/illegal-ufcs-drop.fixed

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// run-rustfix
2+
struct Foo;
3+
4+
impl Drop for Foo {
5+
fn drop(&mut self) {}
6+
}
7+
8+
fn main() {
9+
drop(&mut Foo) //~ ERROR explicit use of destructor method
10+
}

‎src/test/ui/illegal-ufcs-drop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// run-rustfix
12
struct Foo;
23

34
impl Drop for Foo {

‎src/test/ui/illegal-ufcs-drop.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0040]: explicit use of destructor method
2-
--> $DIR/illegal-ufcs-drop.rs:8:5
2+
--> $DIR/illegal-ufcs-drop.rs:9:5
33
|
44
LL | Drop::drop(&mut Foo)
55
| ^^^^^^^^^^

‎src/tools/rustdoc-js/tester.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,7 @@ function loadMainJsAndIndex(mainJs, searchIndex, storageJs, crate) {
263263
"handleAliases", "getQuery", "buildIndex", "execQuery", "execSearch"];
264264

265265
ALIASES = {};
266-
finalJS += 'window = { "currentCrate": "' + crate + '" };\n';
267-
finalJS += 'var rootPath = "../";\n';
266+
finalJS += 'window = { "currentCrate": "' + crate + '", rootPath: "../" };\n';
268267
finalJS += loadThings(["hasOwnProperty", "onEach"], 'function', extractFunction, storageJs);
269268
finalJS += loadThings(arraysToLoad, 'array', extractArrayVariable, mainJs);
270269
finalJS += loadThings(variablesToLoad, 'variable', extractVariable, mainJs);

0 commit comments

Comments
 (0)
This repository has been archived.