Differently from Directive 2011/65/EU, the Ecodesign legislation does not restrict substances in products but sets energy consumption values to be respected in order for the products to be placed on the market. The latest Ecodesign act on lighting Commission Regulation (EU) 2019/2020 identifies mercury content as a significant environmental aspect in the life-cycle of a light source, but acknowledges that the use of hazardous substances, including mercury in light sources, is governed by Directive 2011/65/EU.
The RoHS Directive 2011/65/EC might impose other requirements such as the allowable mercury content in each single light source. In such a case a product can be in conformity with Ecodesign measures but not with the RoHS Directive and is therefore not allowed to be placed on the market.
Disclaimer: Please note that the European Commission cannot provide a legally binding interpretation of the EU legislation, as this is the sole competence of the European Court of Justice. Any remarks from the European Commission services are without prejudice to the position the Commission might take should related cases arise in a procedure before the Court of Justice.