Skip to content

Commit

Permalink
Merge pull request #1082 from hash-org/cli-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
feds01 authored Dec 8, 2024
2 parents 1699427 + 64c2671 commit 9c5b2c3
Show file tree
Hide file tree
Showing 70 changed files with 279 additions and 258 deletions.
323 changes: 165 additions & 158 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion compiler/hash-ast-utils/src/pretty/collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl CollectionPrintingOptions {
}
}

impl<'ast, T> AstPrettyPrinter<'ast, T>
impl<T> AstPrettyPrinter<'_, T>
where
T: std::io::Write,
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-ast-utils/src/pretty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ where
}
}

impl<'ast, T> AstVisitorMutSelf for AstPrettyPrinter<'ast, T>
impl<T> AstVisitorMutSelf for AstPrettyPrinter<'_, T>
where
T: std::io::Write,
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-ast-utils/src/pretty/tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use hash_token::{delimiter::Delimiter, Token, TokenKind};

use super::{AstPrettyPrinter, FmtResult};

impl<'ast, T> AstPrettyPrinter<'ast, T>
impl<T> AstPrettyPrinter<'_, T>
where
T: std::io::Write,
{
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-ast-utils/src/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ impl AstVisitor for AstTreePrinter {
) -> Result<Self::RefTyRet, Self::Error> {
let walk::RefTy { inner, mutability, .. } = walk::walk_ref_ty(self, node)?;

let label = if node.kind.as_ref().map_or(false, |t| *t.body() == ast::RefKind::Raw) {
let label = if node.kind.as_ref().is_some_and(|t| *t.body() == ast::RefKind::Raw) {
"raw_ref"
} else {
"ref"
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-attrs/src/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl AttrStore {
/// Check whether a particular [AstNodeId] has a specific
/// attribute.
pub fn node_has_attr(&self, id: AstNodeId, attr: AttrId) -> bool {
self.0.borrow(id).map_or(false, |attrs| attrs.has_attr(attr))
self.0.borrow(id).is_some_and(|attrs| attrs.has_attr(attr))
}

/// Get an [Attr] by name, from a node.
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-codegen-llvm/src/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl<'b, 'm> CodeGenCtx<'b, 'm> {
}

/// Implement the types for the [CodeGenCtx].
impl<'b, 'm> BackendTypes for CodeGenCtx<'b, 'm> {
impl<'m> BackendTypes for CodeGenCtx<'_, 'm> {
type Value = llvm::values::AnyValueEnum<'m>;

type Function = llvm::values::FunctionValue<'m>;
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-codegen-llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub struct LLVMBackend<'b> {
metrics: &'b mut StageMetrics,
}

impl<'b> HasMutMetrics for LLVMBackend<'b> {
impl HasMutMetrics for LLVMBackend<'_> {
fn metrics(&mut self) -> &mut StageMetrics {
self.metrics
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-codegen-llvm/src/translation/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use inkwell::{
use super::{ty::ExtendedTyBuilderMethods, LLVMBuilder};
use crate::{ctx::CodeGenCtx, misc::AttributeKind};

impl<'b, 'm> AbiBuilderMethods<'b> for LLVMBuilder<'_, 'b, 'm> {
impl<'b> AbiBuilderMethods<'b> for LLVMBuilder<'_, 'b, '_> {
fn get_param(&mut self, index: usize) -> Self::Value {
let func = self.basic_block().get_parent().unwrap();
func.get_nth_param(index as u32).unwrap().into()
Expand Down
4 changes: 2 additions & 2 deletions compiler/hash-codegen-llvm/src/translation/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub fn instruction_from_any_value(value: AnyValueEnum<'_>) -> InstructionValue<'
value.as_instruction_value().unwrap()
}

impl<'a, 'b, 'm> LLVMBuilder<'a, 'b, 'm> {
impl<'m> LLVMBuilder<'_, '_, 'm> {
/// Create a PHI node in the current block.
fn phi(
&mut self,
Expand Down Expand Up @@ -128,7 +128,7 @@ impl<'a, 'b, 'm> LLVMBuilder<'a, 'b, 'm> {
}
}

impl<'a, 'b, 'm> BlockBuilderMethods<'a, 'b> for LLVMBuilder<'a, 'b, 'm> {
impl<'a, 'b> BlockBuilderMethods<'a, 'b> for LLVMBuilder<'a, 'b, '_> {
fn ctx(&self) -> &Self::CodegenCtx {
self.ctx
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-codegen-llvm/src/translation/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use llvm_sys::core as llvm;

use crate::ctx::CodeGenCtx;

impl<'b, 'm> ConstValueBuilderMethods<'b> for CodeGenCtx<'b, 'm> {
impl<'b> ConstValueBuilderMethods<'b> for CodeGenCtx<'b, '_> {
fn const_undef(&self, ty: Self::Type) -> Self::Value {
let ty: BasicTypeEnum = ty.try_into().unwrap();
match ty {
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-codegen-llvm/src/translation/debug_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use hash_source::{identifier::Identifier, location::Span};

use super::LLVMBuilder;

impl<'b, 'm> DebugInfoBuilderMethods for LLVMBuilder<'_, 'b, 'm> {
impl DebugInfoBuilderMethods for LLVMBuilder<'_, '_, '_> {
fn create_debug_info_scope_for_fn(
&self,
_fn_abi: &FnAbi,
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-codegen-llvm/src/translation/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use inkwell::{
use super::abi::ExtendedFnAbiMethods;
use crate::ctx::CodeGenCtx;

impl<'b, 'm> CodeGenCtx<'b, 'm> {
impl<'m> CodeGenCtx<'_, 'm> {
/// Standard function to declare a C-like function. This should only be used
/// for declaring FFI functions or various LLVM intrinsics.
///
Expand Down
4 changes: 2 additions & 2 deletions compiler/hash-codegen-llvm/src/translation/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use inkwell::{

use super::LLVMBuilder;

impl<'b, 'm> LLVMBuilder<'_, 'b, 'm> {
impl<'m> LLVMBuilder<'_, '_, 'm> {
/// Call an intrinsic function with the specified arguments.
pub(crate) fn call_intrinsic(
&mut self,
Expand Down Expand Up @@ -319,7 +319,7 @@ impl<'b, 'm> LLVMBuilder<'_, 'b, 'm> {
}
}

impl<'b, 'm> IntrinsicBuilderMethods<'b> for LLVMBuilder<'_, 'b, 'm> {
impl<'b> IntrinsicBuilderMethods<'b> for LLVMBuilder<'_, 'b, '_> {
fn codegen_intrinsic_call(
&mut self,
ty: ReprTyId,
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-codegen-llvm/src/translation/layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl<'b> LayoutMethods<'b> for CodeGenCtx<'b, '_> {
}
}

impl<'b, 'm> LayoutMethods<'b> for LLVMBuilder<'_, 'b, 'm> {
impl<'b> LayoutMethods<'b> for LLVMBuilder<'_, 'b, '_> {
fn backend_field_index(&self, info: TyInfo, index: usize) -> u64 {
self.ctx.backend_field_index(info, index)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/hash-codegen-llvm/src/translation/misc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use inkwell::{
use super::abi::ExtendedFnAbiMethods;
use crate::ctx::CodeGenCtx;

impl<'b, 'm> CodeGenCtx<'b, 'm> {
impl<'m> CodeGenCtx<'_, 'm> {
/// Generate code for a reference to a function or method item. The
/// [Instance] specifies the function reference to generate, and any
/// attributes that need to be applied to the function. If the function
Expand Down Expand Up @@ -61,7 +61,7 @@ impl<'b, 'm> CodeGenCtx<'b, 'm> {
}
}

impl<'b, 'm> MiscBuilderMethods<'b> for CodeGenCtx<'b, 'm> {
impl<'b> MiscBuilderMethods<'b> for CodeGenCtx<'b, '_> {
fn get_fn(&self, instance: InstanceId) -> Self::Function {
self.get_fn_or_create_ref(instance)
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/hash-codegen-llvm/src/translation/statics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use inkwell::values::{AnyValue, AnyValueEnum, BasicValueEnum, GlobalValue, Unnam

use crate::ctx::CodeGenCtx;

impl<'b, 'm> CodeGenCtx<'b, 'm> {
impl<'m> CodeGenCtx<'_, 'm> {
// Define a global static variable within the current [LLVMModule]. This
// function is only invoked if the static variable has not already been
// defined.
Expand All @@ -35,7 +35,7 @@ impl<'b, 'm> CodeGenCtx<'b, 'm> {
}
}

impl<'b, 'm> StaticMethods for CodeGenCtx<'b, 'm> {
impl StaticMethods for CodeGenCtx<'_, '_> {
fn static_addr_of(&self, cv: Self::Value, align: Alignment) -> Self::Value {
// Check if we've already created the global
if let Some(global) = self.global_consts.borrow().get(&cv) {
Expand Down
4 changes: 2 additions & 2 deletions compiler/hash-codegen-llvm/src/translation/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn convert_basic_ty_to_any(ty: BasicTypeEnum) -> AnyTypeEnum {
}
}

impl<'b, 'm> CodeGenCtx<'b, 'm> {
impl<'m> CodeGenCtx<'_, 'm> {
/// Create a [VectorType] from a [`AbiRepresentation::Vector`].
pub(crate) fn type_vector(&self, element_ty: AnyTypeEnum<'m>, len: u64) -> AnyTypeEnum<'m> {
// @@PatchInkwell: we should allow creating a vector type from a
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<'b, 'm> CodeGenCtx<'b, 'm> {
}
}

impl<'b, 'm> TypeBuilderMethods<'b> for CodeGenCtx<'b, 'm> {
impl<'b> TypeBuilderMethods<'b> for CodeGenCtx<'b, '_> {
fn type_i1(&self) -> Self::Type {
self.ll_ctx.bool_type().into()
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-codegen-vm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct VMBackend<'b> {
metrics: &'b mut StageMetrics,
}

impl<'b> HasMutMetrics for VMBackend<'b> {
impl HasMutMetrics for VMBackend<'_> {
fn metrics(&mut self) -> &mut StageMetrics {
self.metrics
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/hash-codegen/src/lower/locals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ struct LocalKindAnalyser<'ir, 'a, 'b, Builder: BlockBuilderMethods<'a, 'b>> {
locals: IndexVec<Local, LocalMemoryKind>,
}

impl<'ir, 'a, 'b, Builder: BlockBuilderMethods<'a, 'b>> fmt::Display
for LocalKindAnalyser<'ir, 'a, 'b, Builder>
impl<'a, 'b, Builder: BlockBuilderMethods<'a, 'b>> fmt::Display
for LocalKindAnalyser<'_, 'a, 'b, Builder>
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// compute the longest local name, and align all of the
Expand All @@ -171,7 +171,7 @@ impl<'ir, 'a, 'b, Builder: BlockBuilderMethods<'a, 'b>> fmt::Display
}
}

impl<'ir, 'a, 'b, Builder: BlockBuilderMethods<'a, 'b>> LocalKindAnalyser<'ir, 'a, 'b, Builder> {
impl<'a, 'b, Builder: BlockBuilderMethods<'a, 'b>> LocalKindAnalyser<'_, 'a, 'b, Builder> {
/// Perform an "assignment" to a particular local. This will
/// change the previous kind of memory with the following rules:
///
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-const-eval/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct ConstFolder<'ctx> {

type OverflowingOp = fn(i128, i128) -> (i128, bool);

impl<'ctx> ConstFolder<'ctx> {
impl ConstFolder<'_> {
/// Attempt to evaluate two [Const]s and a binary operator.
pub fn try_fold_bin_op(&self, op: BinOp, lhs: &Const, rhs: &Const) -> Option<Const> {
// If the two constants are non-scalar, then we abort the folding...
Expand Down
1 change: 0 additions & 1 deletion compiler/hash-const-eval/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! This is the main compiler sources for constant value management. This
//! representation is used across the compiler from AST all of the way to
//! the executable construction and or VM execution.v
#![feature(const_option)]
pub mod error;
pub mod eval;
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-exhaustiveness/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ impl<E: ExhaustivenessEnv> HasTarget for ExhaustivenessChecker<'_, E> {
}
}

impl<'env, E: ExhaustivenessEnv> TyLowerEnv for ExhaustivenessChecker<'env, E> {}
impl<E: ExhaustivenessEnv> TyLowerEnv for ExhaustivenessChecker<'_, E> {}

impl<'env, E: ExhaustivenessEnv> ExhaustivenessChecker<'env, E> {
/// Create a new checker.
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-exhaustiveness/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl ExhaustivenessCtx {
}
}

impl<'env, E: ExhaustivenessEnv> ExhaustivenessChecker<'env, E> {
impl<E: ExhaustivenessEnv> ExhaustivenessChecker<'_, E> {
pub(crate) fn get_ctor(&self, id: DeconstructedCtorId) -> &DeconstructedCtor {
&self.ecx.dc[id]
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/hash-ir/src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ pub struct SwitchTargetsIter<'a> {
inner: iter::Zip<slice::Iter<'a, u128>, slice::Iter<'a, BasicBlock>>,
}

impl<'a> Iterator for SwitchTargetsIter<'a> {
impl Iterator for SwitchTargetsIter<'_> {
type Item = (u128, BasicBlock);

fn next(&mut self) -> Option<Self::Item> {
Expand Down Expand Up @@ -840,7 +840,7 @@ impl BasicBlockData {
/// the terminator is of kind [TerminatorKind::Unreachable].
pub fn is_empty_and_unreachable(&self) -> bool {
self.statements.is_empty()
&& self.terminator.as_ref().map_or(false, |t| t.kind == TerminatorKind::Unreachable)
&& self.terminator.as_ref().is_some_and(|t| t.kind == TerminatorKind::Unreachable)
}
}

Expand Down
3 changes: 1 addition & 2 deletions compiler/hash-ir/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
type_alias_impl_trait,
decl_macro,
box_patterns,
variant_count,
const_option
variant_count
)]

pub mod basic_blocks;
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-ir/src/traversal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,4 @@ impl<'ir> Iterator for ReversePostOrder<'ir> {
}
}

impl<'ir> ExactSizeIterator for ReversePostOrder<'ir> {}
impl ExactSizeIterator for ReversePostOrder<'_> {}
4 changes: 2 additions & 2 deletions compiler/hash-link/src/linker/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct GccLinker<'ctx> {
pub static_hint: bool,
}

impl<'ctx> GccLinker<'ctx> {
impl GccLinker<'_> {
/// Passes an arbitrary argument directly to the linker.
fn linker_arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Self {
self.linker_args(&[arg]);
Expand Down Expand Up @@ -101,7 +101,7 @@ impl<'ctx> GccLinker<'ctx> {
}
}

impl<'ctx> Linker for GccLinker<'ctx> {
impl Linker for GccLinker<'_> {
fn cmd(&mut self) -> &mut LinkCommand {
&mut self.command
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/hash-link/src/linker/mold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct MoldLinker<'ctx> {
settings: &'ctx CompilerSettings,
}

impl<'ctx> MoldLinker<'ctx> {
impl MoldLinker<'_> {
/// Passes a collection of argument directly to the linker.
fn linker_args(&mut self, args: &[impl AsRef<OsStr>]) -> &mut Self {
args.iter().for_each(|arg| {
Expand All @@ -34,7 +34,7 @@ impl<'ctx> MoldLinker<'ctx> {
}
}

impl<'ctx> Linker for MoldLinker<'ctx> {
impl Linker for MoldLinker<'_> {
fn cmd(&mut self) -> &mut LinkCommand {
&mut self.command
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-link/src/linker/msvc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct MsvcLinker<'ctx> {
pub settings: &'ctx CompilerSettings,
}

impl<'ctx> Linker for MsvcLinker<'ctx> {
impl Linker for MsvcLinker<'_> {
fn cmd(&mut self) -> &mut LinkCommand {
&mut self.command
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-lower/src/build/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use hash_tir::tir::{self, HasAstNodeId};

use super::BodyBuilder;

impl<'tcx> BodyBuilder<'tcx> {
impl BodyBuilder<'_> {
/// Lower a literal value into a [constant::Const].
pub(crate) fn lit_as_const(&self, lit: tir::LitId) -> ir::Const {
match *lit.value() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-lower/src/build/into.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use hash_utils::itertools::Itertools;

use super::{ty::FnCallTermKind, unpack, BlockAnd, BlockAndExtend, BodyBuilder, LoopBlockInfo};

impl<'tcx> BodyBuilder<'tcx> {
impl BodyBuilder<'_> {
/// Compile the given [Term] and place the value of the [Term]
/// into the specified destination [Place].
pub(crate) fn term_into_dest(
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-lower/src/build/matches/candidate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub(super) enum BindingMode {
ByRef,
}

impl<'tcx> BodyBuilder<'tcx> {
impl BodyBuilder<'_> {
/// This function attempts to simplify a [Candidate] so that all match pairs
/// can be tested. This method will also split the candidate in which
/// the only match pair is a `or` pattern, in order for matches like:
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-lower/src/build/matches/declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use hash_tir::tir::{
use super::{candidate::Candidate, BlockAnd, BodyBuilder};
use crate::build::{place::PlaceBuilder, unpack, BlockAndExtend};

impl<'tcx> BodyBuilder<'tcx> {
impl BodyBuilder<'_> {
/// Push a [LocalDecl] in the current [BodyBuilder] with the associated
/// [Symbol]. This will put the [LocalDecl] into the declarations, and
/// create an entry in the lookup map so that the [Local] can be looked up
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-lower/src/build/matches/optimise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use hash_utils::smallvec::SmallVec;
use super::candidate::{Candidate, MatchPair};
use crate::build::{place::PlaceBuilder, BodyBuilder};

impl<'tcx> BodyBuilder<'tcx> {
impl BodyBuilder<'_> {
/// Attempt to optimise the sub-candidates of a provided [Candidate]. This
/// only performs a trivial merge, so we avoid generating exponential
pub(super) fn merge_sub_candidates(&mut self, candidate: &mut Candidate, origin: AstNodeId) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/hash-lower/src/build/matches/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Test {
}
}

impl<'tcx> BodyBuilder<'tcx> {
impl BodyBuilder<'_> {
pub(super) fn test_or_pat(
&mut self,
candidate: &mut Candidate,
Expand Down
Loading

0 comments on commit 9c5b2c3

Please sign in to comment.