It can depend on the rules and regulations of your local public swimming pool.
But most public pools have a rule in place where your child if they're 3 or under they must wear a swim diaper whether they're potty trained or not.
The swim diaper is to prevent any poop from getting into the pool should your child have an accident.