From e09caa6a1fb3bbc813871b952171c91c237f8291 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 10 Apr 2022 18:06:09 -0700 Subject: [PATCH] Enforce edition on all Bazel targets --- BUILD | 5 +++++ WORKSPACE | 5 +---- demo/BUILD | 1 + tests/BUILD | 2 ++ third-party/BUILD | 19 +++++++++++++++++++ tools/bazel/third_party.bzl | 12 ++++++------ 6 files changed, 34 insertions(+), 10 deletions(-) diff --git a/BUILD b/BUILD index 43a1a5872..4a46cb530 100644 --- a/BUILD +++ b/BUILD @@ -8,6 +8,7 @@ rust_library( "alloc", "std", ], + edition = "2018", proc_macro_deps = [ ":cxxbridge-macro", ], @@ -19,6 +20,7 @@ rust_binary( name = "codegen", srcs = glob(["gen/cmd/src/**/*.rs"]), data = ["gen/cmd/src/gen/include/cxx.h"], + edition = "2018", visibility = ["//visibility:public"], deps = [ "//third-party:clap", @@ -46,6 +48,7 @@ cc_library( rust_proc_macro( name = "cxxbridge-macro", srcs = glob(["macro/src/**"]), + edition = "2018", deps = [ "//third-party:proc-macro2", "//third-party:quote", @@ -57,6 +60,7 @@ rust_library( name = "build", srcs = glob(["gen/build/src/**/*.rs"]), data = ["gen/build/src/gen/include/cxx.h"], + edition = "2018", visibility = ["//visibility:public"], deps = [ "//third-party:cc", @@ -73,6 +77,7 @@ rust_library( name = "lib", srcs = glob(["gen/lib/src/**/*.rs"]), data = ["gen/lib/src/gen/include/cxx.h"], + edition = "2018", visibility = ["//visibility:public"], deps = [ "//third-party:cc", diff --git a/WORKSPACE b/WORKSPACE index fba62aa36..9ca4a43dc 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -16,10 +16,7 @@ load("@rules_rust//rust:repositories.bzl", "rust_repositories") RUST_VERSION = "1.57.0" -rust_repositories( - edition = "2018", - version = RUST_VERSION, -) +rust_repositories(version = RUST_VERSION) load("//tools/bazel:vendor.bzl", "vendor") diff --git a/demo/BUILD b/demo/BUILD index 0c940d134..3f598fe25 100644 --- a/demo/BUILD +++ b/demo/BUILD @@ -5,6 +5,7 @@ load("//tools/bazel:rust_cxx_bridge.bzl", "rust_cxx_bridge") rust_binary( name = "demo", srcs = glob(["src/**/*.rs"]), + edition = "2018", deps = [ ":blobstore-sys", ":bridge", diff --git a/tests/BUILD b/tests/BUILD index 4803e13b4..3c25d9633 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -6,6 +6,7 @@ rust_test( name = "test", size = "small", srcs = ["test.rs"], + edition = "2018", deps = [ ":cxx_test_suite", "//:cxx", @@ -19,6 +20,7 @@ rust_library( "ffi/lib.rs", "ffi/module.rs", ], + edition = "2018", deps = [ ":impl", "//:cxx", diff --git a/third-party/BUILD b/third-party/BUILD index e56be365d..dfae99759 100644 --- a/third-party/BUILD +++ b/third-party/BUILD @@ -8,11 +8,13 @@ load( rust_library( name = "bitflags", srcs = glob(["vendor/bitflags-1.3.2/src/**"]), + edition = "2018", ) rust_library( name = "cc", srcs = glob(["vendor/cc-1.0.73/src/**"]), + edition = "2018", visibility = ["//visibility:public"], ) @@ -20,6 +22,7 @@ rust_library( name = "clap", srcs = glob(["vendor/clap-3.1.6/src/**"]), crate_features = ["std"], + edition = "2018", visibility = ["//visibility:public"], deps = [ ":bitflags", @@ -32,6 +35,7 @@ rust_library( rust_library( name = "codespan-reporting", srcs = glob(["vendor/codespan-reporting-0.11.1/src/**"]), + edition = "2018", visibility = ["//visibility:public"], deps = [ ":termcolor", @@ -43,12 +47,14 @@ rust_library( name = "hashbrown", srcs = glob(["vendor/hashbrown-0.11.2/src/**"]), crate_features = ["raw"], + edition = "2018", ) rust_library( name = "indexmap", srcs = glob(["vendor/indexmap-1.8.0/src/**"]), crate_features = ["std"], + edition = "2018", rustc_flags = ["--cfg=has_std"], deps = [":hashbrown"], ) @@ -57,6 +63,7 @@ rust_library( name = "memchr", srcs = glob(["vendor/memchr-2.4.1/src/**/*.rs"]), crate_features = ["std"], + edition = "2018", ) rust_library( @@ -66,6 +73,7 @@ rust_library( "alloc", "std", ], + edition = "2018", visibility = ["//visibility:public"], ) @@ -76,6 +84,7 @@ rust_library( "memchr", "raw_os_str", ], + edition = "2018", deps = [":memchr"], ) @@ -86,6 +95,7 @@ rust_library( "proc-macro", "span-locations", ], + edition = "2018", visibility = ["//visibility:public"], deps = [ ":proc-macro2@build", @@ -101,12 +111,14 @@ cargo_build_script( "span-locations", ], crate_name = "build", + edition = "2018", ) rust_library( name = "quote", srcs = glob(["vendor/quote-1.0.15/src/**"]), crate_features = ["proc-macro"], + edition = "2018", visibility = ["//visibility:public"], deps = [":proc-macro2"], ) @@ -114,6 +126,7 @@ rust_library( rust_library( name = "scratch", srcs = glob(["vendor/scratch-1.0.1/src/**"]), + edition = "2018", rustc_env = {"OUT_DIR": ""}, visibility = ["//visibility:public"], ) @@ -129,6 +142,7 @@ rust_library( "printing", "proc-macro", ], + edition = "2018", visibility = ["//visibility:public"], deps = [ ":proc-macro2", @@ -150,25 +164,30 @@ cargo_build_script( "proc-macro", ], crate_name = "build", + edition = "2018", ) rust_library( name = "termcolor", srcs = glob(["vendor/termcolor-1.1.3/src/**"]), + edition = "2018", ) rust_library( name = "textwrap", srcs = glob(["vendor/textwrap-0.15.0/src/**"]), + edition = "2018", deps = [":unicode-width"], ) rust_library( name = "unicode-width", srcs = glob(["vendor/unicode-width-0.1.9/src/**"]), + edition = "2018", ) rust_library( name = "unicode-xid", srcs = glob(["vendor/unicode-xid-0.2.2/src/**"]), + edition = "2018", ) diff --git a/tools/bazel/third_party.bzl b/tools/bazel/third_party.bzl index 5b2ec3fe7..d1f8b378a 100644 --- a/tools/bazel/third_party.bzl +++ b/tools/bazel/third_party.bzl @@ -5,14 +5,14 @@ load("@third-party//:vendor.bzl", "vendored") def third_party_glob(include): return vendored and native.glob(include) -def third_party_cargo_build_script(rustc_flags = [], **kwargs): +def third_party_cargo_build_script(edition, rustc_flags = [], **kwargs): rustc_flags = rustc_flags + ["--cap-lints=allow"] - cargo_build_script(rustc_flags = rustc_flags, **kwargs) + cargo_build_script(edition = edition, rustc_flags = rustc_flags, **kwargs) -def third_party_rust_binary(rustc_flags = [], **kwargs): +def third_party_rust_binary(edition, rustc_flags = [], **kwargs): rustc_flags = rustc_flags + ["--cap-lints=allow"] - rust_binary(rustc_flags = rustc_flags, **kwargs) + rust_binary(edition = edition, rustc_flags = rustc_flags, **kwargs) -def third_party_rust_library(rustc_flags = [], **kwargs): +def third_party_rust_library(edition, rustc_flags = [], **kwargs): rustc_flags = rustc_flags + ["--cap-lints=allow"] - rust_library(rustc_flags = rustc_flags, **kwargs) + rust_library(edition = edition, rustc_flags = rustc_flags, **kwargs)