Improve trimming of auto-rules
I hadn't got the new function trimAutoRules quite right, so we had a left-over rule which mentioned a local variable whose binding had been discarded. (Result: crash when compiling Haddock.) This patch merges trimAutoRules into an expanded version of findExternalRules, gets it right, and adds lots of comments. See Note [Finding external rules]. And indeed in one regression test we get to trim off more rules (and hence code) than before.