diff --git a/compiler/noirc_frontend/src/ast/mod.rs b/compiler/noirc_frontend/src/ast/mod.rs index 39b23228967..bd2b45d9c48 100644 --- a/compiler/noirc_frontend/src/ast/mod.rs +++ b/compiler/noirc_frontend/src/ast/mod.rs @@ -390,26 +390,3 @@ impl std::fmt::Display for Visibility { } } } - -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -/// Represents whether the return value should compromise of unique witness indices such that no -/// index occurs within the program's abi more than once. -/// -/// This is useful for application stacks that require an uniform abi across across multiple -/// circuits. When index duplication is allowed, the compiler may identify that a public input -/// reaches the output unaltered and is thus referenced directly, causing the input and output -/// witness indices to overlap. Similarly, repetitions of copied values in the output may be -/// optimized away. -pub enum Distinctness { - Distinct, - DuplicationAllowed, -} - -impl std::fmt::Display for Distinctness { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - Self::Distinct => write!(f, "distinct"), - Self::DuplicationAllowed => write!(f, "duplication-allowed"), - } - } -} diff --git a/compiler/noirc_frontend/src/hir/resolution/errors.rs b/compiler/noirc_frontend/src/hir/resolution/errors.rs index d6dd1c2cd54..06f6dda7142 100644 --- a/compiler/noirc_frontend/src/hir/resolution/errors.rs +++ b/compiler/noirc_frontend/src/hir/resolution/errors.rs @@ -40,8 +40,6 @@ pub enum ResolverError { UnnecessaryPub { ident: Ident, position: PubPosition }, #[error("Required 'pub', main function must return public value")] NecessaryPub { ident: Ident }, - #[error("'distinct' keyword can only be used with main method")] - DistinctNotAllowed { ident: Ident }, #[error("Missing expression for declared constant")] MissingRhsExpr { name: String, span: Span }, #[error("Expression invalid in an array length context")] @@ -220,18 +218,6 @@ impl<'a> From<&'a ResolverError> for Diagnostic { diag.add_note("The `pub` keyword is mandatory for the entry-point function return type because the verifier cannot retrieve private witness and thus the function will not be able to return a 'priv' value".to_owned()); diag } - ResolverError::DistinctNotAllowed { ident } => { - let name = &ident.0.contents; - - let mut diag = Diagnostic::simple_error( - format!("Invalid `distinct` keyword on return type of function {name}"), - "Invalid distinct on return type".to_string(), - ident.0.span(), - ); - - diag.add_note("The `distinct` keyword is only valid when used on the main function of a program, as its only purpose is to ensure that all witness indices that occur in the abi are unique".to_owned()); - diag - } ResolverError::MissingRhsExpr { name, span } => Diagnostic::simple_error( format!( "no expression specifying the value stored by the constant variable {name}" diff --git a/compiler/noirc_frontend/src/lexer/token.rs b/compiler/noirc_frontend/src/lexer/token.rs index 950697c2536..d8555b4fbf7 100644 --- a/compiler/noirc_frontend/src/lexer/token.rs +++ b/compiler/noirc_frontend/src/lexer/token.rs @@ -839,7 +839,6 @@ pub enum Keyword { Contract, Crate, Dep, - Distinct, Else, Field, Fn, @@ -884,7 +883,6 @@ impl fmt::Display for Keyword { Keyword::Contract => write!(f, "contract"), Keyword::Crate => write!(f, "crate"), Keyword::Dep => write!(f, "dep"), - Keyword::Distinct => write!(f, "distinct"), Keyword::Else => write!(f, "else"), Keyword::Field => write!(f, "Field"), Keyword::Fn => write!(f, "fn"), @@ -932,7 +930,6 @@ impl Keyword { "contract" => Keyword::Contract, "crate" => Keyword::Crate, "dep" => Keyword::Dep, - "distinct" => Keyword::Distinct, "else" => Keyword::Else, "Field" => Keyword::Field, "fn" => Keyword::Fn, diff --git a/compiler/noirc_frontend/src/noir_parser.lalrpop b/compiler/noirc_frontend/src/noir_parser.lalrpop index 9acb5ef8b58..c6cb788a5a4 100644 --- a/compiler/noirc_frontend/src/noir_parser.lalrpop +++ b/compiler/noirc_frontend/src/noir_parser.lalrpop @@ -67,7 +67,6 @@ extern { "contract" => BorrowedToken::Keyword(noir_token::Keyword::Contract), "crate" => BorrowedToken::Keyword(noir_token::Keyword::Crate), "dep" => BorrowedToken::Keyword(noir_token::Keyword::Dep), - "distinct" => BorrowedToken::Keyword(noir_token::Keyword::Distinct), "else" => BorrowedToken::Keyword(noir_token::Keyword::Else), "Field" => BorrowedToken::Keyword(noir_token::Keyword::Field), "fn" => BorrowedToken::Keyword(noir_token::Keyword::Fn), diff --git a/compiler/noirc_frontend/src/parser/errors.rs b/compiler/noirc_frontend/src/parser/errors.rs index 9f9a8200954..af3d4caa145 100644 --- a/compiler/noirc_frontend/src/parser/errors.rs +++ b/compiler/noirc_frontend/src/parser/errors.rs @@ -30,8 +30,6 @@ pub enum ParserErrorReason { TraitImplFunctionModifiers, #[error("comptime keyword is deprecated")] ComptimeDeprecated, - #[error("distinct keyword is deprecated. The `distinct` behavior is now the default.")] - DistinctDeprecated, #[error("{0} are experimental and aren't fully supported yet")] ExperimentalFeature(&'static str), #[error( diff --git a/compiler/noirc_frontend/src/parser/parser/function.rs b/compiler/noirc_frontend/src/parser/parser/function.rs index 40180a9f9ac..4db5637f6a7 100644 --- a/compiler/noirc_frontend/src/parser/parser/function.rs +++ b/compiler/noirc_frontend/src/parser/parser/function.rs @@ -4,16 +4,12 @@ use super::{ parameter_name_recovery, parameter_recovery, parenthesized, parse_type, pattern, self_parameter, where_clause, NoirParser, }; +use crate::ast::{ + FunctionDefinition, FunctionReturnType, Ident, ItemVisibility, NoirFunction, Param, Visibility, +}; use crate::parser::labels::ParsingRuleLabel; use crate::parser::spanned; use crate::token::{Keyword, Token}; -use crate::{ - ast::{ - FunctionDefinition, FunctionReturnType, Ident, ItemVisibility, NoirFunction, Param, - Visibility, - }, - parser::{ParserError, ParserErrorReason}, -}; use chumsky::prelude::*; @@ -95,20 +91,9 @@ pub(super) fn generics() -> impl NoirParser> { .map(|opt| opt.unwrap_or_default()) } -#[deprecated = "Distinct keyword is now deprecated. Remove this function after the 0.30.0 release"] -fn optional_distinctness() -> impl NoirParser { - keyword(Keyword::Distinct).or_not().validate(|opt, span, emit| { - if opt.is_some() { - emit(ParserError::with_reason(ParserErrorReason::DistinctDeprecated, span)); - } - opt.is_some() - }) -} - pub(super) fn function_return_type() -> impl NoirParser<(Visibility, FunctionReturnType)> { #[allow(deprecated)] just(Token::Arrow) - .ignore_then(optional_distinctness()) .ignore_then(optional_visibility()) .then(spanned(parse_type())) .or_not() @@ -224,8 +209,6 @@ mod test { // A leading plus is not allowed. "fn func_name(f: Field, y : T) where T: + SomeTrait {}", "fn func_name(f: Field, y : T) where T: TraitX + {}", - // `distinct` is deprecated - "fn main(x: pub u8, y: pub u8) -> distinct pub [u8; 2] { [x, y] }", ], ); } diff --git a/tooling/noirc_abi/src/lib.rs b/tooling/noirc_abi/src/lib.rs index 2abb28e2538..514fac2e73d 100644 --- a/tooling/noirc_abi/src/lib.rs +++ b/tooling/noirc_abi/src/lib.rs @@ -107,21 +107,6 @@ impl From<&Visibility> for AbiVisibility { } } -#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "lowercase")] -/// Represents whether the return value should compromise of unique witness indices such that no -/// index occurs within the program's abi more than once. -/// -/// This is useful for application stacks that require an uniform abi across across multiple -/// circuits. When index duplication is allowed, the compiler may identify that a public input -/// reaches the output unaltered and is thus referenced directly, causing the input and output -/// witness indices to overlap. Similarly, repetitions of copied values in the output may be -/// optimized away. -pub enum AbiDistinctness { - Distinct, - DuplicationAllowed, -} - #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)] #[serde(rename_all = "lowercase")] pub enum Sign {