I have baked cakes in cans, not aluminum cans but those where condensed milk comes, and this was an advice that I received from my grandmother whenever I would like to bake a small cake or muffing but not having the right pans or molds at hand.
Greasing and flouring the can as if it were a pan makes the trick to get your cake done without affecting taste or texture.