Issue 12681 - Rewrite rule prevents unique detection

https://issues.dlang.org/show_bug.cgi?id=12681

Move the rewriting to glue-layer.