Limit recursion depth for macro expansions, closes #17628
auto merge of #17678 : fhahn/rust/issue-17628-infinite-recursion, r=alexcrichton

This is a patch for #17628, thanks to @kmcallister for your helpful hints!
Add tests for a few resolved issues