-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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
#![feature(conservative_impl_trait)]
fn main() {
let mut x = &mut 1i32;
let closure = return_closure(x);
closure();
}
fn return_closure(x: &mut i32) -> impl Fn() {
move || println!("{}", x)
}
this gives the error message
error[E0564]: only named lifetimes are allowed in `impl Trait`, but `` was found in the type `[closure@<anon>:11:5: 11:30 x:&mut i32]`
--> <anon>:10:35
|
10 | fn return_closure(x: &mut i32) -> impl Fn() {
| ^^^^^^^^^
but that's wrong, if we amend the code to
#![feature(conservative_impl_trait)]
fn main() {
let mut x = &mut 1i32;
let closure = return_closure(x);
closure();
}
fn return_closure<'a>(x: &'a mut i32) -> impl Fn() {
move || println!("{}", x)
}
it compiles and runs just fine, so the previous error message is incorrect
kennytm and robey
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.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.