The bug
When you ride a pig and right-click with a carrot on a stick, your pig will be fed and will walk faster. Also the durability of the carrot on a stick is decreased by 7 units.
What I expected to happen was:
When the carrot on a stick is nearly broken and I sit on a non-boosted pig and right-click with that carrot on a stick, it should break or become a fishing rod.
What actually happened was:
The carrot on a stick was not broken and the pig did not walk faster than before. Because of this, carrots on sticks cannot be used more often than thrice and are not able to break.
To reproduce
Give yourself an unenchanted
minecraft:carrot_on_a_stick
with a damage value of19
/give @s minecraft:carrot_on_a_stick{Damage:19}
Spawn a pig and equip it with a saddle
Switch into survival mode and ride on that pig
Right-click with the carrot on a stick while riding the pig
Notice that the pig does not get boosted and the carrot on a stick stays the same
Code analysis
From MCP 9.35 for Minecraft 1.11:
ItemCarrotOnAStick.java
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
ItemStack itemstack = worldIn.getHeldItem(playerIn);
if (worldIn.isRiding() && worldIn.getRidingEntity() instanceof EntityPig)
{
EntityPig entitypig = (EntityPig)worldIn.getRidingEntity();
// This line causes to check whether the remaining durability is more than seven. If it is not, the item cannot be used.
if (itemstack.getMaxDamage() - itemstack.getMetadata() >= 7 && entitypig.boost())
{
// Because of this line, the carrot on a stick gets damaged by seven durability points. This function also causes the carrot on a stick to break if necessary.
itemstack.damageItem(7, worldIn);
// This replaces the carrot on a stick by a fishing rod if it was broken.
if (itemstack.func_190926_b())
{
ItemStack itemstack1 = new ItemStack(Items.FISHING_ROD);
itemstack1.setTagCompound(itemstack.getTagCompound());
return new ActionResult(EnumActionResult.SUCCESS, itemstack1);
}
return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
}
worldIn.addStat(StatList.getObjectUseStats(this));
return new ActionResult(EnumActionResult.PASS, itemstack);
}
Possible solutions
The maximum durability of carrots on sticks could be restricted to three or four and when feeding a pig, the durability decreases by one only.
The maximum durability of carrots on sticks could be changed to 21 or 28 and when feeding a pig, the durability decreases by seven still.
The check whether the carrot on a stick has enough damage is removed and you can still use a carrot on a stick if it has less than six durability points remaining.
Comments 7
Affects 17w14a & 17w15a

Confirmed for 1.12-pre 7.
Confirmed for 18w31a
Confirmed for 18w32a
Confirmed for 18w33a
Confirmed for 1.13.1-pre1
I manually tested if the carrot on a stick could be broken with unbreaking enchantments.
Conclusion: Carrot on a stick can't break with unbreaking level 1, 2 or 3.