From 836fc255ba96a6d48a668dd4e0540274a70b5eb5 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sun, 16 Sep 2018 20:53:19 -0700 Subject: [PATCH] Suppress remaining warnings in third party rust crates --- build_extra/rust/BUILD.gn | 14 ++++++++++++++ build_extra/rust/rust.gni | 8 +++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/build_extra/rust/BUILD.gn b/build_extra/rust/BUILD.gn index af84969137..a583a5a0a5 100644 --- a/build_extra/rust/BUILD.gn +++ b/build_extra/rust/BUILD.gn @@ -14,6 +14,7 @@ registry_github = "$crates/registry/src/github.com-1ecc6299db9ec823/" rust_crate("libc") { source_root = "$registry_github/libc-0.2.42/src/lib.rs" features = [ "use_std" ] + args = [ "-Aunused_macros" ] # Unused macro `f` in macros.rs:51. } rust_crate("url") { @@ -163,6 +164,18 @@ rust_crate("winapi-0.2") { crate_name = "winapi" crate_version = "0.2" source_root = "$registry_github/winapi-0.2.8/src/lib.rs" + args = [ + "-Asafe_packed_borrows", + "-Awarnings", + ] + + # The winapi-0.2 crate contains an unused type alias, but it also specifically + # sets the lint level to warn about this, so we can't suppress that warning + # with a command line argument, other than by using "-Awarnings", which has no + # effect if we also pass "-Dwarnings" to treat all warnings as errors. + # Since this crate is outdated and this will never be fixed, just override + # the global 'rust_treat_warnings_as_errors' setting for this crate. + treat_warnings_as_errors = false } # TODO: Remove this crate together with crate 'winapi-0.2'. @@ -242,6 +255,7 @@ rust_crate("miow") { crate_version = "0.2" }, ] + args = [ "-Aunused_macros" ] # Unused macro `t` in lib.rs:21. } rust_crate("iovec") { diff --git a/build_extra/rust/rust.gni b/build_extra/rust/rust.gni index 85959e921c..aaf1116767 100644 --- a/build_extra/rust/rust.gni +++ b/build_extra/rust/rust.gni @@ -57,6 +57,7 @@ template("run_rustc") { "is_test", "source_root", "testonly", + "treat_warnings_as_errors", ]) if (!defined(crate_name)) { crate_name = target_name @@ -64,6 +65,10 @@ template("run_rustc") { if (!defined(is_test)) { is_test = false } + if (!defined(treat_warnings_as_errors)) { + # Use global setting if not explicitly specified for this target. + treat_warnings_as_errors = rust_treat_warnings_as_errors + } sources = [ source_root, @@ -76,7 +81,7 @@ template("run_rustc") { "--crate-type=$crate_type", ] - if (rust_treat_warnings_as_errors) { + if (treat_warnings_as_errors) { args += [ "-Dwarnings" ] } @@ -254,6 +259,7 @@ template("rust_crate") { "is_test", "source_root", "testonly", + "treat_warnings_as_errors", ]) }