Without significant improvement in solar technology, almost nothing. The average panel outputs about 126Wh per square foot. Let's say every car has panels, and say an average length of 10,000ft. Say cars are about 10ft wide. So a total square footage of about 100,000sqft. So perhaps 1.26MWh. Under ideal conditions. Edit: Even with a 10x improvement, that's only 12.6MWh, nowhere close. There needs to be a 100x improvement in solar cell efficiency to get there--and that only works during the day.
A typical train uses about 3000gal of diesel for a 500mi trip (that's right, gallons per mile--and it still moves more freight per gallon burned--other than shipping--than any other transport mechanism). At ~10kWh/L (~38kW/gal), that is 113MWh for a single trip. With solar panels, it would still require an additional 112MWh for the trip. And only 82kWh/1000lbs, you'd have to pull an additional 682 tons in batteries to complete the trip. But that doesn't account for the weight of the batteries, so you have to add more batteries. The train would have to be incredibly long to carry enough energy in batteries to make the trip. And when you get there you have to recharge.
Even if you combined that with batteries (which weigh about 5x more for the same amount of energy), you still can't get an electric train to pull a load 500mi, much less cross country.
Maybe we get there. I don't think we do in our lifetimes. For my part, I don't think batteries are the future. The amount of materials required to create, maintenance, and lifetimes just aren't worth it. Hydrogen seems much more promising to me. It is a much higher density than batteries (though less than hydrocarbons), is much more available, but lacks the environmental impact. The trick there is generation, distribution, and storage.
Edit: But even if battery energy densities increased 10x, there's still the recharge time. IIRC, the average cost of a new diesel-electric locomotive is $2M+. Even if we had an purely electric locomotive that had a capacity of 113MWh and weighed the same as a current locomotive, the charge times would be a huge problem. Railroads run 24/7. The railroads would have huge amounts of capital invested in locomotives sitting there being charged. At a minimum, they'd double their capital costs. Right now, and I think for 30+ years, it just is not cost effective for anyone other than perhaps individuals to switch to EVs.