It will fit. The limit will be a 50 mm objective -I know because I put a 4.5x14x50 VXIII Leupold on a 77/17 and the objective bell just touched the bbl when I got the eye relief where I wanted it. So I got a set of high rings which really weren't that expensive.
I have a number of Ruger 77/22's and I believe that you will be alright with the 40mm on the standard rings. However, in the past Ruger has exchanged rings for me without charge, only a phone call and an $8 mailing fee. FWIW.
I agree that Ruger will exchange rings for rings of another height but I doubt they'd accept old used rings even-up for new ones? I've exchanged rings more than once but the ones I sent back were new and unused in the original packaging.