-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Zero member tuple struct should warn on incorrect construction #87181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We should suggest writing You'll want to look at this file rust/compiler/rustc_typeck/src/astconv/mod.rs Lines 1714 to 1751 in 2119976
and a check to see if |
@rustbot claim |
@rustbot claim |
Error: Parsing assign command in comment failed: ...'tbot claim' | error: expected end of command at >| ' Happy to '... Please let |
Happy to try give this a go as my first contribution. I have a few questions, can I message you on zulip @estebank? |
@JaydenElliott Yes! Feel free to ping me on zulip. |
Hi @JaydenElliott ! |
Hi @inashivb, I think this one was a bit too difficult for me, so feel free to take it off of me! |
Thank you very much, @JaydenElliott ! I'm not sure if I'll be able to do it either but I'd like to give it a try. I hope you find a new issue to work on soon. :) |
@rustbot claim |
Hello everyone, this issue seems to have stalled, so I think I'll take a crack at it myself if that's okay |
@rustbot claim |
It took me a lot of digging, but I've landed in |
I've found a related issue for field access. It can be seen here: struct Bar<T>(T);
struct Inner(u8);
fn main() {
let thing = Bar(Inner);
thing.0.0();
} Which yields: We could probably do something similar to what we're doing here, and tell them to construct the struct/enum variant? Does anyone know if there's an issue for this, and can I fix it here? Edit: Thinking about this a little bit more, it appears that this shows up in a few cases, like where the member of |
Hey folks, this just bit me so and took a bit to figure out, so I'd thought I'd file an issue for this admittedly niche issue.
Given the following code: playground
The current output is:
Ideally the output should look like:
This was an extremely confusing error message for me, as I suddenly had a
fn() -> Inner
type out of no where in my code! Of course, this was a simplified issue, but it's not immediately obvious that 1. a unit struct is actually a function returning its own type, and 2. the problem was due to the fact that a unit struct is not the same as a zero-member tuple struct.This was extracted out of a much more complex error message, where the only hint to the actual problem was that the unit struct "constructor" didn't satisfy the trait bound, which pointed to a construction issue.
Not quite sure whether or not it's possible to actually implement a suggestion as written, but perhaps even a check between
Inner
vsInner()
might be a good note to have?The text was updated successfully, but these errors were encountered: