All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
If the case is as you mentioned in the question, that you entered the toilet with the Quran forgetfully, then there is no sin on you.
This is because a person is not held accountable if he does something by forgetfulness.
The Prophet said: “Allah has forgiven my nation for things they forget, or do by mistake, or which they are forced to do.” [Ibn Maajah and Al-Albaani]
For more benefit on the prohibition of entering the toilet with the Mushaf except for a necessity, please refer to Fatwa 91385.
Allah knows best.