Skip to content

Commit cff9a75

Browse files
committed
Auto merge of #71264 - Dylan-DPC:rollup-njgbey7, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #70467 (Use `call` instead of `invoke` for functions that cannot unwind ) - #71070 (rustbuild: Remove stage 0 LLD flavor workaround for MSVC) - #71167 (big-O notation: parenthesis for function calls, explicit multiplication) - #71238 (Miri: fix typo) - #71242 (Format Mailmap To Work With GitHub) - #71243 (Account for use of `try!()` in 2018 edition and guide users in the right direction) Failed merges: r? @ghost
2 parents ce93331 + 4b9eeca commit cff9a75

File tree

20 files changed

+160
-81
lines changed

20 files changed

+160
-81
lines changed

.mailmap

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ João Oliveira <hello@jxs.pt> joaoxsouls <joaoxsouls@gmail.com>
133133
Johann Hofmann <git@johann-hofmann.com> Johann <git@johann-hofmann.com>
134134
John Clements <clements@racket-lang.org> <clements@brinckerhoff.org>
135135
John Hodge <acessdev@gmail.com> John Hodge <tpg@mutabah.net>
136-
John Kåre Alsaker <john.kare.alsaker@gmail.com>
136+
John Kåre Alsaker <john.kare.alsaker@gmail.com>
137137
John Talling <inrustwetrust@users.noreply.github.com>
138138
Jonathan Bailey <jbailey@mozilla.com> <jbailey@jbailey-20809.local>
139139
Jonathan S <gereeter@gmail.com> Jonathan S <gereeter+code@gmail.com>
@@ -153,7 +153,7 @@ Laurențiu Nicola <lnicola@dend.ro>
153153
Lee Jeffery <leejeffery@gmail.com> Lee Jeffery <lee@leejeffery.co.uk>
154154
Lee Wondong <wdlee91@gmail.com>
155155
Lennart Kudling <github@kudling.de>
156-
Léo Testard <leo.testard@gmail.com>
156+
Léo Testard <leo.testard@gmail.com>
157157
Lindsey Kuper <lindsey@composition.al> <lindsey@rockstargirl.org>
158158
Lindsey Kuper <lindsey@composition.al> <lkuper@mozilla.com>
159159
Luke Metz <luke.metz@students.olin.edu>

src/bootstrap/bin/rustc.rs

-5
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ fn main() {
134134
cmd.arg(format!("-Clinker={}", host_linker));
135135
}
136136

137-
// Override linker flavor if necessary.
138-
if let Ok(host_linker_flavor) = env::var("RUSTC_HOST_LINKER_FLAVOR") {
139-
cmd.arg(format!("-Clinker-flavor={}", host_linker_flavor));
140-
}
141-
142137
if let Ok(s) = env::var("RUSTC_HOST_CRT_STATIC") {
143138
if s == "true" {
144139
cmd.arg("-C").arg("target-feature=+crt-static");

src/bootstrap/builder.rs

-16
Original file line numberDiff line numberDiff line change
@@ -969,27 +969,11 @@ impl<'a> Builder<'a> {
969969
// See https://github.com/rust-lang/rust/issues/68647.
970970
let can_use_lld = mode != Mode::Std;
971971

972-
// FIXME: The beta compiler doesn't pick the `lld-link` flavor for `*-pc-windows-msvc`
973-
// Remove `RUSTC_HOST_LINKER_FLAVOR` when this is fixed
974-
let lld_linker_flavor = |linker: &Path, target: Interned<String>| {
975-
compiler.stage == 0
976-
&& linker.file_name() == Some(OsStr::new("rust-lld"))
977-
&& target.contains("pc-windows-msvc")
978-
};
979-
980972
if let Some(host_linker) = self.linker(compiler.host, can_use_lld) {
981-
if lld_linker_flavor(host_linker, compiler.host) {
982-
cargo.env("RUSTC_HOST_LINKER_FLAVOR", "lld-link");
983-
}
984-
985973
cargo.env("RUSTC_HOST_LINKER", host_linker);
986974
}
987975

988976
if let Some(target_linker) = self.linker(target, can_use_lld) {
989-
if lld_linker_flavor(target_linker, target) {
990-
rustflags.arg("-Clinker-flavor=lld-link");
991-
}
992-
993977
let target = crate::envify(&target);
994978
cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker);
995979
}

src/liballoc/collections/binary_heap.rs

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! A priority queue implemented with a binary heap.
22
//!
3-
//! Insertion and popping the largest element have `O(log n)` time complexity.
3+
//! Insertion and popping the largest element have `O(log(n))` time complexity.
44
//! Checking the largest element is `O(1)`. Converting a vector to a binary heap
55
//! can be done in-place, and has `O(n)` complexity. A binary heap can also be
6-
//! converted to a sorted vector in-place, allowing it to be used for an `O(n
7-
//! log n)` in-place heapsort.
6+
//! converted to a sorted vector in-place, allowing it to be used for an `O(n * log(n))`
7+
//! in-place heapsort.
88
//!
99
//! # Examples
1010
//!
@@ -233,9 +233,9 @@ use super::SpecExtend;
233233
///
234234
/// # Time complexity
235235
///
236-
/// | [push] | [pop] | [peek]/[peek\_mut] |
237-
/// |--------|----------|--------------------|
238-
/// | O(1)~ | O(log n) | O(1) |
236+
/// | [push] | [pop] | [peek]/[peek\_mut] |
237+
/// |--------|-----------|--------------------|
238+
/// | O(1)~ | O(log(n)) | O(1) |
239239
///
240240
/// The value for `push` is an expected cost; the method documentation gives a
241241
/// more detailed analysis.
@@ -398,7 +398,7 @@ impl<T: Ord> BinaryHeap<T> {
398398
///
399399
/// # Time complexity
400400
///
401-
/// Cost is O(1) in the worst case.
401+
/// Cost is `O(1)` in the worst case.
402402
#[stable(feature = "binary_heap_peek_mut", since = "1.12.0")]
403403
pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T>> {
404404
if self.is_empty() { None } else { Some(PeekMut { heap: self, sift: true }) }
@@ -422,8 +422,7 @@ impl<T: Ord> BinaryHeap<T> {
422422
///
423423
/// # Time complexity
424424
///
425-
/// The worst case cost of `pop` on a heap containing *n* elements is O(log
426-
/// n).
425+
/// The worst case cost of `pop` on a heap containing *n* elements is `O(log(n))`.
427426
#[stable(feature = "rust1", since = "1.0.0")]
428427
pub fn pop(&mut self) -> Option<T> {
429428
self.data.pop().map(|mut item| {
@@ -456,15 +455,15 @@ impl<T: Ord> BinaryHeap<T> {
456455
///
457456
/// The expected cost of `push`, averaged over every possible ordering of
458457
/// the elements being pushed, and over a sufficiently large number of
459-
/// pushes, is O(1). This is the most meaningful cost metric when pushing
458+
/// pushes, is `O(1)`. This is the most meaningful cost metric when pushing
460459
/// elements that are *not* already in any sorted pattern.
461460
///
462461
/// The time complexity degrades if elements are pushed in predominantly
463462
/// ascending order. In the worst case, elements are pushed in ascending
464-
/// sorted order and the amortized cost per push is O(log n) against a heap
463+
/// sorted order and the amortized cost per push is `O(log(n))` against a heap
465464
/// containing *n* elements.
466465
///
467-
/// The worst case cost of a *single* call to `push` is O(n). The worst case
466+
/// The worst case cost of a *single* call to `push` is `O(n)`. The worst case
468467
/// occurs when capacity is exhausted and needs a resize. The resize cost
469468
/// has been amortized in the previous figures.
470469
#[stable(feature = "rust1", since = "1.0.0")]
@@ -623,7 +622,7 @@ impl<T: Ord> BinaryHeap<T> {
623622

624623
// `rebuild` takes O(len1 + len2) operations
625624
// and about 2 * (len1 + len2) comparisons in the worst case
626-
// while `extend` takes O(len2 * log_2(len1)) operations
625+
// while `extend` takes O(len2 * log(len1)) operations
627626
// and about 1 * len2 * log_2(len1) comparisons in the worst case,
628627
// assuming len1 >= len2.
629628
#[inline]
@@ -644,7 +643,7 @@ impl<T: Ord> BinaryHeap<T> {
644643
/// The remaining elements will be removed on drop in heap order.
645644
///
646645
/// Note:
647-
/// * `.drain_sorted()` is O(n lg n); much slower than `.drain()`.
646+
/// * `.drain_sorted()` is `O(n * log(n))`; much slower than `.drain()`.
648647
/// You should use the latter for most cases.
649648
///
650649
/// # Examples
@@ -729,7 +728,7 @@ impl<T> BinaryHeap<T> {
729728
///
730729
/// # Time complexity
731730
///
732-
/// Cost is O(1) in the worst case.
731+
/// Cost is `O(1)` in the worst case.
733732
#[stable(feature = "rust1", since = "1.0.0")]
734733
pub fn peek(&self) -> Option<&T> {
735734
self.data.get(0)

src/liballoc/collections/btree/map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ use UnderflowResult::*;
4040
/// performance on *small* nodes of elements which are cheap to compare. However in the future we
4141
/// would like to further explore choosing the optimal search strategy based on the choice of B,
4242
/// and possibly other factors. Using linear search, searching for a random element is expected
43-
/// to take O(B log<sub>B</sub>n) comparisons, which is generally worse than a BST. In practice,
43+
/// to take O(B * log(n)) comparisons, which is generally worse than a BST. In practice,
4444
/// however, performance is excellent.
4545
///
4646
/// It is a logic error for a key to be modified in such a way that the key's ordering relative to

src/liballoc/collections/linked_list.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl<T> LinkedList<T> {
390390
/// This reuses all the nodes from `other` and moves them into `self`. After
391391
/// this operation, `other` becomes empty.
392392
///
393-
/// This operation should compute in O(1) time and O(1) memory.
393+
/// This operation should compute in `O(1)` time and `O(1)` memory.
394394
///
395395
/// # Examples
396396
///
@@ -547,7 +547,7 @@ impl<T> LinkedList<T> {
547547

548548
/// Returns `true` if the `LinkedList` is empty.
549549
///
550-
/// This operation should compute in O(1) time.
550+
/// This operation should compute in `O(1)` time.
551551
///
552552
/// # Examples
553553
///
@@ -568,7 +568,7 @@ impl<T> LinkedList<T> {
568568

569569
/// Returns the length of the `LinkedList`.
570570
///
571-
/// This operation should compute in O(1) time.
571+
/// This operation should compute in `O(1)` time.
572572
///
573573
/// # Examples
574574
///
@@ -594,7 +594,7 @@ impl<T> LinkedList<T> {
594594

595595
/// Removes all elements from the `LinkedList`.
596596
///
597-
/// This operation should compute in O(n) time.
597+
/// This operation should compute in `O(n)` time.
598598
///
599599
/// # Examples
600600
///
@@ -737,7 +737,7 @@ impl<T> LinkedList<T> {
737737

738738
/// Adds an element first in the list.
739739
///
740-
/// This operation should compute in O(1) time.
740+
/// This operation should compute in `O(1)` time.
741741
///
742742
/// # Examples
743743
///
@@ -760,7 +760,7 @@ impl<T> LinkedList<T> {
760760
/// Removes the first element and returns it, or `None` if the list is
761761
/// empty.
762762
///
763-
/// This operation should compute in O(1) time.
763+
/// This operation should compute in `O(1)` time.
764764
///
765765
/// # Examples
766766
///
@@ -783,7 +783,7 @@ impl<T> LinkedList<T> {
783783

784784
/// Appends an element to the back of a list.
785785
///
786-
/// This operation should compute in O(1) time.
786+
/// This operation should compute in `O(1)` time.
787787
///
788788
/// # Examples
789789
///
@@ -803,7 +803,7 @@ impl<T> LinkedList<T> {
803803
/// Removes the last element from a list and returns it, or `None` if
804804
/// it is empty.
805805
///
806-
/// This operation should compute in O(1) time.
806+
/// This operation should compute in `O(1)` time.
807807
///
808808
/// # Examples
809809
///
@@ -824,7 +824,7 @@ impl<T> LinkedList<T> {
824824
/// Splits the list into two at the given index. Returns everything after the given index,
825825
/// including the index.
826826
///
827-
/// This operation should compute in O(n) time.
827+
/// This operation should compute in `O(n)` time.
828828
///
829829
/// # Panics
830830
///
@@ -880,7 +880,7 @@ impl<T> LinkedList<T> {
880880

881881
/// Removes the element at the given index and returns it.
882882
///
883-
/// This operation should compute in O(n) time.
883+
/// This operation should compute in `O(n)` time.
884884
///
885885
/// # Panics
886886
/// Panics if at >= len

src/liballoc/collections/vec_deque.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ impl<T> VecDeque<T> {
13911391
/// Removes an element from anywhere in the `VecDeque` and returns it,
13921392
/// replacing it with the first element.
13931393
///
1394-
/// This does not preserve ordering, but is O(1).
1394+
/// This does not preserve ordering, but is `O(1)`.
13951395
///
13961396
/// Returns `None` if `index` is out of bounds.
13971397
///
@@ -1426,7 +1426,7 @@ impl<T> VecDeque<T> {
14261426
/// Removes an element from anywhere in the `VecDeque` and returns it, replacing it with the
14271427
/// last element.
14281428
///
1429-
/// This does not preserve ordering, but is O(1).
1429+
/// This does not preserve ordering, but is `O(1)`.
14301430
///
14311431
/// Returns `None` if `index` is out of bounds.
14321432
///
@@ -2927,7 +2927,7 @@ impl<T> From<VecDeque<T>> for Vec<T> {
29272927
/// [`Vec<T>`]: crate::vec::Vec
29282928
/// [`VecDeque<T>`]: crate::collections::VecDeque
29292929
///
2930-
/// This never needs to re-allocate, but does need to do O(n) data movement if
2930+
/// This never needs to re-allocate, but does need to do `O(n)` data movement if
29312931
/// the circular buffer doesn't happen to be at the beginning of the allocation.
29322932
///
29332933
/// # Examples

src/liballoc/slice.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ mod hack {
165165
impl<T> [T] {
166166
/// Sorts the slice.
167167
///
168-
/// This sort is stable (i.e., does not reorder equal elements) and `O(n log n)` worst-case.
168+
/// This sort is stable (i.e., does not reorder equal elements) and `O(n * log(n))` worst-case.
169169
///
170170
/// When applicable, unstable sorting is preferred because it is generally faster than stable
171171
/// sorting and it doesn't allocate auxiliary memory.
@@ -200,7 +200,7 @@ impl<T> [T] {
200200

201201
/// Sorts the slice with a comparator function.
202202
///
203-
/// This sort is stable (i.e., does not reorder equal elements) and `O(n log n)` worst-case.
203+
/// This sort is stable (i.e., does not reorder equal elements) and `O(n * log(n))` worst-case.
204204
///
205205
/// The comparator function must define a total ordering for the elements in the slice. If
206206
/// the ordering is not total, the order of the elements is unspecified. An order is a
@@ -254,7 +254,7 @@ impl<T> [T] {
254254

255255
/// Sorts the slice with a key extraction function.
256256
///
257-
/// This sort is stable (i.e., does not reorder equal elements) and `O(m n log n)`
257+
/// This sort is stable (i.e., does not reorder equal elements) and `O(m * n * log(n))`
258258
/// worst-case, where the key function is `O(m)`.
259259
///
260260
/// For expensive key functions (e.g. functions that are not simple property accesses or
@@ -297,7 +297,7 @@ impl<T> [T] {
297297
///
298298
/// During sorting, the key function is called only once per element.
299299
///
300-
/// This sort is stable (i.e., does not reorder equal elements) and `O(m n + n log n)`
300+
/// This sort is stable (i.e., does not reorder equal elements) and `O(m * n + n * log(n))`
301301
/// worst-case, where the key function is `O(m)`.
302302
///
303303
/// For simple key functions (e.g., functions that are property accesses or
@@ -935,7 +935,7 @@ where
935935
/// 1. for every `i` in `1..runs.len()`: `runs[i - 1].len > runs[i].len`
936936
/// 2. for every `i` in `2..runs.len()`: `runs[i - 2].len > runs[i - 1].len + runs[i].len`
937937
///
938-
/// The invariants ensure that the total running time is `O(n log n)` worst-case.
938+
/// The invariants ensure that the total running time is `O(n * log(n))` worst-case.
939939
fn merge_sort<T, F>(v: &mut [T], mut is_less: F)
940940
where
941941
F: FnMut(&T, &T) -> bool,

src/libcore/slice/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1606,7 +1606,7 @@ impl<T> [T] {
16061606
/// Sorts the slice, but may not preserve the order of equal elements.
16071607
///
16081608
/// This sort is unstable (i.e., may reorder equal elements), in-place
1609-
/// (i.e., does not allocate), and `O(n log n)` worst-case.
1609+
/// (i.e., does not allocate), and `O(n * log(n))` worst-case.
16101610
///
16111611
/// # Current implementation
16121612
///
@@ -1642,7 +1642,7 @@ impl<T> [T] {
16421642
/// elements.
16431643
///
16441644
/// This sort is unstable (i.e., may reorder equal elements), in-place
1645-
/// (i.e., does not allocate), and `O(n log n)` worst-case.
1645+
/// (i.e., does not allocate), and `O(n * log(n))` worst-case.
16461646
///
16471647
/// The comparator function must define a total ordering for the elements in the slice. If
16481648
/// the ordering is not total, the order of the elements is unspecified. An order is a
@@ -1697,7 +1697,7 @@ impl<T> [T] {
16971697
/// elements.
16981698
///
16991699
/// This sort is unstable (i.e., may reorder equal elements), in-place
1700-
/// (i.e., does not allocate), and `O(m n log n)` worst-case, where the key function is
1700+
/// (i.e., does not allocate), and `O(m * n * log(n))` worst-case, where the key function is
17011701
/// `O(m)`.
17021702
///
17031703
/// # Current implementation
@@ -1957,7 +1957,7 @@ impl<T> [T] {
19571957
// over all the elements, swapping as we go so that at the end
19581958
// the elements we wish to keep are in the front, and those we
19591959
// wish to reject are at the back. We can then split the slice.
1960-
// This operation is still O(n).
1960+
// This operation is still `O(n)`.
19611961
//
19621962
// Example: We start in this state, where `r` represents "next
19631963
// read" and `w` represents "next_write`.

src/libcore/slice/sort.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ where
143143
}
144144
}
145145

146-
/// Sorts `v` using heapsort, which guarantees `O(n log n)` worst-case.
146+
/// Sorts `v` using heapsort, which guarantees `O(n * log(n))` worst-case.
147147
#[cold]
148148
pub fn heapsort<T, F>(v: &mut [T], is_less: &mut F)
149149
where
@@ -621,7 +621,7 @@ where
621621
}
622622

623623
// If too many bad pivot choices were made, simply fall back to heapsort in order to
624-
// guarantee `O(n log n)` worst-case.
624+
// guarantee `O(n * log(n))` worst-case.
625625
if limit == 0 {
626626
heapsort(v, is_less);
627627
return;
@@ -684,7 +684,7 @@ where
684684
}
685685
}
686686

687-
/// Sorts `v` using pattern-defeating quicksort, which is `O(n log n)` worst-case.
687+
/// Sorts `v` using pattern-defeating quicksort, which is `O(n * log(n))` worst-case.
688688
pub fn quicksort<T, F>(v: &mut [T], mut is_less: F)
689689
where
690690
F: FnMut(&T, &T) -> bool,

src/librustc_codegen_ssa/mir/block.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ impl<'a, 'tcx> TerminatorCodegenHelper<'tcx> {
111111
destination: Option<(ReturnDest<'tcx, Bx::Value>, mir::BasicBlock)>,
112112
cleanup: Option<mir::BasicBlock>,
113113
) {
114-
if let Some(cleanup) = cleanup {
114+
// If there is a cleanup block and the function we're calling can unwind, then
115+
// do an invoke, otherwise do a call.
116+
if let Some(cleanup) = cleanup.filter(|_| fn_abi.can_unwind) {
115117
let ret_bx = if let Some((_, target)) = destination {
116118
fx.blocks[target]
117119
} else {

0 commit comments

Comments
 (0)