It also leads to spectacularly dumb results some times, like this case that had to be overturned by the Supreme Court.
Hope v. Pelzer, 536 U.S. 370 (2002). Prison guards repeatedly handcuffed a dude in a stress position and left him out in the sun all day without bathroom breaks for punishment. The district court found that qualified immunity applied. The circuit court found that his rights had been violated but it wasn't "clearly established law" that you can't just torture prisoners for shits and giggles since there wasn't a case specifically involving this form of torture. SCOTUS had to say wtf you dumbasses and send it back.