Depends on size of said rock! . A year or two ago, a train derailed on the West highland line in Scotland, after hitting a boulder , dislodged, after heavy rain caused a landslide into the track. A lot smaller stuff should be knocked clear by , in the UK, a devise called a “life guard”.