Refactor writeback code. cc #5527
Remove error message that refactor suppresses
auto merge of #13990 : nikomatsakis/rust/issue-5527-cleanup-writeback, r=pcwalton

As part of #5527 I had to make some changes here and I just couldn't take it anymore. Refactor the writeback code. Should be functionally equivalent to the old stuff.

r? @pcwalton