-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Closure inference fails to infer that move
is required when pattern matching
#30046
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
A-type-system
Area: Type system
C-bug
Category: This is a bug.
E-hard
Call for participation: Hard difficulty. Experience needed to fix: A lot.
P-medium
Medium priority
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
triage: P-medium |
A-const-fn? |
Do you just mean the help message is wrong, or it should have automatically created a move closure? |
@durka neither. Normally, even for non-move closures, we infer when particular variables are used in the body and we move just those variables. For some reason, that is not triggering in this particular case. |
Might be duplicate of #26139? |
Related example from #26139: struct Name(String);
fn apply<F>(f: F) where
F: FnOnce() {
f()
}
fn main() {
let n = Name(String::new());
let consume = || {
let Name(i) = n;
};
apply(consume);
} |
nivkner
added a commit
to nivkner/rust
that referenced
this issue
Mar 17, 2018
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
A-const-eval
Area: Constant evaluation, covers all const contexts (static, const fn, ...)
A-type-system
Area: Type system
C-bug
Category: This is a bug.
E-hard
Call for participation: Hard difficulty. Experience needed to fix: A lot.
P-medium
Medium priority
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
See this example, which fails to compile:
Error:
The text was updated successfully, but these errors were encountered: