It's not though. It would be illegal for me to say that "your resume says you're catholic, so I'm going to throw it out."
But saying "As a firm, we do not accept resumes that self-identify race, religion, sex, sexual orientation, gender identity, national origin, or age" is not illegal.
Ever wonder why the disability, demographics, citizenship/visa, and veteran status sections of online applications are at the end and separate? It's because HR keeps tabs on those for a variety of reasons (including to make sure you're hiring and retaining a diverse talent pool) but it's never forwarded to a hiring manager.
I can infer your gender from your name, and your citizenship status if you have a clearance. But as a hiring manager, I am not privy to ANY of that information that the application portal asked from you when I'm handed a stack of resumes to review.