-
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
remove the F-impl-trait-in-bindings code #86729
Comments
Some more explanation for future archeologists:
const FOO: impl Trait = ...; is an entirely different implementation from
But they attempted to share logic between each other and with type-alias-impl-trait and the already stable impl-trait-in-return-position. Several refactorings and bug fixes later we ended up with spaghetti code. Attempts to refactor always ended up exploding. So we removed this feature (which works very differently on let bindings than the other features), and can now do the refactoring. We expect to reintroduce the feature in some form, but caveats may apply. The underlying problem is that impl-trait-in-bindings is expected to hide the type after the binding, but not before. All other uses of
For let bindings, it is obvious for a human, but it gets weird for the compiler. Type-checking, in contrast to borrow-checking, has no real concept of the order of things. It simply builds up a graph for type inference and then kind of floods the graph with the information it has and either ends up successfully resolving everything or it gets an error. The problem is that once you know that a let binding's let x: impl Debug = 5_i32;
let y = x + 1_i32; will either compile (typeck likes this), or we have to patch typeck in weird (to me) ways in order to adhere the RFC. Now... the question is how important that feature is. If it is mostly needed for tutorials and some rare cases, we could probably get away with let x = hide!(5_i32, Debug);
let y = x + 1_i32; // ERROR which expands to let helper = || -> impl Debug { 5_i32 };
let x = helper();
let y = x + 1_i32; // ERROR which could be more manageable on the compiler implementation side. |
This code is not implemented in the correct way, and it is common source of ICEs and other problems. We should remove this logic for now and simply report errors when
impl Trait
is used in let position.The text was updated successfully, but these errors were encountered: