diff --git a/build/rust/cargo_crate.gni b/build/rust/cargo_crate.gni index a1c0abc..6e0ea2b 100644 --- a/build/rust/cargo_crate.gni +++ b/build/rust/cargo_crate.gni @@ -307,11 +307,9 @@ if (defined(invoker.allow_unsafe)) { allow_unsafe = invoker.allow_unsafe } - rustflags += - [ "-Awarnings" ] # Suppress other warnings in 3rd-party crates. - + configs += [ "//build/rust/cargo_crate:allow_all_warnings" ] if (!defined(build_native_rust_unit_tests)) { build_native_rust_unit_tests = _crate_type != "proc-macro" diff --git a/build/rust/cargo_crate/allow_all_warnings.rsp b/build/rust/cargo_crate/allow_all_warnings.rsp new file mode 100644 index 0000000..fc112c8fa --- /dev/null +++ b/build/rust/cargo_crate/allow_all_warnings.rsp @@ -0,0 +1,97 @@ +-Aabsolute_paths_not_starting_with_crate +-Aambiguous_associated_items +-Aambiguous_negative_literals +-Aarithmetic_overflow +-Abinary_asm_labels +-Abindings_with_variant_name +-Aclosure_returning_async_block +-Aconflicting_repr_hints +-Adangerous_implicit_autorefs +-Adefault_overrides_default_fields +-Adeprecated_in_future +-Adeprecated_safe_2024 +-Aderef_into_dyn_supertrait +-Aedition_2024_expr_fragment_specifier +-Aelided_lifetimes_in_associated_constant +-Aelided_lifetimes_in_paths +-Aenum_intrinsics_non_enums +-Aexplicit_builtin_cfgs_in_flags +-Aexplicit_outlives_requirements +-Affi_unwind_calls +-Afuzzy_provenance_casts +-Aif_let_rescope +-Aill_formed_attribute_input +-Aimpl_trait_overcaptures +-Aimpl_trait_redundant_captures +-Aincomplete_include +-Aineffective_unstable_trait_impl +-Ainvalid_atomic_ordering +-Ainvalid_doc_attributes +-Ainvalid_from_utf8_unchecked +-Ainvalid_null_arguments +-Ainvalid_reference_casting +-Ainvalid_type_param_default +-Akeyword_idents_2018 +-Akeyword_idents_2024 +-Alet_underscore_drop +-Alet_underscore_lock +-Alinker_messages +-Along_running_const_eval +-Alossy_provenance_casts +-Amacro_expanded_macro_exports_accessed_by_absolute_paths +-Amacro_use_extern_crate +-Ameta_variable_misuse +-Amismatched_lifetime_syntaxes +-Amissing_copy_implementations +-Amissing_debug_implementations +-Amissing_docs +-Amissing_unsafe_on_extern +-Amultiple_supertrait_upcastable +-Amust_not_suspend +-Amutable_transmutes +-Anamed_asm_labels +-Ano_mangle_const_items +-Anon_ascii_idents +-Anon_exhaustive_omitted_patterns +-Aoverflowing_literals +-Apatterns_in_fns_without_body +-Aproc_macro_derive_resolution_fallback +-Apub_use_of_private_extern_crate +-Aredundant_imports +-Aredundant_lifetimes +-Arust_2021_incompatible_closure_captures +-Arust_2021_incompatible_or_patterns +-Arust_2021_prefixes_incompatible_syntax +-Arust_2021_prelude_collisions +-Arust_2024_guarded_string_incompatible_syntax +-Arust_2024_incompatible_pat +-Arust_2024_prelude_collisions +-Asingle_use_lifetimes +-Asoft_unstable +-Asupertrait_item_shadowing_definition +-Asupertrait_item_shadowing_usage +-Atail_expr_drop_order +-Atest_unstable_lint +-Atext_direction_codepoint_in_comment +-Atext_direction_codepoint_in_literal +-Atrivial_casts +-Atrivial_numeric_casts +-Aunconditional_panic +-Aundropped_manually_drops +-Aunit_bindings +-Aunknown_crate_types +-Aunnameable_types +-Aunqualified_local_imports +-Aunreachable_pub +-Aunsafe_attr_outside_unsafe +-Aunsafe_op_in_unsafe_fn +-Aunstable_features +-Aunused_crate_dependencies +-Aunused_extern_crates +-Aunused_import_braces +-Aunused_lifetimes +-Aunused_macro_rules +-Aunused_qualifications +-Aunused_results +-Auseless_deprecated +-Avariant_size_differences diff --git a/build/rust/cargo_crate/BUILD.gn b/build/rust/cargo_crate/BUILD.gn new file mode 100644 index 0000000..bcbe13d --- /dev/null +++ b/build/rust/cargo_crate/BUILD.gn @@ -0,0 +1,29 @@ +# Copyright 2025 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# The `allow_all_warnings` is meant to be used for suppressing warnings in +# third-party crates coming from crates.io (ones under `//third_party/rust`). +# Note that Chromium still wants to deny most warnings in some notionally +# "third-party" code like `//third_party/skia` or `//third_party/crabbyavif`. +config("allow_all_warnings") { + rustflags = [ "-Awarnings" ] + + # Ideally we would just use `-Awarnings` or `--cap-lints=allow`, but this + # interacts in undesirable ways with other requirements - see + # https://github.com/rust-lang/rust/issues/143108 for more context. + # So, to work around that, we explicitly allow individual warnings + # (because `-Amore-specific-warning` will win over + # the less specific `#![deny(warnings)]`). + # + # `allow_all_warnings.rsp` has been initially generated by taking the output + # of `rustc -W help` and then manually removing entries for warnings + # explicitly controlled by gni templates (e.g. `unsafe_code` warning covered + # by `//build/rust:forbid_unsafe`). + # + # TODO(https://crbug.com/428207407): Stop suppressing individual warnings + # once a single flag can reliably suppress all warnings. + _path = rebase_path("allow_all_warnings.rsp", root_build_dir) + rustflags += [ "@${_path}" ] + inputs = [ "allow_all_warnings.rsp" ] +}