Add test for #11881

Closes #11881.

This code has been copied from the original issue and updated for
modern Rust APIs.
auto merge of #13276 : JustAPerson/rust/master, r=huonw

This code has been copied from the original issue and updated for modern Rust APIs.