Skip to content

Commit 1aea1a6

Browse files
authored
Update default edition to 2018 (bazelbuild#901)
1 parent 93431fb commit 1aea1a6

File tree

10 files changed

+18
-13
lines changed

10 files changed

+18
-13
lines changed

docs/flatten.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ See @rules_rust//proto:BUILD for examples of defining the toolchain.
875875
| Name | Description | Type | Mandatory | Default |
876876
| :------------- | :------------- | :------------- | :------------- | :------------- |
877877
| <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 | |
878-
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "2015" |
878+
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "2018" |
879879
| <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")] |
880880
| <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 |
881881
| <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")] |
@@ -1212,7 +1212,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
12121212
| <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 |
12131213
| <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 |
12141214
| <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"} |
1215-
| <a id="rust_toolchain-default_edition"></a>default_edition | The edition to use for rust_* rules that don't specify an edition. | String | optional | "2015" |
1215+
| <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" |
12161216
| <a id="rust_toolchain-dylib_ext"></a>dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
12171217
| <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 | optional | "" |
12181218
| <a id="rust_toolchain-opt_level"></a>opt_level | Rustc optimization levels. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {"dbg": "0", "fastbuild": "0", "opt": "3"} |
@@ -1250,7 +1250,7 @@ A given instance of this rule should be accompanied by a rust_toolchain_reposito
12501250
| :------------- | :------------- | :------------- | :------------- | :------------- |
12511251
| <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 | |
12521252
| <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 |
1253-
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default. | String | optional | "2015" |
1253+
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default. | String | optional | "2018" |
12541254
| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
12551255
| <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 | [] |
12561256
| <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 |
@@ -1687,7 +1687,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai
16871687
| <a id="rust_repositories-version"></a>version | The version of Rust. Either "nightly", "beta", or an exact version. Defaults to a modern version. | <code>"1.54.0"</code> |
16881688
| <a id="rust_repositories-iso_date"></a>iso_date | The date of the nightly or beta release (ignored if the version is a specific version). | <code>None</code> |
16891689
| <a id="rust_repositories-rustfmt_version"></a>rustfmt_version | The version of rustfmt. Either "nightly", "beta", or an exact version. Defaults to <code>version</code> if not specified. | <code>None</code> |
1690-
| <a id="rust_repositories-edition"></a>edition | The rust edition to be used by default (2015 (default) or 2018) | <code>None</code> |
1690+
| <a id="rust_repositories-edition"></a>edition | The rust edition to be used by default (2015, 2018 (default), or 2021) | <code>None</code> |
16911691
| <a id="rust_repositories-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | <code>False</code> |
16921692
| <a id="rust_repositories-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. Defaults to None. | <code>None</code> |
16931693
| <a id="rust_repositories-include_rustc_srcs"></a>include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. See [rust_toolchain_repository.include_rustc_srcs](#rust_toolchain_repository-include_rustc_srcs). for more details | <code>False</code> |
@@ -1720,7 +1720,7 @@ N.B. A "proxy repository" is needed to allow for registering the toolchain (with
17201720
| <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> |
17211721
| <a id="rust_repository_set-iso_date"></a>iso_date | The date of the tool. Defaults to None. | <code>None</code> |
17221722
| <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> |
1723-
| <a id="rust_repository_set-edition"></a>edition | The rust edition to be used by default (2015 (if None) or 2018). | <code>None</code> |
1723+
| <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> |
17241724
| <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> |
17251725
| <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> |
17261726
| <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 | "2015" |
255+
| <a id="rust_proto_toolchain-edition"></a>edition | The edition used by the generated rust source. | String | optional | "2018" |
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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ See @rules_rust//rust:repositories.bzl for examples of defining the @rust_cpuX r
9090
| <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 |
9191
| <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 |
9292
| <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"} |
93-
| <a id="rust_toolchain-default_edition"></a>default_edition | The edition to use for rust_* rules that don't specify an edition. | String | optional | "2015" |
93+
| <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" |
9494
| <a id="rust_toolchain-dylib_ext"></a>dylib_ext | The extension for dynamic libraries created from rustc. | String | required | |
9595
| <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 | optional | "" |
9696
| <a id="rust_toolchain-opt_level"></a>opt_level | Rustc optimization levels. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {"dbg": "0", "fastbuild": "0", "opt": "3"} |
@@ -128,7 +128,7 @@ A given instance of this rule should be accompanied by a rust_toolchain_reposito
128128
| :------------- | :------------- | :------------- | :------------- | :------------- |
129129
| <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 | |
130130
| <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 |
131-
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default. | String | optional | "2015" |
131+
| <a id="rust_toolchain_repository-edition"></a>edition | The rust edition to be used by default. | String | optional | "2018" |
132132
| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple | The Rust-style target that this compiler runs on | String | required | |
133133
| <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 | [] |
134134
| <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 |
@@ -199,7 +199,7 @@ See `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more detai
199199
| <a id="rust_repositories-version"></a>version | The version of Rust. Either "nightly", "beta", or an exact version. Defaults to a modern version. | <code>"1.54.0"</code> |
200200
| <a id="rust_repositories-iso_date"></a>iso_date | The date of the nightly or beta release (ignored if the version is a specific version). | <code>None</code> |
201201
| <a id="rust_repositories-rustfmt_version"></a>rustfmt_version | The version of rustfmt. Either "nightly", "beta", or an exact version. Defaults to <code>version</code> if not specified. | <code>None</code> |
202-
| <a id="rust_repositories-edition"></a>edition | The rust edition to be used by default (2015 (default) or 2018) | <code>None</code> |
202+
| <a id="rust_repositories-edition"></a>edition | The rust edition to be used by default (2015, 2018 (default), or 2021) | <code>None</code> |
203203
| <a id="rust_repositories-dev_components"></a>dev_components | Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly". | <code>False</code> |
204204
| <a id="rust_repositories-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. Defaults to None. | <code>None</code> |
205205
| <a id="rust_repositories-include_rustc_srcs"></a>include_rustc_srcs | Whether to download rustc's src code. This is required in order to use rust-analyzer support. See [rust_toolchain_repository.include_rustc_srcs](#rust_toolchain_repository-include_rustc_srcs). for more details | <code>False</code> |
@@ -232,7 +232,7 @@ N.B. A "proxy repository" is needed to allow for registering the toolchain (with
232232
| <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> |
233233
| <a id="rust_repository_set-iso_date"></a>iso_date | The date of the tool. Defaults to None. | <code>None</code> |
234234
| <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> |
235-
| <a id="rust_repository_set-edition"></a>edition | The rust edition to be used by default (2015 (if None) or 2018). | <code>None</code> |
235+
| <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> |
236236
| <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> |
237237
| <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> |
238238
| <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> |

examples/WORKSPACE.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ load("@rules_rust//rust:rust.bzl", "rust_library")
8888
rust_library(
8989
name = "libc",
9090
srcs = glob(["src/**/*.rs"]),
91+
edition = "2015",
9192
visibility = ["//visibility:public"],
9293
)
9394
"""

rust/private/common.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ load(":providers.bzl", "CrateInfo", "DepInfo", "StdLibInfo")
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.54.0"
35-
DEFAULT_RUST_EDITION = "2015"
35+
DEFAULT_RUST_EDITION = "2018"
3636

3737
def _create_crate_info(**kwargs):
3838
"""A constructor for a `CrateInfo` provider

rust/repositories.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def rust_repositories(
6262
version (str, optional): The version of Rust. Either "nightly", "beta", or an exact version. Defaults to a modern version.
6363
iso_date (str, optional): The date of the nightly or beta release (ignored if the version is a specific version).
6464
rustfmt_version (str, optional): The version of rustfmt. Either "nightly", "beta", or an exact version. Defaults to `version` if not specified.
65-
edition (str, optional): The rust edition to be used by default (2015 (default) or 2018)
65+
edition (str, optional): The rust edition to be used by default (2015, 2018 (default), or 2021)
6666
dev_components (bool, optional): Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".
6767
sha256s (str, optional): A dict associating tool subdirectories to sha256 hashes. Defaults to None.
6868
include_rustc_srcs (bool, optional): Whether to download rustc's src code. This is required in order to use rust-analyzer support.
@@ -273,7 +273,7 @@ def rust_repository_set(
273273
iso_date (str, optional): The date of the tool. Defaults to None.
274274
rustfmt_version (str, optional): The version of rustfmt to be associated with the
275275
toolchain. Defaults to None.
276-
edition (str, optional): The rust edition to be used by default (2015 (if None) or 2018).
276+
edition (str, optional): The rust edition to be used by default (2015, 2018 (if None), or 2021).
277277
dev_components (bool, optional): Whether to download the rustc-dev components.
278278
Requires version to be "nightly". Defaults to False.
279279
sha256s (str, optional): A dict associating tool subdirectories to sha256 hashes. See

test/conflicting_deps/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package(default_visibility = ["//visibility:public"])
99
rust_library(
1010
name = "conflicting_deps",
1111
srcs = ["lib.rs"],
12+
edition = "2015",
1213
deps = [
1314
"//test/conflicting_deps/first_crate:example_name_conflict",
1415
],

test/conflicting_deps/first_crate/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package(default_visibility = ["//visibility:public"])
88
rust_library(
99
name = "example_name_conflict",
1010
srcs = ["lib.rs"],
11+
edition = "2015",
1112
deps = [
1213
"//test/conflicting_deps/second_crate:example_name_conflict",
1314
],

test/conflicting_deps/second_crate/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@ package(default_visibility = ["//visibility:public"])
88
rust_library(
99
name = "example_name_conflict",
1010
srcs = ["lib.rs"],
11+
edition = "2015",
1112
deps = [],
1213
)

test/deps.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ load("@rules_rust//rust:rust.bzl", "rust_library")
1010
rust_library(
1111
name = "libc",
1212
srcs = glob(["src/**/*.rs"]),
13+
edition = "2015",
1314
visibility = ["//visibility:public"],
1415
)
1516
"""

0 commit comments

Comments
 (0)