Merge "Update protobuf-codegen to 2.27.1" am: 78338078b5 am: ad6438f959 am: eef6b8189c

Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/protobuf-codegen/+/2005934

Change-Id: Ib85dd35b8a7ab24c10603875415cc95ff7f8a38a
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 051cfa6..8ec5394 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,5 +1,6 @@
 {
   "git": {
-    "sha1": "d65abd3c6cee1dacef1448146b488ee168492a7d"
-  }
-}
+    "sha1": "ec31ce829473039ac598ca6fdcb245cbd6fa82ba"
+  },
+  "path_in_vcs": "protobuf-codegen"
+}
\ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 0661355..dd251e9 100644
--- a/Android.bp
+++ b/Android.bp
@@ -24,7 +24,7 @@
     name: "libprotobuf_codegen",
     crate_name: "protobuf_codegen",
     cargo_env_compat: true,
-    cargo_pkg_version: "2.25.1",
+    cargo_pkg_version: "2.27.1",
     srcs: ["src/lib.rs"],
     edition: "2015",
     rustlibs: [
@@ -36,7 +36,7 @@
     name: "protobuf-codegen_test_src_lib",
     crate_name: "protobuf_codegen",
     cargo_env_compat: true,
-    cargo_pkg_version: "2.25.1",
+    cargo_pkg_version: "2.27.1",
     srcs: ["src/lib.rs"],
     test_suites: ["general-tests"],
     auto_gen_config: true,
@@ -53,7 +53,7 @@
     name: "protoc-gen-rust",
     crate_name: "protoc_gen_rust",
     cargo_env_compat: true,
-    cargo_pkg_version: "2.25.1",
+    cargo_pkg_version: "2.27.1",
     srcs: ["src/bin/protoc-gen-rust.rs"],
     edition: "2015",
     rustlibs: [
diff --git a/Cargo.lock b/Cargo.lock
index 23a2ce0..e9b0703 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4,13 +4,13 @@
 
 [[package]]
 name = "protobuf"
-version = "2.25.1"
+version = "2.27.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "23129d50f2c9355ced935fce8a08bd706ee2e7ce2b3b33bf61dace0e379ac63a"
+checksum = "cf7e6d18738ecd0902d30d1ad232c9125985a3422929b16c65517b38adc14f96"
 
 [[package]]
 name = "protobuf-codegen"
-version = "2.25.1"
+version = "2.27.1"
 dependencies = [
  "protobuf",
 ]
diff --git a/Cargo.toml b/Cargo.toml
index 9221304..ca327e2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,12 +11,19 @@
 
 [package]
 name = "protobuf-codegen"
-version = "2.25.1"
+version = "2.27.1"
 authors = ["Stepan Koltsov <stepan.koltsov@gmail.com>"]
-description = "Code generator for rust-protobuf.\n\nIncludes a library and `protoc-gen-rust` binary.\n\nSee `protoc-rust` and `protobuf-codegen-pure` crates.\n"
+description = """
+Code generator for rust-protobuf.
+
+Includes a library and `protoc-gen-rust` binary.
+
+See `protoc-rust` and `protobuf-codegen-pure` crates.
+"""
 homepage = "https://github.com/stepancheg/rust-protobuf/"
 license = "MIT"
 repository = "https://github.com/stepancheg/rust-protobuf/"
+
 [package.metadata.docs.rs]
 all-features = true
 
@@ -32,5 +39,6 @@
 name = "protobuf-bin-gen-rust-do-not-use"
 path = "src/bin/protobuf-bin-gen-rust-do-not-use.rs"
 test = false
+
 [dependencies.protobuf]
-version = "=2.25.1"
+version = "=2.27.1"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index c223967..3400e66 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
 [package]
 name = "protobuf-codegen"
-version = "2.25.1"
+version = "2.27.1"
 authors = ["Stepan Koltsov <stepan.koltsov@gmail.com>"]
 license = "MIT"
 homepage = "https://github.com/stepancheg/rust-protobuf/"
@@ -17,7 +17,7 @@
 bench = false
 
 [dependencies]
-protobuf = { path = "../protobuf", version = "=2.25.1" }
+protobuf = { path = "../protobuf", version = "=2.27.1" }
 
 [[bin]]
 
diff --git a/METADATA b/METADATA
index 5ebf251..4593845 100644
--- a/METADATA
+++ b/METADATA
@@ -7,13 +7,13 @@
   }
   url {
     type: ARCHIVE
-    value: "https://static.crates.io/crates/protobuf-codegen/protobuf-codegen-2.25.1.crate"
+    value: "https://static.crates.io/crates/protobuf-codegen/protobuf-codegen-2.27.1.crate"
   }
-  version: "2.25.1"
+  version: "2.27.1"
   license_type: NOTICE
   last_upgrade_date {
-    year: 2021
-    month: 9
-    day: 22
+    year: 2022
+    month: 3
+    day: 1
   }
 }
diff --git a/README.md b/README.md
index 5b654ef..2ab7e05 100644
--- a/README.md
+++ b/README.md
@@ -1,35 +1,49 @@
-# protobuf-codegen
+<!-- cargo-sync-readme start -->
 
-This crate contains protobuf code generator and a `protoc-gen-rust` `protoc` plugin.
+# Protobuf code generator
 
-## protoc-gen-rust
+This crate contains protobuf code generator implementation
+and a `protoc-gen-rust` `protoc` plugin.
 
-`protoc-gen-rust` implements standard protobuf `protoc` plugin conventions.
+This crate:
+* provides `protoc-gen-rust` plugin for `protoc` command
+* implement protobuf codegen
 
-Probably you do not want to use it directly in Rust environment, there are easier to use alternatives:
+This crate is not meant to be used directly, in fact, it does not provide any public API
+(except for `protoc-gen-rust` binary).
 
-* [protoc-rust crate](https://github.com/stepancheg/rust-protobuf/tree/master/protoc-rust)
-  which can be invoked programmatically from `build.rs` of your project
-  which requires only `protoc` in `$PATH` but not `protoc-gen-rust`.
-* [protobuf-codegen-pure crate](https://github.com/stepancheg/rust-protobuf/tree/master/protobuf-codegen-pure)
-  which behaves like protoc-rust, but does not depend on `protoc` binary
+Code can be generated with either:
+* `protoc-gen-rust` plugin for `protoc` or
+* [`protoc-rust`](https://docs.rs/protoc) crate
+  (code generator which depends on `protoc` binary for parsing of `.proto` files)
+* [`protobuf-codegen-pure`](https://docs.rs/protobuf-codegen-pure) crate,
+  similar API to `protoc-rust`, but uses pure rust parser of `.proto` files.
 
-## But if you really want to use that plugin, here's the instruction
+# `protoc-gen-rust` plugin for `protoc`
+
+When non-cargo build system is used, consider using standard protobuf code generation pattern:
+`protoc` command does all the work of handling paths and parsing `.proto` files.
+When `protoc` is invoked with `--rust_out=` option, it invokes `protoc-gen-rust` plugin.
+provided by this crate.
+
+When building with cargo, consider using `protoc-rust` or `protobuf-codegen-pure` crates.
+
+## How to use `protoc-gen-rust` if you have to
 
 (Note `protoc` can be invoked programmatically with
-[protoc crate](https://github.com/stepancheg/rust-protobuf/tree/master/protoc/))
+[protoc crate](https://docs.rs/protoc))
 
 0) Install protobuf for `protoc` binary.
 
 On OS X [Homebrew](https://github.com/Homebrew/brew) can be used:
 
-```
+```sh
 brew install protobuf
 ```
 
 On Ubuntu, `protobuf-compiler` package can be installed:
 
-```
+```sh
 apt-get install protobuf-compiler
 ```
 
@@ -44,14 +58,23 @@
 
 If you installed it with cargo, it should be
 
-```
+```sh
 PATH="$HOME/.cargo/bin:$PATH"
 ```
 
 3) Generate .rs files:
 
-```
+```sh
 protoc --rust_out . foo.proto
 ```
 
 This will generate .rs files in current directory.
+
+# Version 2
+
+This is documentation for version 2 of the crate.
+
+[Version 3 of the crate](https://docs.rs/protobuf-codegen/%3E=3.0.0-alpha)
+(currently in development) encapsulates both `protoc` and pure codegens in this crate.
+
+<!-- cargo-sync-readme end -->
diff --git a/src/code_writer.rs b/src/code_writer.rs
index f6d4c07..50eaeb8 100644
--- a/src/code_writer.rs
+++ b/src/code_writer.rs
@@ -1,8 +1,9 @@
 // TODO: used by grpc-rust, should move it into separate crate.
 #![doc(hidden)]
 
-use inside::protobuf_crate_path;
 use std::io::Write;
+
+use inside::protobuf_crate_path;
 use Customize;
 
 /// Field visibility.
diff --git a/src/customize.rs b/src/customize.rs
index f8e73aa..b3415ab 100644
--- a/src/customize.rs
+++ b/src/customize.rs
@@ -1,3 +1,4 @@
+use protobuf::descriptor::EnumOptions;
 use protobuf::descriptor::FieldOptions;
 use protobuf::descriptor::FileOptions;
 use protobuf::descriptor::MessageOptions;
@@ -20,6 +21,8 @@
     pub serde_derive: Option<bool>,
     /// When `serde_derive` is set, serde annotations will be guarded with `#[cfg(cfg, ...)]`.
     pub serde_derive_cfg: Option<String>,
+    /// When `serde_derive` is set, use attribute rename_all
+    pub serde_rename_all: Option<String>,
     /// Enable lite runtime
     pub lite_runtime: Option<bool>,
     /// Generate `mod.rs` in the output directory.
@@ -71,6 +74,9 @@
         if let Some(ref v) = that.serde_derive_cfg {
             self.serde_derive_cfg = Some(v.clone());
         }
+        if let Some(ref v) = that.serde_rename_all {
+            self.serde_rename_all = Some(v.clone());
+        }
         if let Some(v) = that.lite_runtime {
             self.lite_runtime = Some(v);
         }
@@ -120,6 +126,8 @@
                 r.serde_derive = Some(parse_bool(v)?);
             } else if n == "serde_derive_cfg" {
                 r.serde_derive_cfg = Some(v.to_owned());
+            } else if n == "serde_rename_all" {
+                r.serde_rename_all = Some(v.to_owned());
             } else if n == "lite_runtime" {
                 r.lite_runtime = Some(parse_bool(v)?);
             } else if n == "gen_mod_rs" {
@@ -147,6 +155,7 @@
     let lite_runtime = None;
     let gen_mod_rs = None;
     let inside_protobuf = None;
+    let serde_rename_all = None;
     Customize {
         expose_oneof,
         expose_fields,
@@ -155,6 +164,7 @@
         carllerche_bytes_for_string,
         serde_derive,
         serde_derive_cfg,
+        serde_rename_all,
         lite_runtime,
         gen_mod_rs,
         inside_protobuf,
@@ -162,6 +172,13 @@
     }
 }
 
+pub fn customize_from_rustproto_for_enum(source: &EnumOptions) -> Customize {
+    let serde_rename_all = rustproto::exts::serde_rename_all.get(source);
+    let mut r = Customize::default();
+    r.serde_rename_all = serde_rename_all;
+    return r;
+}
+
 pub fn customize_from_rustproto_for_field(source: &FieldOptions) -> Customize {
     let expose_oneof = None;
     let expose_fields = rustproto::exts::expose_fields_field.get(source);
@@ -169,6 +186,7 @@
     let carllerche_bytes_for_bytes = rustproto::exts::carllerche_bytes_for_bytes_field.get(source);
     let carllerche_bytes_for_string =
         rustproto::exts::carllerche_bytes_for_string_field.get(source);
+    let serde_rename_all = None;
     let serde_derive = None;
     let serde_derive_cfg = None;
     let lite_runtime = None;
@@ -182,6 +200,7 @@
         carllerche_bytes_for_string,
         serde_derive,
         serde_derive_cfg,
+        serde_rename_all,
         lite_runtime,
         gen_mod_rs,
         inside_protobuf,
@@ -200,6 +219,7 @@
     let lite_runtime = rustproto::exts::lite_runtime_all.get(source);
     let gen_mod_rs = None;
     let inside_protobuf = None;
+    let serde_rename_all = None;
     Customize {
         expose_oneof,
         expose_fields,
@@ -208,6 +228,7 @@
         carllerche_bytes_for_string,
         serde_derive,
         serde_derive_cfg,
+        serde_rename_all,
         lite_runtime,
         inside_protobuf,
         gen_mod_rs,
diff --git a/src/enums.rs b/src/enums.rs
index c2ce241..ec3444e 100644
--- a/src/enums.rs
+++ b/src/enums.rs
@@ -1,17 +1,18 @@
 use std::collections::HashSet;
 
-use protobuf::descriptor::*;
-
-use super::code_writer::*;
-use super::customize::Customize;
 use file_descriptor::file_descriptor_proto_expr;
 use inside::protobuf_crate_path;
+use protobuf::descriptor::*;
 use protobuf_name::ProtobufAbsolutePath;
 use rust_types_values::type_name_to_rust_relative;
 use scope::EnumWithScope;
 use scope::RootScope;
 use scope::WithScope;
 use serde;
+use CodeWriter;
+
+use crate::customize::customize_from_rustproto_for_enum;
+use crate::Customize;
 
 #[derive(Clone)]
 pub struct EnumValueGen {
@@ -90,11 +91,16 @@
                 == FileOptions_OptimizeMode::LITE_RUNTIME
         });
 
+        let mut customize = customize.clone();
+        customize.update_with(&customize_from_rustproto_for_enum(
+            enum_with_scope.en.options.as_ref().unwrap_or_default(),
+        ));
+
         EnumGen {
             enum_with_scope,
             type_name: rust_name,
             lite_runtime,
-            customize: customize.clone(),
+            customize,
         }
     }
 
@@ -175,6 +181,10 @@
             &self.customize,
             "derive(::serde::Serialize, ::serde::Deserialize)",
         );
+        if let Some(ref ren) = self.customize.serde_rename_all {
+            let attr = format!("serde(rename_all = \"{}\")", ren);
+            serde::write_serde_attr(w, &self.customize, &attr);
+        }
         let ref type_name = self.type_name;
         w.expr_block(&format!("pub enum {}", type_name), |w| {
             for value in self.values_all() {
diff --git a/src/extensions.rs b/src/extensions.rs
index 0740fdb..def5948 100644
--- a/src/extensions.rs
+++ b/src/extensions.rs
@@ -1,5 +1,3 @@
-use super::code_writer::CodeWriter;
-use super::rust_types_values::*;
 use field::rust_field_name_for_protobuf_field_name;
 use inside::protobuf_crate_path;
 use protobuf::descriptor::*;
@@ -7,6 +5,9 @@
 use scope::RootScope;
 use Customize;
 
+use super::code_writer::CodeWriter;
+use super::rust_types_values::*;
+
 struct ExtGen<'a> {
     file: &'a FileDescriptorProto,
     root_scope: &'a RootScope<'a>,
diff --git a/src/field/mod.rs b/src/field/mod.rs
index 842f01f..e4be944 100644
--- a/src/field/mod.rs
+++ b/src/field/mod.rs
@@ -1,20 +1,14 @@
+use std::marker;
+
+use float;
+use inside::protobuf_crate_path;
+use message::RustTypeMessage;
+use oneof::OneofField;
 use protobuf::descriptor::*;
 use protobuf::rt;
 use protobuf::rust;
 use protobuf::text_format;
 use protobuf::wire_format;
-
-use super::code_writer::CodeWriter;
-use super::enums::*;
-use super::rust_types_values::*;
-
-use super::customize::customize_from_rustproto_for_field;
-use super::customize::Customize;
-use oneof::OneofField;
-
-use float;
-use inside::protobuf_crate_path;
-use message::RustTypeMessage;
 use protobuf_name::ProtobufAbsolutePath;
 use rust_name::RustIdent;
 use rust_name::RustIdentWithPath;
@@ -22,9 +16,14 @@
 use scope::MessageOrEnumWithScope;
 use scope::RootScope;
 use scope::WithScope;
-use std::marker;
 use syntax::Syntax;
 
+use super::code_writer::CodeWriter;
+use super::customize::customize_from_rustproto_for_field;
+use super::customize::Customize;
+use super::enums::*;
+use super::rust_types_values::*;
+
 fn type_is_copy(field_type: FieldDescriptorProto_Type) -> bool {
     match field_type {
         FieldDescriptorProto_Type::TYPE_MESSAGE
@@ -189,7 +188,7 @@
 
 #[derive(Clone)]
 pub struct MapField<'a> {
-    name: String,
+    _name: String,
     key: FieldElem<'a>,
     value: FieldElem<'a>,
 }
@@ -428,7 +427,7 @@
 
 #[derive(Clone)]
 pub(crate) struct FieldGen<'a> {
-    root_scope: &'a RootScope<'a>,
+    _root_scope: &'a RootScope<'a>,
     syntax: Syntax,
     pub proto_field: FieldWithContext<'a>,
     // field name in generated code
@@ -472,7 +471,7 @@
                 // map field
                 (FieldElem::Message(name, _, Some(key_value), _), true) => {
                     FieldKind::Map(MapField {
-                        name: name,
+                        _name: name,
                         key: key_value.0.clone(),
                         value: key_value.1.clone(),
                     })
@@ -499,7 +498,7 @@
         };
 
         FieldGen {
-            root_scope,
+            _root_scope: root_scope,
             syntax: field.message.get_scope().file_scope.syntax(),
             rust_name: field.rust_name(),
             proto_type: field.field.get_field_type(),
diff --git a/src/lib.rs b/src/lib.rs
index 0a0316c..826e18b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,4 +1,7 @@
-//! This crate implement protobuf codegen.
+//! # Protobuf code generator
+//!
+//! This crate contains protobuf code generator implementation
+//! and a `protoc-gen-rust` `protoc` plugin.
 //!
 //! This crate:
 //! * provides `protoc-gen-rust` plugin for `protoc` command
@@ -8,11 +11,71 @@
 //! (except for `protoc-gen-rust` binary).
 //!
 //! Code can be generated with either:
-//! * `protoc-gen-rust` binary or
-//! * `protoc-rust` crate (codegen which depends on `protoc` binary for parsing)
-//! * `protobuf-codegen-pure` crate
+//! * `protoc-gen-rust` plugin for `protoc` or
+//! * [`protoc-rust`](https://docs.rs/protoc) crate
+//!   (code generator which depends on `protoc` binary for parsing of `.proto` files)
+//! * [`protobuf-codegen-pure`](https://docs.rs/protobuf-codegen-pure) crate,
+//!   similar API to `protoc-rust`, but uses pure rust parser of `.proto` files.
+//!
+//! # `protoc-gen-rust` plugin for `protoc`
+//!
+//! When non-cargo build system is used, consider using standard protobuf code generation pattern:
+//! `protoc` command does all the work of handling paths and parsing `.proto` files.
+//! When `protoc` is invoked with `--rust_out=` option, it invokes `protoc-gen-rust` plugin.
+//! provided by this crate.
+//!
+//! When building with cargo, consider using `protoc-rust` or `protobuf-codegen-pure` crates.
+//!
+//! ## How to use `protoc-gen-rust` if you have to
+//!
+//! (Note `protoc` can be invoked programmatically with
+//! [protoc crate](https://docs.rs/protoc))
+//!
+//! 0) Install protobuf for `protoc` binary.
+//!
+//! On OS X [Homebrew](https://github.com/Homebrew/brew) can be used:
+//!
+//! ```sh
+//! brew install protobuf
+//! ```
+//!
+//! On Ubuntu, `protobuf-compiler` package can be installed:
+//!
+//! ```sh
+//! apt-get install protobuf-compiler
+//! ```
+//!
+//! Protobuf is needed only for code generation, `rust-protobuf` runtime
+//! does not use `protobuf` library.
+//!
+//! 1) Install `protoc-gen-rust` program (which is `protoc` plugin)
+//!
+//! It can be installed either from source or with `cargo install protobuf` command.
+//!
+//! 2) Add `protoc-gen-rust` to $PATH
+//!
+//! If you installed it with cargo, it should be
+//!
+//! ```sh
+//! PATH="$HOME/.cargo/bin:$PATH"
+//! ```
+//!
+//! 3) Generate .rs files:
+//!
+//! ```sh
+//! protoc --rust_out . foo.proto
+//! ```
+//!
+//! This will generate .rs files in current directory.
+//!
+//! # Version 2
+//!
+//! This is documentation for version 2 of the crate.
+//!
+//! [Version 3 of the crate](https://docs.rs/protobuf-codegen/%3E=3.0.0-alpha)
+//! (currently in development) encapsulates both `protoc` and pure codegens in this crate.
 
-#![deny(broken_intra_doc_links)]
+#![deny(rustdoc::broken_intra_doc_links)]
 #![deny(missing_docs)]
 
 extern crate protobuf;
@@ -57,22 +120,21 @@
 
 pub mod code_writer;
 
-use self::code_writer::CodeWriter;
-use self::enums::*;
-use self::extensions::*;
-use self::message::*;
 use inside::protobuf_crate_path;
-use scope::FileScope;
-use scope::RootScope;
-
-use crate::file::proto_path_to_rust_mod;
-
 #[doc(hidden)]
 pub use protobuf_name::ProtobufAbsolutePath;
 #[doc(hidden)]
 pub use protobuf_name::ProtobufIdent;
 #[doc(hidden)]
 pub use protobuf_name::ProtobufRelativePath;
+use scope::FileScope;
+use scope::RootScope;
+
+use self::code_writer::CodeWriter;
+use self::enums::*;
+use self::extensions::*;
+use self::message::*;
+use crate::file::proto_path_to_rust_mod;
 
 fn escape_byte(s: &mut String, b: u8) {
     if b == b'\n' {
@@ -192,7 +254,7 @@
     {
         let mut w = CodeWriter::new(&mut v);
 
-        w.write_generated_by("rust-protobuf", "2.25.1");
+        w.write_generated_by("rust-protobuf", "2.27.1");
         w.write_line(&format!("//! Generated file from `{}`", file.get_name()));
         if customize.inside_protobuf != Some(true) {
             w.write_line("");
diff --git a/src/message.rs b/src/message.rs
index 6987ce7..fbe9ed4 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -1,9 +1,5 @@
-use super::code_writer::*;
-use super::customize::customize_from_rustproto_for_message;
-use super::customize::Customize;
-use super::enums::*;
-use super::field::*;
-use super::rust_types_values::*;
+use std::fmt;
+
 use file_descriptor::file_descriptor_proto_expr;
 use inside::protobuf_crate_path;
 use oneof::OneofGen;
@@ -15,7 +11,12 @@
 use scope::WithScope;
 use serde;
 
-use std::fmt;
+use super::code_writer::*;
+use super::customize::customize_from_rustproto_for_message;
+use super::customize::Customize;
+use super::enums::*;
+use super::field::*;
+use super::rust_types_values::*;
 
 /// Protobuf message Rust type name
 #[derive(Debug, Clone, PartialEq, Eq)]
diff --git a/src/oneof.rs b/src/oneof.rs
index e767709..44201ea 100644
--- a/src/oneof.rs
+++ b/src/oneof.rs
@@ -1,5 +1,7 @@
 //! Oneof-related codegen functions.
 
+use std::collections::HashSet;
+
 use code_writer::CodeWriter;
 use field::FieldElem;
 use field::FieldGen;
@@ -14,7 +16,6 @@
 use scope::RootScope;
 use scope::WithScope;
 use serde;
-use std::collections::HashSet;
 use Customize;
 
 // oneof one { ... }
@@ -78,12 +79,12 @@
 
 #[derive(Clone)]
 pub(crate) struct OneofVariantGen<'a> {
-    oneof: &'a OneofGen<'a>,
-    variant: OneofVariantWithContext<'a>,
+    _oneof: &'a OneofGen<'a>,
+    _variant: OneofVariantWithContext<'a>,
     oneof_field: OneofField<'a>,
     pub field: FieldGen<'a>,
     path: String,
-    customize: Customize,
+    _customize: Customize,
 }
 
 impl<'a> OneofVariantGen<'a> {
@@ -95,8 +96,8 @@
         customize: Customize,
     ) -> OneofVariantGen<'a> {
         OneofVariantGen {
-            oneof,
-            variant: variant.clone(),
+            _oneof: oneof,
+            _variant: variant.clone(),
             field: field.clone(),
             path: format!(
                 "{}::{}",
@@ -109,7 +110,7 @@
                 field.oneof().elem.clone(),
                 oneof.message.root_scope,
             ),
-            customize,
+            _customize: customize,
         }
     }
 
@@ -128,7 +129,6 @@
     message: &'a MessageGen<'a>,
     pub oneof: OneofWithContext<'a>,
     type_name: RustType,
-    lite_runtime: bool,
     customize: Customize,
 }
 
@@ -143,7 +143,6 @@
             message,
             oneof,
             type_name: RustType::Oneof(rust_name.to_string()),
-            lite_runtime: message.lite_runtime,
             customize: customize.clone(),
         }
     }
diff --git a/src/rust_types_values.rs b/src/rust_types_values.rs
index 9660062..e9b017d 100644
--- a/src/rust_types_values.rs
+++ b/src/rust_types_values.rs
@@ -1,6 +1,5 @@
 use std::cmp;
 
-use super::well_known_types::is_well_known_type_full;
 use inside::protobuf_crate_path;
 use message::RustTypeMessage;
 use protobuf::descriptor::*;
@@ -11,6 +10,8 @@
 use strx::capitalize;
 use Customize;
 
+use super::well_known_types::is_well_known_type_full;
+
 // Represent subset of rust types used in generated code
 #[derive(Debug, Clone, PartialEq, Eq)]
 pub(crate) enum RustType {
diff --git a/src/scope.rs b/src/scope.rs
index 87faf1f..5f92d08 100644
--- a/src/scope.rs
+++ b/src/scope.rs
@@ -1,3 +1,10 @@
+use protobuf::descriptor::DescriptorProto;
+use protobuf::descriptor::EnumDescriptorProto;
+use protobuf::descriptor::EnumValueDescriptorProto;
+use protobuf::descriptor::FieldDescriptorProto;
+use protobuf::descriptor::FileDescriptorProto;
+use protobuf::descriptor::OneofDescriptorProto;
+
 use crate::field::rust_field_name_for_protobuf_field_name;
 use crate::file::proto_path_to_rust_mod;
 use crate::protobuf_name::ProtobufAbsolutePath;
@@ -7,12 +14,6 @@
 use crate::rust_name::RustIdent;
 use crate::rust_name::RustIdentWithPath;
 use crate::syntax::Syntax;
-use protobuf::descriptor::DescriptorProto;
-use protobuf::descriptor::EnumDescriptorProto;
-use protobuf::descriptor::EnumValueDescriptorProto;
-use protobuf::descriptor::FieldDescriptorProto;
-use protobuf::descriptor::FileDescriptorProto;
-use protobuf::descriptor::OneofDescriptorProto;
 
 pub(crate) struct RootScope<'a> {
     pub file_descriptors: &'a [FileDescriptorProto],
@@ -395,7 +396,7 @@
             .get_value()
             .iter()
             .map(|v| EnumValueWithContext {
-                en: self.clone(),
+                _en: self.clone(),
                 proto: v,
             })
             .collect()
@@ -412,7 +413,7 @@
 
 #[derive(Clone, Debug)]
 pub(crate) struct EnumValueWithContext<'a> {
-    pub en: EnumWithScope<'a>,
+    _en: EnumWithScope<'a>,
     pub proto: &'a EnumValueDescriptorProto,
 }