Skip to content

Commit fff2e0f

Browse files
committed
Print function pointer type for function pointer const generics
1 parent b78dbf4 commit fff2e0f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/librustc/ty/print/pretty.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,11 @@ pub trait PrettyPrinter<'tcx>:
10091009
let alloc_map = self.tcx().alloc_map.lock();
10101010
alloc_map.unwrap_fn(ptr.alloc_id)
10111011
};
1012-
p!(print_value_path(instance.def_id(), instance.substs));
1012+
self = self.typed_value(
1013+
|this| this.print_value_path(instance.def_id(), instance.substs),
1014+
|this| this.print_type(ty),
1015+
true,
1016+
)?;
10131017
}
10141018
// For function type zsts just printing the type is enough
10151019
(Scalar::Raw { size: 0, .. }, ty::FnDef(..)) => p!(print(ty)),

src/test/ui/const-generics/fn-const-param-infer.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ error[E0308]: mismatched types
1010
--> $DIR/fn-const-param-infer.rs:16:31
1111
|
1212
LL | let _: Checked<not_one> = Checked::<not_two>;
13-
| ---------------- ^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two`
13+
| ---------------- ^^^^^^^^^^^^^^^^^^ expected `{not_one as fn(usize) -> bool}`, found `{not_two as fn(usize) -> bool}`
1414
| |
1515
| expected due to this
1616
|
17-
= note: expected struct `Checked<not_one>`
18-
found struct `Checked<not_two>`
17+
= note: expected struct `Checked<{not_one as fn(usize) -> bool}>`
18+
found struct `Checked<{not_two as fn(usize) -> bool}>`
1919

2020
error[E0308]: mismatched types
2121
--> $DIR/fn-const-param-infer.rs:20:24
@@ -36,12 +36,12 @@ error[E0308]: mismatched types
3636
--> $DIR/fn-const-param-infer.rs:25:40
3737
|
3838
LL | let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
39-
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `generic::<u32>`, found `generic::<u16>`
39+
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{generic::<u32> as fn(usize) -> bool}`, found `{generic::<u16> as fn(usize) -> bool}`
4040
| |
4141
| expected due to this
4242
|
43-
= note: expected struct `Checked<generic::<u32>>`
44-
found struct `Checked<generic::<u16>>`
43+
= note: expected struct `Checked<{generic::<u32> as fn(usize) -> bool}>`
44+
found struct `Checked<{generic::<u16> as fn(usize) -> bool}>`
4545

4646
error: aborting due to 4 previous errors
4747

0 commit comments

Comments
 (0)