Interesting idea. One problem, based on a tiny bit of research, is that states are now allowed-not required-to treat student loan payments as a qualified distribution. So ymmv by state.
"The big unknown is how the states will react," Kantrowitz wrote. "We do not yet know which of the 30+ states with state income tax deductions or tax credits will allow them to be used with student loan repayment. If the addition of K-12 tuition by the Tax Cuts and Jobs Act of 2017 is any indication, probably 21 of the states will allow it. The others will treat using 529 plan funds for student loan repayment as an non-qualified distribution."