Skip to content

Commit 7067c3a

Browse files
authored
make the changes suggested by the compiler to make the rust linter happy (#236)
1 parent 291af0b commit 7067c3a

13 files changed

Lines changed: 16 additions & 21 deletions

File tree

circ_fields/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ impl FieldV {
314314
let ptr: *const FullFieldV = self.0 as *const _;
315315
unsafe { &*ptr }
316316
}
317-
fn full_cow(&self) -> std::borrow::Cow<FullFieldV> {
317+
fn full_cow(&self) -> std::borrow::Cow<'_, FullFieldV> {
318318
if self.is_full() {
319319
std::borrow::Cow::Borrowed(self.full_ref())
320320
} else {

src/front/datalog/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<'ast> Gen<'ast> {
113113
)
114114
}
115115

116-
fn entry_rule(&mut self, name: &'ast str) -> Result<()> {
116+
fn entry_rule(&mut self, name: &'ast str) -> Result<'_, ()> {
117117
let rule = *self
118118
.rules
119119
.get(name)
@@ -291,7 +291,7 @@ impl<'ast> Gen<'ast> {
291291
}
292292

293293
// Begin prim-rec linting
294-
fn lint_rules(&mut self) -> Result<()> {
294+
fn lint_rules(&mut self) -> Result<'_, ()> {
295295
let rules: Vec<&'ast ast::Rule_> = self.rules.values().cloned().collect();
296296
let bug_if = rules.iter().try_fold(term::bool_lit(false), |x, rule| {
297297
let cond = self.lint_rule(rule)?;

src/front/datalog/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub mod ast {
2424
pub use pest::Span;
2525
use pest_ast::FromPest;
2626

27-
fn span_into_str(span: Span) -> &str {
27+
fn span_into_str(span: Span<'_>) -> &str {
2828
span.as_str()
2929
}
3030

@@ -534,7 +534,7 @@ pub mod ast {
534534
}
535535

536536
#[allow(clippy::result_large_err)]
537-
pub fn parse(file_string: &str) -> Result<ast::Program, Error<Rule>> {
537+
pub fn parse(file_string: &str) -> Result<ast::Program<'_>, Error<Rule>> {
538538
let mut pest_pairs = MyParser::parse(Rule::program, file_string)?;
539539
use from_pest::FromPest;
540540
Ok(ast::Program::from_pest(&mut pest_pairs).expect("bug in AST construction"))

src/front/zsharp/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl ZLoad {
106106
/// ## Returns
107107
///
108108
/// Returns a map from file paths to parsed files.
109-
pub fn load<P: AsRef<Path>>(&self, p: &P) -> HashMap<PathBuf, ast::File> {
109+
pub fn load<P: AsRef<Path>>(&self, p: &P) -> HashMap<PathBuf, ast::File<'_>> {
110110
self.recursive_load(p).unwrap()
111111
}
112112

src/front/zsharpcurly/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl ZLoad {
106106
/// ## Returns
107107
///
108108
/// Returns a map from file paths to parsed files.
109-
pub fn load<P: AsRef<Path>>(&self, p: &P) -> HashMap<PathBuf, ast::File> {
109+
pub fn load<P: AsRef<Path>>(&self, p: &P) -> HashMap<PathBuf, ast::File<'_>> {
110110
self.recursive_load(p).unwrap()
111111
}
112112

src/ir/term/bv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl BitVector {
253253

254254
impl Display for BitVector {
255255
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
256-
if self.width % 4 == 0 {
256+
if self.width.is_multiple_of(4) {
257257
write!(
258258
f,
259259
"#x{:0>width$}",

src/ir/term/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub struct IrWrapper<'a, T> {
228228
}
229229

230230
/// Wrap a reference for IR formatting. Uses [IrCfg::from_circ_cfg].
231-
pub fn wrap<T>(t: &T) -> IrWrapper<T> {
231+
pub fn wrap<T>(t: &T) -> IrWrapper<'_, T> {
232232
IrWrapper::new(t, IrCfg::from_circ_cfg())
233233
}
234234

src/ir/term/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ impl std::hash::Hash for Value {
819819
}
820820
}
821821

822-
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
822+
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, Default)]
823823
/// The "type" of an IR term
824824
pub enum Sort {
825825
/// bit-vectors of this width
@@ -833,6 +833,7 @@ pub enum Sort {
833833
/// prime field, integers mod FieldT.modulus()
834834
Field(FieldT),
835835
/// boolean
836+
#[default]
836837
Bool,
837838
/// Array from one sort to another, of fixed size.
838839
///
@@ -864,12 +865,6 @@ pub struct MapSort {
864865
pub val: Sort,
865866
}
866867

867-
impl Default for Sort {
868-
fn default() -> Self {
869-
Self::Bool
870-
}
871-
}
872-
873868
impl Sort {
874869
#[track_caller]
875870
/// Unwrap the bitsize of this bit-vector, panicking otherwise.

src/ir/term/text/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl Debug for TokTree<'_> {
125125
}
126126

127127
/// Parse a token tree.
128-
fn parse_tok_tree(bytes: &[u8]) -> TokTree {
128+
fn parse_tok_tree(bytes: &[u8]) -> TokTree<'_> {
129129
let mut stack: Vec<Vec<TokTree>> = vec![vec![]];
130130
let lex = Token::lexer(bytes).spanned();
131131
for (t, s) in lex {

third_party/ZoKrates/zokrates_parser/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use pest::Parser;
1212
#[grammar = "zokrates.pest"]
1313
struct ZoKratesParser;
1414

15-
pub fn parse(input: &str) -> Result<Pairs<Rule>, Error<Rule>> {
15+
pub fn parse(input: &str) -> Result<Pairs<'_, Rule>, Error<Rule>> {
1616
ZoKratesParser::parse(Rule::file, input)
1717
}
1818

0 commit comments

Comments
 (0)