fn infer_literal<T>(
    context: &Context,
    raw_literal: &raw::Literal,
    wrap_literal: impl Fn(Literal) -> T,
) -> Result<(T, RcType), TypeError> {
    match *raw_literal {
        raw::Literal::String(span, _) => Err(TypeError::AmbiguousStringLiteral { span }),
        raw::Literal::Char(_, value) => {
            Ok((wrap_literal(Literal::Char(value)), context.char().clone()))
        },
        raw::Literal::Int(_, ref value, format) => {
            Ok((wrap_literal(Literal::Int(value.clone(), format)), {
                let value = RcValue::from(Value::Literal(Literal::Int(value.clone(), format)));
                RcValue::from(Value::IntType(Some(value.clone()), Some(value)))
            }))
        },
        raw::Literal::Float(span, _, _) => Err(TypeError::AmbiguousFloatLiteral { span }),
    }
}
/// Synthesize the type of a literal, returning the elaborated literal and the
/// inferred type if successful
Synthesize the type of a literal, returning the elaborated literal and the
inferred type if successful
Synthesize the type of a literal returning the elaborated literal and the inferred type if successful
fn infer_literal<T>(
    context: &Context,
    raw_literal: &raw::Literal,
    wrap_literal: impl Fn(Literal) -> T,
) -> Result<(T, RcType), TypeError> {
    match *raw_literal {
        raw::Literal::String(span, _) => Err(TypeError::AmbiguousStringLiteral { span }),
        raw::Literal::Char(_, value) => {
            Ok((wrap_literal(Literal::Char(value)), context.char().clone()))
        },
        raw::Literal::Int(_, ref value, format) => {
            Ok((wrap_literal(Literal::Int(value.clone(), format)), {
                let value = RcValue::from(Value::Literal(Literal::Int(value.clone(), format)));
                RcValue::from(Value::IntType(Some(value.clone()), Some(value)))
            }))
        },
        raw::Literal::Float(span, _, _) => Err(TypeError::AmbiguousFloatLiteral { span }),
    }
}
fn infer_literal < T > ( context : & Context , raw_literal : & raw :: Literal , wrap_literal : impl Fn ( Literal ) -> T , ) -> Result < ( T , RcType ) , TypeError > { match * raw_literal { raw :: Literal :: String ( span , _ ) => Err ( TypeError :: AmbiguousStringLiteral { span } ) , raw :: Literal :: Char ( _ , value ) => { Ok ( ( wrap_literal ( Literal :: Char ( value ) ) , context . char ( ) . clone ( ) ) ) } , raw :: Literal :: Int ( _ , ref value , format ) => { Ok ( ( wrap_literal ( Literal :: Int ( value . clone ( ) , format ) ) , { let value = RcValue :: from ( Value :: Literal ( Literal :: Int ( value . clone ( ) , format ) ) ) ; RcValue :: from ( Value :: IntType ( Some ( value . clone ( ) ) , Some ( value ) ) ) } ) ) } , raw :: Literal :: Float ( span , _ , _ ) => Err ( TypeError :: AmbiguousFloatLiteral { span } ) , } }
Synthesize the type of a literal, returning the elaborated literal and the
inferred type if successful
Synthesize the type of a literal returning the elaborated literal and the inferred type if successful
context
&Context
raw_literal
&raw::Literal
wrap_literal
impl Fn(Literal) -> T
context
&Context
raw_literal
&raw::Literal
wrap_literal
impl Fn(Literal) -> T