Skip to content

Commit

Permalink
Fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Jul 31, 2024
1 parent 1888caa commit 287b1bd
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
11 changes: 5 additions & 6 deletions compiler/noirc_frontend/src/elaborator/comptime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<'context> Elaborator<'context> {
match expression.kind {
ExpressionKind::Call(call) => Some((*call.func, call.arguments)),
ExpressionKind::Variable(_) => Some((expression, Vec::new())),
_ => return None,
_ => None,
}
}

Expand Down Expand Up @@ -214,11 +214,10 @@ impl<'context> Elaborator<'context> {

if *param_type == Type::Quoted(crate::QuotedType::TraitDefinition) {
let trait_id = match arg.kind {
ExpressionKind::Variable(path) => {
interpreter.elaborator.resolve_trait_by_path(path).ok_or_else(|| {
InterpreterError::FailedToResolveTraitDefinition { location }
})
}
ExpressionKind::Variable(path) => interpreter
.elaborator
.resolve_trait_by_path(path)
.ok_or(InterpreterError::FailedToResolveTraitDefinition { location }),
_ => Err(InterpreterError::TraitDefinitionMustBeAPath { location }),
}?;
push_arg(Value::TraitDefinition(trait_id));
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/hir/comptime/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ impl<'a> From<&'a InterpreterError> for CustomDiagnostic {
}
InterpreterError::FailingConstraint { message, location } => {
let (primary, secondary) = match message {
Some(msg) => (format!("{msg}"), "Assertion failed".into()),
Some(msg) => (msg.clone(), "Assertion failed".into()),
None => ("Assertion failed".into(), String::new()),
};
CustomDiagnostic::simple_error(primary, secondary, location.span)
Expand Down
11 changes: 6 additions & 5 deletions compiler/noirc_frontend/src/hir/comptime/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl Value {
| Value::ModuleDefinition(_) => {
let typ = self.get_type().into_owned();
let value = self.display(interner).to_string();
return Err(InterpreterError::CannotInlineMacro { typ, value, location })
return Err(InterpreterError::CannotInlineMacro { typ, value, location });
}
};

Expand Down Expand Up @@ -352,7 +352,7 @@ impl Value {
| Value::ModuleDefinition(_) => {
let typ = self.get_type().into_owned();
let value = self.display(interner).to_string();
return Err(InterpreterError::CannotInlineMacro { value, typ, location })
return Err(InterpreterError::CannotInlineMacro { value, typ, location });
}
};

Expand Down Expand Up @@ -399,7 +399,7 @@ impl Value {
) -> IResult<Vec<TopLevelStatement>> {
match self {
Value::Code(tokens) => parse_tokens(tokens, parser::top_level_items(), location.file),
value => {
_ => {
let typ = self.get_type().into_owned();
let value = self.display(interner).to_string();
Err(InterpreterError::CannotInlineMacro { value, typ, location })
Expand Down Expand Up @@ -431,7 +431,7 @@ fn parse_tokens<T>(tokens: Rc<Tokens>, parser: impl NoirParser<T>, file: fm::Fil
}
}

struct ValuePrinter<'value, 'interner> {
pub struct ValuePrinter<'value, 'interner> {
value: &'value Value,
interner: &'interner NodeInterner,
}
Expand Down Expand Up @@ -490,7 +490,8 @@ impl<'value, 'interner> Display for ValuePrinter<'value, 'interner> {
}
Value::StructDefinition(id) => {
let def = self.interner.get_struct(*id);
write!(f, "{}", def.borrow().name)
let def = def.borrow();
write!(f, "{}", def.name)
}
Value::TraitConstraint(trait_id, generics) => {
let trait_ = self.interner.get_trait(*trait_id);
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_frontend/src/lexer/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ impl Attributes {
}

pub fn is_varargs(&self) -> bool {
self.secondary.iter().find(|attr| matches!(attr, SecondaryAttribute::Varargs)).is_some()
self.secondary.iter().any(|attr| matches!(attr, SecondaryAttribute::Varargs))
}
}

Expand Down

0 comments on commit 287b1bd

Please sign in to comment.