Yeah, that exact scenario has happened to me twice. I like to glance at the rearview if I'm the last car in line to avoid some drunk ramming me, and it definitely saved my life once.
Once I just saw someone coming in a little too hot and was able to pull forward a bit to make room as they were standing on the brakes. Not a big deal.
The lifesaving situation was different though, I was the only car in the right lane and one of those massive F250 trucks was barreling up behind me, not appearing to slow down at all. I was kind of boxed in because the cross street had heavy, fast traffic, and I couldn't pull forward or to the left since there was another car stopped next to me there. So I just quickly scanned the sidewalk to my right to make sure there were no pedestrians, and hopped up the curb to drive on the sidewalk/grass. I wasn't sure if this would work in my tiny car with small wheels, but I figured it would be better than dying.
Worked great. The truck blew through the light and T-boned a Tesla. The guy had 37 empty Coors Light cans scattered around the floor of his truck.
Have any of the self driving car companies even gotten started on the "when should I drive on the sidewalk" subroutine? No, of course not, they are still mired in the bad, early days of the tech where they can't deal with a missing double yellow. It's laughable, the engineers can do much better instead of just repeatedly lowering the bar.