The Mage Slayer feat provides the following benefit, amongst others:
You have advantage on saving throws against spells cast by creatures within 5 feet of you.
For spells with a duration of instantaneous, it’s clear when this effect occurs – when the creature is within 5 feet of you, and casts a spell you need to make a saving throw against.
What about spells with longer durations, where the casting and you making the save might not be at the same moment? Examples might be Evard’s Black Tentacles, or Thunderous Smite. Does the creature need to be within 5 feet of you (a) when they cast the spell, or (b) when you make the saving throw (or both)?