其实总结起来就是前有do后没to.
一.当主句前面存在do 动词的任何形式(did. does. will do. have done, had done.), 介词but 后就省去to
例如:I can't do anything but sleep
I did nothing but wait
He had nothing to do but cry.
二.而前面是其他动词的,没有do 动词的任何形式,就要加to了.
例如:I had no choice but +to sleep
也就是加to do