-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli)!: Add
--unstable-features
to gate unstable features (#7449)
- Loading branch information
Showing
18 changed files
with
219 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use std::str::FromStr; | ||
|
||
#[derive(Copy, Clone, Debug, PartialEq, Eq)] | ||
pub enum UnstableFeature { | ||
Enums, | ||
ArrayOwnership, | ||
} | ||
|
||
impl std::fmt::Display for UnstableFeature { | ||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { | ||
match self { | ||
Self::Enums => write!(f, "enums"), | ||
Self::ArrayOwnership => write!(f, "array-ownership"), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for UnstableFeature { | ||
type Err = String; | ||
|
||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"enums" => Ok(Self::Enums), | ||
"array-ownership" => Ok(Self::ArrayOwnership), | ||
other => Err(format!("Unknown unstable feature '{other}'")), | ||
} | ||
} | ||
} | ||
|
||
/// Generic options struct meant to resolve to ElaboratorOptions below when | ||
/// we can resolve a file path to a file id later. This generic struct is used | ||
/// so that FrontendOptions doesn't need to duplicate fields and methods with ElaboratorOptions. | ||
#[derive(Copy, Clone)] | ||
pub struct GenericOptions<'a, T> { | ||
/// The scope of --debug-comptime, or None if unset | ||
pub debug_comptime_in_file: Option<T>, | ||
|
||
/// Use pedantic ACVM solving | ||
pub pedantic_solving: bool, | ||
|
||
/// Unstable compiler features that were explicitly enabled. Any unstable features | ||
/// that are not in this list result in an error when used. | ||
pub enabled_unstable_features: &'a [UnstableFeature], | ||
} | ||
|
||
/// Options from nargo_cli that need to be passed down to the elaborator | ||
pub(crate) type ElaboratorOptions<'a> = GenericOptions<'a, fm::FileId>; | ||
|
||
/// This is the unresolved version of `ElaboratorOptions` | ||
/// CLI options that need to be passed to the compiler frontend (the elaborator). | ||
pub type FrontendOptions<'a> = GenericOptions<'a, &'a str>; | ||
|
||
impl<'a, T> GenericOptions<'a, T> { | ||
/// A sane default of frontend options for running tests | ||
pub fn test_default() -> GenericOptions<'static, T> { | ||
GenericOptions { | ||
debug_comptime_in_file: None, | ||
pedantic_solving: true, | ||
enabled_unstable_features: &[UnstableFeature::Enums], | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.