Skip to content

Commit 534b423

Browse files
committed
Auto merge of #63408 - Centril:rollup-skqrez3, r=Centril
Rollup of 7 pull requests Successful merges: - #62672 (Deprecate `try!` macro) - #62950 (Check rustbook links on all platforms when running locally) - #63114 (Remove gensym in format_args) - #63397 (Add tests for some ICEs) - #63403 (Improve test output) - #63404 (enable flt2dec tests in Miri) - #63407 (reduce some test sizes in Miri) Failed merges: r? @ghost
2 parents 813a3a5 + 4e3c209 commit 534b423

Some content is hidden

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

44 files changed

+538
-99
lines changed

src/bootstrap/tool.rs

+23-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use build_helper::t;
99
use crate::Mode;
1010
use crate::Compiler;
1111
use crate::builder::{Step, RunConfig, ShouldRun, Builder};
12-
use crate::util::{exe, add_lib_path};
12+
use crate::util::{exe, add_lib_path, CiEnv};
1313
use crate::compile;
1414
use crate::channel::GitInfo;
1515
use crate::channel;
@@ -279,11 +279,26 @@ pub fn prepare_tool_cargo(
279279
cargo
280280
}
281281

282+
fn rustbook_features() -> Vec<String> {
283+
let mut features = Vec::new();
284+
285+
// Due to CI budged and risk of spurious failures we want to limit jobs running this check.
286+
// At same time local builds should run it regardless of the platform.
287+
// `CiEnv::None` means it's local build and `CHECK_LINKS` is defined in x86_64-gnu-tools to
288+
// explicitly enable it on single job
289+
if CiEnv::current() == CiEnv::None || env::var("CHECK_LINKS").is_ok() {
290+
features.push("linkcheck".to_string());
291+
}
292+
293+
features
294+
}
295+
282296
macro_rules! bootstrap_tool {
283297
($(
284298
$name:ident, $path:expr, $tool_name:expr
285299
$(,llvm_tools = $llvm:expr)*
286300
$(,is_external_tool = $external:expr)*
301+
$(,features = $features:expr)*
287302
;
288303
)+) => {
289304
#[derive(Copy, PartialEq, Eq, Clone)]
@@ -350,7 +365,12 @@ macro_rules! bootstrap_tool {
350365
} else {
351366
SourceType::InTree
352367
},
353-
extra_features: Vec::new(),
368+
extra_features: {
369+
// FIXME(#60643): avoid this lint by using `_`
370+
let mut _tmp = Vec::new();
371+
$(_tmp.extend($features);)*
372+
_tmp
373+
},
354374
}).expect("expected to build -- essential tool")
355375
}
356376
}
@@ -359,7 +379,7 @@ macro_rules! bootstrap_tool {
359379
}
360380

361381
bootstrap_tool!(
362-
Rustbook, "src/tools/rustbook", "rustbook";
382+
Rustbook, "src/tools/rustbook", "rustbook", features = rustbook_features();
363383
UnstableBookGen, "src/tools/unstable-book-gen", "unstable-book-gen";
364384
Tidy, "src/tools/tidy", "tidy";
365385
Linkchecker, "src/tools/linkchecker", "linkchecker";

src/ci/docker/x86_64-gnu-tools/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ COPY x86_64-gnu-tools/checkregression.py /tmp/
2121
COPY x86_64-gnu-tools/checktools.sh /tmp/
2222
COPY x86_64-gnu-tools/repo.sh /tmp/
2323

24+
# Run rustbook with `linkcheck` feature enabled
25+
ENV CHECK_LINKS 1
26+
2427
ENV RUST_CONFIGURE_ARGS \
2528
--build=x86_64-unknown-linux-gnu \
2629
--save-toolstates=/tmp/toolstates.json

src/liballoc/tests/btree/map.rs

+3
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,10 @@ fn test_split_off_empty_left() {
689689

690690
#[test]
691691
fn test_split_off_large_random_sorted() {
692+
#[cfg(not(miri))] // Miri is too slow
692693
let mut data = rand_data(1529);
694+
#[cfg(miri)]
695+
let mut data = rand_data(529);
693696
// special case with maximum height.
694697
data.sort();
695698

src/liballoc/tests/btree/set.rs

+26-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn test_clone_eq() {
1010
m.insert(1);
1111
m.insert(2);
1212

13-
assert!(m.clone() == m);
13+
assert_eq!(m.clone(), m);
1414
}
1515

1616
#[test]
@@ -28,7 +28,7 @@ fn test_hash() {
2828
y.insert(2);
2929
y.insert(1);
3030

31-
assert!(hash(&x) == hash(&y));
31+
assert_eq!(hash(&x), hash(&y));
3232
}
3333

3434
fn check<F>(a: &[i32], b: &[i32], expected: &[i32], f: F)
@@ -69,6 +69,11 @@ fn test_intersection() {
6969
check_intersection(&[11, 1, 3, 77, 103, 5, -5],
7070
&[2, 11, 77, -9, -42, 5, 3],
7171
&[3, 5, 11, 77]);
72+
73+
if cfg!(miri) { // Miri is too slow
74+
return;
75+
}
76+
7277
let large = (0..1000).collect::<Vec<_>>();
7378
check_intersection(&[], &large, &[]);
7479
check_intersection(&large, &[], &[]);
@@ -98,6 +103,11 @@ fn test_difference() {
98103
check_difference(&[-5, 11, 22, 33, 40, 42],
99104
&[-12, -5, 14, 23, 34, 38, 39, 50],
100105
&[11, 22, 33, 40, 42]);
106+
107+
if cfg!(miri) { // Miri is too slow
108+
return;
109+
}
110+
101111
let large = (0..1000).collect::<Vec<_>>();
102112
check_difference(&[], &large, &[]);
103113
check_difference(&[-1], &large, &[-1]);
@@ -166,6 +176,17 @@ fn test_is_subset() {
166176
assert_eq!(is_subset(&[1, 2], &[1]), false);
167177
assert_eq!(is_subset(&[1, 2], &[1, 2]), true);
168178
assert_eq!(is_subset(&[1, 2], &[2, 3]), false);
179+
assert_eq!(is_subset(&[-5, 11, 22, 33, 40, 42],
180+
&[-12, -5, 14, 23, 11, 34, 22, 38, 33, 42, 39, 40]),
181+
true);
182+
assert_eq!(is_subset(&[-5, 11, 22, 33, 40, 42],
183+
&[-12, -5, 14, 23, 34, 38, 22, 11]),
184+
false);
185+
186+
if cfg!(miri) { // Miri is too slow
187+
return;
188+
}
189+
169190
let large = (0..1000).collect::<Vec<_>>();
170191
assert_eq!(is_subset(&[], &large), true);
171192
assert_eq!(is_subset(&large, &[]), false);
@@ -371,7 +392,10 @@ fn test_split_off_empty_left() {
371392

372393
#[test]
373394
fn test_split_off_large_random_sorted() {
395+
#[cfg(not(miri))] // Miri is too slow
374396
let mut data = rand_data(1529);
397+
#[cfg(miri)]
398+
let mut data = rand_data(529);
375399
// special case with maximum height.
376400
data.sort();
377401

src/libcore/macros.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ macro_rules! debug_assert_ne {
302302
/// ```
303303
#[macro_export]
304304
#[stable(feature = "rust1", since = "1.0.0")]
305+
#[rustc_deprecated(since = "1.39.0", reason = "use the `?` operator instead")]
305306
#[doc(alias = "?")]
306307
macro_rules! r#try {
307308
($expr:expr) => (match $expr {
@@ -767,7 +768,6 @@ pub(crate) mod builtin {
767768
#[stable(feature = "rust1", since = "1.0.0")]
768769
#[allow_internal_unstable(fmt_internals)]
769770
#[rustc_builtin_macro]
770-
#[rustc_macro_transparency = "semitransparent"]
771771
pub macro format_args {
772772
($fmt:expr) => ({ /* compiler built-in */ }),
773773
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })
@@ -779,7 +779,6 @@ pub(crate) mod builtin {
779779
language use and is subject to change")]
780780
#[allow_internal_unstable(fmt_internals)]
781781
#[rustc_builtin_macro]
782-
#[rustc_macro_transparency = "semitransparent"]
783782
pub macro format_args_nl {
784783
($fmt:expr) => ({ /* compiler built-in */ }),
785784
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ })

src/libcore/tests/num/dec2flt/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ fn infinity() {
7777
fn zero() {
7878
test_literal!(0.0);
7979
test_literal!(1e-325);
80+
#[cfg(not(miri))] // Miri is too slow
8081
test_literal!(1e-326);
8182
#[cfg(not(miri))] // Miri is too slow
8283
test_literal!(1e-500);

src/libcore/tests/num/flt2dec/estimator.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,12 @@ fn test_estimate_scaling_factor() {
4242
assert_almost_eq!(estimate_scaling_factor(1, -1074), -323);
4343
assert_almost_eq!(estimate_scaling_factor(0x1fffffffffffff, 971), 309);
4444

45-
for i in -1074..972 {
45+
#[cfg(not(miri))] // Miri is too slow
46+
let iter = -1074..972;
47+
#[cfg(miri)]
48+
let iter = (-1074..972).step_by(37);
49+
50+
for i in iter {
4651
let expected = super::ldexp_f64(1.0, i).log10().ceil();
4752
assert_almost_eq!(estimate_scaling_factor(1, i as i16), expected as i16);
4853
}

src/libcore/tests/num/flt2dec/mod.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![cfg(not(miri))] // Miri does not implement ldexp, which most tests here need
2-
31
use std::prelude::v1::*;
42
use std::{str, i16, f32, f64, fmt};
53

@@ -257,6 +255,7 @@ pub fn f32_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8])
257255
check_shortest!(f(minf32) => b"1", -44);
258256
}
259257

258+
#[cfg(not(miri))] // Miri is too slow
260259
pub fn f32_exact_sanity_test<F>(mut f: F)
261260
where F: FnMut(&Decoded, &mut [u8], i16) -> (usize, i16) {
262261
let minf32 = ldexp_f32(1.0, -149);
@@ -362,6 +361,7 @@ pub fn f64_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8])
362361
check_shortest!(f(minf64) => b"5", -323);
363362
}
364363

364+
#[cfg(not(miri))] // Miri is too slow
365365
pub fn f64_exact_sanity_test<F>(mut f: F)
366366
where F: FnMut(&Decoded, &mut [u8], i16) -> (usize, i16) {
367367
let minf64 = ldexp_f64(1.0, -1074);
@@ -553,6 +553,10 @@ pub fn to_shortest_str_test<F>(mut f_: F)
553553
assert_eq!(to_string(f, minf64, Minus, 324, false), format!("0.{:0>323}5", ""));
554554
assert_eq!(to_string(f, minf64, Minus, 325, false), format!("0.{:0>323}50", ""));
555555

556+
if cfg!(miri) { // Miri is too slow
557+
return;
558+
}
559+
556560
// very large output
557561
assert_eq!(to_string(f, 1.1, Minus, 80000, false), format!("1.1{:0>79999}", ""));
558562
}
@@ -807,6 +811,10 @@ pub fn to_exact_exp_str_test<F>(mut f_: F)
807811
"1.401298464324817070923729583289916131280261941876515771757068283\
808812
8897910826858606014866381883621215820312500000000000000000000000e-45");
809813

814+
if cfg!(miri) { // Miri is too slow
815+
return;
816+
}
817+
810818
assert_eq!(to_string(f, f64::MAX, Minus, 1, false), "2e308");
811819
assert_eq!(to_string(f, f64::MAX, Minus, 2, false), "1.8e308");
812820
assert_eq!(to_string(f, f64::MAX, Minus, 4, false), "1.798e308");
@@ -1040,6 +1048,10 @@ pub fn to_exact_fixed_str_test<F>(mut f_: F)
10401048
assert_eq!(to_string(f, f32::MAX, Minus, 2, false),
10411049
"340282346638528859811704183484516925440.00");
10421050

1051+
if cfg!(miri) { // Miri is too slow
1052+
return;
1053+
}
1054+
10431055
let minf32 = ldexp_f32(1.0, -149);
10441056
assert_eq!(to_string(f, minf32, Minus, 0, false), "0");
10451057
assert_eq!(to_string(f, minf32, Minus, 1, false), "0.0");

src/libcore/tests/num/flt2dec/random.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,13 @@ pub fn f32_exhaustive_equivalence_test<F, G>(f: F, g: G, k: usize)
109109
#[test]
110110
fn shortest_random_equivalence_test() {
111111
use core::num::flt2dec::strategy::dragon::format_shortest as fallback;
112-
f64_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, 10_000);
113-
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, 10_000);
112+
#[cfg(not(miri))] // Miri is too slow
113+
const N: usize = 10_000;
114+
#[cfg(miri)]
115+
const N: usize = 10;
116+
117+
f64_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, N);
118+
f32_random_equivalence_test(format_shortest_opt, fallback, MAX_SIG_DIGITS, N);
114119
}
115120

116121
#[test] #[ignore] // it is too expensive
@@ -138,17 +143,27 @@ fn shortest_f64_hard_random_equivalence_test() {
138143
#[test]
139144
fn exact_f32_random_equivalence_test() {
140145
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
146+
#[cfg(not(miri))] // Miri is too slow
147+
const N: usize = 1_000;
148+
#[cfg(miri)]
149+
const N: usize = 3;
150+
141151
for k in 1..21 {
142152
f32_random_equivalence_test(|d, buf| format_exact_opt(d, buf, i16::MIN),
143-
|d, buf| fallback(d, buf, i16::MIN), k, 1_000);
153+
|d, buf| fallback(d, buf, i16::MIN), k, N);
144154
}
145155
}
146156

147157
#[test]
148158
fn exact_f64_random_equivalence_test() {
149159
use core::num::flt2dec::strategy::dragon::format_exact as fallback;
160+
#[cfg(not(miri))] // Miri is too slow
161+
const N: usize = 1_000;
162+
#[cfg(miri)]
163+
const N: usize = 3;
164+
150165
for k in 1..21 {
151166
f64_random_equivalence_test(|d, buf| format_exact_opt(d, buf, i16::MIN),
152-
|d, buf| fallback(d, buf, i16::MIN), k, 1_000);
167+
|d, buf| fallback(d, buf, i16::MIN), k, N);
153168
}
154169
}

src/libcore/tests/num/flt2dec/strategy/dragon.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ fn shortest_sanity_test() {
2323
}
2424

2525
#[test]
26+
#[cfg(not(miri))] // Miri is too slow
2627
fn exact_sanity_test() {
2728
// This test ends up running what I can only assume is some corner-ish case
2829
// of the `exp2` library function, defined in whatever C runtime we're

src/libcore/tests/num/flt2dec/strategy/grisu.rs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ fn shortest_sanity_test() {
3636
}
3737

3838
#[test]
39+
#[cfg(not(miri))] // Miri is too slow
3940
fn exact_sanity_test() {
4041
// See comments in dragon.rs's exact_sanity_test for why this test is
4142
// ignored on MSVC

src/libcore/tests/slice.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ use core::result::Result::{Ok, Err};
33
#[test]
44
fn test_position() {
55
let b = [1, 2, 3, 5, 5];
6-
assert!(b.iter().position(|&v| v == 9) == None);
7-
assert!(b.iter().position(|&v| v == 5) == Some(3));
8-
assert!(b.iter().position(|&v| v == 3) == Some(2));
9-
assert!(b.iter().position(|&v| v == 0) == None);
6+
assert_eq!(b.iter().position(|&v| v == 9), None);
7+
assert_eq!(b.iter().position(|&v| v == 5), Some(3));
8+
assert_eq!(b.iter().position(|&v| v == 3), Some(2));
9+
assert_eq!(b.iter().position(|&v| v == 0), None);
1010
}
1111

1212
#[test]
1313
fn test_rposition() {
1414
let b = [1, 2, 3, 5, 5];
15-
assert!(b.iter().rposition(|&v| v == 9) == None);
16-
assert!(b.iter().rposition(|&v| v == 5) == Some(4));
17-
assert!(b.iter().rposition(|&v| v == 3) == Some(2));
18-
assert!(b.iter().rposition(|&v| v == 0) == None);
15+
assert_eq!(b.iter().rposition(|&v| v == 9), None);
16+
assert_eq!(b.iter().rposition(|&v| v == 5), Some(4));
17+
assert_eq!(b.iter().rposition(|&v| v == 3), Some(2));
18+
assert_eq!(b.iter().rposition(|&v| v == 0), None);
1919
}
2020

2121
#[test]
@@ -1153,7 +1153,7 @@ fn test_rotate_right() {
11531153
}
11541154

11551155
#[test]
1156-
#[cfg(not(miri))]
1156+
#[cfg(not(miri))] // Miri is too slow
11571157
fn brute_force_rotate_test_0() {
11581158
// In case of edge cases involving multiple algorithms
11591159
let n = 300;

src/libcore/tests/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::time::Duration;
22

33
#[test]
44
fn creation() {
5-
assert!(Duration::from_secs(1) != Duration::from_secs(0));
5+
assert_ne!(Duration::from_secs(1), Duration::from_secs(0));
66
assert_eq!(Duration::from_secs(1) + Duration::from_secs(2),
77
Duration::from_secs(3));
88
assert_eq!(Duration::from_millis(10) + Duration::from_secs(4),

0 commit comments

Comments
 (0)