Will never happen. There will always be a need for a few diesel locos, even after electrification spreads further. And batteries will never have sufficient capacity to work some of the heaviest / longest workings. The Class 66 successors, built 2045 onwards may last until about 2100.
This point always amuses me, railways are fabulously efficient, but batteries don't have enough capacity for rail vehicles despite it being possible to drive anywhere in the UK with an electric car!
Even with todays technology we could pack a 60 tonne freight wagon with 9MWhr of storage and plug it into the loco, just keep adding cars until you have enough range to get between electrification with whatever load you need to move. That 9 MWhr of battery pack would cost about $1 million at the prices that car makers currently pay.
The last steam locos were good to last to the 80/90's, it's perfectly feasible that everything diesel is gone in about 20 years, the government action is just to set a phase out date once options have been proven to be feasible.
Battery capacity is limited by chemistry. We have not yet reached that limit, but once the limit due to chemistry has been reached, the only way to increase capacity will be to include more battery cells.
1: As stated above you can get 9MWh onto a 60 tonne payload wagon with current 5,000 cycle LFP batteries used in value BEVs. Just add enough wagons until you have enough range, then look at a few places where you could install intermittent electrification cheaply and look at putting wires into certain destinations.
2: The chemistry limits for Lithium Sulphur are about 10X the energy density we currently have, however as I alluded to in point 1, trains care more about battery cost and cycle life than they do about energy density. There are no fundamental limitations on cycle life.