Walmart crossed a $1 trillion market capitalization on Tuesday, capping a sharp stock rally driven by digital growth and new customer gains.