File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
c2rust-transpile/src/c_ast Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -508,15 +508,17 @@ impl TypedAstContext {
508508 }
509509
510510 /// Return the list of types for a list of declared function parameters.
511+ ///
512+ /// Returns `None` if one of the parameters is not a `CDeclKind::Variable`, e.g. if it was not a
513+ /// function parameter but actually some other kind of declaration.
511514 pub fn tys_of_params ( & self , parameters : & [ CDeclId ] ) -> Option < Vec < CQualTypeId > > {
512- let mut param_tys = vec ! [ ] ;
513- for p in parameters {
514- match self . index ( * p) . kind {
515- CDeclKind :: Variable { typ, .. } => param_tys. push ( CQualTypeId :: new ( typ. ctype ) ) ,
516- _ => return None ,
517- }
518- }
519- return Some ( param_tys) ;
515+ parameters
516+ . iter ( )
517+ . map ( |p| match self . index ( * p) . kind {
518+ CDeclKind :: Variable { typ, .. } => Some ( CQualTypeId :: new ( typ. ctype ) ) ,
519+ _ => None ,
520+ } )
521+ . collect ( )
520522 }
521523
522524 /// Return the most precise possible CTypeKind for the given function declaration.
You can’t perform that action at this time.
0 commit comments