Skip to content

Commit 92aff72

Browse files
committed
Auto merge of #54575 - pietroalbini:rollup, r=pietroalbini
Rollup of 12 pull requests Successful merges: - #53518 (Add doc for impl From in char_convert) - #54058 (Introduce the partition_dedup/by/by_key methods for slices) - #54281 (Search box) - #54368 (Reduce code block sides padding) - #54498 (The project moved under the Mozilla umbrella) - #54518 (resolve: Do not block derive helper resolutions on single import resolutions) - #54522 (Fixed three small typos.) - #54529 (aarch64-pc-windows-msvc: Don't link libpanic_unwind to libtest.) - #54537 (Rename slice::exact_chunks() to slice::chunks_exact()) - #54539 (Fix js error) - #54557 (incr.comp.: Don't automatically enable -Zshare-generics for incr. comp. builds.) - #54558 (Improvements to finding LLVM's FileCheck) Failed merges: r? @ghost
2 parents 4141a40 + cc9dea4 commit 92aff72

File tree

27 files changed

+538
-224
lines changed

27 files changed

+538
-224
lines changed

config.toml.example

+5
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@
322322

323323
# Flag indicating whether codegen tests will be run or not. If you get an error
324324
# saying that the FileCheck executable is missing, you may want to disable this.
325+
# Also see the target's llvm-filecheck option.
325326
#codegen-tests = true
326327

327328
# Flag indicating whether git info will be retrieved from .git automatically.
@@ -416,6 +417,10 @@
416417
# target.
417418
#llvm-config = "../path/to/llvm/root/bin/llvm-config"
418419

420+
# Normally the build system can find LLVM's FileCheck utility, but if
421+
# not, you can specify an explicit file name for it.
422+
#llvm-filecheck = "/path/to/FileCheck"
423+
419424
# Path to the custom jemalloc static library to link into the standard library
420425
# by default. This is only used if jemalloc is still enabled above
421426
#jemalloc = "/path/to/jemalloc/libjemalloc_pic.a"

src/bootstrap/config.rs

+6
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@ pub struct Config {
162162
pub struct Target {
163163
/// Some(path to llvm-config) if using an external LLVM.
164164
pub llvm_config: Option<PathBuf>,
165+
/// Some(path to FileCheck) if one was specified.
166+
pub llvm_filecheck: Option<PathBuf>,
165167
pub jemalloc: Option<PathBuf>,
166168
pub cc: Option<PathBuf>,
167169
pub cxx: Option<PathBuf>,
@@ -330,6 +332,7 @@ struct Rust {
330332
#[serde(deny_unknown_fields, rename_all = "kebab-case")]
331333
struct TomlTarget {
332334
llvm_config: Option<String>,
335+
llvm_filecheck: Option<String>,
333336
jemalloc: Option<String>,
334337
cc: Option<String>,
335338
cxx: Option<String>,
@@ -583,6 +586,9 @@ impl Config {
583586
if let Some(ref s) = cfg.llvm_config {
584587
target.llvm_config = Some(config.src.join(s));
585588
}
589+
if let Some(ref s) = cfg.llvm_filecheck {
590+
target.llvm_filecheck = Some(config.src.join(s));
591+
}
586592
if let Some(ref s) = cfg.jemalloc {
587593
target.jemalloc = Some(config.src.join(s));
588594
}

src/bootstrap/configure.py

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def v(*args):
9595
v("bindir", "install.bindir", "install binaries")
9696

9797
v("llvm-root", None, "set LLVM root")
98+
v("llvm-config", None, "set path to llvm-config")
99+
v("llvm-filecheck", None, "set path to LLVM's FileCheck utility")
98100
v("python", "build.python", "set path to python")
99101
v("jemalloc-root", None, "set directory where libjemalloc_pic.a is located")
100102
v("android-cross-path", "target.arm-linux-androideabi.android-ndk",
@@ -323,6 +325,10 @@ def set(key, value):
323325
set('build.cargo', value + '/bin/cargo')
324326
elif option.name == 'llvm-root':
325327
set('target.{}.llvm-config'.format(build()), value + '/bin/llvm-config')
328+
elif option.name == 'llvm-config':
329+
set('target.{}.llvm-config'.format(build()), value)
330+
elif option.name == 'llvm-filecheck':
331+
set('target.{}.llvm-filecheck'.format(build()), value)
326332
elif option.name == 'jemalloc-root':
327333
set('target.{}.jemalloc'.format(build()), value + '/libjemalloc_pic.a')
328334
elif option.name == 'tools':

src/bootstrap/lib.rs

+21-2
Original file line numberDiff line numberDiff line change
@@ -641,9 +641,28 @@ impl Build {
641641
/// Returns the path to `FileCheck` binary for the specified target
642642
fn llvm_filecheck(&self, target: Interned<String>) -> PathBuf {
643643
let target_config = self.config.target_config.get(&target);
644-
if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
644+
if let Some(s) = target_config.and_then(|c| c.llvm_filecheck.as_ref()) {
645+
s.to_path_buf()
646+
} else if let Some(s) = target_config.and_then(|c| c.llvm_config.as_ref()) {
645647
let llvm_bindir = output(Command::new(s).arg("--bindir"));
646-
Path::new(llvm_bindir.trim()).join(exe("FileCheck", &*target))
648+
let filecheck = Path::new(llvm_bindir.trim()).join(exe("FileCheck", &*target));
649+
if filecheck.exists() {
650+
filecheck
651+
} else {
652+
// On Fedora the system LLVM installs FileCheck in the
653+
// llvm subdirectory of the libdir.
654+
let llvm_libdir = output(Command::new(s).arg("--libdir"));
655+
let lib_filecheck = Path::new(llvm_libdir.trim())
656+
.join("llvm").join(exe("FileCheck", &*target));
657+
if lib_filecheck.exists() {
658+
lib_filecheck
659+
} else {
660+
// Return the most normal file name, even though
661+
// it doesn't exist, so that any error message
662+
// refers to that.
663+
filecheck
664+
}
665+
}
647666
} else {
648667
let base = self.llvm_out(self.config.build).join("build");
649668
let base = if !self.config.ninja && self.config.build.contains("msvc") {

src/doc/index.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@
44
nav {
55
display: none;
66
}
7+
#search-input {
8+
width: calc(100% - 58px);
9+
}
10+
#search-but {
11+
cursor: pointer;
12+
}
13+
#search-but, #search-input {
14+
padding: 4px;
15+
border: 1px solid #ccc;
16+
border-radius: 3px;
17+
outline: none;
18+
font-size: 0.7em;
19+
background-color: #fff;
20+
}
21+
#search-but:hover, #search-input:focus {
22+
border-color: #55a9ff;
23+
}
724
</style>
825

926
Welcome to an overview of the documentation provided by the Rust project.
@@ -45,8 +62,9 @@ accomplishing various tasks.
4562

4663
<div>
4764
<form action="std/index.html" method="get">
48-
<input type="search" name="search"/>
49-
<button>Search</button>
65+
<input id="search-input" type="search" name="search"
66+
placeholder="Search through the standard library"/>
67+
<button id="search-but">Search</button>
5068
</form>
5169
</div>
5270

src/doc/unstable-book/src/compiler-flags/profile.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ cargo run
1818
```
1919

2020
Once you've built and run your program, files with the `gcno` (after build) and `gcda` (after execution) extensions will be created.
21-
You can parse them with [llvm-cov gcov](http://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-gcov) or [grcov](https://github.com/marco-c/grcov).
21+
You can parse them with [llvm-cov gcov](https://llvm.org/docs/CommandGuide/llvm-cov.html#llvm-cov-gcov) or [grcov](https://github.com/mozilla/grcov).

src/liballoc/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@
116116
#![feature(unsize)]
117117
#![feature(allocator_internals)]
118118
#![feature(on_unimplemented)]
119-
#![feature(exact_chunks)]
119+
#![feature(chunks_exact)]
120120
#![feature(rustc_const_unstable)]
121121
#![feature(const_vec_new)]
122+
#![feature(slice_partition_dedup)]
122123
#![feature(maybe_uninit)]
123124

124125
// Allow testing this library

src/liballoc/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ pub use core::slice::{from_raw_parts, from_raw_parts_mut};
123123
pub use core::slice::{from_ref, from_mut};
124124
#[stable(feature = "slice_get_slice", since = "1.28.0")]
125125
pub use core::slice::SliceIndex;
126-
#[unstable(feature = "exact_chunks", issue = "47115")]
127-
pub use core::slice::{ExactChunks, ExactChunksMut};
126+
#[unstable(feature = "chunks_exact", issue = "47115")]
127+
pub use core::slice::{ChunksExact, ChunksExactMut};
128128

129129
////////////////////////////////////////////////////////////////////////////////
130130
// Basic slice extension methods

src/liballoc/tests/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![feature(str_escape)]
2121
#![feature(try_reserve)]
2222
#![feature(unboxed_closures)]
23-
#![feature(exact_chunks)]
23+
#![feature(chunks_exact)]
2424
#![feature(repeat_generic_slice)]
2525

2626
extern crate alloc_system;

src/liballoc/tests/slice.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -975,27 +975,27 @@ fn test_chunksator_0() {
975975
}
976976

977977
#[test]
978-
fn test_exact_chunksator() {
978+
fn test_chunks_exactator() {
979979
let v = &[1, 2, 3, 4, 5];
980980

981-
assert_eq!(v.exact_chunks(2).len(), 2);
981+
assert_eq!(v.chunks_exact(2).len(), 2);
982982

983983
let chunks: &[&[_]] = &[&[1, 2], &[3, 4]];
984-
assert_eq!(v.exact_chunks(2).collect::<Vec<_>>(), chunks);
984+
assert_eq!(v.chunks_exact(2).collect::<Vec<_>>(), chunks);
985985
let chunks: &[&[_]] = &[&[1, 2, 3]];
986-
assert_eq!(v.exact_chunks(3).collect::<Vec<_>>(), chunks);
986+
assert_eq!(v.chunks_exact(3).collect::<Vec<_>>(), chunks);
987987
let chunks: &[&[_]] = &[];
988-
assert_eq!(v.exact_chunks(6).collect::<Vec<_>>(), chunks);
988+
assert_eq!(v.chunks_exact(6).collect::<Vec<_>>(), chunks);
989989

990990
let chunks: &[&[_]] = &[&[3, 4], &[1, 2]];
991-
assert_eq!(v.exact_chunks(2).rev().collect::<Vec<_>>(), chunks);
991+
assert_eq!(v.chunks_exact(2).rev().collect::<Vec<_>>(), chunks);
992992
}
993993

994994
#[test]
995995
#[should_panic]
996-
fn test_exact_chunksator_0() {
996+
fn test_chunks_exactator_0() {
997997
let v = &[1, 2, 3, 4];
998-
let _it = v.exact_chunks(0);
998+
let _it = v.chunks_exact(0);
999999
}
10001000

10011001
#[test]
@@ -1235,10 +1235,10 @@ fn test_mut_chunks_0() {
12351235
}
12361236

12371237
#[test]
1238-
fn test_mut_exact_chunks() {
1238+
fn test_mut_chunks_exact() {
12391239
let mut v = [0, 1, 2, 3, 4, 5, 6];
1240-
assert_eq!(v.exact_chunks_mut(2).len(), 3);
1241-
for (i, chunk) in v.exact_chunks_mut(3).enumerate() {
1240+
assert_eq!(v.chunks_exact_mut(2).len(), 3);
1241+
for (i, chunk) in v.chunks_exact_mut(3).enumerate() {
12421242
for x in chunk {
12431243
*x = i as u8;
12441244
}
@@ -1248,9 +1248,9 @@ fn test_mut_exact_chunks() {
12481248
}
12491249

12501250
#[test]
1251-
fn test_mut_exact_chunks_rev() {
1251+
fn test_mut_chunks_exact_rev() {
12521252
let mut v = [0, 1, 2, 3, 4, 5, 6];
1253-
for (i, chunk) in v.exact_chunks_mut(3).rev().enumerate() {
1253+
for (i, chunk) in v.chunks_exact_mut(3).rev().enumerate() {
12541254
for x in chunk {
12551255
*x = i as u8;
12561256
}
@@ -1261,9 +1261,9 @@ fn test_mut_exact_chunks_rev() {
12611261

12621262
#[test]
12631263
#[should_panic]
1264-
fn test_mut_exact_chunks_0() {
1264+
fn test_mut_chunks_exact_0() {
12651265
let mut v = [1, 2, 3, 4];
1266-
let _it = v.exact_chunks_mut(0);
1266+
let _it = v.chunks_exact_mut(0);
12671267
}
12681268

12691269
#[test]

src/liballoc/vec.rs

+11-89
Original file line numberDiff line numberDiff line change
@@ -947,10 +947,9 @@ impl<T> Vec<T> {
947947
/// Removes all but the first of consecutive elements in the vector satisfying a given equality
948948
/// relation.
949949
///
950-
/// The `same_bucket` function is passed references to two elements from the vector, and
951-
/// returns `true` if the elements compare equal, or `false` if they do not. The elements are
952-
/// passed in opposite order from their order in the vector, so if `same_bucket(a, b)` returns
953-
/// `true`, `a` is removed.
950+
/// The `same_bucket` function is passed references to two elements from the vector and
951+
/// must determine if the elements compare equal. The elements are passed in opposite order
952+
/// from their order in the slice, so if `same_bucket(a, b)` returns `true`, `a` is removed.
954953
///
955954
/// If the vector is sorted, this removes all duplicates.
956955
///
@@ -964,90 +963,12 @@ impl<T> Vec<T> {
964963
/// assert_eq!(vec, ["foo", "bar", "baz", "bar"]);
965964
/// ```
966965
#[stable(feature = "dedup_by", since = "1.16.0")]
967-
pub fn dedup_by<F>(&mut self, mut same_bucket: F) where F: FnMut(&mut T, &mut T) -> bool {
968-
unsafe {
969-
// Although we have a mutable reference to `self`, we cannot make
970-
// *arbitrary* changes. The `same_bucket` calls could panic, so we
971-
// must ensure that the vector is in a valid state at all time.
972-
//
973-
// The way that we handle this is by using swaps; we iterate
974-
// over all the elements, swapping as we go so that at the end
975-
// the elements we wish to keep are in the front, and those we
976-
// wish to reject are at the back. We can then truncate the
977-
// vector. This operation is still O(n).
978-
//
979-
// Example: We start in this state, where `r` represents "next
980-
// read" and `w` represents "next_write`.
981-
//
982-
// r
983-
// +---+---+---+---+---+---+
984-
// | 0 | 1 | 1 | 2 | 3 | 3 |
985-
// +---+---+---+---+---+---+
986-
// w
987-
//
988-
// Comparing self[r] against self[w-1], this is not a duplicate, so
989-
// we swap self[r] and self[w] (no effect as r==w) and then increment both
990-
// r and w, leaving us with:
991-
//
992-
// r
993-
// +---+---+---+---+---+---+
994-
// | 0 | 1 | 1 | 2 | 3 | 3 |
995-
// +---+---+---+---+---+---+
996-
// w
997-
//
998-
// Comparing self[r] against self[w-1], this value is a duplicate,
999-
// so we increment `r` but leave everything else unchanged:
1000-
//
1001-
// r
1002-
// +---+---+---+---+---+---+
1003-
// | 0 | 1 | 1 | 2 | 3 | 3 |
1004-
// +---+---+---+---+---+---+
1005-
// w
1006-
//
1007-
// Comparing self[r] against self[w-1], this is not a duplicate,
1008-
// so swap self[r] and self[w] and advance r and w:
1009-
//
1010-
// r
1011-
// +---+---+---+---+---+---+
1012-
// | 0 | 1 | 2 | 1 | 3 | 3 |
1013-
// +---+---+---+---+---+---+
1014-
// w
1015-
//
1016-
// Not a duplicate, repeat:
1017-
//
1018-
// r
1019-
// +---+---+---+---+---+---+
1020-
// | 0 | 1 | 2 | 3 | 1 | 3 |
1021-
// +---+---+---+---+---+---+
1022-
// w
1023-
//
1024-
// Duplicate, advance r. End of vec. Truncate to w.
1025-
1026-
let ln = self.len();
1027-
if ln <= 1 {
1028-
return;
1029-
}
1030-
1031-
// Avoid bounds checks by using raw pointers.
1032-
let p = self.as_mut_ptr();
1033-
let mut r: usize = 1;
1034-
let mut w: usize = 1;
1035-
1036-
while r < ln {
1037-
let p_r = p.add(r);
1038-
let p_wm1 = p.add(w - 1);
1039-
if !same_bucket(&mut *p_r, &mut *p_wm1) {
1040-
if r != w {
1041-
let p_w = p_wm1.offset(1);
1042-
mem::swap(&mut *p_r, &mut *p_w);
1043-
}
1044-
w += 1;
1045-
}
1046-
r += 1;
1047-
}
1048-
1049-
self.truncate(w);
1050-
}
966+
pub fn dedup_by<F>(&mut self, same_bucket: F) where F: FnMut(&mut T, &mut T) -> bool {
967+
let len = {
968+
let (dedup, _) = self.as_mut_slice().partition_dedup_by(same_bucket);
969+
dedup.len()
970+
};
971+
self.truncate(len);
1051972
}
1052973

1053974
/// Appends an element to the back of a collection.
@@ -1533,7 +1454,8 @@ impl<'a> Drop for SetLenOnDrop<'a> {
15331454
}
15341455

15351456
impl<T: PartialEq> Vec<T> {
1536-
/// Removes consecutive repeated elements in the vector.
1457+
/// Removes consecutive repeated elements in the vector according to the
1458+
/// [`PartialEq`] trait implementation.
15371459
///
15381460
/// If the vector is sorted, this removes all duplicates.
15391461
///

0 commit comments

Comments
 (0)