Skip to content

Commit b8c2171

Browse files
committed
add a ui test specifically for linked issue 69232
1 parent 1479e40 commit b8c2171

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
663663
p!(print_def_path(def_id, args));
664664
} else {
665665
let sig = self.tcx().fn_sig(def_id).instantiate(self.tcx(), args);
666-
p!("{{fn item ", print_value_path(def_id, args), " :", print(sig), "}}");
666+
p!("{{fn item ", print_value_path(def_id, args), ": ", print(sig), "}}");
667667
}
668668
}
669669
ty::FnPtr(ref bare_fn) => p!(print(bare_fn)),

tests/ui/c-variadic/issue-69232.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
extern "C" {
2+
fn foo(x: usize, ...);
3+
}
4+
5+
fn test() -> u8 {
6+
127
7+
}
8+
9+
fn main() {
10+
foo(1, test);
11+
}
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
error[E0617]: can't pass `{fn item test: fn() -> u8}` to variadic function
2+
--> $DIR/issue-69232.rs:10:12
3+
|
4+
LL | foo(1, test);
5+
| ^^^^
6+
|
7+
= help: a function item is zero-sized and needs to be casted into a function pointer to be used in FFI
8+
= note: for more information on function items, visit https://doc.rust-lang.org/reference/types/function-item.html
9+
help: cast the value to `fn() -> u8`
10+
|
11+
LL | foo(1, test as fn() -> u8);
12+
| ~~~~~~~~~~~~~~~~~~
13+
help: cast the value into a function pointer
14+
|
15+
LL | foo(1, test as fn() -> u8);
16+
| ~~~~~~~~~~~~~~~~~~
17+
18+
error: aborting due to 1 previous error
19+
20+
For more information about this error, try `rustc --explain E0617`.

0 commit comments

Comments
 (0)