Fix handling of struct variants in a couple of places

Fixes #17405.
Fixes #17518.
Fixes #17800.
auto merge of #17414 : jakub-/rust/issue-17405, r=alexcrichton

Fixes #17405.
Fixes #17518.
Fixes #17800.