Is W-D 40 a lubricant yes and no if you spray it on some metal and let dry it will turn into a sticky mess. If you spray it on metal and remove most of it and let it dry you will have a dry lubed suffice. Brownells did a gun oil test it did pretty well for rust protection.
I also encourage you to check out the article “GUN CLEANING CLINIC: Knowing The Limits Of Rust Preventives” on the Brownells website. In this test, the following products were tested: Birchwood Casey Sheath, Boeshield T-9, Break-Free CLP, Break-Free Weapon Wipes, Brownells Cosmoline, Brownells Rust Preventive No. 2, Hoppe’s Lubricating Oil, Rig Universal Grease, Tetra Gun Lubricant, Valvoline 5W-30 motor oil, and WD-40. In the Brownells test, the samples were left in an outdoor environment for 72-hours, during which they experienced high temperatures and a rainstorm.
The best performers in the Brownells test were Boeshield T-9, Brownells Cosmoline, and Rig Universal Grease for long term storage, and Brownells RP2, Tetra Gun, and WD-40 for corrosion resistance that is usable on your daily carry guns.