If it is "sufficiently obvious" that a law is unconstitutional, evidence obtained relying on that law can probably be suppressed.
Two important principles help discern the answer to this question:
- The Constitution prohibits searches that are "unreasonable." The existence of a warrant authorizing a search is strong evidence that a search is reasonable, but the warrant is neither necessary nor sufficient to make a search reasonable.
- The Exclusionary Rule is designed to do one and only one thing: discourage law enforcement misconduct. Therefore, evidence obtained in reliance on a defective warrant will only be suppressed if it was "objectively unreasonable" for the officer to rely on that warrant.
Courts typically find reliance on a warrant to be objectively unreasonable when the warrant was obtained through deception, when it authorizes a search of a person or place with no connection to a crime, or when it fails reasonably describe the person or place to be searched.
It is likely also possible to have evidence suppressed because the warrant authorized a search for evidence of the violation of a plainly unconstitutional law. That was the question in Illinois v. Krull, 480 U.S. 340, (1987), where a defendant was prosecuted based on evidence obtained in reliance on a law that was later ruled unconsitutional. The Illinois Supreme Court held that because the law was unconstitutional, the search relying on it was also unconstitutional, and the evidence obtained thereby must be suppressed. But the Supreme Court reversed, holding that the evidence need not be suppressed because "this defect in the statute was not sufficiently obvious so as to render a police officer's reliance upon the statute objectively unreasonable."
This suggests that if a statute's unconstitutionality is sufficiently obvious, that an officer seeking evidence in reliance on it would be objectively unreasonable, and that that evidence would therefore be subject to suppression. I don't know of it ever happening, but it's easy enough to make up ridiculous laws that might satisfy this standard. For instance, if Congress passed a law permitting police to write their own warrants to search any mosque at any time, evidence from that search would likely be suppressed. Or if Congress passed a law prohibiting all black women from criticizing the president, evidence that a defendant had violated that law would likely also be suppressed, even if it had been obtained with an otherwise validly issued warrant.
Of course, most laws are not as obviously unconstitutional as those, so a challenge on these grounds will likely revolve around what exactly should have alerted a reasonable officer to the statute's consitutional infirmities.
Likewise, an officer executing such a search is exposed to Section 1983 liability for an unreasonable search or seizure if his reliance on the warrant is not objectively reasonable. As always, there will be a question of whether the officer is entitled to qualified immunity, but that question will turn as always on whether his violation of the law was clearly established. If he is searching for evidence of black people voting, qualified immunity is going to be a hard sell. If he's searching for evidence that a defendant violated a law in a gray area, qualified immunity may save him.