The Eldritch Invocation "Aspect of the Moon" from Xanathar's Guide to Everything (pg. 56) provides you with the benefit of no longer needing to sleep:
Aspect of the Moon
Prerequisite: Pact of the Tome feature
You no longer need to sleep and can't be forced to sleep by any means. To gain the benefits of a long rest, you can spend all 8 hours doing light activity, such as reading your Book of Shadows and keeping watch.
Elves do not sleep; they "trance" (from the PHB, pg. 23):
Trance
Elves don’t need to sleep. Instead, they meditate deeply, remaining semiconscious, for 4 hours a day. (The Common word for such meditation is “trance.”) While meditating, you can dream after a fashion; such dreams are actually mental exercises that have become reflexive through years of practice. After resting in this way, you gain the same benefit that a human does from 8 hours of sleep.
If I have an elven warlock, does gaining the Aspect of the Moon invocation override the need to trance? Can an elven warlock still trance if they want to (since elves can gain the benefits of a long rest in 4h if they trance, but presumably not if they don't trance as per Aspect of the Moon)? Or is it the case that, because trancing is not sleeping, this invocation does nothing for an elf?
Best Answer
The elf can choose to use Trance or Aspect of the Moon
The language from the Invocation says (emphasis mine)
This suggests that it is a choice to utilize that versus the standard long rest option for the character.
The Functional Differences
Aspect of the Moon gives you the option to be awake and aware for the full 8 hours to gain the benefits of a long rest.
Trance gives you the option to shut down for just 4 hours for in order to gain the benefits of a Long Rest - but you are not aware for those 4 hours while in the trance. See the printed Sage Advice for reference to this change: