-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
impl trait error message around 'static
is probably confusing
#48467
Comments
I've seen other cases of this too, it'd be great to improve it.
|
Suggesting both might be good. However, this label is inaccurate:
That trait bound forbids us from capturing the anonymous lifetime, because it is not mentioned anywhere, but it does not imply |
Your suggested text seems great to me for the label, while this is one of the error messages that would benefit greatly from |
This comes up in My suggestion is: No matter what, don't say Users don't write When Rust points to a "Temporary references are not allowed here" may be guiding them towards better solutions. |
Another case from user forum: type EvalFn = Fn() -> (u8);
fn take_callback(f: &EvalFn) -> u8 {
1
}
fn test(arg: Option<&u8>) -> (u8) {
let closure = || arg.cloned().unwrap();
take_callback(&closure)
} The error points that the argument should be |
I hit this when implementing In my case I can't seem to find a way to tell |
A separate situation that would need to be handled is the following:
where the suggestion would need to be to add
|
…, r=pnkfelix Suggest using anonymous lifetime in `impl Trait` return Fix rust-lang#48467. r? @nikomatsakis
…, r=pnkfelix Suggest using anonymous lifetime in `impl Trait` return Fix rust-lang#48467. r? @nikomatsakis
The error message for this example seems potentially confusing:
I get:
What's going wrong here is that
impl Iterator
can only capture lifetimes that it names, and this one doesn't name any lifetimes. It can be fixed by changing toimpl Iterator + '_
-- this is probably what we want to suggest? I'm not sure how best to phrase this, suggestions welcome.cc @cramertj @estebank
The text was updated successfully, but these errors were encountered: