mirror of
https://github.com/fluencelabs/aquavm
synced 2025-06-24 04:01:32 +00:00
Get rid of unsafe code in the interpreter (#303)
* Get rid of unsafe code unless really necessary * Add lint levels where appropriate Some crates (air-beautifier, air-testing-framework) have lot of rust_2018_idioms violations, that will be resolved later.
This commit is contained in:
@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![deny(
|
||||
dead_code,
|
||||
nonstandard_style,
|
||||
|
@ -23,6 +23,8 @@ use crate::ValueAccessor;
|
||||
|
||||
use va_lambda::LambdaParser;
|
||||
|
||||
use std::convert::TryFrom;
|
||||
|
||||
// Caching parser to cache internal regexes, which are expensive to instantiate
|
||||
// See also https://github.com/lalrpop/lalrpop/issues/269
|
||||
thread_local!(static PARSER: LambdaParser = LambdaParser::new());
|
||||
@ -43,10 +45,5 @@ pub fn parse(lambda: &str) -> LambdaParserResult<'_, LambdaAST> {
|
||||
}
|
||||
|
||||
fn try_to_lambda(accessors: Vec<ValueAccessor>) -> LambdaParserResult<'_, LambdaAST> {
|
||||
if accessors.is_empty() {
|
||||
return Err(LambdaParserError::EmptyLambda);
|
||||
}
|
||||
|
||||
let ast = unsafe { LambdaAST::new_unchecked(accessors) };
|
||||
Ok(ast)
|
||||
LambdaAST::try_from(accessors).or(Err(LambdaParserError::EmptyLambda))
|
||||
}
|
||||
|
Reference in New Issue
Block a user