Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
limuy2022 committed Mar 16, 2024
1 parent 9bf0e8b commit 64914e3
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl ValuePool {
ret.stringpool
.resize(self.const_strings.len(), "".to_string());
for i in &self.const_strings {
ret.stringpool[*i.1] = i.0.clone();
ret.stringpool[*i.1].clone_from(i.0);
}
ret
}
Expand Down Expand Up @@ -424,9 +424,9 @@ mod tests {
#[test]
fn test_file_read() {
let test_file_path = "tests/testdata/compiler/compiler1.txt";
let source = std::fs::read_to_string(test_file_path).expect("please run in root dir");
let source = fs::read_to_string(test_file_path).expect("please run in root dir");
let mut t =
FileSource::new(std::fs::File::open(test_file_path).expect("please run in root dir"));
FileSource::new(fs::File::open(test_file_path).expect("please run in root dir"));
let mut tmp: Vec<char> = vec![t.read(), t.read()];
tmp.reverse();
for i in &tmp {
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ impl<'a> AstBuilder<'a> {
loop {
let t = self.token_lexer.next_token()?;
function_body.push((t.clone(), self.token_lexer.compiler_data.context.get_line()));
if t.tp == TokenType::RightBigBrace {
if t.tp == RightBigBrace {
break;
}
}
Expand Down Expand Up @@ -943,7 +943,7 @@ impl<'a> AstBuilder<'a> {
let mut is_pop = false;
loop {
let t = self.token_lexer.next_token()?;
if t.tp == TokenType::RightBigBrace {
if t.tp == RightBigBrace {
break;
}
is_pop = false;
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ enum NumValue {
impl<'a> Iterator for TokenLex<'a> {
type Item = Token;

fn next(&mut self) -> std::option::Option<Self::Item> {
fn next(&mut self) -> Option<Self::Item> {
match self.next_token() {
Ok(v) => {
if v.tp == TokenType::EndOfFile {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/tshell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ pub fn tshell() -> RunResult<()> {
if i.tp == TokenType::EndOfFile {
break;
}
if i.tp == compiler::token::TokenType::LeftBigBrace {
if i.tp == TokenType::LeftBigBrace {
cnt += 1;
} else if i.tp == compiler::token::TokenType::RightBigBrace {
} else if i.tp == TokenType::RightBigBrace {
cnt -= 1;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/tools/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ impl Display for UpdateError {
}
}

impl Default for UpdateError {
fn default() -> Self {
Self::new()
}
}

impl UpdateError {
pub fn new() -> Self {
Self {}
Expand Down
6 changes: 0 additions & 6 deletions src/tvm/types/data_structure/ac.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ impl AcAutomaton {
}

/// use search function to add your string
/// # Example
/// ```
/// ac.search("hello", 1);
/// ac.search("world", 2);
/// let ans = ac.get_ans();
/// ````
fn search(&self, _pattern: &str, _id: u32) {}

fn get_ans(&self) -> HashMap<u32, usize> {
Expand Down
2 changes: 1 addition & 1 deletion src/tvm/types/data_structure/sam.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Sam {
s._states.push(u);
} else {
let mut clone = Node::new(s._states[last].len + 1);
clone.next = s._states[q].next.clone();
clone.next.clone_from(&s._states[q].next);
clone.link = s._states[q].link;
let cloneid = id + 1;
loop {
Expand Down
2 changes: 1 addition & 1 deletion src/tvm/types/trcstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl TrcObj for TrcStr {
return unsafe {
match (*other).downcast_ref::<TrcStr>() {
Some(v) => {
let val = gc.alloc(cat_string(&*self._value, &*((*v)._value)));
let val = gc.alloc(cat_string(&*self._value, &*(v._value)));
Ok(gc.alloc(TrcStr::new(val)))
}
None => Err(ErrorInfo::new(
Expand Down

0 comments on commit 64914e3

Please sign in to comment.