GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
gccrs

gccrs: Allow bidirectional inference on call expressions

Type inference for function calls now considers expected return types, aiding in complex scenarios like 'try'.

GCC’s Rust compiler (gccrs) now supports bidirectional type inference for function call expressions. This enhancement is crucial for scenarios like the ? operator (try), where the expected return type of the surrounding block must constrain the type inference of the call.

In Details

The gccrs type checker now supports bidirectional inference for call expressions by pushing and applying expected types. This resolves issues with type inference in contexts where the call's return type significantly constrains other type decisions, such as handling the ? operator's propagation of errors which requires the call to match the expected block return type.

For Context
type inference
The process by which a compiler automatically deduces the data types of expressions and variables without explicit type annotations from the programmer.
bidirectional inference
A type inference strategy that uses both the expected type of a context and the type of an expression to deduce types. This is more powerful than unidirectional inference.
call expression
An expression that invokes a function or method, typically resulting in a value.
? operator (try)
In Rust, a shorthand operator for propagating errors. If an expression returns a Result or Option, the ? operator unwraps the Ok or Some value, or returns the Err or None from the surrounding function.
Filed Under: gccrstype inferenceRust