summaryrefslogtreecommitdiff
path: root/src/idl_gen_rust.cpp
diff options
context:
space:
mode:
authorVladimir Glavnyy <31897320+vglavnyy@users.noreply.github.com>2019-07-02 01:38:21 +0700
committerWouter van Oortmerssen <aardappel@gmail.com>2019-07-01 11:38:21 -0700
commit7a63792929e2ab6edbbc2b6270a48c74e7022f96 (patch)
tree7701e36dfdaa27f591e439d2b1a62d1e9af9f2a2 /src/idl_gen_rust.cpp
parent7d7d796cd09dfaed3aed5cd1f973b86f8c2d79bb (diff)
downloadflatbuffers-7a63792929e2ab6edbbc2b6270a48c74e7022f96.tar.gz
flatbuffers-7a63792929e2ab6edbbc2b6270a48c74e7022f96.tar.bz2
flatbuffers-7a63792929e2ab6edbbc2b6270a48c74e7022f96.zip
Remove unused variables (#5382)
- Fix GenerateTextFromTable (aliasing typo) - Fix unused variable in idl_gen_dart.cpp - Fix std::string passing (should be non-const value or const-reference) - Remove unused variables
Diffstat (limited to 'src/idl_gen_rust.cpp')
-rw-r--r--src/idl_gen_rust.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp
index cdd5d843..409f7a11 100644
--- a/src/idl_gen_rust.cpp
+++ b/src/idl_gen_rust.cpp
@@ -449,7 +449,7 @@ class RustGenerator : public BaseGenerator {
std::stringstream stream;
stream << "::";
- for (auto d = dst->components.begin(); d != dst->components.end(); d++) {
+ for (auto d = dst->components.begin(); d != dst->components.end(); ++d) {
stream << MakeSnakeCase(*d) + "::";
}
return stream.str();
@@ -481,15 +481,15 @@ class RustGenerator : public BaseGenerator {
if (s == src->components.end()) { break; }
if (d == dst->components.end()) { break; }
if (*s != *d) { break; }
- s++;
- d++;
- i++;
+ ++s;
+ ++d;
+ ++i;
}
- for (; s != src->components.end(); s++) {
+ for (; s != src->components.end(); ++s) {
stream << "super::";
}
- for (; d != dst->components.end(); d++) {
+ for (; d != dst->components.end(); ++d) {
stream << MakeSnakeCase(*d) + "::";
}
return stream.str();
@@ -758,7 +758,7 @@ class RustGenerator : public BaseGenerator {
// the vtable, or
// 3) return a hardcoded value because the vtable field value is set to zero.
std::string TableBuilderArgsDefnType(const FieldDef &field,
- const std::string lifetime) {
+ const std::string &lifetime) {
const Type& type = field.value.type;
switch (GetFullType(type)) {
@@ -786,7 +786,6 @@ class RustGenerator : public BaseGenerator {
return typname;
}
case ftUnionValue: {
- const auto typname = WrapInNameSpace(*type.enum_def);
return "Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>";
}
@@ -836,10 +835,11 @@ class RustGenerator : public BaseGenerator {
return GetDefaultScalarValue(field);
}
std::string TableBuilderAddFuncDefaultValue(const FieldDef &field) {
+ // All branches of switch do the same action!
switch (GetFullType(field.value.type)) {
case ftUnionKey:
case ftEnumKey: {
- const std::string basetype = GetTypeBasic(field.value.type);
+ const std::string basetype = GetTypeBasic(field.value.type); //<- never used
return GetDefaultScalarValue(field);
}
@@ -848,7 +848,7 @@ class RustGenerator : public BaseGenerator {
}
std::string TableBuilderArgsAddFuncType(const FieldDef &field,
- const std::string lifetime) {
+ const std::string &lifetime) {
const Type& type = field.value.type;
switch (GetFullType(field.value.type)) {
@@ -883,7 +883,6 @@ class RustGenerator : public BaseGenerator {
", " + typname + ">>";
}
case ftVectorOfUnionValue: {
- const auto typname = WrapInNameSpace(*type.enum_def);
return "flatbuffers::WIPOffset<flatbuffers::Vector<" + lifetime + \
", flatbuffers::ForwardsUOffset<flatbuffers::Table<" + \
lifetime + ">>>";
@@ -916,7 +915,6 @@ class RustGenerator : public BaseGenerator {
return typname;
}
case ftUnionValue: {
- const auto typname = WrapInNameSpace(*type.enum_def);
return "flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>";
}
}
@@ -970,7 +968,7 @@ class RustGenerator : public BaseGenerator {
}
std::string GenTableAccessorFuncReturnType(const FieldDef &field,
- const std::string lifetime) {
+ const std::string &lifetime) {
const Type& type = field.value.type;
switch (GetFullType(field.value.type)) {
@@ -1041,8 +1039,8 @@ class RustGenerator : public BaseGenerator {
}
std::string GenTableAccessorFuncBody(const FieldDef &field,
- const std::string lifetime,
- const std::string offset_prefix) {
+ const std::string &lifetime,
+ const std::string &offset_prefix) {
const std::string offset_name = offset_prefix + "::" + \
GetFieldOffsetName(field);
const Type& type = field.value.type;
@@ -1072,7 +1070,7 @@ class RustGenerator : public BaseGenerator {
}
case ftUnionKey:
case ftEnumKey: {
- const auto underlying_typname = GetTypeBasic(type);
+ const auto underlying_typname = GetTypeBasic(type); //<- never used
const auto typname = WrapInNameSpace(*type.enum_def);
const auto default_value = GetDefaultScalarValue(field);
return "self._tab.get::<" + typname + ">(" + offset_name + \
@@ -1394,8 +1392,6 @@ class RustGenerator : public BaseGenerator {
const bool is_scalar = IsScalar(field.value.type.base_type);
std::string offset = GetFieldOffsetName(field);
- std::string name = Name(field);
- std::string value = GetDefaultScalarValue(field);
// Generate functions to add data, which take one of two forms.
//