Skip to content

Commit f5f8284

Browse files
committed
Auto merge of #58495 - kennytm:rollup, r=kennytm
Rollup of 19 pull requests Successful merges: - #57929 (Rustdoc remove old style files) - #57981 (Fix #57730) - #58074 (Stabilize slice_sort_by_cached_key) - #58196 (Add specific feature gate error for const-unstable features) - #58293 (Remove code for updating copyright years in generate-deriving-span-tests) - #58306 (Don't default on std crate when manipulating browser history) - #58359 (librustc_mir: use ? in impl_snapshot_for! macro) - #58395 (Instant::checked_duration_since) - #58429 (fix Box::into_unique effecitvely transmuting to a raw ptr) - #58433 (Update which libcore/liballoc tests Miri ignores, and document why) - #58438 (Use posix_spawn_file_actions_addchdir_np when possible) - #58440 (Whitelist the ARM v6 target-feature) - #58448 (rustdoc: mask `compiler_builtins` docs) - #58468 (split MaybeUninit into several features, expand docs a bit) - #58477 (Fix the syntax error in publish_toolstate.py) - #58479 (compile-pass test for #53606) - #58489 (Fix runtime error in generate-keyword-tests) - #58496 (Fix documentation for std::path::PathBuf::pop) - #58509 (Notify myself when Clippy toolstate changes)
2 parents eac0908 + ae922a9 commit f5f8284

File tree

89 files changed

+818
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+818
-299
lines changed

src/bootstrap/bin/rustdoc.rs

+17-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ fn main() {
1616
let libdir = env::var_os("RUSTDOC_LIBDIR").expect("RUSTDOC_LIBDIR was not set");
1717
let stage = env::var("RUSTC_STAGE").expect("RUSTC_STAGE was not set");
1818
let sysroot = env::var_os("RUSTC_SYSROOT").expect("RUSTC_SYSROOT was not set");
19+
let mut has_unstable = false;
1920

2021
use std::str::FromStr;
2122

@@ -54,9 +55,22 @@ fn main() {
5455
// it up so we can make rustdoc print this into the docs
5556
if let Some(version) = env::var_os("RUSTDOC_CRATE_VERSION") {
5657
// This "unstable-options" can be removed when `--crate-version` is stabilized
57-
cmd.arg("-Z")
58-
.arg("unstable-options")
59-
.arg("--crate-version").arg(version);
58+
if !has_unstable {
59+
cmd.arg("-Z")
60+
.arg("unstable-options");
61+
}
62+
cmd.arg("--crate-version").arg(version);
63+
has_unstable = true;
64+
}
65+
66+
// Needed to be able to run all rustdoc tests.
67+
if let Some(_) = env::var_os("RUSTDOC_GENERATE_REDIRECT_PAGES") {
68+
// This "unstable-options" can be removed when `--generate-redirect-pages` is stabilized
69+
if !has_unstable {
70+
cmd.arg("-Z")
71+
.arg("unstable-options");
72+
}
73+
cmd.arg("--generate-redirect-pages");
6074
}
6175

6276
if verbose > 1 {

src/bootstrap/doc.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ impl Step for Std {
517517
cargo.arg("--")
518518
.arg("--markdown-css").arg("rust.css")
519519
.arg("--markdown-no-toc")
520+
.arg("--generate-redirect-pages")
520521
.arg("--index-page").arg(&builder.src.join("src/doc/index.md"));
521522

522523
builder.run(&mut cargo);
@@ -581,7 +582,9 @@ impl Step for Test {
581582
let mut cargo = builder.cargo(compiler, Mode::Test, target, "doc");
582583
compile::test_cargo(builder, &compiler, target, &mut cargo);
583584

584-
cargo.arg("--no-deps").arg("-p").arg("test");
585+
cargo.arg("--no-deps")
586+
.arg("-p").arg("test")
587+
.env("RUSTDOC_GENERATE_REDIRECT_PAGES", "1");
585588

586589
builder.run(&mut cargo);
587590
builder.cp_r(&my_out, &out);
@@ -650,9 +653,9 @@ impl Step for WhitelistedRustc {
650653
// We don't want to build docs for internal compiler dependencies in this
651654
// step (there is another step for that). Therefore, we whitelist the crates
652655
// for which docs must be built.
653-
cargo.arg("--no-deps");
654656
for krate in &["proc_macro"] {
655-
cargo.arg("-p").arg(krate);
657+
cargo.arg("-p").arg(krate)
658+
.env("RUSTDOC_GENERATE_REDIRECT_PAGES", "1");
656659
}
657660

658661
builder.run(&mut cargo);

src/etc/generate-deriving-span-tests.py

+7-23
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
sample usage: src/etc/generate-deriving-span-tests.py
99
"""
1010

11-
import os, datetime, stat, re
11+
import os, stat
1212

1313
TEST_DIR = os.path.abspath(
1414
os.path.join(os.path.dirname(__file__), '../test/ui/derives/'))
1515

16-
YEAR = datetime.datetime.now().year
17-
18-
TEMPLATE = """
16+
TEMPLATE = """\
1917
// This file was auto-generated using 'src/etc/generate-deriving-span-tests.py'
2018
2119
{error_deriving}
@@ -63,19 +61,11 @@ def create_test_case(type, trait, super_traits, error_count):
6361

6462
errors = '\n'.join('//~%s ERROR' % ('^' * n) for n in range(error_count))
6563
code = string.format(traits = all_traits, errors = errors)
66-
return TEMPLATE.format(year = YEAR, error_deriving=error_deriving, code = code)
64+
return TEMPLATE.format(error_deriving=error_deriving, code = code)
6765

6866
def write_file(name, string):
6967
test_file = os.path.join(TEST_DIR, 'derives-span-%s.rs' % name)
7068

71-
with open(test_file) as f:
72-
old_str = f.read()
73-
old_str_ignoring_date = re.sub(r'^// Copyright \d+',
74-
'// Copyright {year}'.format(year = YEAR), old_str)
75-
if old_str_ignoring_date == string:
76-
# if all we're doing is updating the copyright year, ignore it
77-
return 0
78-
7969
# set write permission if file exists, so it can be changed
8070
if os.path.exists(test_file):
8171
os.chmod(test_file, stat.S_IWUSR)
@@ -86,8 +76,6 @@ def write_file(name, string):
8676
# mark file read-only
8777
os.chmod(test_file, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
8878

89-
return 1
90-
9179

9280
ENUM = 1
9381
STRUCT = 2
@@ -110,15 +98,11 @@ def write_file(name, string):
11098
('Hash', [], 1)]:
11199
traits[trait] = (ALL, supers, errs)
112100

113-
files = 0
114-
115101
for (trait, (types, super_traits, error_count)) in traits.items():
116102
mk = lambda ty: create_test_case(ty, trait, super_traits, error_count)
117103
if types & ENUM:
118-
files += write_file(trait + '-enum', mk(ENUM_TUPLE))
119-
files += write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
104+
write_file(trait + '-enum', mk(ENUM_TUPLE))
105+
write_file(trait + '-enum-struct-variant', mk(ENUM_STRUCT))
120106
if types & STRUCT:
121-
files += write_file(trait + '-struct', mk(STRUCT_FIELDS))
122-
files += write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))
123-
124-
print('Generated {files} deriving span test{}.'.format('s' if files != 1 else '', files = files))
107+
write_file(trait + '-struct', mk(STRUCT_FIELDS))
108+
write_file(trait + '-tuple-struct', mk(STRUCT_TUPLE))

src/etc/generate-keyword-tests.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import stat
1616

1717

18-
template = """
18+
template = """\
1919
// This file was auto-generated using 'src/etc/generate-keyword-tests.py %s'
2020
2121
fn main() {
@@ -35,7 +35,7 @@
3535
os.chmod(test_file, stat.S_IWUSR)
3636

3737
with open(test_file, 'wt') as f:
38-
f.write(template % (datetime.datetime.now().year, kw, kw, kw))
38+
f.write(template % (kw, kw, kw))
3939

4040
# mark file read-only
4141
os.chmod(test_file, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)

src/liballoc/benches/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(repr_simd)]
2-
#![feature(slice_sort_by_cached_key)]
32
#![feature(test)]
43

54
extern crate rand;

src/liballoc/boxed.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,15 @@ impl<T: ?Sized> Box<T> {
202202
#[unstable(feature = "ptr_internals", issue = "0", reason = "use into_raw_non_null instead")]
203203
#[inline]
204204
#[doc(hidden)]
205-
pub fn into_unique(b: Box<T>) -> Unique<T> {
206-
let unique = b.0;
205+
pub fn into_unique(mut b: Box<T>) -> Unique<T> {
206+
// Box is kind-of a library type, but recognized as a "unique pointer" by
207+
// Stacked Borrows. This function here corresponds to "reborrowing to
208+
// a raw pointer", but there is no actual reborrow here -- so
209+
// without some care, the pointer we are returning here still carries
210+
// the `Uniq` tag. We round-trip through a mutable reference to avoid that.
211+
let unique = unsafe { b.0.as_mut() as *mut T };
207212
mem::forget(b);
208-
unique
213+
unsafe { Unique::new_unchecked(unique) }
209214
}
210215

211216
/// Consumes and leaks the `Box`, returning a mutable reference,

src/liballoc/collections/btree/node.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ impl<BorrowType, K, V, Type> NodeRef<BorrowType, K, V, Type> {
453453
root: self.root,
454454
_marker: PhantomData
455455
},
456-
idx: unsafe { usize::from(*self.as_header().parent_idx.get_ref()) },
456+
idx: unsafe { usize::from(*self.as_header().parent_idx.as_ptr()) },
457457
_marker: PhantomData
458458
})
459459
} else {
@@ -1143,7 +1143,7 @@ impl<BorrowType, K, V>
11431143
NodeRef {
11441144
height: self.node.height - 1,
11451145
node: unsafe {
1146-
self.node.as_internal().edges.get_unchecked(self.idx).get_ref().as_ptr()
1146+
(&*self.node.as_internal().edges.get_unchecked(self.idx).as_ptr()).as_ptr()
11471147
},
11481148
root: self.node.root,
11491149
_marker: PhantomData

src/liballoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
#![feature(rustc_const_unstable)]
113113
#![feature(const_vec_new)]
114114
#![feature(slice_partition_dedup)]
115-
#![feature(maybe_uninit)]
115+
#![feature(maybe_uninit, maybe_uninit_slice, maybe_uninit_array)]
116116
#![feature(alloc_layout_extra)]
117117
#![feature(try_trait)]
118118

src/liballoc/slice.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ impl<T> [T] {
257257
/// This sort is stable (i.e., does not reorder equal elements) and `O(m n log(m n))`
258258
/// worst-case, where the key function is `O(m)`.
259259
///
260+
/// For expensive key functions (e.g. functions that are not simple property accesses or
261+
/// basic operations), [`sort_by_cached_key`](#method.sort_by_cached_key) is likely to be
262+
/// significantly faster, as it does not recompute element keys.
263+
///
260264
/// When applicable, unstable sorting is preferred because it is generally faster than stable
261265
/// sorting and it doesn't allocate auxiliary memory.
262266
/// See [`sort_unstable_by_key`](#method.sort_unstable_by_key).
@@ -312,15 +316,14 @@ impl<T> [T] {
312316
/// # Examples
313317
///
314318
/// ```
315-
/// #![feature(slice_sort_by_cached_key)]
316319
/// let mut v = [-5i32, 4, 32, -3, 2];
317320
///
318321
/// v.sort_by_cached_key(|k| k.to_string());
319322
/// assert!(v == [-3, -5, 2, 32, 4]);
320323
/// ```
321324
///
322325
/// [pdqsort]: https://github.com/orlp/pdqsort
323-
#[unstable(feature = "slice_sort_by_cached_key", issue = "34447")]
326+
#[stable(feature = "slice_sort_by_cached_key", since = "1.34.0")]
324327
#[inline]
325328
pub fn sort_by_cached_key<K, F>(&mut self, f: F)
326329
where F: FnMut(&T) -> K, K: Ord

src/liballoc/tests/arc.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::any::Any;
42
use std::sync::{Arc, Weak};
53
use std::cell::RefCell;

src/liballoc/tests/binary_heap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ fn assert_covariance() {
282282
//
283283
// Destructors must be called exactly once per element.
284284
#[test]
285-
#[cfg(not(miri))]
285+
#[cfg(not(miri))] // Miri does not support panics
286286
fn panic_safe() {
287287
static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0);
288288

src/liballoc/tests/btree/map.rs

+30
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ use super::DeterministicRng;
99
#[test]
1010
fn test_basic_large() {
1111
let mut map = BTreeMap::new();
12+
#[cfg(not(miri))] // Miri is too slow
1213
let size = 10000;
14+
#[cfg(miri)]
15+
let size = 200;
1316
assert_eq!(map.len(), 0);
1417

1518
for i in 0..size {
@@ -69,7 +72,10 @@ fn test_basic_small() {
6972

7073
#[test]
7174
fn test_iter() {
75+
#[cfg(not(miri))] // Miri is too slow
7276
let size = 10000;
77+
#[cfg(miri)]
78+
let size = 200;
7379

7480
// Forwards
7581
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -91,7 +97,10 @@ fn test_iter() {
9197

9298
#[test]
9399
fn test_iter_rev() {
100+
#[cfg(not(miri))] // Miri is too slow
94101
let size = 10000;
102+
#[cfg(miri)]
103+
let size = 200;
95104

96105
// Forwards
97106
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -127,7 +136,10 @@ fn test_values_mut() {
127136

128137
#[test]
129138
fn test_iter_mixed() {
139+
#[cfg(not(miri))] // Miri is too slow
130140
let size = 10000;
141+
#[cfg(miri)]
142+
let size = 200;
131143

132144
// Forwards
133145
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@@ -214,42 +226,50 @@ fn test_range_equal_empty_cases() {
214226

215227
#[test]
216228
#[should_panic]
229+
#[cfg(not(miri))] // Miri does not support panics
217230
fn test_range_equal_excluded() {
218231
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
219232
map.range((Excluded(2), Excluded(2)));
220233
}
221234

222235
#[test]
223236
#[should_panic]
237+
#[cfg(not(miri))] // Miri does not support panics
224238
fn test_range_backwards_1() {
225239
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
226240
map.range((Included(3), Included(2)));
227241
}
228242

229243
#[test]
230244
#[should_panic]
245+
#[cfg(not(miri))] // Miri does not support panics
231246
fn test_range_backwards_2() {
232247
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
233248
map.range((Included(3), Excluded(2)));
234249
}
235250

236251
#[test]
237252
#[should_panic]
253+
#[cfg(not(miri))] // Miri does not support panics
238254
fn test_range_backwards_3() {
239255
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
240256
map.range((Excluded(3), Included(2)));
241257
}
242258

243259
#[test]
244260
#[should_panic]
261+
#[cfg(not(miri))] // Miri does not support panics
245262
fn test_range_backwards_4() {
246263
let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect();
247264
map.range((Excluded(3), Excluded(2)));
248265
}
249266

250267
#[test]
251268
fn test_range_1000() {
269+
#[cfg(not(miri))] // Miri is too slow
252270
let size = 1000;
271+
#[cfg(miri)]
272+
let size = 200;
253273
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
254274

255275
fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
@@ -286,7 +306,10 @@ fn test_range_borrowed_key() {
286306

287307
#[test]
288308
fn test_range() {
309+
#[cfg(not(miri))] // Miri is too slow
289310
let size = 200;
311+
#[cfg(miri)]
312+
let size = 30;
290313
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
291314

292315
for i in 0..size {
@@ -305,7 +328,10 @@ fn test_range() {
305328

306329
#[test]
307330
fn test_range_mut() {
331+
#[cfg(not(miri))] // Miri is too slow
308332
let size = 200;
333+
#[cfg(miri)]
334+
let size = 30;
309335
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
310336

311337
for i in 0..size {
@@ -479,7 +505,10 @@ fn test_bad_zst() {
479505
#[test]
480506
fn test_clone() {
481507
let mut map = BTreeMap::new();
508+
#[cfg(not(miri))] // Miri is too slow
482509
let size = 100;
510+
#[cfg(miri)]
511+
let size = 30;
483512
assert_eq!(map.len(), 0);
484513

485514
for i in 0..size {
@@ -631,6 +660,7 @@ create_append_test!(test_append_145, 145);
631660
create_append_test!(test_append_170, 170);
632661
create_append_test!(test_append_181, 181);
633662
create_append_test!(test_append_239, 239);
663+
#[cfg(not(miri))] // Miri is too slow
634664
create_append_test!(test_append_1700, 1700);
635665

636666
fn rand_data(len: usize) -> Vec<(u32, u32)> {

src/liballoc/tests/btree/mod.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
mod map;
42
mod set;
53

src/liballoc/tests/heap.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))]
2-
31
use std::alloc::{Global, Alloc, Layout, System};
42

53
/// Issue #45955.

0 commit comments

Comments
 (0)