From what I can gather (And I'm not a lawyer and haven't been involved in a union since the 2010 act passed) - I would say the legal onus would be on them (if they withdrew their offer) to prove that they had taken a reasonable decision that you would not be fit to do the job safely.
Guidance document for employers (opens as PDF)
here on Equality & Human Rights Commission website.
it probably would be illegal, but it's been illegal for years for companies to decline to employ people because of their gender / race, and there's organisations out there who manage it, they are just a bit discreet about it...
they might find that "their circumstances have changed and they don't have a job to offer you"
some employers are very negative towards anything remotely in the line of 'mental health' - my gut feeling is if they are not checking with your doctor (which as has been said, they would need your specific written permission for) then keep quiet.
but yes, you would lose the limited protection of the equalities act in the event of future problems, although I'm not sure how useful those protections are if you do get ill at work with a long term problem. I don't think it over-rides the right of employers to get shot of people on 'capability' grounds.
Best of luck.