What does it mean if your upper right rib hurts when you breathe in and lean forward?

Breathing rib pain. In the absence of trauma or injury it could mean several things such as a injured lung (spontaneous pneumothorax) or irritation of the lining of the chest (pleurisy) due to infection or inflammation, or costochondritis.