-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
The following code fails in the playground, on the latest stable (1.32.0), latest beta (1.33.0-beta.6) and latest nightly (2019-02-07):
struct S<F: Fn() -> [u8; 1]>(F);
impl<F: Fn() -> [u8; 1]> Drop for S<F> {
fn drop(&mut self) {}
}
fn main() {}The error is the following:
error[E0367]: The requirement `<F as std::ops::FnOnce<()>>::Output == [u8; _]` is added only by the Drop impl.
--> src/main.rs:3:1
|
3 | / impl<F: Fn() -> [u8; 1]> Drop for S<F> {
4 | | fn drop(&mut self) {}
5 | | }
| |_^
|
note: The same requirement must be part of the struct/enum definition
--> src/main.rs:1:1
|
1 | struct S<F: Fn() -> [u8; 1]>(F);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The error seems to be the same regardless of rust version, and regardless of whether the function is an Fn, an FnMut, or an FnOnce (in particular, the error mentions std::ops::FnOnce<()>>::Output even when F isn't an FnOnce, if that's relevant).
The error does not occur when the return type [u8; 1] is replaced with, for example, u8 or (u8, u8), but still occurs with a more complex type still containing an array such as (u8, [u8; 1], u8);
Have a nice day.
ExpHP
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.