Structural and mechanical stability of rare-earth diborides