From 48b013ee6c942820e84e7da200dd6f6320663568 Mon Sep 17 00:00:00 2001 From: Fallible <118682743+fallible-algebra@users.noreply.github.com> Date: Mon, 6 Jul 2026 10:05:07 +0100 Subject: [PATCH 1/4] empty file --- src/analysis/hir-tyck.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/analysis/hir-tyck.md diff --git a/src/analysis/hir-tyck.md b/src/analysis/hir-tyck.md new file mode 100644 index 0000000000..e69de29bb2 From e996b384ed8fdad5a960499dac1c7d6adc483b4a Mon Sep 17 00:00:00 2001 From: Fallible <118682743+fallible-algebra@users.noreply.github.com> Date: Mon, 6 Jul 2026 16:13:03 +0100 Subject: [PATCH 2/4] Some expectations writeup --- src/analysis/hir-tyck.md | 0 src/hir-typeck/expectations.md | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+) delete mode 100644 src/analysis/hir-tyck.md create mode 100644 src/hir-typeck/expectations.md diff --git a/src/analysis/hir-tyck.md b/src/analysis/hir-tyck.md deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/hir-typeck/expectations.md b/src/hir-typeck/expectations.md new file mode 100644 index 0000000000..d4be2d83a7 --- /dev/null +++ b/src/hir-typeck/expectations.md @@ -0,0 +1,23 @@ +# Expectations + +In an ideal world, we would only perform type inference at one point in the compiler: once all constraints have been collected. + +In reality, we perform it (at least) twice: First, at eager evaluation points, and secondly "at the end." + +`Expectations` are a piece of type-checking state we maintain for the cases where we need to eagerly infer the types of expressions rather than leave them to the end. + +The main subjects of "eager type inference" are: + +- Method calls +- Closures (their signatures could be higher-ranked) +- Coercions +- fields +- indexing (because of weird dereferencing stuff this isn't just a Method Call) + + +## Closures and Higher-Ranked Variables + +Closures need to have type inference eagerly applied to them because [reasons]. + +Papers: +- [This one](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/putting.pdf) \ No newline at end of file From 0dbb79a718e92d5ab0fd7cb48ac01f78df67a49f Mon Sep 17 00:00:00 2001 From: Fallible <118682743+fallible-algebra@users.noreply.github.com> Date: Fri, 10 Jul 2026 16:18:28 +0100 Subject: [PATCH 3/4] Some assertions, mostly blank space --- src/hir-typeck/expectations.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/hir-typeck/expectations.md b/src/hir-typeck/expectations.md index d4be2d83a7..e0515aba5a 100644 --- a/src/hir-typeck/expectations.md +++ b/src/hir-typeck/expectations.md @@ -2,22 +2,27 @@ In an ideal world, we would only perform type inference at one point in the compiler: once all constraints have been collected. -In reality, we perform it (at least) twice: First, at eager evaluation points, and secondly "at the end." +In reality, we perform it (at least) twice: First, at eager evaluation points, and secondly "at the end" when those constraints have been collected. `Expectations` are a piece of type-checking state we maintain for the cases where we need to eagerly infer the types of expressions rather than leave them to the end. -The main subjects of "eager type inference" are: +## Eager Type Checking / Inference. -- Method calls -- Closures (their signatures could be higher-ranked) -- Coercions -- fields -- indexing (because of weird dereferencing stuff this isn't just a Method Call) + +### Closures and Higher-Ranked Variables -## Closures and Higher-Ranked Variables +Closures need to have type inference eagerly applied to them because they are functions that are rarely fully annotated. Top-level functions i.e. `fn (what_that_is: T, what_it_isnt: Y) -> bool {/* */}` have their input / output types fully defined (opaque types still being an explicit annotation) but closures tend to have most/all of their type annotations missing, like `|a, b| if a < b {vec![1, 2, 3]} else {vec![6, 7, 8]} `. -Closures need to have type inference eagerly applied to them because [reasons]. +Eager, Higher-Ranked type inference happens in closures because closures can introduce Higher-Ranked Lifetimes. `for<'a> T<'a>` is the only style of higher-ranked bound in Rust, and these can appear in the types of closures. + +### Method calls + +### Coercions + +### Fields + +### Indexing Papers: - [This one](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/putting.pdf) \ No newline at end of file From b5dafa7a758fff09f64d5f5c504cedc64b542384 Mon Sep 17 00:00:00 2001 From: Fallible <118682743+fallible-algebra@users.noreply.github.com> Date: Fri, 10 Jul 2026 16:39:50 +0100 Subject: [PATCH 4/4] More sketching --- src/hir-typeck/eager-inference.md | 1 + src/hir-typeck/expectations.md | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/hir-typeck/eager-inference.md diff --git a/src/hir-typeck/eager-inference.md b/src/hir-typeck/eager-inference.md new file mode 100644 index 0000000000..894af9e527 --- /dev/null +++ b/src/hir-typeck/eager-inference.md @@ -0,0 +1 @@ +## Eager Type Inference \ No newline at end of file diff --git a/src/hir-typeck/expectations.md b/src/hir-typeck/expectations.md index e0515aba5a..ada16e28eb 100644 --- a/src/hir-typeck/expectations.md +++ b/src/hir-typeck/expectations.md @@ -4,7 +4,7 @@ In an ideal world, we would only perform type inference at one point in the comp In reality, we perform it (at least) twice: First, at eager evaluation points, and secondly "at the end" when those constraints have been collected. -`Expectations` are a piece of type-checking state we maintain for the cases where we need to eagerly infer the types of expressions rather than leave them to the end. +`Expectations` are a piece of type inference state we maintain for the cases where we need to eagerly infer the types of expressions rather than leave them to the end. ## Eager Type Checking / Inference. @@ -16,13 +16,22 @@ Closures need to have type inference eagerly applied to them because they are fu Eager, Higher-Ranked type inference happens in closures because closures can introduce Higher-Ranked Lifetimes. `for<'a> T<'a>` is the only style of higher-ranked bound in Rust, and these can appear in the types of closures. -### Method calls ### Coercions -### Fields +Actually yes does use expectations. + +### Method calls? + +Maybe Not. Maybe just point to [method lookup](./method-lookup.md). + +### Fields? + +Maybe Not ### Indexing +lcnr said so. + Papers: - [This one](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/putting.pdf) \ No newline at end of file