united kingdom – Applying for UK Tier 4 (passport expiration)

I am applying for a UK Tier 4 visa that ends September 2021 but my passport expires in May 2021. Can I apply and renew my passport while I am in the UK?

I read that to enter the UK, my passport has to be valid throughout the stay. But the gov.uk website also says:

You can use the valid visa in your expired passport when you’re
travelling to and from the UK. You’ll need to travel with your expired
and your new passport.

Does this mean they will grant me the visa beyond my passport’s expiry date?