Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 6248-warn-item-more…
Browse files Browse the repository at this point in the history
…-private
  • Loading branch information
aakoshh committed Oct 19, 2024
2 parents 1664a3d + 4302e7e commit a063a67
Show file tree
Hide file tree
Showing 30 changed files with 2,516 additions and 530 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ jobs:

- name: Build docs
env:
MATOMO_ENV: staging # not really a secret, it will show in the footer anyway
ENV: staging # not really a secret, it will show in the footer anyway
run: yarn workspaces foreach -Rpt --from docs run build

- name: Upload artifact
Expand Down
2 changes: 1 addition & 1 deletion acvm-repo/acvm/src/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ mod transformers;

pub use optimizers::optimize;
use optimizers::optimize_internal;
pub use transformers::transform;
use transformers::transform_internal;
pub use transformers::{transform, MIN_EXPRESSION_WIDTH};

/// This module moves and decomposes acir opcodes. The transformation map allows consumers of this module to map
/// metadata they had about the opcodes to the new opcode structure generated after the transformation.
Expand Down
9 changes: 7 additions & 2 deletions acvm-repo/acvm/src/compiler/transformers/csat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ use acir::{
};
use indexmap::IndexMap;

/// Minimum width accepted by the `CSatTransformer`.
pub const MIN_EXPRESSION_WIDTH: usize = 3;

/// A transformer which processes any [`Expression`]s to break them up such that they
/// fit within the [`ProofSystemCompiler`][crate::ProofSystemCompiler]'s width.
///
Expand All @@ -22,9 +25,11 @@ pub(crate) struct CSatTransformer {
}

impl CSatTransformer {
// Configure the width for the optimizer
/// Create an optimizer with a given width.
///
/// Panics if `width` is less than `MIN_EXPRESSION_WIDTH`.
pub(crate) fn new(width: usize) -> CSatTransformer {
assert!(width > 2);
assert!(width >= MIN_EXPRESSION_WIDTH, "width has to be at least {MIN_EXPRESSION_WIDTH}");

CSatTransformer { width, solvable_witness: HashSet::new() }
}
Expand Down
1 change: 1 addition & 0 deletions acvm-repo/acvm/src/compiler/transformers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use indexmap::IndexMap;
mod csat;

pub(crate) use csat::CSatTransformer;
pub use csat::MIN_EXPRESSION_WIDTH;

use super::{transform_assert_messages, AcirTransformationMap};

Expand Down
7 changes: 6 additions & 1 deletion compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use abi_gen::{abi_type_from_hir_type, value_from_hir_expression};
use acvm::acir::circuit::ExpressionWidth;
use acvm::compiler::MIN_EXPRESSION_WIDTH;
use clap::Args;
use fm::{FileId, FileManager};
use iter_extended::vecmap;
Expand Down Expand Up @@ -134,7 +135,11 @@ pub fn parse_expression_width(input: &str) -> Result<ExpressionWidth, std::io::E

match width {
0 => Ok(ExpressionWidth::Unbounded),
_ => Ok(ExpressionWidth::Bounded { width }),
w if w >= MIN_EXPRESSION_WIDTH => Ok(ExpressionWidth::Bounded { width }),
_ => Err(Error::new(
ErrorKind::InvalidInput,
format!("has to be 0 or at least {MIN_EXPRESSION_WIDTH}"),
)),
}
}

Expand Down
3 changes: 2 additions & 1 deletion compiler/noirc_frontend/src/elaborator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,8 @@ impl<'context> Elaborator<'context> {
// so we need to reintroduce the same IDs into scope here.
for parameter in &func_meta.parameter_idents {
let name = self.interner.definition_name(parameter.id).to_owned();
self.add_existing_variable_to_scope(name, parameter.clone(), true);
let warn_if_unused = !(func_meta.trait_impl.is_some() && name == "self");
self.add_existing_variable_to_scope(name, parameter.clone(), warn_if_unused);
}

self.add_trait_constraints_to_scope(&func_meta);
Expand Down
20 changes: 20 additions & 0 deletions compiler/noirc_frontend/src/tests/unused_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,23 @@ fn no_warning_on_indirect_struct_if_it_has_an_abi_attribute() {
"#;
assert_no_errors(src);
}

#[test]
fn no_warning_on_self_in_trait_impl() {
let src = r#"
struct Bar {}
trait Foo {
fn foo(self, a: u64);
}
impl Foo for Bar {
fn foo(self, _a: u64) {}
}
fn main() {
let _ = Bar {};
}
"#;
assert_no_errors(src);
}
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ yarn-error.log*

package-lock.json
versions.json
.supermavenignore
3 changes: 0 additions & 3 deletions docs/.markdownlint.json

This file was deleted.

8 changes: 7 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ yarn build
### Local Development

```
yarn workspace docs start
yarn workspace docs version
```

This command fetches and compiles the list of documentation versions to build with.

```
yarn workspace docs dev
```

This command starts a local development server and opens up a browser window. Most changes are
Expand Down
5 changes: 0 additions & 5 deletions docs/docs/getting_started/_category_.json

This file was deleted.

6 changes: 0 additions & 6 deletions docs/docs/getting_started/backend/_category_.json

This file was deleted.

31 changes: 0 additions & 31 deletions docs/docs/getting_started/backend/index.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/docs/getting_started/hello_noir/_category_.json

This file was deleted.

157 changes: 0 additions & 157 deletions docs/docs/getting_started/hello_noir/index.md

This file was deleted.

6 changes: 0 additions & 6 deletions docs/docs/getting_started/installation/_category_.json

This file was deleted.

46 changes: 0 additions & 46 deletions docs/docs/getting_started/installation/index.md

This file was deleted.

Loading

0 comments on commit a063a67

Please sign in to comment.