Correctly populate trait impl map when checking for impl overlaps

Also fix an existing compile-fail test which was intended to cover
this case.

This closes issue #17593