Skip to content

Commit b6551ea

Browse files
committed
Misc fixes + added a list of broken tests and info on how to mimize them.
1 parent 445ad57 commit b6551ea

File tree

3 files changed

+251
-5
lines changed

3 files changed

+251
-5
lines changed

BROKEN_TESTS.md

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# How to find the source code of a broken test?
2+
1. Download the rust compiler source
3+
`git clone https://github.com/rust-lang/rust.git --depth 1000`
4+
2. Go into the library directory
5+
3. Serach for the name of your test `grep -r "broken_test"`
6+
# How to minimze a broken test?
7+
1. After finding a broken test, extract it into a spearte crate.
8+
2. Build the crate into native Rust using `cargo test` and check that it behaves as expcted.
9+
3. IMPORTANT! Clean the build cache using `cargo clean`. NEVER skip this step, beacause it can lead to suprising results which may hide the real issue.
10+
4. Build the crate using `rustc_codegen_clr` and observe the incorrect results.
11+
5. Make a small change by removing \ simplifing some code in your example.
12+
6. Clean the build cache using `cargo clean` again before rebuilding to prevent issues. DO NOT SKIP THS STEP.
13+
7. Repeat steps 2-7 untill the test program can no longer be simplified.
14+
8. Create an issue with your simplified broken test.
15+
# List of broken core test:
16+
## Did not compleate:
17+
```
18+
atomic::atomic_access_bool
19+
atomic::bool_
20+
atomic::int_max
21+
atomic::int_min
22+
atomic::int_nand
23+
atomic::int_xor
24+
atomic::ptr_bitops
25+
atomic::uint_max
26+
atomic::uint_min
27+
atomic::uint_nand
28+
atomic::uint_xor
29+
cell::refcell_ref_coercion
30+
future::test_join
31+
hash::test_writer_hasher
32+
iter::adapters::step_by::test_iterator_step_by_nth_try_fold
33+
iter::range::test_range_advance_by
34+
iter::test_monad_laws_left_identity
35+
manually_drop::smoke
36+
num::flt2dec::random::shortest_f32_exhaustive_equivalence_test
37+
num::flt2dec::random::shortest_f64_hard_random_equivalence_test
38+
num::i128::tests::test_saturating_abs
39+
num::i128::tests::test_saturating_neg
40+
num::int_log::checked_ilog
41+
ptr::ptr_metadata
42+
ptr::test_ptr_metadata_in_const
43+
ptr::test_variadic_fnptr
44+
result::result_try_trait_v2_branch
45+
simd::testing
46+
slice::select_nth_unstable
47+
slice::take_in_bounds_max_range_from
48+
slice::take_in_bounds_max_range_to
49+
slice::take_mut_in_bounds_max_range_from
50+
slice::take_mut_in_bounds_max_range_to
51+
slice::take_mut_oob_max_range_to_inclusive
52+
slice::take_oob_max_range_to_inclusive
53+
```
54+
## Failed
55+
```
56+
num::i8::tests::test_pow
57+
iter::adapters::flat_map::test_flat_map_try_folds
58+
num::bignum::test_add_small_overflow
59+
num::i16::tests::test_checked_next_multiple_of
60+
slice::swap_panics::index_b_equals_len
61+
num::bignum::test_mul_small_overflow
62+
mem::uninit_fill_clone_panic_drop
63+
num::i128::tests::test_lots_of_isqrt
64+
iter::adapters::peekable::test_peek_try_folds
65+
num::bignum::test_mul_digits_overflow_1
66+
num::i8::tests::test_from_str_radix
67+
net::ip_addr::ipv6_properties
68+
num::test_int_from_str_overflow
69+
iter::traits::double_ended::test_rev_try_folds
70+
ascii::test_is_ascii_align_size_thoroughly
71+
num::i16::tests::test_pow
72+
slice::swap_panics::index_a_equals_len
73+
net::ip_addr::ipv6_addr_to_string
74+
iter::adapters::flatten::test_flatten_try_folds
75+
num::bignum::test_get_bit_out_of_range
76+
slice::take_last_nonempty
77+
num::bignum::test_add_overflow_1
78+
iter::adapters::skip::test_skip_try_folds
79+
num::i16::tests::test_from_str
80+
net::socket_addr::ipv6_socket_addr_to_string
81+
iter::adapters::map::test_map_try_folds
82+
cell::refcell_unsized
83+
num::f32::min
84+
iter::adapters::cloned::test_cloned_try_folds
85+
num::bignum::test_from_u64_overflow
86+
iter::adapters::flatten::test_flatten_one_shot
87+
slice::take_first_nonempty
88+
num::i16::tests::test_from_str_radix
89+
num::f32::max
90+
option::as_slice
91+
num::u16::tests::test_rotate
92+
iter::adapters::step_by::test_iterator_step_by_nth_try_rfold
93+
iter::range::test_range_inclusive_folds
94+
iter::adapters::take_while::test_take_while_folds
95+
iter::adapters::take::test_take_try_folds
96+
num::u16::tests::test_leading_trailing_ones
97+
slice::swap_panics::index_b_greater_than_len
98+
iter::adapters::skip_while::test_skip_while_try_fold
99+
slice::take_first_mut_nonempty
100+
num::f64::max
101+
net::socket_addr::socket_v6_to_str
102+
num::i16::tests::test_rotate
103+
slice::swap_panics::index_a_greater_than_len
104+
num::i8::tests::test_checked_next_multiple_of
105+
num::bignum::test_mul_digits_overflow_2
106+
num::f64::min
107+
num::i8::tests::test_from_str
108+
slice::take_last_mut_nonempty
109+
iter::adapters::filter_map::test_filter_map_try_folds
110+
ptr::from_raw_parts
111+
num::u8::tests::test_leading_trailing_ones
112+
num::i16::tests::test_leading_trailing_ones
113+
num::i8::tests::test_leading_trailing_ones
114+
iter::adapters::flatten::test_flatten_one_shot_rev
115+
num::bignum::test_mul_pow5_overflow_2
116+
num::bignum::test_add_overflow_2
117+
num::u128::tests::test_pow
118+
result::result_const
119+
iter::adapters::filter::test_filter_try_folds
120+
num::bignum::test_mul_pow2_overflow_2
121+
num::i128::tests::test_pow
122+
```
123+
# List of broken alloc tests:
124+
## Did not compleate:
125+
```
126+
arc::make_mut_unsized
127+
arc::shared_from_iter_normal
128+
arc::shared_from_iter_trustedlen_no_fuse
129+
arc::shared_from_iter_trustedlen_normal
130+
arc::shared_from_iter_trustedlen_panic
131+
arc::slice
132+
arc::trait_object
133+
arc::uninhabited
134+
autotraits::test_binary_heap
135+
autotraits::test_btree_map
136+
autotraits::test_btree_set
137+
autotraits::test_linked_list
138+
autotraits::test_vec_deque
139+
borrow::test_from_cow_c_str
140+
borrow::test_from_cow_os_str
141+
borrow::test_from_cow_path
142+
borrow::test_from_cow_slice
143+
borrow::test_from_cow_str
144+
heap::alloc_system_overaligned_request
145+
rc::shared_from_iter_normal
146+
rc::shared_from_iter_trustedlen_no_fuse
147+
rc::shared_from_iter_trustedlen_normal
148+
rc::shared_from_iter_trustedlen_panic
149+
rc::slice
150+
rc::trait_object
151+
rc::uninhabited
152+
slice::subslice_patterns
153+
slice::test_split_last
154+
string::test_try_reserve
155+
task::test_local_waker_will_wake_clone
156+
task::test_waker_will_wake_clone
157+
thin_box::align1zst
158+
thin_box::align2zst
159+
thin_box::align64_size_not_pow2
160+
thin_box::align64big
161+
thin_box::align64med
162+
thin_box::align64small
163+
thin_box::align64zst
164+
vec::test_try_reserve
165+
vec_deque::test_try_reserve
166+
```
167+
## Failed:
168+
```
169+
slice::test_split_first_mut
170+
vec::test_index_out_of_bounds
171+
vec::vec_macro_repeating_null_raw_fat_pointer
172+
slice::test_split_first
173+
vec::extract_if_unconsumed_panic
174+
vec::extract_if_consumed_panic
175+
vec_deque::test_try_rfold_moves_iter
176+
vec_deque::test_try_fold_moves_iter
177+
str::const_str_ptr
178+
vec::test_collect_after_iterator_clone
179+
```

src/bin/autotest.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ fn main() {
4949
}
5050
}
5151
}
52-
if stderr.contains("failures:") | stdout.contains("failures:") {
52+
if stderr.contains("failures:")
53+
| stdout.contains("failures:")
54+
| stderr.contains("finished")
55+
| stdout.contains("finished")
56+
{
5357
println!("search done.");
5458
break;
5559
}

src/terminator/intrinsics/saturating.rs

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ pub fn saturating_add<'tcx>(
1717
) -> CILRoot {
1818
let a = handle_operand(&args[0].node, ctx);
1919
let b = handle_operand(&args[1].node, ctx);
20+
let a_ty = ctx.monomorphize(
21+
call_instance.args[0]
22+
.as_type()
23+
.expect("saturating_sub works only on types!"),
24+
);
2025
let a_type = ctx.type_from_cache(
2126
ctx.monomorphize(
2227
call_instance.args[0]
@@ -25,10 +30,10 @@ pub fn saturating_add<'tcx>(
2530
),
2631
);
2732
let calc = match a_type {
28-
Type::USize | Type::U64 | Type::U32 | Type::U16 | Type::U8 => {
29-
let sum = a.clone() + b.clone();
30-
let or = a | b;
31-
let flag = lt_un!(sum.clone(), or);
33+
Type::USize | Type::U128 | Type::U64 | Type::U32 | Type::U16 | Type::U8 => {
34+
let sum = crate::binop::add_unchecked(a_ty, a_ty, ctx, a.clone(), b.clone());
35+
let or = crate::binop::bitop::bit_or_unchecked(a_ty, a_ty, ctx, a.clone(), b.clone());
36+
let flag = crate::binop::cmp::lt_unchecked(a_ty, sum.clone(), or.clone());
3237
let max = crate::r#type::max_value(&a_type);
3338
CILNode::select(a_type, max, sum, flag)
3439
}
@@ -51,6 +56,36 @@ pub fn saturating_add<'tcx>(
5156
);
5257
conv_i32!(diff_capped)
5358
}
59+
60+
Type::I64 => {
61+
let a = crate::casts::int_to_int(Type::I64, &Type::I128, a);
62+
let b = crate::casts::int_to_int(Type::I64, &Type::I128, b);
63+
let diff = call!(
64+
CallSite::new_extern(
65+
DotnetTypeRef::int_128(),
66+
"op_Addition".into(),
67+
FnSig::new(&[Type::I128, Type::I128], Type::I128),
68+
true,
69+
),
70+
[a, b]
71+
);
72+
#[allow(clippy::cast_sign_loss)]
73+
let diff_capped = call!(
74+
CallSite::new_extern(
75+
DotnetTypeRef::int_128(),
76+
"Clamp".into(),
77+
FnSig::new(&[Type::I128, Type::I128, Type::I128], Type::I128),
78+
true
79+
),
80+
[
81+
diff,
82+
CILNode::const_i128(i128::from(i64::MIN) as u128),
83+
CILNode::const_i128(i128::from(i64::MAX) as u128),
84+
]
85+
);
86+
crate::casts::int_to_int(Type::I128, &Type::I64, diff_capped)
87+
}
88+
5489
Type::I16 => {
5590
let a = conv_i32!(a);
5691
let b = conv_i32!(b);
@@ -114,6 +149,34 @@ pub fn saturating_sub<'tcx>(
114149
let zero = crate::binop::checked::zero(a_ty);
115150
CILNode::select(a_type, zero, diff, undeflow)
116151
}
152+
Type::I64 => {
153+
let a = crate::casts::int_to_int(Type::I64, &Type::I128, a);
154+
let b = crate::casts::int_to_int(Type::I64, &Type::I128, b);
155+
let diff = call!(
156+
CallSite::new_extern(
157+
DotnetTypeRef::int_128(),
158+
"op_Subtraction".into(),
159+
FnSig::new(&[Type::I128, Type::I128], Type::I128),
160+
true,
161+
),
162+
[a, b]
163+
);
164+
#[allow(clippy::cast_sign_loss)]
165+
let diff_capped = call!(
166+
CallSite::new_extern(
167+
DotnetTypeRef::int_128(),
168+
"Clamp".into(),
169+
FnSig::new(&[Type::I128, Type::I128, Type::I128], Type::I128),
170+
true
171+
),
172+
[
173+
diff,
174+
CILNode::const_i128(i128::from(i64::MIN) as u128),
175+
CILNode::const_i128(i128::from(i64::MAX) as u128),
176+
]
177+
);
178+
crate::casts::int_to_int(Type::I128, &Type::I64, diff_capped)
179+
}
117180
Type::I32 => {
118181
let a = conv_i64!(a);
119182
let b = conv_i64!(b);

0 commit comments

Comments
 (0)