Skip to content

Commit

Permalink
Ensure module attributes are applied to all modules.
Browse files Browse the repository at this point in the history
Effectively revert #1089, and go back to putting `#[allow(dead_code)]`
on all modules for now, because the code in #1089 didn't work for
interfaces defined inline inside of worlds, which turn into top-level
modules in the Rust bindings.
  • Loading branch information
sunfishcode committed Nov 20, 2024
1 parent 1739caf commit a17138c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions crates/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, "}}");
Expand Down

0 comments on commit a17138c

Please sign in to comment.