Can somebody smarter than me please tell me why rustc can't infer the type of `http://div.events ` in this code? Not sure if I'm being an idiot or if I found a compiler bug (and it's almost always the former). https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=a2206278bcc36846ab8c3eac60f82ac2 …
-
Show this thread
-
Replying to @bodil
I could be wrong, but it looks like Rust's type inference affects previous statements. When a statement causes an indeterminate type to be inferred, it's only inferred from that point on. To illustrate: It works with a typed borrow above, but not below, the events assignment.
1 reply 0 retweets 0 likes -
Replying to @zootbepraised @bodil
Er, that should be "Rust's type inference *doesn't affect* previous statements"
1 reply 0 retweets 0 likes -
Replying to @zootbepraised
No, that would be the most broken type system in history. It's a bit more complicated than that. Eg. you can put the first two in a block, return `div`, and assign it to `node` _ahead_ of the block, it still fails to type `events`.
1 reply 0 retweets 0 likes -
Replying to @bodil @zootbepraised
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=5cd447be0569f03d070cacba1e15e2de … - This typechecks but not sure there's an obvious way to do it the way you wanted
1 reply 0 retweets 0 likes -
Replying to @darachennis @zootbepraised
Yeah, the div declaration can't hard code the type variable, because in my use case it's generated by a macro. See my latest addendum to the thread.
1 reply 0 retweets 1 like
I'm stuck there too - probably a bug in my understanding of unification - nice puzzle!
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.