Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5e584d2

Browse files
committed
Auto merge of rust-lang#2252 - dtolnay-contrib:rustfmt5, r=oli-obk
Format tests with rustfmt (225-275 of 300) Extracted from rust-lang#2097. These cases all involve a line comment at the end of a block that rustfmt has chosen to wrap. ```diff - unsafe { (*ptr).set(20); } //~ ERROR does not exist in the borrow stack + unsafe { + (*ptr).set(20); + } //~ ERROR does not exist in the borrow stack ``` I have moved all of those comments back onto the same line as the content of the block instead, as was indicated being `@RalfJung's` preference in rust-lang/miri#2097 (comment). ```diff + unsafe { + (*ptr).set(20); //~ ERROR does not exist in the borrow stack + } ```
2 parents 769c6c7 + f1044d2 commit 5e584d2

File tree

101 files changed

+294
-185
lines changed

Some content is hidden

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

101 files changed

+294
-185
lines changed

tests/fail/box-cell-alias.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use std::cell::Cell;
66

77
fn helper(val: Box<Cell<u8>>, ptr: *const Cell<u8>) -> u8 {
88
val.set(10);
9-
unsafe { (*ptr).set(20); } //~ ERROR does not exist in the borrow stack
9+
unsafe {
10+
(*ptr).set(20); //~ ERROR does not exist in the borrow stack
11+
}
1012
val.get()
1113
}
1214

tests/fail/box-cell-alias.stderr

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error: Undefined Behavior: trying to reborrow <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
22
--> $DIR/box-cell-alias.rs:LL:CC
33
|
4-
LL | unsafe { (*ptr).set(20); }
5-
| ^^^^^^^^^^^^^^
6-
| |
7-
| trying to reborrow <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8-
| this error occurs as part of a reborrow at ALLOC[0x0..0x1]
4+
LL | (*ptr).set(20);
5+
| ^^^^^^^^^^^^^^
6+
| |
7+
| trying to reborrow <TAG> for SharedReadWrite permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
8+
| this error occurs as part of a reborrow at ALLOC[0x0..0x1]
99
|
1010
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
1111
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information

tests/fail/dangling_pointers/maybe_null_pointer_write_zst.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,7 @@ fn main() {
77
// Also not assigning directly as that's array initialization, not assignment.
88
let zst_val = [1u8; 0];
99
let ptr = (&0u8 as *const u8).wrapping_sub(0x800) as *mut [u8; 0];
10-
unsafe { *ptr = zst_val; } //~ ERROR out-of-bounds
10+
unsafe {
11+
*ptr = zst_val; //~ ERROR out-of-bounds
12+
}
1113
}

tests/fail/dangling_pointers/maybe_null_pointer_write_zst.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds
22
--> $DIR/maybe_null_pointer_write_zst.rs:LL:CC
33
|
4-
LL | unsafe { *ptr = zst_val; }
5-
| ^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds
4+
LL | *ptr = zst_val;
5+
| ^^^^^^^^^^^^^^ dereferencing pointer failed: ALLOC has size 1, so pointer at offset -2048 is out-of-bounds
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/copy_null.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ fn main() {
99
let mut data = [0u16; 4];
1010
let ptr = &mut data[0] as *mut u16;
1111
// Even copying 0 elements from NULL should error.
12-
unsafe { copy_nonoverlapping(std::ptr::null(), ptr, 0); } //~ ERROR: memory access failed: null pointer is not a valid pointer
12+
unsafe {
13+
copy_nonoverlapping(std::ptr::null(), ptr, 0); //~ ERROR: memory access failed: null pointer is not a valid pointer
14+
}
1315
}

tests/fail/intrinsics/copy_null.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: memory access failed: null pointer is not a valid pointer
22
--> $DIR/copy_null.rs:LL:CC
33
|
4-
LL | unsafe { copy_nonoverlapping(std::ptr::null(), ptr, 0); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is not a valid pointer
4+
LL | copy_nonoverlapping(std::ptr::null(), ptr, 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ memory access failed: null pointer is not a valid pointer
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/copy_unaligned.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ fn main() {
99
let mut data = [0u16; 8];
1010
let ptr = (&mut data[0] as *mut u16 as *mut u8).wrapping_add(1) as *mut u16;
1111
// Even copying 0 elements to something unaligned should error
12-
unsafe { copy_nonoverlapping(&data[5], ptr, 0); } //~ ERROR accessing memory with alignment 1, but alignment 2 is required
12+
unsafe {
13+
copy_nonoverlapping(&data[5], ptr, 0); //~ ERROR accessing memory with alignment 1, but alignment 2 is required
14+
}
1315
}

tests/fail/intrinsics/copy_unaligned.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: accessing memory with alignment ALIGN, but alignment ALIGN is required
22
--> $DIR/copy_unaligned.rs:LL:CC
33
|
4-
LL | unsafe { copy_nonoverlapping(&data[5], ptr, 0); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required
4+
LL | copy_nonoverlapping(&data[5], ptr, 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ accessing memory with alignment ALIGN, but alignment ALIGN is required
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/exact_div1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// divison by 0
4-
unsafe { std::intrinsics::exact_div(2, 0); } //~ ERROR divisor of zero
4+
unsafe {
5+
std::intrinsics::exact_div(2, 0); //~ ERROR divisor of zero
6+
}
57
}

tests/fail/intrinsics/exact_div1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: calculating the remainder with a divisor of zero
22
--> $DIR/exact_div1.rs:LL:CC
33
|
4-
LL | unsafe { std::intrinsics::exact_div(2, 0); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero
4+
LL | std::intrinsics::exact_div(2, 0);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ calculating the remainder with a divisor of zero
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/exact_div2.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// divison with a remainder
4-
unsafe { std::intrinsics::exact_div(2u16, 3); } //~ ERROR 2_u16 cannot be divided by 3_u16 without remainder
4+
unsafe {
5+
std::intrinsics::exact_div(2u16, 3); //~ ERROR 2_u16 cannot be divided by 3_u16 without remainder
6+
}
57
}

tests/fail/intrinsics/exact_div2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: exact_div: 2_u16 cannot be divided by 3_u16 without remainder
22
--> $DIR/exact_div2.rs:LL:CC
33
|
4-
LL | unsafe { std::intrinsics::exact_div(2u16, 3); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 2_u16 cannot be divided by 3_u16 without remainder
4+
LL | std::intrinsics::exact_div(2u16, 3);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: 2_u16 cannot be divided by 3_u16 without remainder
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/exact_div3.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// signed divison with a remainder
4-
unsafe { std::intrinsics::exact_div(-19i8, 2); } //~ ERROR -19_i8 cannot be divided by 2_i8 without remainder
4+
unsafe {
5+
std::intrinsics::exact_div(-19i8, 2); //~ ERROR -19_i8 cannot be divided by 2_i8 without remainder
6+
}
57
}

tests/fail/intrinsics/exact_div3.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: exact_div: -19_i8 cannot be divided by 2_i8 without remainder
22
--> $DIR/exact_div3.rs:LL:CC
33
|
4-
LL | unsafe { std::intrinsics::exact_div(-19i8, 2); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: -19_i8 cannot be divided by 2_i8 without remainder
4+
LL | std::intrinsics::exact_div(-19i8, 2);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ exact_div: -19_i8 cannot be divided by 2_i8 without remainder
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/exact_div4.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![feature(core_intrinsics)]
22
fn main() {
33
// divison of MIN by -1
4-
unsafe { std::intrinsics::exact_div(i64::MIN, -1); } //~ ERROR overflow in signed remainder (dividing MIN by -1)
4+
unsafe {
5+
std::intrinsics::exact_div(i64::MIN, -1); //~ ERROR overflow in signed remainder (dividing MIN by -1)
6+
}
57
}

tests/fail/intrinsics/exact_div4.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: overflow in signed remainder (dividing MIN by -1)
22
--> $DIR/exact_div4.rs:LL:CC
33
|
4-
LL | unsafe { std::intrinsics::exact_div(i64::MIN, -1); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1)
4+
LL | std::intrinsics::exact_div(i64::MIN, -1);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ overflow in signed remainder (dividing MIN by -1)
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_32_inf1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f32, i32>(f32::INFINITY); } //~ ERROR: cannot be represented in target type `i32`
9+
unsafe {
10+
float_to_int_unchecked::<f32, i32>(f32::INFINITY); //~ ERROR: cannot be represented in target type `i32`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_32_inf1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `i32`
22
--> $DIR/float_to_int_32_inf1.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f32, i32>(f32::INFINITY); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `i32`
4+
LL | float_to_int_unchecked::<f32, i32>(f32::INFINITY);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `i32`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_32_infneg1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f32, i32>(f32::NEG_INFINITY); } //~ ERROR: cannot be represented in target type `i32`
9+
unsafe {
10+
float_to_int_unchecked::<f32, i32>(f32::NEG_INFINITY); //~ ERROR: cannot be represented in target type `i32`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_32_infneg1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `i32`
22
--> $DIR/float_to_int_32_infneg1.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f32, i32>(f32::NEG_INFINITY); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `i32`
4+
LL | float_to_int_unchecked::<f32, i32>(f32::NEG_INFINITY);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -Inf which cannot be represented in target type `i32`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_32_nan.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f32, u32>(f32::NAN); } //~ ERROR: cannot be represented in target type `u32`
9+
unsafe {
10+
float_to_int_unchecked::<f32, u32>(f32::NAN); //~ ERROR: cannot be represented in target type `u32`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_32_nan.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32`
22
--> $DIR/float_to_int_32_nan.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f32, u32>(f32::NAN); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32`
4+
LL | float_to_int_unchecked::<f32, u32>(f32::NAN);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_32_nanneg.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f32, u32>(-f32::NAN); } //~ ERROR: cannot be represented in target type `u32`
9+
unsafe {
10+
float_to_int_unchecked::<f32, u32>(-f32::NAN); //~ ERROR: cannot be represented in target type `u32`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_32_nanneg.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32`
22
--> $DIR/float_to_int_32_nanneg.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f32, u32>(-f32::NAN); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32`
4+
LL | float_to_int_unchecked::<f32, u32>(-f32::NAN);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on NaN which cannot be represented in target type `u32`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_32_neg.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f32, u32>(-1.000000001f32); } //~ ERROR: cannot be represented in target type `u32`
9+
unsafe {
10+
float_to_int_unchecked::<f32, u32>(-1.000000001f32); //~ ERROR: cannot be represented in target type `u32`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_32_neg.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -1 which cannot be represented in target type `u32`
22
--> $DIR/float_to_int_32_neg.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f32, u32>(-1.000000001f32); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -1 which cannot be represented in target type `u32`
4+
LL | float_to_int_unchecked::<f32, u32>(-1.000000001f32);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -1 which cannot be represented in target type `u32`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_32_too_big1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f32, i32>(2147483648.0f32); } //~ ERROR: cannot be represented in target type `i32`
9+
unsafe {
10+
float_to_int_unchecked::<f32, i32>(2147483648.0f32); //~ ERROR: cannot be represented in target type `i32`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_32_too_big1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 2.14748365E+9 which cannot be represented in target type `i32`
22
--> $DIR/float_to_int_32_too_big1.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f32, i32>(2147483648.0f32); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 2.14748365E+9 which cannot be represented in target type `i32`
4+
LL | float_to_int_unchecked::<f32, i32>(2147483648.0f32);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 2.14748365E+9 which cannot be represented in target type `i32`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_32_too_big2.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f32, u32>((u32::MAX-127) as f32); } //~ ERROR: cannot be represented in target type `u32`
9+
unsafe {
10+
float_to_int_unchecked::<f32, u32>((u32::MAX - 127) as f32); //~ ERROR: cannot be represented in target type `u32`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_32_too_big2.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on 4.2949673E+9 which cannot be represented in target type `u32`
22
--> $DIR/float_to_int_32_too_big2.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f32, u32>((u32::MAX-127) as f32); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 4.2949673E+9 which cannot be represented in target type `u32`
4+
LL | float_to_int_unchecked::<f32, u32>((u32::MAX - 127) as f32);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on 4.2949673E+9 which cannot be represented in target type `u32`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_32_too_small1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f32, i32>(-2147483904.0f32); } //~ ERROR: cannot be represented in target type `i32`
9+
unsafe {
10+
float_to_int_unchecked::<f32, i32>(-2147483904.0f32); //~ ERROR: cannot be represented in target type `i32`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_32_too_small1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on -2.1474839E+9 which cannot be represented in target type `i32`
22
--> $DIR/float_to_int_32_too_small1.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f32, i32>(-2147483904.0f32); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -2.1474839E+9 which cannot be represented in target type `i32`
4+
LL | float_to_int_unchecked::<f32, i32>(-2147483904.0f32);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on -2.1474839E+9 which cannot be represented in target type `i32`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/intrinsics/float_to_int_64_inf1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ extern "rust-intrinsic" {
66
}
77

88
fn main() {
9-
unsafe { float_to_int_unchecked::<f64, u128>(f64::INFINITY); } //~ ERROR: cannot be represented in target type `u128`
9+
unsafe {
10+
float_to_int_unchecked::<f64, u128>(f64::INFINITY); //~ ERROR: cannot be represented in target type `u128`
11+
}
1012
}

tests/fail/intrinsics/float_to_int_64_inf1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `u128`
22
--> $DIR/float_to_int_64_inf1.rs:LL:CC
33
|
4-
LL | unsafe { float_to_int_unchecked::<f64, u128>(f64::INFINITY); }
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `u128`
4+
LL | float_to_int_unchecked::<f64, u128>(f64::INFINITY);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `float_to_int_unchecked` intrinsic called on +Inf which cannot be represented in target type `u128`
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

0 commit comments

Comments
 (0)