Using random numbers from Google for a Tesla 3 for an example, it has a 50kWh battery and 305 miles of range. That's 164Wh per mile. 40 miles would require 6,560Wh.
Assuming you leave the car in perfect sunlight for a full 8 hours every day, and there's no cloud, and you get 100% sunlight for the entire 8 hours, then you'd need enough panels to produce 6560Wh / 8hr or 820W.
I could probably barely fit 300W-400W worth of panels on top of my vehicle, and that's with covering the hood, trunk, roof, everything.
So even in the MOST IDEAL possible scenario, where you have your car in perfect sunlight for 8 hours a day, you're not even half way to producing 40 miles per day.