expectations from fudging are a mess
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
At its core we use fudging for the following pattern
fn foo<T>(x: T) -> Box<T> { Box::new(x) }
fn main() {
let _: Box<dyn Fn(&str) -> usize> = foo(|s| s.len());
}
We end up with the expectation that foos argument is dyn Fn(&str) -> usize even though that type is not Sized. This is why fudge_inference_if_ok exists and why it's used for function calls when checkig their arguments.
We try to deal with this by weakening the expectation in case it's not sized
This is widely insufficient for multiple reasons
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with compiler/rustc_hir_typeck/src/expectation.rs around lines 77–89, then inspect fudge_inference_if_ok and its use when checking function-call arguments. Reproduce the generic function example from the issue and trace how the unsized dyn Fn expectation is formed. The issue does not yet define the remaining cases or a concrete completion criterion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100