Auto merge of #108080 - oli-obk:FnPtr-trait, r=lcnr
Add a builtin `FnPtr` trait that is implemented for all function pointers r? `@ghost` Rebased version of https://github.com/rust-lang/rust/pull/99531 (plus adjustments mentioned in the PR). If perf is happy with this version, I would like to land it, even if the diagnostics fix in 9df8e1befb5031a5bf9d8dfe25170620642d3c59 only works for `FnPtr` specifically, and does not generally improve blanket impls.
This commit is contained in:
commit
bf57e8ada6
23 changed files with 476 additions and 180 deletions
9
tests/ui/fn/fn-ptr-trait.rs
Normal file
9
tests/ui/fn/fn-ptr-trait.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#![feature(fn_ptr_trait)]
|
||||
// check-pass
|
||||
|
||||
use std::marker::FnPtr;
|
||||
|
||||
trait Foo {}
|
||||
impl<T> Foo for Vec<T> where T: FnPtr {}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -90,16 +90,6 @@ LL | assert_eq!(Foo::Bar, i);
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
||||
|
|
||||
= help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}`
|
||||
= help: the following other types implement trait `Debug`:
|
||||
extern "C" fn() -> Ret
|
||||
extern "C" fn(A, B) -> Ret
|
||||
extern "C" fn(A, B, ...) -> Ret
|
||||
extern "C" fn(A, B, C) -> Ret
|
||||
extern "C" fn(A, B, C, ...) -> Ret
|
||||
extern "C" fn(A, B, C, D) -> Ret
|
||||
extern "C" fn(A, B, C, D, ...) -> Ret
|
||||
extern "C" fn(A, B, C, D, E) -> Ret
|
||||
and 118 others
|
||||
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug`
|
||||
|
|
@ -109,16 +99,6 @@ LL | assert_eq!(Foo::Bar, i);
|
|||
| ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
||||
|
|
||||
= help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}`
|
||||
= help: the following other types implement trait `Debug`:
|
||||
extern "C" fn() -> Ret
|
||||
extern "C" fn(A, B) -> Ret
|
||||
extern "C" fn(A, B, ...) -> Ret
|
||||
extern "C" fn(A, B, C) -> Ret
|
||||
extern "C" fn(A, B, C, ...) -> Ret
|
||||
extern "C" fn(A, B, C, D) -> Ret
|
||||
extern "C" fn(A, B, C, D, ...) -> Ret
|
||||
extern "C" fn(A, B, C, D, E) -> Ret
|
||||
and 118 others
|
||||
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 10 previous errors
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue