-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix clippy warnings #753
Fix clippy warnings #753
Conversation
@@ -83,7 +83,7 @@ impl<I: Interner> Table<I> { | |||
} | |||
|
|||
pub(crate) fn take_strands(&mut self) -> VecDeque<CanonicalStrand<I>> { | |||
mem::replace(&mut self.strands, VecDeque::new()) | |||
mem::take(&mut self.strands) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the less common changes.
.items | ||
.iter() | ||
.map(|_| lowerer.next_item_id()) | ||
.collect::<Vec<_>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added ::<Vec<_>>
. Caused by extract_associated_types
signature being changed to use &[...]
.
} else if let Some(_) = self.adt_ids.get(&name.str) { | ||
Err(RustIrError::NotTrait(name.clone())) | ||
} else if let Some(id) = self.trait_ids.get(&name.str) { | ||
Ok(*id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored:
- Check if the identifier is a trait, return ID if it is
- Return a custom error if the identifier is a parameter or an ADT node
- Return a generic error otherwise
@@ -53,13 +53,13 @@ impl ProgramLowerer { | |||
pub fn extract_associated_types( | |||
&mut self, | |||
program: &Program, | |||
raw_ids: &Vec<RawId>, | |||
raw_ids: &[RawId], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backwards compatibility note: I don't think this fn is available outside the crate since ProgramLowerer
isn't public, so this should be fine.
output += &" ".repeat(11 + start); | ||
output += &"^".repeat(end - start); | ||
output.push('\n'); | ||
output |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor:
- Replaced
position_string
closure with a fn - Simplified match body
@@ -86,7 +85,7 @@ pub fn add_fn_trait_program_clauses<I: Interner>( | |||
builder: &mut ClauseBuilder<'_, I>, | |||
well_known: WellKnownTrait, | |||
self_ty: Ty<I>, | |||
) -> Result<(), Floundered> { | |||
) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor: made add_fn_trait_program_clauses
return ()
because it's infallible.
} else { | ||
self.table | ||
.new_variable(universe_index) | ||
.to_lifetime(self.interner) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor: flattened into two branches.
if level.is_empty() { | ||
println!("debug <level> set debug level to <level>"); | ||
} else { | ||
std::env::set_var("CHALK_DEBUG", level); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small behavior change: repl will print a warning for debug debug debug
instead of ignoring everything after the second space.
c63e601
to
b38fb85
Compare
@bors r+ Thanks! |
📌 Commit b38fb85 has been approved by |
☀️ Test successful - checks-actions |
This PR contains:
needless_borrow
,redundant_clone
,match_like_matches_macro
,try_err
,needless_return
, ...Each type of change is in a separate commit, except for the last commit that has a mix of unique changes.
The 18 remaining clippy errors are a bit more substantial.