Being locked up may not be a “punishment” (har har) but it may still be punishing.
There was a case that made it to the Supreme Court a while back (mid 1980’s or so) in which a person who wasn’t thus being punished complained of cruel and unusual treatment. The Supremes, in their infinite wisdom which transcends the ken of mortal men, determined that inasmuch as pre-trial confinement in not punishment, it cannot be cruel and/or unusual punishment.
Hence, even the worst abuse that any Joe Arpaio or Joe Arpaio wannabee can throw at his non-punishees is permissible, as long as, you know, they aren’t being punished.
Now, to be sure, IIRC, the case was profoundly stupid from the get-go. The guy’s complaint was that he wasn’t allowed to watch TV while he languished in pre-trial non-punishment. I don’t recall how the chain of decisions went as it made its way up the courts, but finally the Supreme Court chose to take this silly case. Why in the world would they have done that anyway? My take was, the prevailing sentiment on the court (this was in the Rehnquist days) was like, here is a perfect case for us to further trash prisoners’ rights. So as frivolous as the case was, they took it just to have the opportunity to make the decision that they did.