Show the name of the trait in the error message

Fix #5925.