It's not sufficient to do this merely on `brew upgrade` because
`brew install` and `brew reinstall` can also result in formulae being
upgraded.
This requires moving logic from `cmd/upgrade.rb` to `upgrade.rb`. To
save you searching the diff the changes that resulted from doing that:
- Query the installed formulae from class state in `FormulaInstaller`
rather than the (incomplete) list that we passed into it.
- Don't output the "Checking dependents" message. It was there for
systems and configurations where this is slow but for most users
and most installations this will be a (annoying, noisy) no-op.
Fixes https://github.com/Homebrew/brew/issues/7860