Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upMatching on a place in borrowed context should no longer suggest `ref` #52423
Comments
oli-obk
added
A-diagnostics
A-borrow-checker
labels
Jul 16, 2018
This comment has been minimized.
This comment has been minimized.
|
cc @ashtneoi |
This comment has been minimized.
This comment has been minimized.
|
Yeah, I can probably tackle this. |
This comment has been minimized.
This comment has been minimized.
|
For something like this...
...should it suggest changing the type, the pattern (which might be tricky, idk), or neither? |
This comment has been minimized.
This comment has been minimized.
|
@ashtneoi My personal goal is to have the compiler never mention fn bar<T>(MyStruct { x: _a }: &MyStruct<T>)...but I have no idea how hard that might be. |
This comment has been minimized.
This comment has been minimized.
|
...Can we lint against top-level type declarations like that? It's really confusing trying to figure out the type of |
This comment has been minimized.
This comment has been minimized.
|
Oh, one more question (sorry): In a lot of cases, NLL already has better suggestions. Should I bother fixing the non-NLL suggestions or just focus on NLL assuming it'll land sometime soon? |
This comment has been minimized.
This comment has been minimized.
|
Oh, good point; I didn't try NLL. Only fixing the NLL ones sounds like a smart plan. |
This comment has been minimized.
This comment has been minimized.
|
It took a ton of reading (which is why I'm only now figuring it out), but I managed to put each binding's top-level pattern span into the |
scottmcm commentedJul 16, 2018
https://play.rust-lang.org/?gist=a88b996b2d1c86d1f6d32eee66c70cd4&version=stable&mode=debug&edition=2015
This suggests using
ref:With match ergonomics now stable, it would be better to instead suggest borrowing the field:
To help people move away from needing to know that
refexists.(Context that lead me to open this: https://discordapp.com/channels/273534239310479360/274215136414400513/468303728986816512)