Skip to content

Commit ffb827a

Browse files
committed
Fix test redux
1 parent 864f6d1 commit ffb827a

File tree

5 files changed

+34
-27
lines changed

5 files changed

+34
-27
lines changed

src/librustc_typeck/check/cast.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -293,21 +293,21 @@ impl<'a, 'gcx, 'tcx> CastCheck<'tcx> {
293293
if fcx.tcx.sess.opts.debugging_opts.explain
294294
&& !fcx.tcx.sess.parse_sess.span_diagnostic
295295
.code_emitted(&err.get_code().unwrap()) {
296-
err.note(
296+
err.help(
297297
"Thin pointers are \"simple\" pointers: they are purely a reference to a
298298
memory address.
299299
300300
Fat pointers are pointers referencing \"Dynamically Sized Types\" (also
301301
called DST). DST don't have a statically known size, therefore they can
302302
only exist behind some kind of pointers that contain additional
303303
information. Slices and trait objects are DSTs. In the case of slices,
304-
the additional information the fat pointer holds is their size.");
305-
err.note("to fix this error, don't try to cast directly between thin and fat \
306-
pointers");
307-
err.help("for more information about casts, take a look at
308-
[The Book]\
309-
(https://doc.rust-lang.org/book/first-edition/\
310-
casting-between-types.html)");
304+
the additional information the fat pointer holds is their size.
305+
306+
To fix this error, don't try to cast directly between thin and fat
307+
pointers.
308+
309+
For more information about casts, take a look at The Book:
310+
https://doc.rust-lang.org/book/first-edition/casting-between-types.html");
311311
}
312312
err.emit();
313313
}

src/test/compile-fail/E0617.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ extern {
1717
fn main() {
1818
unsafe {
1919
printf(::std::ptr::null(), 0f32);
20-
//~^ ERROR can't pass `f32` to variadic function, cast to `c_double` [E0617]
20+
//~^ ERROR can't pass `f32` to variadic function
21+
//~| HELP cast the value to `c_double`
2122
printf(::std::ptr::null(), 0i8);
22-
//~^ ERROR can't pass `i8` to variadic function, cast to `c_int` [E0617]
23+
//~^ ERROR can't pass `i8` to variadic function
24+
//~| HELP cast the value to `c_int`
2325
printf(::std::ptr::null(), 0i16);
24-
//~^ ERROR can't pass `i16` to variadic function, cast to `c_int` [E0617]
26+
//~^ ERROR can't pass `i16` to variadic function
27+
//~| HELP cast the value to `c_int`
2528
printf(::std::ptr::null(), 0u8);
26-
//~^ ERROR can't pass `u8` to variadic function, cast to `c_uint` [E0617]
29+
//~^ ERROR can't pass `u8` to variadic function
30+
//~| HELP cast the value to `c_uint`
2731
printf(::std::ptr::null(), 0u16);
28-
//~^ ERROR can't pass `u16` to variadic function, cast to `c_uint` [E0617]
32+
//~^ ERROR can't pass `u16` to variadic function
33+
//~| HELP cast the value to `c_uint`
2934
printf(::std::ptr::null(), printf);
30-
//~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function, cast to `unsafe extern "C" fn(*const i8, ...)` [E0617]
35+
//~^ ERROR can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function
36+
//~| HELP cast the value to `unsafe extern "C" fn(*const i8, ...)`
3137
}
3238
}

src/test/compile-fail/issue-32201.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ fn bar(_: *const u8) {}
1717
fn main() {
1818
unsafe {
1919
foo(0, bar);
20-
//~^ ERROR can't pass `fn(*const u8) {bar}` to variadic function, cast to `fn(*const u8)`
20+
//~^ ERROR can't pass `fn(*const u8) {bar}` to variadic function
21+
//~| HELP cast the value to `fn(*const u8)`
2122
}
2223
}

src/test/ui/variadic-ffi-3.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ fn main() {
3131
//~| expected type `extern "C" fn(isize, u8, ...)`
3232
//~| found type `extern "C" fn(isize, u8) {bar}`
3333

34-
foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function, cast to `c_double`
35-
foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function, cast to `c_int`
36-
foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function, cast to `c_int`
37-
foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function, cast to `c_uint`
38-
foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function, cast to `c_int`
39-
foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function, cast to `c_uint`
34+
foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
35+
foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
36+
foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
37+
foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
38+
foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
39+
foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
4040
}
4141
}

src/test/ui/variadic-ffi-3.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,37 @@ error[E0308]: mismatched types
3737
error[E0617]: can't pass `f32` to variadic function
3838
--> $DIR/variadic-ffi-3.rs:34:19
3939
|
40-
34 | foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function, cast to `c_double`
40+
34 | foo(1, 2, 3f32); //~ ERROR can't pass `f32` to variadic function
4141
| ^^^^ help: cast the value to `c_double`: `3f32 as c_double`
4242

4343
error[E0617]: can't pass `bool` to variadic function
4444
--> $DIR/variadic-ffi-3.rs:35:19
4545
|
46-
35 | foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function, cast to `c_int`
46+
35 | foo(1, 2, true); //~ ERROR can't pass `bool` to variadic function
4747
| ^^^^ help: cast the value to `c_int`: `true as c_int`
4848

4949
error[E0617]: can't pass `i8` to variadic function
5050
--> $DIR/variadic-ffi-3.rs:36:19
5151
|
52-
36 | foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function, cast to `c_int`
52+
36 | foo(1, 2, 1i8); //~ ERROR can't pass `i8` to variadic function
5353
| ^^^ help: cast the value to `c_int`: `1i8 as c_int`
5454

5555
error[E0617]: can't pass `u8` to variadic function
5656
--> $DIR/variadic-ffi-3.rs:37:19
5757
|
58-
37 | foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function, cast to `c_uint`
58+
37 | foo(1, 2, 1u8); //~ ERROR can't pass `u8` to variadic function
5959
| ^^^ help: cast the value to `c_uint`: `1u8 as c_uint`
6060

6161
error[E0617]: can't pass `i16` to variadic function
6262
--> $DIR/variadic-ffi-3.rs:38:19
6363
|
64-
38 | foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function, cast to `c_int`
64+
38 | foo(1, 2, 1i16); //~ ERROR can't pass `i16` to variadic function
6565
| ^^^^ help: cast the value to `c_int`: `1i16 as c_int`
6666

6767
error[E0617]: can't pass `u16` to variadic function
6868
--> $DIR/variadic-ffi-3.rs:39:19
6969
|
70-
39 | foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function, cast to `c_uint`
70+
39 | foo(1, 2, 1u16); //~ ERROR can't pass `u16` to variadic function
7171
| ^^^^ help: cast the value to `c_uint`: `1u16 as c_uint`
7272

7373
error: aborting due to 10 previous errors

0 commit comments

Comments
 (0)