Skip to content

Commit f8de427

Browse files
Fix lints in op-codegen
Fixes lints "renamed_and_removed_lints", "clippy::unnecessary_to_owned", "clippy::manual_inspect", "ambiguous_glob_reexports".
1 parent c1db4b7 commit f8de427

File tree

11 files changed

+25
-40
lines changed

11 files changed

+25
-40
lines changed

tensorflow-op-codegen/src/bin/eager.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use std::io::Write;
1010
use std::path::Path;
1111
use std::result::Result;
1212
use tensorflow_op_codegen::parser;
13-
use tensorflow_op_codegen::protos::OpDef;
13+
use tensorflow_op_codegen::protos::op_def::OpDef;
1414

1515
use ::protobuf::ProtobufEnum;
16-
use tensorflow_op_codegen::protos::AttrValue_oneof_value;
17-
use tensorflow_op_codegen::protos::OpDef_ArgDef;
16+
use tensorflow_op_codegen::protos::attr_value::AttrValue_oneof_value;
17+
use tensorflow_op_codegen::protos::op_def::OpDef_ArgDef;
1818

1919
#[derive(Clone)]
2020
struct Attr {
@@ -337,7 +337,7 @@ fn define_op<W: Write>(
337337
let mut attr_escaper = Escaper::new(keywords);
338338
for attr in op.attr.iter() {
339339
// skip if the attr is for type annotation
340-
if skip_attrs.contains(&attr.get_name().to_string()) {
340+
if skip_attrs.contains(attr.get_name()) {
341341
continue;
342342
}
343343

@@ -637,14 +637,13 @@ fn main() -> Result<(), Box<dyn Error>> {
637637
.to_str()
638638
.ok_or("Unable to format path for tensorflow folder")?,
639639
)?;
640-
let ops = parser::parse(&ops_bytes).map_err(|e| {
640+
let ops = parser::parse(&ops_bytes).inspect_err(|e| {
641641
println!("Parse error at {:?}", e.pos);
642642
if let Some(p) = &e.pos {
643643
let input = String::from_utf8_lossy(&ops_bytes);
644644
println!("Previous: {}", &input[0..*p]);
645645
println!("Next: {}", &input[*p..]);
646646
}
647-
e
648647
})?;
649648
let keywords: HashSet<String> = [
650649
"abstract",

tensorflow-op-codegen/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use std::io::Write;
1212
use std::path::Path;
1313
use std::result::Result;
1414
use tensorflow_op_codegen::parser;
15-
use tensorflow_op_codegen::protos::OpDef;
15+
use tensorflow_op_codegen::protos::op_def::OpDef;
1616

1717
#[derive(Clone)]
1818
struct Attr {

tensorflow-op-codegen/src/parser.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
// currently implemented directly with nom to parse the text proto, but ideally this would use a
33
// proto library with support for parsing text protos.
44

5-
use crate::protos::AttrValue;
6-
use crate::protos::AttrValue_ListValue;
7-
use crate::protos::DataType;
8-
use crate::protos::FullTypeDef;
9-
use crate::protos::FullTypeId;
10-
use crate::protos::OpDef;
11-
use crate::protos::OpDef_ArgDef;
12-
use crate::protos::OpDef_AttrDef;
13-
use crate::protos::OpDeprecation;
14-
use crate::protos::TensorProto;
15-
use crate::protos::TensorShapeProto;
16-
use crate::protos::TensorShapeProto_Dim;
5+
use crate::protos::attr_value::AttrValue;
6+
use crate::protos::attr_value::AttrValue_ListValue;
7+
use crate::protos::full_type::FullTypeDef;
8+
use crate::protos::full_type::FullTypeId;
9+
use crate::protos::op_def::OpDef;
10+
use crate::protos::op_def::OpDef_ArgDef;
11+
use crate::protos::op_def::OpDef_AttrDef;
12+
use crate::protos::op_def::OpDeprecation;
13+
use crate::protos::tensor::TensorProto;
14+
use crate::protos::tensor_shape::TensorShapeProto;
15+
use crate::protos::tensor_shape::TensorShapeProto_Dim;
16+
use crate::protos::types::DataType;
1717
use nom::branch::alt;
1818
use nom::bytes::complete::tag;
1919
use nom::character::complete::anychar;

tensorflow-op-codegen/src/protos/attr_value.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![allow(unused_attributes)]
99
#![cfg_attr(rustfmt, rustfmt::skip)]
1010

11-
#![allow(box_pointers)]
1211
#![allow(dead_code)]
1312
#![allow(missing_docs)]
1413
#![allow(non_camel_case_types)]

tensorflow-op-codegen/src/protos/full_type.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![allow(unused_attributes)]
99
#![cfg_attr(rustfmt, rustfmt::skip)]
1010

11-
#![allow(box_pointers)]
1211
#![allow(dead_code)]
1312
#![allow(missing_docs)]
1413
#![allow(non_camel_case_types)]
Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
mod attr_value;
2-
pub use attr_value::*;
1+
pub mod attr_value;
32

4-
mod full_type;
5-
pub use full_type::*;
3+
pub mod full_type;
64

7-
mod op_def;
8-
pub use op_def::*;
5+
pub mod op_def;
96

10-
mod resource_handle;
11-
pub use resource_handle::*;
7+
pub mod resource_handle;
128

13-
mod tensor;
14-
pub use tensor::*;
9+
pub mod tensor;
1510

16-
mod tensor_shape;
17-
pub use tensor_shape::*;
11+
pub mod tensor_shape;
1812

19-
mod types;
20-
pub use types::*;
13+
pub mod types;

tensorflow-op-codegen/src/protos/op_def.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![allow(unused_attributes)]
99
#![cfg_attr(rustfmt, rustfmt::skip)]
1010

11-
#![allow(box_pointers)]
1211
#![allow(dead_code)]
1312
#![allow(missing_docs)]
1413
#![allow(non_camel_case_types)]

tensorflow-op-codegen/src/protos/resource_handle.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![allow(unused_attributes)]
99
#![cfg_attr(rustfmt, rustfmt::skip)]
1010

11-
#![allow(box_pointers)]
1211
#![allow(dead_code)]
1312
#![allow(missing_docs)]
1413
#![allow(non_camel_case_types)]

tensorflow-op-codegen/src/protos/tensor.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![allow(unused_attributes)]
99
#![cfg_attr(rustfmt, rustfmt::skip)]
1010

11-
#![allow(box_pointers)]
1211
#![allow(dead_code)]
1312
#![allow(missing_docs)]
1413
#![allow(non_camel_case_types)]

tensorflow-op-codegen/src/protos/tensor_shape.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![allow(unused_attributes)]
99
#![cfg_attr(rustfmt, rustfmt::skip)]
1010

11-
#![allow(box_pointers)]
1211
#![allow(dead_code)]
1312
#![allow(missing_docs)]
1413
#![allow(non_camel_case_types)]

0 commit comments

Comments
 (0)