Skip to content

Commit 980d54a

Browse files
committed
Remove DEFAULT_RUST_EDITION
1 parent a823def commit 980d54a

File tree

8 files changed

+22
-21
lines changed

8 files changed

+22
-21
lines changed

docs/flatten.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ See @rules_rust//proto:BUILD for examples of defining the toolchain.
779779
| Name | Description | Type | Mandatory | Default |
780780
| :------------- | :------------- | :------------- | :------------- | :------------- |
781781
| <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 | |
782-
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "2018" |
782+
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "" |
783783
| <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")] |
784784
| <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 |
785785
| <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")] |
@@ -1117,7 +1117,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
11171117
| <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 |
11181118
| <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 |
11191119
| <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"} |
1120-
| <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" |
1120+
| <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 | "" |
11211121
| <a id="rust_toolchain-dylib_ext"></a>dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
11221122
| <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 | |
11231123
| <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 |
@@ -1158,7 +1158,7 @@ A given instance of this rule should be accompanied by a rust_toolchain_reposito
11581158
| <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 | |
11591159
| <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 | {} |
11601160
| <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 |
1161-
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default. | String | optional | "2018" |
1161+
| <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 | "" |
11621162
| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
11631163
| <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 | [] |
11641164
| <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 |
@@ -1632,7 +1632,7 @@ N.B. A "proxy repository" is needed to allow for registering the toolchain (with
16321632
| <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> |
16331633
| <a id="rust_repository_set-iso_date"></a>iso_date | The date of the tool. Defaults to None. | <code>None</code> |
16341634
| <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> |
1635-
| <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> |
1635+
| <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> |
16361636
| <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> |
16371637
| <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> |
16381638
| <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

+1-1
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

+3-3
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

-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ rust_proto_toolchain = rule(
146146
attrs = {
147147
"edition": attr.string(
148148
doc = "The edition used by the generated rust source.",
149-
default = rust_common.default_edition,
150149
),
151150
"grpc_compile_deps": attr.label_list(
152151
doc = "The crates the generated grpc libraries depends on.",

rust/private/common.bzl

+3-5
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

+1-1
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 toolchain.default_edition == "":
123123
fail("Attribute `edition` is required for {}.".format(label))
124124
else:
125125
return toolchain.default_edition

rust/repositories.bzl

+6-4
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def rust_register_toolchains(
9191
9292
Args:
9393
dev_components (bool, optional): Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".
94-
edition (str, optional): The rust edition to be used by default (2015, 2018 (default), or 2021)
94+
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.
9595
include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support.
9696
See [rust_toolchain_repository.include_rustc_srcs](#rust_toolchain_repository-include_rustc_srcs). for more details
9797
iso_date (str, optional): The date of the nightly or beta release (ignored if the version is a specific version).
@@ -202,8 +202,10 @@ rust_toolchain_repository = repository_rule(
202202
default = False,
203203
),
204204
"edition": attr.string(
205-
doc = "The rust edition to be used by default.",
206-
default = rust_common.default_edition,
205+
doc = (
206+
"The rust edition to be used by default (2015, 2018, or 2021). " +
207+
"If absent, every rule is required to specify its `edition` attribute."
208+
),
207209
),
208210
"exec_triple": attr.string(
209211
doc = "The Rust-style target that this compiler runs on",
@@ -301,7 +303,7 @@ def rust_repository_set(
301303
iso_date (str, optional): The date of the tool. Defaults to None.
302304
rustfmt_version (str, optional): The version of rustfmt to be associated with the
303305
toolchain. Defaults to None.
304-
edition (str, optional): The rust edition to be used by default (2015, 2018 (if None), or 2021).
306+
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.
305307
dev_components (bool, optional): Whether to download the rustc-dev components.
306308
Requires version to be "nightly". Defaults to False.
307309
sha256s (str, optional): A dict associating tool subdirectories to sha256 hashes. See

rust/toolchain.bzl

+4-2
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)