@@ -11,6 +11,7 @@ load("//rs/experimental/miri/private:miri_repository.bzl", "miri_repository")
1111load ("//rs/platforms:triples.bzl" , "SUPPORTED_EXEC_TRIPLES" , "SUPPORTED_TIER_1_AND_2_TRIPLES" )
1212load ("//rs/private:cargo_repository.bzl" , "cargo_repository" )
1313load ("//rs/private:clippy_repository.bzl" , "clippy_repository" )
14+ load ("//rs/private:default_lint_config_repository.bzl" , "default_lint_config_repository" )
1415load ("//rs/private:host_tools_repository.bzl" , "host_tools_repository" )
1516load ("//rs/private:rust_analyzer_repository.bzl" , "rust_analyzer_repository" )
1617load ("//rs/private:rust_src_repository.bzl" , "rust_src_repository" )
@@ -84,6 +85,11 @@ _TOOLCHAIN_TAG = tag_class(
8485 doc = "Default edition to apply to toolchains." ,
8586 default = _DEFAULT_EDITION ,
8687 ),
88+ "default_lint_config" : attr .label (
89+ doc = "Default lint_config label applied to rules_rs Rust targets " +
90+ "when they don't set lint_config explicitly. Should refer to " +
91+ "a target providing LintsInfo (e.g. @crates//:cargo_lints)." ,
92+ ),
8793 "extra_rustc_flags" : attr .string_list_dict (
8894 doc = "Additional rustc flags by target triple." ,
8995 ),
@@ -154,9 +160,17 @@ def _toolchains_impl(mctx):
154160
155161 version_tags = []
156162 had_tags = True
163+ root_default_lint_config = None
157164 for mod in mctx .modules :
158165 for tag in mod .tags .toolchain :
159166 version_tags .append (tag )
167+ if mod .is_root and tag .default_lint_config :
168+ if root_default_lint_config and root_default_lint_config != tag .default_lint_config :
169+ fail (
170+ "Conflicting default_lint_config values on root module toolchain tags: " +
171+ "{} vs {}" .format (root_default_lint_config , tag .default_lint_config ),
172+ )
173+ root_default_lint_config = tag .default_lint_config
160174
161175 if not version_tags :
162176 had_tags = False
@@ -166,6 +180,7 @@ def _toolchains_impl(mctx):
166180 rustfmt_version = "" ,
167181 rust_analyzer_version = "" ,
168182 edition = _DEFAULT_EDITION ,
183+ default_lint_config = None ,
169184 extra_rustc_flags = {},
170185 extra_exec_rustc_flags = {},
171186 ))
@@ -417,10 +432,17 @@ def _toolchains_impl(mctx):
417432 host_cargo = host_cargo ,
418433 )
419434
420- # `rs_rust_host_tools` is an implementation detail of rules_rs itself.
421- # Report it as a direct dependency only for the rules_rs root module so
422- # user modules are not asked to import it.
423- direct_deps = ["rs_rust_host_tools" ] if root_module_name == "rules_rs" else []
435+ default_lint_config_repository (
436+ name = "rules_rs_default_lint_config" ,
437+ lint_config = str (root_default_lint_config ) if root_default_lint_config else "" ,
438+ )
439+
440+ # `rs_rust_host_tools` and `rules_rs_default_lint_config` are implementation
441+ # details of rules_rs itself. Report them as direct dependencies only for the
442+ # rules_rs root module so user modules are not asked to import them.
443+ direct_deps = (
444+ ["rs_rust_host_tools" , "rules_rs_default_lint_config" ] if root_module_name == "rules_rs" else []
445+ )
424446 direct_dev_deps = []
425447 repo_configs = {}
426448 for tag in version_tags :
0 commit comments