Rollup merge of #71311 - estebank:fn-type-param, r=varkor
On `FnDef` type annotation suggestion, use fn-pointer output Address the last point in #71209.
This commit is contained in:
commit
d9c1f5cf4f
3 changed files with 23 additions and 1 deletions
|
@ -257,7 +257,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
printer.name_resolver = Some(Box::new(&getter));
|
printer.name_resolver = Some(Box::new(&getter));
|
||||||
let _ = ty.print(printer);
|
let _ = if let ty::FnDef(..) = ty.kind {
|
||||||
|
// We don't want the regular output for `fn`s because it includes its path in
|
||||||
|
// invalid pseduo-syntax, we want the `fn`-pointer output instead.
|
||||||
|
ty.fn_sig(self.tcx).print(printer)
|
||||||
|
} else {
|
||||||
|
ty.print(printer)
|
||||||
|
};
|
||||||
s
|
s
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
fn f<A>() -> A { unimplemented!() }
|
||||||
|
fn foo() {
|
||||||
|
let _ = f; //~ ERROR type annotations needed for `fn() -> A`
|
||||||
|
}
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,11 @@
|
||||||
|
error[E0282]: type annotations needed for `fn() -> A`
|
||||||
|
--> $DIR/fn-needing-specified-return-type-param.rs:3:13
|
||||||
|
|
|
||||||
|
LL | let _ = f;
|
||||||
|
| - ^ cannot infer type for type parameter `A` declared on the function `f`
|
||||||
|
| |
|
||||||
|
| consider giving this pattern the explicit type `fn() -> A`, where the type parameter `A` is specified
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0282`.
|
Loading…
Add table
Add a link
Reference in a new issue