Eliminate uses of rewrite from datatypes theory (#7354)