reference icon indicating copy to clipboard operation
reference copied to clipboard

is a scrutinee always a place expression?

Open steveklabnik opened this issue 3 years ago • 2 comments

https://doc.rust-lang.org/stable/reference/expressions/match-expr.html says:

A match behaves differently depending on whether or not the scrutinee expression is a place expression or value expression.

And a little lower,

When the scrutinee expression is a place expression,

Let's click that link. It says:

The following contexts are place expression contexts:

...

The former implies it can be either, the latter implies it is always a place expression. I suspect that the wording of the latter is the one that's wrong.

steveklabnik avatar Feb 10 '22 16:02 steveklabnik

IIRC, the distinction here is that the scrutinee is a place expression context. A place context can receive either a place or value expression. Being a place expression context doesn't mean it can only take a place expression.

ehuss avatar Feb 10 '22 22:02 ehuss

Ahhhh. That would make sense. I'm not sure if that means "close this bug, steve is just wrong" or if there's a way to make this distinction more obvious.

Regardless, thank you 👍

steveklabnik avatar Feb 11 '22 23:02 steveklabnik