diff --git a/crates/rust/src/lib.rs b/crates/rust/src/lib.rs index 50ba0b3d7..55866ed14 100644 --- a/crates/rust/src/lib.rs +++ b/crates/rust/src/lib.rs @@ -296,20 +296,18 @@ impl RustWasm { emit(&mut self.src, map, &self.opts, true); fn emit(me: &mut Source, module: Module, opts: &Opts, toplevel: bool) { for (name, submodule) in module.submodules { - if toplevel { - // Disable rustfmt. By default we already format the code - // using prettyplease, so we don't want `cargo fmt` to create - // extra diffs for users to deal with. - if opts.format { - uwriteln!(me, "#[rustfmt::skip]"); - } - - // Ignore dead-code and clippy warnings. If the bindings are - // only used within a crate, and not exported to a different - // crate, some parts may be unused, and that's ok. - uwriteln!(me, "#[allow(dead_code, clippy::all)]"); + // Disable rustfmt. By default we already format the code + // using prettyplease, so we don't want `cargo fmt` to create + // extra diffs for users to deal with. + if opts.format { + uwriteln!(me, "#[rustfmt::skip]"); } + // Ignore dead-code and clippy warnings. If the bindings are + // only used within a crate, and not exported to a different + // crate, some parts may be unused, and that's ok. + uwriteln!(me, "#[allow(dead_code, clippy::all)]"); + uwriteln!(me, "pub mod {name} {{"); emit(me, submodule, opts, false); uwriteln!(me, "}}");