The diameter of the uniform spanning tree of dense graphs