@@ -121,7 +121,7 @@ pub enum TypeRef {
121
121
Slice ( Box < TypeRef > ) ,
122
122
/// A fn pointer. Last element of the vector is the return type.
123
123
Fn (
124
- Vec < ( Option < Name > , TypeRef ) > ,
124
+ Box < [ ( Option < Name > , TypeRef ) ] > ,
125
125
bool , /*varargs*/
126
126
bool , /*is_unsafe*/
127
127
Option < Symbol > , /* abi */
@@ -228,7 +228,7 @@ impl TypeRef {
228
228
} )
229
229
. collect ( )
230
230
} else {
231
- Vec :: new ( )
231
+ Vec :: with_capacity ( 1 )
232
232
} ;
233
233
fn lower_abi ( abi : ast:: Abi ) -> Symbol {
234
234
match abi. abi_string ( ) {
@@ -240,7 +240,7 @@ impl TypeRef {
240
240
241
241
let abi = inner. abi ( ) . map ( lower_abi) ;
242
242
params. push ( ( None , ret_ty) ) ;
243
- TypeRef :: Fn ( params, is_varargs, inner. unsafe_token ( ) . is_some ( ) , abi)
243
+ TypeRef :: Fn ( params. into ( ) , is_varargs, inner. unsafe_token ( ) . is_some ( ) , abi)
244
244
}
245
245
// for types are close enough for our purposes to the inner type for now...
246
246
ast:: Type :: ForType ( inner) => TypeRef :: from_ast_opt ( ctx, inner. ty ( ) ) ,
@@ -396,7 +396,7 @@ impl TypeBound {
396
396
397
397
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
398
398
pub enum ConstRef {
399
- Scalar ( LiteralConstRef ) ,
399
+ Scalar ( Box < LiteralConstRef > ) ,
400
400
Path ( Name ) ,
401
401
Complex ( AstId < ast:: ConstArg > ) ,
402
402
}
@@ -408,7 +408,7 @@ impl ConstRef {
408
408
return Self :: from_expr ( expr, Some ( lower_ctx. ast_id ( & arg) ) ) ;
409
409
}
410
410
}
411
- Self :: Scalar ( LiteralConstRef :: Unknown )
411
+ Self :: Scalar ( Box :: new ( LiteralConstRef :: Unknown ) )
412
412
}
413
413
414
414
pub ( crate ) fn from_const_param (
@@ -452,10 +452,10 @@ impl ConstRef {
452
452
ast:: Expr :: PathExpr ( p) if is_path_ident ( & p) => {
453
453
match p. path ( ) . and_then ( |it| it. segment ( ) ) . and_then ( |it| it. name_ref ( ) ) {
454
454
Some ( it) => Self :: Path ( it. as_name ( ) ) ,
455
- None => Self :: Scalar ( LiteralConstRef :: Unknown ) ,
455
+ None => Self :: Scalar ( Box :: new ( LiteralConstRef :: Unknown ) ) ,
456
456
}
457
457
}
458
- ast:: Expr :: Literal ( literal) => Self :: Scalar ( match literal. kind ( ) {
458
+ ast:: Expr :: Literal ( literal) => Self :: Scalar ( Box :: new ( match literal. kind ( ) {
459
459
ast:: LiteralKind :: IntNumber ( num) => {
460
460
num. value ( ) . map ( LiteralConstRef :: UInt ) . unwrap_or ( LiteralConstRef :: Unknown )
461
461
}
@@ -464,12 +464,12 @@ impl ConstRef {
464
464
}
465
465
ast:: LiteralKind :: Bool ( f) => LiteralConstRef :: Bool ( f) ,
466
466
_ => LiteralConstRef :: Unknown ,
467
- } ) ,
467
+ } ) ) ,
468
468
_ => {
469
469
if let Some ( ast_id) = ast_id {
470
470
Self :: Complex ( ast_id)
471
471
} else {
472
- Self :: Scalar ( LiteralConstRef :: Unknown )
472
+ Self :: Scalar ( Box :: new ( LiteralConstRef :: Unknown ) )
473
473
}
474
474
}
475
475
}
0 commit comments