Skip to content

Commit 4f3eb12

Browse files
committed
Remove DEFAULT_RUST_EDITION
1 parent db90bc7 commit 4f3eb12

File tree

8 files changed

+22
-23
lines changed

8 files changed

+22
-23
lines changed

docs/flatten.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ See @rules_rust//proto:BUILD for examples of defining the toolchain.
787787
| Name | Description | Type | Mandatory | Default |
788788
| :------------- | :------------- | :------------- | :------------- | :------------- |
789789
| <a id="rust_proto_toolchain-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
790-
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "2018" |
790+
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "" |
791791
| <a id="rust_proto_toolchain-grpc_compile_deps"></a>grpc_compile_deps | The crates the generated grpc libraries depends on. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [Label("//proto/raze:protobuf"), Label("//proto/raze:grpc"), Label("//proto/raze:tls_api"), Label("//proto/raze:tls_api_stub")] |
792792
| <a id="rust_proto_toolchain-grpc_plugin"></a>grpc_plugin | The location of the Rust protobuf compiler plugin to generate rust gRPC stubs. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //proto:protoc_gen_rust_grpc |
793793
| <a id="rust_proto_toolchain-proto_compile_deps"></a>proto_compile_deps | The crates the generated protobuf libraries depends on. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [Label("//proto/raze:protobuf")] |
@@ -1120,7 +1120,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
11201120
| <a id="rust_toolchain-cargo"></a>cargo | The location of the <code>cargo</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
11211121
| <a id="rust_toolchain-clippy_driver"></a>clippy_driver | The location of the <code>clippy-driver</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
11221122
| <a id="rust_toolchain-debug_info"></a>debug_info | Rustc debug info levels per opt level | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {"dbg": "2", "fastbuild": "0", "opt": "0"} |
1123-
| <a id="rust_toolchain-default_edition"></a>default_edition | The edition to use for rust_* rules that don't specify an edition. | String | optional | "2018" |
1123+
| <a id="rust_toolchain-default_edition"></a>default_edition | The edition to use for rust_* rules that don't specify an edition. If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | "" |
11241124
| <a id="rust_toolchain-dylib_ext"></a>dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
11251125
| <a id="rust_toolchain-exec_triple"></a>exec_triple | The platform triple for the toolchains execution environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | required | |
11261126
| <a id="rust_toolchain-llvm_tools"></a>llvm_tools | LLVM tools that are shipped with the Rust toolchain. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
@@ -1161,7 +1161,7 @@ A given instance of this rule should be accompanied by a rust_toolchain_reposito
11611161
| <a id="rust_toolchain_repository-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
11621162
| <a id="rust_toolchain_repository-auth"></a>auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
11631163
| <a id="rust_toolchain_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | False |
1164-
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default. | String | optional | "2018" |
1164+
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | "" |
11651165
| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
11661166
| <a id="rust_toolchain_repository-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that this set of toolchains should support. | List of strings | optional | [] |
11671167
| <a id="rust_toolchain_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. An environment variable <code>RULES_RUST_TOOLCHAIN_INCLUDE_RUSTC_SRCS</code> can also be used to control this attribute. This variable will take precedence over the hard coded attribute. Setting it to <code>true</code> to activates this attribute where all other values deactivate it. | Boolean | optional | False |
@@ -1635,7 +1635,7 @@ N.B. A "proxy repository" is needed to allow for registering the toolchain (with
16351635
| <a id="rust_repository_set-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that this set of toolchains should support. Defaults to []. | <code>[]</code> |
16361636
| <a id="rust_repository_set-iso_date"></a>iso_date | The date of the tool. Defaults to None. | <code>None</code> |
16371637
| <a id="rust_repository_set-rustfmt_version"></a>rustfmt_version | The version of rustfmt to be associated with the toolchain. Defaults to None. | <code>None</code> |
1638-
| <a id="rust_repository_set-edition"></a>edition | The rust edition to be used by default (2015, 2018 (if None), or 2021). | <code>None</code> |
1638+
| <a id="rust_repository_set-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | <code>None</code> |
16391639
| <a id="rust_repository_set-dev_components"></a>dev_components | Whether to download the rustc-dev components. Requires version to be "nightly". Defaults to False. | <code>False</code> |
16401640
| <a id="rust_repository_set-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <code>None</code> |
16411641
| <a id="rust_repository_set-urls"></a>urls | A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.gz'] | <code>["https://static.rust-lang.org/dist/{}.tar.gz"]</code> |

docs/rust_proto.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ See @rules_rust//proto:BUILD for examples of defining the toolchain.
252252
| Name | Description | Type | Mandatory | Default |
253253
| :------------- | :------------- | :------------- | :------------- | :------------- |
254254
| <a id="rust_proto_toolchain-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
255-
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "2018" |
255+
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "" |
256256
| <a id="rust_proto_toolchain-grpc_compile_deps"></a>grpc_compile_deps | The crates the generated grpc libraries depends on. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [Label("//proto/raze:protobuf"), Label("//proto/raze:grpc"), Label("//proto/raze:tls_api"), Label("//proto/raze:tls_api_stub")] |
257257
| <a id="rust_proto_toolchain-grpc_plugin"></a>grpc_plugin | The location of the Rust protobuf compiler plugin to generate rust gRPC stubs. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //proto:protoc_gen_rust_grpc |
258258
| <a id="rust_proto_toolchain-proto_compile_deps"></a>proto_compile_deps | The crates the generated protobuf libraries depends on. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [Label("//proto/raze:protobuf")] |

docs/rust_repositories.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
9292
| <a id="rust_toolchain-cargo"></a>cargo | The location of the <code>cargo</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
9393
| <a id="rust_toolchain-clippy_driver"></a>clippy_driver | The location of the <code>clippy-driver</code> binary. Can be a direct source or a filegroup containing one item. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
9494
| <a id="rust_toolchain-debug_info"></a>debug_info | Rustc debug info levels per opt level | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {"dbg": "2", "fastbuild": "0", "opt": "0"} |
95-
| <a id="rust_toolchain-default_edition"></a>default_edition | The edition to use for rust_* rules that don't specify an edition. | String | optional | "2018" |
95+
| <a id="rust_toolchain-default_edition"></a>default_edition | The edition to use for rust_* rules that don't specify an edition. If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | "" |
9696
| <a id="rust_toolchain-dylib_ext"></a>dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
9797
| <a id="rust_toolchain-exec_triple"></a>exec_triple | The platform triple for the toolchains execution environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations | String | required | |
9898
| <a id="rust_toolchain-llvm_tools"></a>llvm_tools | LLVM tools that are shipped with the Rust toolchain. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
@@ -133,7 +133,7 @@ A given instance of this rule should be accompanied by a rust_toolchain_reposito
133133
| <a id="rust_toolchain_repository-name"></a>name | A unique name for this repository. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
134134
| <a id="rust_toolchain_repository-auth"></a>auth | Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
135135
| <a id="rust_toolchain_repository-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | Boolean | optional | False |
136-
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default. | String | optional | "2018" |
136+
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | String | optional | "" |
137137
| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
138138
| <a id="rust_toolchain_repository-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that this set of toolchains should support. | List of strings | optional | [] |
139139
| <a id="rust_toolchain_repository-include_rustc_srcs"></a>include_rustc_srcs | Whether to download and unpack the rustc source files. These are very large, and slow to unpack, but are required to support rust analyzer. An environment variable <code>RULES_RUST_TOOLCHAIN_INCLUDE_RUSTC_SRCS</code> can also be used to control this attribute. This variable will take precedence over the hard coded attribute. Setting it to <code>true</code> to activates this attribute where all other values deactivate it. | Boolean | optional | False |
@@ -214,7 +214,7 @@ N.B. A "proxy repository" is needed to allow for registering the toolchain (with
214214
| <a id="rust_repository_set-extra_target_triples"></a>extra_target_triples | Additional rust-style targets that this set of toolchains should support. Defaults to []. | <code>[]</code> |
215215
| <a id="rust_repository_set-iso_date"></a>iso_date | The date of the tool. Defaults to None. | <code>None</code> |
216216
| <a id="rust_repository_set-rustfmt_version"></a>rustfmt_version | The version of rustfmt to be associated with the toolchain. Defaults to None. | <code>None</code> |
217-
| <a id="rust_repository_set-edition"></a>edition | The rust edition to be used by default (2015, 2018 (if None), or 2021). | <code>None</code> |
217+
| <a id="rust_repository_set-edition"></a>edition | The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its <code>edition</code> attribute. | <code>None</code> |
218218
| <a id="rust_repository_set-dev_components"></a>dev_components | Whether to download the rustc-dev components. Requires version to be "nightly". Defaults to False. | <code>False</code> |
219219
| <a id="rust_repository_set-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <code>None</code> |
220220
| <a id="rust_repository_set-urls"></a>urls | A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.gz'] | <code>["https://static.rust-lang.org/dist/{}.tar.gz"]</code> |

proto/toolchain.bzl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
"""Toolchain for compiling rust stubs from protobuf and gRPC."""
1616

17-
load("//rust:defs.bzl", "rust_common")
18-
1917
# buildifier: disable=bzl-visibility
2018
load("//rust/private:utils.bzl", "name_to_crate_name")
2119

@@ -146,7 +144,6 @@ rust_proto_toolchain = rule(
146144
attrs = {
147145
"edition": attr.string(
148146
doc = "The edition used by the generated rust source.",
149-
default = rust_common.default_edition,
150147
),
151148
"grpc_compile_deps": attr.label_list(
152149
doc = "The crates the generated grpc libraries depends on.",

rust/private/common.bzl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,13 @@ In the Bazel lingo, `rust_common` gives the access to the Rust Sandwich API.
2525

2626
load(":providers.bzl", "CrateInfo", "DepInfo", "StdLibInfo")
2727

28-
# These constants only represent the default value for attributes and macros
29-
# defiend in `rules_rust`. Like any attribute public attribute, they can be
30-
# overwritten by the user on the rules they're defiend on.
28+
# This constant only represents the default value for attributes and macros
29+
# defined in `rules_rust`. Like any attribute public attribute, it can be
30+
# overwritten by the user on the rules they're defined on.
3131
#
3232
# Note: Code in `.github/workflows/crate_universe.yaml` looks for this line, if
3333
# you remove it or change its format, you will also need to update that code.
3434
DEFAULT_RUST_VERSION = "1.60.0"
35-
DEFAULT_RUST_EDITION = "2018"
3635

3736
def _create_crate_info(**kwargs):
3837
"""A constructor for a `CrateInfo` provider
@@ -55,6 +54,5 @@ rust_common = struct(
5554
crate_info = CrateInfo,
5655
dep_info = DepInfo,
5756
stdlib_info = StdLibInfo,
58-
default_edition = DEFAULT_RUST_EDITION,
5957
default_version = DEFAULT_RUST_VERSION,
6058
)

rust/private/rust.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def get_edition(attr, toolchain, label):
119119
"""
120120
if getattr(attr, "edition"):
121121
return attr.edition
122-
elif toolchain.default_edition == "required":
122+
elif not toolchain.default_edition:
123123
fail("Attribute `edition` is required for {}.".format(label))
124124
else:
125125
return toolchain.default_edition

rust/repositories.bzl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def rust_register_toolchains(
101101
102102
Args:
103103
dev_components (bool, optional): Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".
104-
edition (str, optional): The rust edition to be used by default (2015, 2018 (default), or 2021)
104+
edition (str, optional): The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute.
105105
include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support.
106106
See [rust_toolchain_repository.include_rustc_srcs](#rust_toolchain_repository-include_rustc_srcs). for more details
107107
iso_date (str, optional): The date of the nightly or beta release (ignored if the version is a specific version).
@@ -212,8 +212,10 @@ rust_toolchain_repository = repository_rule(
212212
default = False,
213213
),
214214
"edition": attr.string(
215-
doc = "The rust edition to be used by default.",
216-
default = rust_common.default_edition,
215+
doc = (
216+
"The rust edition to be used by default (2015, 2018, or 2021). " +
217+
"If absent, every rule is required to specify its `edition` attribute."
218+
),
217219
),
218220
"exec_triple": attr.string(
219221
doc = "The Rust-style target that this compiler runs on",
@@ -311,7 +313,7 @@ def rust_repository_set(
311313
iso_date (str, optional): The date of the tool. Defaults to None.
312314
rustfmt_version (str, optional): The version of rustfmt to be associated with the
313315
toolchain. Defaults to None.
314-
edition (str, optional): The rust edition to be used by default (2015, 2018 (if None), or 2021).
316+
edition (str, optional): The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute.
315317
dev_components (bool, optional): Whether to download the rustc-dev components.
316318
Requires version to be "nightly". Defaults to False.
317319
sha256s (str, optional): A dict associating tool subdirectories to sha256 hashes. See

rust/toolchain.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,10 @@ rust_toolchain = rule(
519519
},
520520
),
521521
"default_edition": attr.string(
522-
doc = "The edition to use for rust_* rules that don't specify an edition.",
523-
default = rust_common.default_edition,
522+
doc = (
523+
"The edition to use for rust_* rules that don't specify an edition. " +
524+
"If absent, every rule is required to specify its `edition` attribute."
525+
),
524526
),
525527
"dylib_ext": attr.string(
526528
doc = "The extension for dynamic libraries created from rustc.",

0 commit comments

Comments
 (0)