Improve use of ErrorGuaranteed and code cleanup Part of #103874
For more information about how rustc works, see the rustc dev guide.