Too lazy to try to compute the atmospheric energy loss due to shock wave from a Mach > 50 projectile, but there is a reason why rail guns are not used - not even to resupply the low earth orbit manned space station much less even send robot to Mars which energetically must be (guessing) at least 20 times less energy required than to go to the sun per Kg sent. All that energy must be in the waste package when it leaves the end of the rail gun, probably at more than Mach = 100 ! (I'm falsely assuming it does not just totally vaporize before leaving the Earth's atmosphere but think that is highly probable. The leading edges of fighter wings that go Mach = 3 are titanium* as aluminum would melt.)
Earth has an orbital velocity around the sun of c.30km/s.
To get something to impact the sun would need to reach Earth's escape velocity, which from the surface is about 11 km/s, and then lose orbital speed with respect to the sun until the orbital perigee is within the sun's radius.
So let's say 41km/s delta-V required.
To get something to land on moon requires roughly around half of this, I think: 11 to escape earth, a bit to get into transfer orbit, about 4 to then get in to Mars orbit etc.
So purely from energy point of view, probably only 4 times as much is needed to shoot for the sun (although my calls are very simplistic).
However, there are more efficient ways for the solar shot, such as shooting to Jupiter and doing a slingshot.
That said, even just sending something into a highly elliptic orbit might do the job... Or at least put it out of our concern for 100+ years.
But it's ultimately about cost, as such transport is not cheap.
Heh! Teach me for not reading all the posts: seems ElectricFetus has already said almost exactly the same.