incorrect type is inferred for a local variable holding a closure #92282
Labels
A-closures
Area: Closures (`|…| { … }`)
A-lifetimes
Area: Lifetimes / regions
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
(https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=f40ec4a2d13b41aa91d6a48ee04214bf)
I expected to see this happen: this should compile, because this equivalent(?) code compiles:
(https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=2809e18e87c789f7591fe7ed57d13ba1)
the only difference here is the intermediate variable
rule
, which appears to be inferring an incorrect type for some reason. the code also compiles successfully ifrule
is given an explicit type annotation with the same type as defined in the struct.Instead, this happened:
this seems maybe related to #87079 or #70263 but i can't tell if it's actually the same problem or not (this one isn't a problem with function arguments).
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: