-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.F-unboxed_closures`#![feature(unboxed_closures)]``#![feature(unboxed_closures)]`P-mediumMedium priorityMedium priorityT-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.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.
Description
Attempting to implement FnOnce
for a reference to a struct or a trait object:
#![feature(fn_traits)]
#![feature(unboxed_closures)]
struct S;
fn repro_ref(thing: &S) {
thing();
}
impl<'a> FnOnce<()> for &'a S {
type Output = ();
extern "rust-call" fn call_once(self, _arg: ()) -> () {}
}
fn main() {}
Produces the error:
error[E0618]: expected function, found `&S`
--> src/main.rs:7:5
|
7 | thing();
| ^^^^^^^
|
note: defined here
--> src/main.rs:6:14
|
6 | fn repro_ref(thing: &S) {
| ^^^^^
Interestingly, both of these alternatives work:
fn ok_ref_ref_arg(thing: &&S) {
thing();
}
fn ok_ref_ref(thing: &S) {
(&thing)();
}
cc #29625.
Originally from this Stack Overflow question.
GuillerLT and schneiderfelipe
Metadata
Metadata
Assignees
Labels
A-type-systemArea: Type systemArea: Type systemC-bugCategory: This is a bug.Category: This is a bug.F-unboxed_closures`#![feature(unboxed_closures)]``#![feature(unboxed_closures)]`P-mediumMedium priorityMedium priorityT-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.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.