I guess the only reason the "self-pin" (common chess term) works is a concrete variation...After 46...Rg6, when White pinned with 47. Qf5, Black advanced 47...c4 intending ...Qd3 when White would have to either trade Queens (losing) or abandon the pin.
Few (certainly not I) would have self-pinned in real time, but it was a combination of Ding's wanting to win (retreating the King to the 8th rank would likely have led to perpetual check) and accurate calculation.
Many GMs in that situation would have opted for draw via perpetual and rolled the dice on blitz games. All credit to Ding.
Funny thing: apparently the correct pronunciation of Ding's surname is "Lizhen", which is clearly shown by the Russian transliteration. The onsite FIDE reps pronounced it correctly, but the vast majority of English commentators stuck to "Liren".