4 ms·
Do you still find that holds for somewhat ideomatic rust? I have made the same experience running tutorials and simple example code, but as soon as I took on a
by ThePadawan 5y ago
Do you still find that holds for somewhat ideomatic rust?
I have made the same experience running tutorials and simple example code, but as soon as I took on anything more intricate, I got thrown right back into "GCC compiling a C++ template" territory.
Basically, the compiler told me "constraint Foo<<<<trait::?>'<mut&>><other> does not meet bounds Bar<trait::dist>?<other>" and that was it.
- estebank 5y agoErrors involving multiple levels of trait bounds haven't historically been great, but we've made strides on them and there's still some ongoing work to make them better. Feel free to file a ticket next time you come across a case like these! For complex or uncommon cases we rely on people's reports to handle them better.
- ThePadawan 5y agoThanks for the info! I have to admit I was pretty discouraged and rage-deleted the code that made me give up, so I don't have it at hand any more. I also am really early in the process in learning about Rust, and dove in very deep by trying to use warp to write a web application. I'm usually the type to dive in by copy-pasting examples and modifying them to my needs, and I just hit a brick wall of compile errors here that discouraged me from continuing. When I gather the patience to continue, I will keep in mind what you said.
- Arnavion 5y agoThe compiler also loves to tell you that your borrows aren't long-lived enough and you need to make them `'static`, when making them `'static` is almost always the opposite of what you actually do to resolve the problem - change the borrow to be a move of the original value or a move of an Rc/Arc of the original value. I've seen multiple colleagues new to Rust ask me for help with their code that has `&'static mut`, and when I tell them that's never going to work and ask them how they got there, it's always because the compiler told them to do it. Like [1] says, you eventually get the experience to ignore the compiler error message (or at least the "suggestions"), and instead understand the real problem and apply the real fix yourself. Similarly, when you have a case of value of type A being assigned to a binding of type B, there's a 50% chance that the compiler gets the "expected type" and "actual type" the other way around from what you want. This isn't really a fixable problem, because only you the human know which one you expected and which one you didn't. But it's yet another case where you eventually gain the experience of ignoring the "expected type" "actual type" parts of the compiler error because they don't matter, and just looking at the types. [1]: https://news.ycombinator.com/item?id=28014288 https://news.ycombinator.com/item?id=28014288
- estebank 5y ago> The compiler also loves to tell you that your borrows aren't long-lived enough and you need to make them `'static`, when making them `'static` is almost always the opposite of what you actually do to resolve the problem Most of the time the compiler complains about an unmet 'static lifetime, what it's actually talking about is about wanting an owned type. Sadly, I haven't gotten around to making those diagnostics more accurate (from the user's points of view). > I've seen multiple colleagues new to Rust ask me for help with their code that has `&'static mut`, and when I tell them that's never going to work and ask them how they got there, it's always because the compiler told them to do it. > Like [1] says, you eventually get the experience to ignore the compiler error message (or at least the "suggestions"), and instead understand the real problem and apply the real fix yourself. I would appreciate bug reports at https://github.com/rust-lang/rust/issues/ https://github.com/rust-lang/rust/issues/ when encountering these kind of situations. If there's something worse than missing suggestions is inaccurate or misleading suggestions.