Check type when struct is matched against enum-like pattern

Previously check always succeeded because struct type was derived from
the matched expression, not the matched pattern.
auto merge of #5046 : sanxiyn/rust/struct-match, r=catamorphism

Previously check always succeeded because struct type was derived from the matched expression, not the matched pattern.

Fix #4849.