Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/noirc_frontend/src/ast/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,10 @@ pub enum UnaryOp {
mutable: bool,
},

/// If implicitly_added is true, this operation was implicitly added by the compiler for a
/// If `implicitly_added` is true, this operation was implicitly added by the compiler for a
/// field dereference. The compiler may undo some of these implicitly added dereferences if
/// the reference later turns out to be needed (e.g. passing a field by reference to a function
/// requiring an &mut parameter).
/// requiring an `&mut` parameter).
Dereference {
implicitly_added: bool,
},
Expand Down Expand Up @@ -577,6 +577,8 @@ pub enum ConstrainKind {
}

impl ConstrainKind {
/// The number of arguments expected by the constraint,
/// not counting the optional assertion message.
pub fn required_arguments_count(&self) -> usize {
match self {
ConstrainKind::Assert | ConstrainKind::Constrain => 1,
Expand Down
17 changes: 9 additions & 8 deletions compiler/noirc_frontend/src/ast/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ pub enum StatementKind {
Continue,
/// This statement should be executed at compile-time
Comptime(Box<Statement>),
// This is an expression with a trailing semi-colon
/// This is an expression with a trailing semi-colon
Semi(Expression),
// This is an interned StatementKind during comptime code.
// The actual StatementKind can be retrieved with a NodeInterner.
/// This is an interned StatementKind during comptime code.
/// The actual StatementKind can be retrieved with a NodeInterner.
Interned(InternedStatementKind),
// This statement is the result of a recovered parse error.
// To avoid issuing multiple errors in later steps, it should
// be skipped in any future analysis if possible.
/// This statement is the result of a recovered parse error.
/// To avoid issuing multiple errors in later steps, it should
/// be skipped in any future analysis if possible.
Error,
}

Expand Down Expand Up @@ -421,7 +421,7 @@ pub struct Path {
pub segments: Vec<PathSegment>,
pub kind: PathKind,
pub location: Location,
// The location of `kind` (this is the same as `location` for plain kinds)
/// The location of `kind` (this is the same as `location` for plain kinds)
pub kind_location: Location,
}

Expand All @@ -439,12 +439,13 @@ impl Path {
self
}

/// Construct a PathKind::Plain from this single
/// Construct a [PathKind::Plain] from a single identifier name.
pub fn from_single(name: String, location: Location) -> Path {
let segment = Ident::from(Located::from(location, name));
Path::from_ident(segment)
}

/// Construct a [PathKind::Plain] from a single [Ident].
pub fn from_ident(name: Ident) -> Path {
let location = name.location();
Path::plain(vec![PathSegment::from(name)], location)
Expand Down
34 changes: 17 additions & 17 deletions compiler/noirc_frontend/src/elaborator/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,23 +334,23 @@ impl Elaborator<'_> {
.ok();
}

// Given:
// ```
// enum FooEnum { Foo(u32, u8), ... }
//
// fn Foo(a: u32, b: u8) -> FooEnum {}
// ```
// Create (pseudocode):
// ```
// fn Foo(a: u32, b: u8) -> FooEnum {
// // This can't actually be written directly in Noir
// FooEnum {
// tag: Foo_tag,
// Foo: (a, b),
// // fields from other variants are zeroed in monomorphization
// }
// }
// ```
/// Given:
/// ```ignore
/// enum FooEnum { Foo(u32, u8), ... }
///
/// fn Foo(a: u32, b: u8) -> FooEnum {}
/// ```
/// Create (pseudocode):
/// ```ignore
/// fn Foo(a: u32, b: u8) -> FooEnum {
/// // This can't actually be written directly in Noir
/// FooEnum {
/// tag: Foo_tag,
/// Foo: (a, b),
/// // fields from other variants are zeroed in monomorphization
/// }
/// }
/// ```
fn make_enum_variant_constructor(
&mut self,
self_type: &Shared<DataType>,
Expand Down
Loading
Loading