Skip to content

Commit

Permalink
Fixed future clippy warnings. (#6473)
Browse files Browse the repository at this point in the history
  • Loading branch information
orizi authored Oct 10, 2024
1 parent 7256492 commit 5900876
Show file tree
Hide file tree
Showing 36 changed files with 90 additions and 93 deletions.
2 changes: 1 addition & 1 deletion crates/bin/cairo-format/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn format_file_in_place(fmt: &CairoFormatter, args: &FormatterArgs, path: &Path)
}
}

impl<'t> ParallelVisitor for PathFormatter<'t> {
impl ParallelVisitor for PathFormatter<'_> {
fn visit(&mut self, dir_entry_res: Result<DirEntry, Error>) -> WalkState {
let dir_entry = if let Ok(dir_entry) = dir_entry_res {
dir_entry
Expand Down
6 changes: 3 additions & 3 deletions crates/cairo-lang-casm/src/hints/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ pub enum DeprecatedHint {
}

struct DerefOrImmediateFormatter<'a>(&'a DerefOrImmediate);
impl<'a> Display for DerefOrImmediateFormatter<'a> {
impl Display for DerefOrImmediateFormatter<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self.0 {
DerefOrImmediate::Deref(d) => write!(f, "memory{d}"),
Expand All @@ -340,7 +340,7 @@ impl<'a> Display for DerefOrImmediateFormatter<'a> {
}

struct ResOperandAsIntegerFormatter<'a>(&'a ResOperand);
impl<'a> Display for ResOperandAsIntegerFormatter<'a> {
impl Display for ResOperandAsIntegerFormatter<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self.0 {
ResOperand::Deref(d) => write!(f, "memory{d}"),
Expand All @@ -360,7 +360,7 @@ impl<'a> Display for ResOperandAsIntegerFormatter<'a> {
}

struct ResOperandAsAddressFormatter<'a>(&'a ResOperand);
impl<'a> Display for ResOperandAsAddressFormatter<'a> {
impl Display for ResOperandAsAddressFormatter<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
match self.0 {
ResOperand::Deref(d) => write!(f, "memory{d}"),
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-compiler/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ trait DiagnosticCallback {
fn on_diagnostic(&mut self, diagnostic: FormattedDiagnosticEntry);
}

impl<'a> DiagnosticCallback for Option<Box<dyn DiagnosticCallback + 'a>> {
impl DiagnosticCallback for Option<Box<dyn DiagnosticCallback + '_>> {
fn on_diagnostic(&mut self, diagnostic: FormattedDiagnosticEntry) {
if let Some(callback) = self {
callback.on_diagnostic(diagnostic)
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-lang-filesystem/src/ids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ impl VirtualFile {
}

define_short_id!(FileId, FileLongId, FilesGroup, lookup_intern_file, intern_file);
impl<'b> FileId {
impl FileId {
pub fn new(db: &dyn FilesGroup, path: PathBuf) -> FileId {
FileLongId::OnDisk(path.clean()).intern(db)
}
pub fn file_name(self, db: &'b dyn FilesGroup) -> String {
pub fn file_name(self, db: &dyn FilesGroup) -> String {
match self.lookup_intern(db) {
FileLongId::OnDisk(path) => {
path.file_name().and_then(|x| x.to_str()).unwrap_or("<unknown>").to_string()
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-lang-formatter/src/cairo_formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub struct FileDiffColoredDisplay<'a> {
diff: &'a FileDiff,
}

impl<'a> Display for FileDiffColoredDisplay<'a> {
impl Display for FileDiffColoredDisplay<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let patch = create_patch(&self.diff.original, &self.diff.formatted);
let patch_formatter = PatchFormatter::new().with_color();
Expand All @@ -61,7 +61,7 @@ impl<'a> Display for FileDiffColoredDisplay<'a> {
}
}

impl<'a> Debug for FileDiffColoredDisplay<'a> {
impl Debug for FileDiffColoredDisplay<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
writeln!(f, "FileDiffColoredDisplay({:?})", self.diff)
}
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-lang-lowering/src/borrow_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ impl DropPosition {
}
}

impl<'a> DemandReporter<VariableId, PanicState> for BorrowChecker<'a> {
impl DemandReporter<VariableId, PanicState> for BorrowChecker<'_> {
// Note that for in BorrowChecker `IntroducePosition` is used to pass the cause of
// the drop.
type IntroducePosition = (Option<DropPosition>, BlockId);
Expand Down Expand Up @@ -163,7 +163,7 @@ impl<'a> DemandReporter<VariableId, PanicState> for BorrowChecker<'a> {
}
}

impl<'a> Analyzer<'_> for BorrowChecker<'a> {
impl Analyzer<'_> for BorrowChecker<'_> {
type Info = BorrowCheckerDemand;

fn visit_stmt(
Expand Down
6 changes: 3 additions & 3 deletions crates/cairo-lang-lowering/src/destructs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct PanicDeconstructionEntry {
impl_id: ImplId,
}

impl<'a> DestructAdder<'a> {
impl DestructAdder<'_> {
/// Checks if the statement introduces a panic variable and sets the panic state accordingly.
fn set_post_stmt_destruct(
&mut self,
Expand Down Expand Up @@ -117,7 +117,7 @@ impl<'a> DestructAdder<'a> {
}
}

impl<'a> DemandReporter<VariableId, PanicState> for DestructAdder<'a> {
impl DemandReporter<VariableId, PanicState> for DestructAdder<'_> {
type IntroducePosition = StatementLocation;
type UsePosition = ();

Expand Down Expand Up @@ -200,7 +200,7 @@ pub enum PanicLocation {
PanicMatch { match_block_id: BlockId, target_block_id: BlockId },
}

impl<'a> Analyzer<'_> for DestructAdder<'a> {
impl Analyzer<'_> for DestructAdder<'_> {
type Info = DestructAdderDemand;

fn visit_stmt(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct ConcreteFunctionWithBodyNode<'a> {
pub db: &'a dyn LoweringGroup,
pub dependency_type: DependencyType,
}
impl<'a> GraphNode for ConcreteFunctionWithBodyNode<'a> {
impl GraphNode for ConcreteFunctionWithBodyNode<'_> {
type NodeId = ConcreteFunctionWithBodyId;

fn get_neighbors(&self) -> Vec<Self> {
Expand All @@ -37,7 +37,7 @@ impl<'a> GraphNode for ConcreteFunctionWithBodyNode<'a> {
self.function_id
}
}
impl<'a> ComputeScc for ConcreteFunctionWithBodyNode<'a> {
impl ComputeScc for ConcreteFunctionWithBodyNode<'_> {
fn compute_scc(&self) -> Vec<Self::NodeId> {
concrete_function_with_body_scc(self.db, self.function_id, self.dependency_type)
}
Expand All @@ -49,7 +49,7 @@ pub struct ConcreteFunctionWithBodyPostPanicNode<'a> {
pub db: &'a dyn LoweringGroup,
pub dependency_type: DependencyType,
}
impl<'a> GraphNode for ConcreteFunctionWithBodyPostPanicNode<'a> {
impl GraphNode for ConcreteFunctionWithBodyPostPanicNode<'_> {
type NodeId = ConcreteFunctionWithBodyId;

fn get_neighbors(&self) -> Vec<Self> {
Expand All @@ -75,7 +75,7 @@ impl<'a> GraphNode for ConcreteFunctionWithBodyPostPanicNode<'a> {
self.function_id
}
}
impl<'a> ComputeScc for ConcreteFunctionWithBodyPostPanicNode<'a> {
impl ComputeScc for ConcreteFunctionWithBodyPostPanicNode<'_> {
fn compute_scc(&self) -> Vec<Self::NodeId> {
concrete_function_with_body_scc(self.db, self.function_id, self.dependency_type)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-lowering/src/inline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub struct Mapper<'a, 'b> {
block_id_offset: BlockId,
}

impl<'a, 'b> Rebuilder for Mapper<'a, 'b> {
impl Rebuilder for Mapper<'_, '_> {
/// Maps a var id from the original lowering representation to the equivalent id in the
/// new lowering representation.
/// If the variable wasn't assigned an id yet, a new id is assigned.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a> ApproxCasmInlineWeight<'a> {
}
}

impl<'a> InlineWeight for ApproxCasmInlineWeight<'a> {
impl InlineWeight for ApproxCasmInlineWeight<'_> {
fn calling_weight(&self, _lowered: &FlatLowered) -> isize {
0
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-lowering/src/lower/block_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ struct BlockStructRecomposer<'a, 'b, 'c> {
ctx: &'a mut LoweringContext<'b, 'c>,
location: LocationId,
}
impl<'a, 'b, 'c> StructRecomposer for BlockStructRecomposer<'a, 'b, 'c> {
impl StructRecomposer for BlockStructRecomposer<'_, '_, '_> {
fn deconstruct(
&mut self,
concrete_struct_id: semantic::ConcreteStructId,
Expand Down
8 changes: 4 additions & 4 deletions crates/cairo-lang-lowering/src/lower/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<'db> VariableAllocator<'db> {
LocationId::from_stable_location(self.db, StableLocation::new(stable_ptr))
}
}
impl<'db> Index<VariableId> for VariableAllocator<'db> {
impl Index<VariableId> for VariableAllocator<'_> {
type Output = Variable;

fn index(&self, index: VariableId) -> &Self::Output {
Expand Down Expand Up @@ -165,19 +165,19 @@ impl<'a, 'db> LoweringContext<'a, 'db> {
})
}
}
impl<'a, 'db> Deref for LoweringContext<'a, 'db> {
impl<'db> Deref for LoweringContext<'_, 'db> {
type Target = EncapsulatingLoweringContext<'db>;

fn deref(&self) -> &Self::Target {
self.encapsulating_ctx.as_ref().unwrap()
}
}
impl<'a, 'db> DerefMut for LoweringContext<'a, 'db> {
impl DerefMut for LoweringContext<'_, '_> {
fn deref_mut(&mut self) -> &mut Self::Target {
self.encapsulating_ctx.as_mut().unwrap()
}
}
impl<'a, 'db> LoweringContext<'a, 'db> {
impl LoweringContext<'_, '_> {
/// Allocates a new variable in the context's variable arena according to the context.
pub fn new_var(&mut self, req: VarRequest) -> VariableId {
self.variables.new_var(req)
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-lang-lowering/src/optimizations/const_folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ pub fn const_folding(db: &dyn LoweringGroup, lowered: &mut FlatLowered) {
ctx.variables[input.var_id]
.copyable
.is_ok()
.then(|| VarInfo::Var(*input)),
.then_some(VarInfo::Var(*input)),
);
continue;
};
Expand Down Expand Up @@ -219,7 +219,7 @@ struct ConstFoldingContext<'a> {
libfunc_info: &'a ConstFoldingLibfuncInfo,
}

impl<'a> ConstFoldingContext<'a> {
impl ConstFoldingContext<'_> {
/// Handles a statement call.
///
/// Returns None if no additional changes are required.
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-lowering/src/panic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct PanicLoweringContext<'a> {
flat_blocks: FlatBlocksBuilder,
panic_info: PanicSignatureInfo,
}
impl<'a> PanicLoweringContext<'a> {
impl PanicLoweringContext<'_> {
pub fn db(&self) -> &dyn LoweringGroup {
self.variables.db
}
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-lowering/src/scc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct FunctionWithBodyNode<'a> {
dependency_type: DependencyType,
db: &'a dyn LoweringGroup,
}
impl<'a> GraphNode for FunctionWithBodyNode<'a> {
impl GraphNode for FunctionWithBodyNode<'_> {
type NodeId = FunctionWithBodyId;

fn get_neighbors(&self) -> Vec<Self> {
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-parser/src/colored_printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct ColoredPrinter<'a> {
verbose: bool,
result: String,
}
impl<'a> ColoredPrinter<'a> {
impl ColoredPrinter<'_> {
fn print(&mut self, syntax_node: &SyntaxNode) {
let node = syntax_node.green_node(self.db);
match &node.details {
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-lang-parser/src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ impl<'a> Lexer<'a> {
}
}

/// Token matchers.
/// =================================================================================
// Token matchers.
// =================================================================================

/// Takes a number. May be decimal, hex, oct or bin.
fn take_token_literal_number(&mut self) -> TokenKind {
Expand Down
2 changes: 1 addition & 1 deletion crates/cairo-lang-plugins/src/plugins/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub struct ItemsInCfg<'a, Item: QueryAttrs> {
iterator: <Vec<Item> as IntoIterator>::IntoIter,
}

impl<'a, Item: QueryAttrs> Iterator for ItemsInCfg<'a, Item> {
impl<Item: QueryAttrs> Iterator for ItemsInCfg<'_, Item> {
type Item = Item;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-lang-runner/src/casm_run/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,13 +620,13 @@ impl<'a> MemBuffer<'a> {
}
}

impl<'a> VMWrapper for MemBuffer<'a> {
impl VMWrapper for MemBuffer<'_> {
fn vm(&mut self) -> &mut VirtualMachine {
self.vm.vm()
}
}

impl<'a> CairoHintProcessor<'a> {
impl CairoHintProcessor<'_> {
/// Executes a syscall.
fn execute_syscall(
&mut self,
Expand Down
4 changes: 2 additions & 2 deletions crates/cairo-lang-semantic/src/expr/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ pub struct ExprFormatter<'a> {
pub function_id: FunctionWithBodyId,
}

impl<'a> Upcast<dyn SemanticGroup + 'static> for ExprFormatter<'a> {
impl Upcast<dyn SemanticGroup + 'static> for ExprFormatter<'_> {
fn upcast(&self) -> &(dyn SemanticGroup + 'static) {
self.db
}
}
impl<'a> Upcast<dyn DefsGroup + 'static> for ExprFormatter<'a> {
impl Upcast<dyn DefsGroup + 'static> for ExprFormatter<'_> {
fn upcast(&self) -> &(dyn DefsGroup + 'static) {
self.db.upcast()
}
Expand Down
14 changes: 7 additions & 7 deletions crates/cairo-lang-semantic/src/expr/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl DerefMut for Inference<'_> {
}
}

impl<'db> std::fmt::Debug for Inference<'db> {
impl std::fmt::Debug for Inference<'_> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let x = self.data.debug(self.db.elongate());
write!(f, "{x:?}")
Expand Down Expand Up @@ -1113,23 +1113,23 @@ impl<'a> HasDb<&'a dyn SemanticGroup> for Inference<'a> {
add_basic_rewrites!(<'a>, Inference<'a>, NoError, @exclude TypeLongId TypeId ImplLongId ImplId ConstValue);
add_expr_rewrites!(<'a>, Inference<'a>, NoError, @exclude);
add_rewrite!(<'a>, Inference<'a>, NoError, Ambiguity);
impl<'a> SemanticRewriter<TypeId, NoError> for Inference<'a> {
impl SemanticRewriter<TypeId, NoError> for Inference<'_> {
fn internal_rewrite(&mut self, value: &mut TypeId) -> Result<RewriteResult, NoError> {
if value.is_var_free(self.db) {
return Ok(RewriteResult::NoChange);
}
value.default_rewrite(self)
}
}
impl<'a> SemanticRewriter<ImplId, NoError> for Inference<'a> {
impl SemanticRewriter<ImplId, NoError> for Inference<'_> {
fn internal_rewrite(&mut self, value: &mut ImplId) -> Result<RewriteResult, NoError> {
if value.is_var_free(self.db) {
return Ok(RewriteResult::NoChange);
}
value.default_rewrite(self)
}
}
impl<'a> SemanticRewriter<TypeLongId, NoError> for Inference<'a> {
impl SemanticRewriter<TypeLongId, NoError> for Inference<'_> {
fn internal_rewrite(&mut self, value: &mut TypeLongId) -> Result<RewriteResult, NoError> {
match value {
TypeLongId::Var(var) => {
Expand Down Expand Up @@ -1197,7 +1197,7 @@ impl<'a> SemanticRewriter<TypeLongId, NoError> for Inference<'a> {
value.default_rewrite(self)
}
}
impl<'a> SemanticRewriter<ConstValue, NoError> for Inference<'a> {
impl SemanticRewriter<ConstValue, NoError> for Inference<'_> {
fn internal_rewrite(&mut self, value: &mut ConstValue) -> Result<RewriteResult, NoError> {
match value {
ConstValue::Var(var, _) => {
Expand Down Expand Up @@ -1250,7 +1250,7 @@ impl<'a> SemanticRewriter<ConstValue, NoError> for Inference<'a> {
value.default_rewrite(self)
}
}
impl<'a> SemanticRewriter<ImplLongId, NoError> for Inference<'a> {
impl SemanticRewriter<ImplLongId, NoError> for Inference<'_> {
fn internal_rewrite(&mut self, value: &mut ImplLongId) -> Result<RewriteResult, NoError> {
match value {
ImplLongId::ImplVar(var) => {
Expand Down Expand Up @@ -1328,7 +1328,7 @@ impl<'a> HasDb<&'a dyn SemanticGroup> for InferenceIdReplacer<'a> {
add_basic_rewrites!(<'a>, InferenceIdReplacer<'a>, NoError, @exclude InferenceId);
add_expr_rewrites!(<'a>, InferenceIdReplacer<'a>, NoError, @exclude);
add_rewrite!(<'a>, InferenceIdReplacer<'a>, NoError, Ambiguity);
impl<'a> SemanticRewriter<InferenceId, NoError> for InferenceIdReplacer<'a> {
impl SemanticRewriter<InferenceId, NoError> for InferenceIdReplacer<'_> {
fn internal_rewrite(&mut self, value: &mut InferenceId) -> Result<RewriteResult, NoError> {
if value == &self.from_inference_id {
*value = self.to_inference_id;
Expand Down
Loading

0 comments on commit 5900876

Please sign in to comment.