Implement higher-ranked trait bounds.

Enough said.

Fixes #18639.

r? @pcwalton (or someone else?)