-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Is this difference in lifetime elision for impl Trait
arguments between async and non-async function intended?
#85417
Comments
We discussed this in our meeting today. The difference in behavior comes from this code: rust/compiler/rustc_ast_lowering/src/lib.rs Lines 1800 to 1807 in af2ed1b
While we decided that async fn probably exhibits the right behavior, it's possible this could affect other things too which could lead to bugs. Before declaring this fixed we should account for anything that might appear in arguments and be affected by this code. We also noticed that in sync code, we aren't consistent in the behavior of impl Trait and dyn Trait. For example: trait Something { type Item; }
fn foo(x: &dyn Something<Item = &u32>) { } // works fine
fn foo(x: &impl Something<Item = &u32>) { } // error We should be more consistent and document the elision rules for all these cases in the reference. Since dyn already accepts this, we decided we should go ahead and accept this for impl Trait too. |
The output of this is regressing in 1.64. 1.63:
1.64:
|
#97720 originally suggested to remove the difference between the async and regular fns. In order to avoid and insta-stable change, the choice was made to introduce the feature gate instead in #97720 (comment). Removing this feature gate is trivial: revert 5a20834. |
This compiles:
But this doesn't:
This difference strikes me as very odd. Is this intended? If so, why?
This is formulated as a question, but if I had to guess, I would classify this as oversight or bug -- that's why I created an issue instead of askig in the forum.
(originally asked here)
The text was updated successfully, but these errors were encountered: