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?