File tree Expand file tree Collapse file tree 4 files changed +17
-18
lines changed
semantic_analysis/ast_node/expression Expand file tree Collapse file tree 4 files changed +17
-18
lines changed Original file line number Diff line number Diff line change @@ -1697,7 +1697,7 @@ fn const_eval_intrinsic(
16971697 }
16981698 Intrinsic :: RuntimeMemoryId => {
16991699 assert ! ( intrinsic. type_arguments. len( ) == 1 ) ;
1700- assert ! ( intrinsic. arguments. len ( ) == 0 ) ;
1700+ assert ! ( intrinsic. arguments. is_empty ( ) ) ;
17011701
17021702 let t = & intrinsic. type_arguments [ 0 ] ;
17031703 let t = convert_resolved_type_id (
@@ -1721,7 +1721,7 @@ fn const_eval_intrinsic(
17211721 }
17221722 Intrinsic :: EncodingMemoryId => {
17231723 assert ! ( intrinsic. type_arguments. len( ) == 1 ) ;
1724- assert ! ( intrinsic. arguments. len ( ) == 0 ) ;
1724+ assert ! ( intrinsic. arguments. is_empty ( ) ) ;
17251725
17261726 let t = intrinsic. type_arguments [ 0 ] . as_type_argument ( ) . unwrap ( ) ;
17271727
Original file line number Diff line number Diff line change @@ -2422,7 +2422,7 @@ impl<'a> FnCompiler<'a> {
24222422 }
24232423 Intrinsic :: RuntimeMemoryId => {
24242424 assert ! ( type_arguments. len( ) == 1 ) ;
2425- assert ! ( arguments. len ( ) == 0 ) ;
2425+ assert ! ( arguments. is_empty ( ) ) ;
24262426
24272427 let arg = type_arguments[ 0 ] . as_type_argument ( ) . unwrap ( ) ;
24282428 let t = convert_resolved_type_id (
@@ -2443,8 +2443,8 @@ impl<'a> FnCompiler<'a> {
24432443 }
24442444 Intrinsic :: EncodingMemoryId => {
24452445 assert ! ( type_arguments. len( ) == 1 ) ;
2446- assert ! ( arguments. len ( ) == 0 ) ;
2447-
2446+ assert ! ( arguments. is_empty ( ) ) ;
2447+
24482448 let arg = type_arguments[ 0 ] . as_type_argument ( ) . unwrap ( ) ;
24492449 let id = get_encoding_id ( self . engines , arg. type_id ) ;
24502450 let val = ConstantContent :: get_uint ( context, 64 , id) ;
Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ fn type_check_encoding_memory_id(
131131 span : Span ,
132132 ctx : TypeCheckContext ,
133133) -> Result < ( TyIntrinsicFunctionKind , TypeId ) , ErrorEmitted > {
134- if arguments. len ( ) != 0 {
134+ if ! arguments. is_empty ( ) {
135135 return Err ( handler. emit_err ( CompileError :: IntrinsicIncorrectNumArgs {
136136 name : kind. to_string ( ) ,
137137 expected : 0 ,
@@ -177,7 +177,7 @@ fn type_check_runtime_memory_id(
177177 span : Span ,
178178 ctx : TypeCheckContext ,
179179) -> Result < ( TyIntrinsicFunctionKind , TypeId ) , ErrorEmitted > {
180- if arguments. len ( ) != 0 {
180+ if ! arguments. is_empty ( ) {
181181 return Err ( handler. emit_err ( CompileError :: IntrinsicIncorrectNumArgs {
182182 name : kind. to_string ( ) ,
183183 expected : 0 ,
@@ -194,7 +194,8 @@ fn type_check_runtime_memory_id(
194194 }
195195
196196 let targ = & type_arguments[ 0 ] ;
197- let arg = ctx. resolve_type (
197+ let arg = ctx
198+ . resolve_type (
198199 handler,
199200 targ. type_id ( ) ,
200201 & targ. span ( ) ,
Original file line number Diff line number Diff line change @@ -27,17 +27,15 @@ impl Length {
2727 pub fn extract_literal ( & self , engines : & Engines ) -> Option < u64 > {
2828 match & self . 0 {
2929 ConstGenericExpr :: Literal { val, .. } => Some ( * val as u64 ) ,
30- ConstGenericExpr :: AmbiguousVariableExpression { decl, .. } => {
31- match decl. as_ref ( ) ? {
32- ConstGenericExprTyDecl :: ConstGenericDecl ( decl) => {
33- let decl = engines. de ( ) . get ( & decl. decl_id ) ;
34- let expr = decl. value . as_ref ( ) ?;
35- let expr = expr. expression . as_literal ( ) ?;
36- expr. cast_value_to_u64 ( )
37- }
38- ConstGenericExprTyDecl :: ConstantDecl ( _) => None ,
30+ ConstGenericExpr :: AmbiguousVariableExpression { decl, .. } => match decl. as_ref ( ) ? {
31+ ConstGenericExprTyDecl :: ConstGenericDecl ( decl) => {
32+ let decl = engines. de ( ) . get ( & decl. decl_id ) ;
33+ let expr = decl. value . as_ref ( ) ?;
34+ let expr = expr. expression . as_literal ( ) ?;
35+ expr. cast_value_to_u64 ( )
3936 }
40- }
37+ ConstGenericExprTyDecl :: ConstantDecl ( _) => None ,
38+ } ,
4139 }
4240 }
4341}
You can’t perform that action at this time.
0 commit comments