I assume that you're trying to upload the code with the Rx and Tx pins connected..
Try removing the Rx and Tx and then click the upload button in the IDE..
This
This happens because your computer communicates with the Arduino via Serial communication. The Rx and Tx pins also do communicate via Serial communication. An Arduino does not have the capability to handle two such communications simultaneously. So, it goes out of sync.. And that's how you get this error...