Skip to content

Commit

Permalink
Fix panic warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
roignpar committed May 5, 2021
1 parent 5e1e70a commit 6dcb8a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/attrs/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub trait AttrGenerator {

fn parse_meta(&self, attr: &Attribute) -> Meta {
attr.parse_meta()
.unwrap_or_else(|e| panic!(error::unexpected(self.error_action_text(), e)))
.unwrap_or_else(|e| panic!("{}", error::unexpected(self.error_action_text(), e)))
}

fn generate(&self) -> Vec<Attribute> {
Expand Down Expand Up @@ -86,7 +86,7 @@ pub trait AttrGenerator {

Attribute::parse_outer
.parse2(attrs_tokens)
.unwrap_or_else(|e| panic!(error::unexpected(self.error_action_text(), e)))
.unwrap_or_else(|e| panic!("{}", error::unexpected(self.error_action_text(), e)))
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/attrs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ impl<'a> AttrGenerator for AttrGen<'a> {
doc = #d
};

Some(parse2(tokens).unwrap_or_else(|e| panic!(unexpected(self.error_action_text(), e))))
Some(
parse2(tokens)
.unwrap_or_else(|e| panic!("{}", unexpected(self.error_action_text(), e))),
)
} else {
None
}
Expand Down
8 changes: 6 additions & 2 deletions src/fields/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ pub fn generate(item: &ItemStruct, args: &Args) -> Fields {
Option<#ty>
};

field.ty = parse2(opt_type)
.unwrap_or_else(|e| panic!(unexpected(format!("generating {} fields", item_name), e)));
field.ty = parse2(opt_type).unwrap_or_else(|e| {
panic!(
"{}",
unexpected(format!("generating {} fields", item_name), e)
)
});
}

fields
Expand Down

0 comments on commit 6dcb8a3

Please sign in to comment.