It's been done . . . many times. Often, you get something that's a little "weird" in the final product. I put that in quotes because none of us have ever been able to put a finger on what that "weird" thing is. It's very, very subtle, though. We have wondered if it is not a little bit of souring from bacteria or wild yeast, but there is so little of it. If you keep the lid closed after mashing in, sanitation should not be a major concern (beyond this little "weird" thing).
Also, you better be brewing a beer that you want fairly low on dextrines.
ETA: The tannins that Pompeii mentioned also could be that little "weird" something. One of these days, we'll figure it out, but overnight mashes are too rare.
TL