[D1] backport "Modules can't be marked as deprecated"

Original D2 commit : 2af112ec0f156c19b63a9d8269b37ba0555c5857 "fix Issue 12567 - Modules can't be marked as deprecated "

It happens that we do many module deprecations lately and changeset of that pull request looked pretty simple. Apart from few minor tweaks dumb copy-pasting seemed to just work.