Paleopeat-forming environments have an important effect on the dispersion and enrichment of trace elements in coal. The C3 coal seam of the Xuanwei Formation in eastern Yunnan was used as a case study to reconstruct the paleopeat-forming environment based on the coal facies parameters and geochemical characteristics, and its influence on trace element (including rare earth elements and yttrium, REY) enrichment was investigated. The C3 coal was classified as medium rank coking coal with an ultra-low moisture content, medium-high-ash yield, and low-medium volatile content. Compared to the average values for Chinese coals, Cu and V were enriched and Co was slightly enriched in the C3 coal. Compared with the average values for world coals, Cu and V were enriched, while several other trace elements were slightly enriched, including Co, Hf, Nb, Sc, Ta, Zn, and Zr in the C3 coal. The C3 coal was deposited in a low peat mainly limno-telmatic swamp, with deep water, weak hydrodynamic conditions, brackish to salty water, and reducing conditions. Trace elements, including Cu, V, Hf, Nb, Sc, Ta, Zr, and REY, are typically enriched in a limno-telmatic environment with fresh water, and reducing and weak hydrodynamic conditions. Additionally, REY and V are also significantly enriched in brackish water limno-telmatic conditions with the same depositional environment.