From 733768d7be42a5235c5d042401407eaa58dc32f9 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Mon, 30 Nov 2020 21:15:16 +0100 Subject: [PATCH] codegen/flags: Add missing display trait generation Analysis was copied from enums which adds an std::fmt when generate_display_trait is true, but the codegen for it was missing. Instead of removing the import, provide a simple Display trait that forwards to bitflags' Debug implementation. --- src/codegen/flags.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/codegen/flags.rs b/src/codegen/flags.rs index b2f4df283..264cfab75 100644 --- a/src/codegen/flags.rs +++ b/src/codegen/flags.rs @@ -125,6 +125,20 @@ fn generate_flags( writeln!(w)?; + if config.generate_display_trait { + // Generate Display trait implementation. + version_condition(w, env, flags.version, false, 0)?; + writeln!( + w, + "impl fmt::Display for {0} {{\n\ + \tfn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {{\n\ + \t\t::fmt(self, f)\n\ + \t}}\n\ + }}\n", + flags.name + )?; + } + version_condition(w, env, flags.version, false, 0)?; writeln!( w,