Make the diagnostic for static variables in patterns better

Fixes #17933.
auto merge of #17948 : jakub-/rust/issue-17933, r=alexcrichton

Fixes #17933.