Type 2 diabetes linked with cognitive impairments, study shows