How it works: The carrot rust fly finds its host by the smell of carrot foliage. Onion and other allium volatiles growing among the carrots mask that scent, so fewer flies locate the row to lay eggs. Because the protection is the smell, it lasts only while the alliums are in the ground. Once they are pulled, the masking goes with them.
Evidence: checked against 1 source in the research-based literature.
The source
Intercropping with onion has been shown to reduce damage by carrot rust flies.