about summary refs log tree commit diff
path: root/tests/ui/inference/cannot-infer-closure-circular.stderr
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2025-01-24 01:06:14 +0000
committerEsteban Küber <esteban@kuber.com.ar>2025-02-03 19:51:20 +0000
commit6005619bde6abacfdce096d1f67437323b63d8dc (patch)
tree79643e5d4c6c37fd3ec5c8e207afa75a1a9305d3 /tests/ui/inference/cannot-infer-closure-circular.stderr
parent534d79adf938fc3839fad47832c7cf2b4927d7d9 (diff)
downloadrust-6005619bde6abacfdce096d1f67437323b63d8dc.tar.gz
rust-6005619bde6abacfdce096d1f67437323b63d8dc.zip
In "specify type" suggestion, skip type params that are already known
When we suggest specifying a type for an expression or pattern, like in a `let` binding, we previously would print the entire type as the type system knew it. We now look at the params that have *no* inference variables, so they are fully known to the type system which means that they don't need to be specified.

This helps in suggestions for types that are really long, because we can usually skip most of the type params and make the annotation as short as possible:

```
error[E0282]: type annotations needed for `Result<_, ((..., ..., ..., ...), ..., ..., ...)>`
  --> $DIR/really-long-type-in-let-binding-without-sufficient-type-info.rs:7:9
   |
LL |     let y = Err(x);
   |         ^   ------ type must be known at this point
   |
help: consider giving `y` an explicit type, where the type for type parameter `T` is specified
   |
LL |     let y: Result<T, _> = Err(x);
   |          ++++++++++++++
```
Diffstat (limited to 'tests/ui/inference/cannot-infer-closure-circular.stderr')
-rw-r--r--tests/ui/inference/cannot-infer-closure-circular.stderr4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/ui/inference/cannot-infer-closure-circular.stderr b/tests/ui/inference/cannot-infer-closure-circular.stderr
index a16e832f8ef..ee17f7737cf 100644
--- a/tests/ui/inference/cannot-infer-closure-circular.stderr
+++ b/tests/ui/inference/cannot-infer-closure-circular.stderr
@@ -9,8 +9,8 @@ LL |         Ok(v)
    |
 help: consider giving this closure parameter an explicit type, where the type for type parameter `E` is specified
    |
-LL |     let x = |r: Result<(), E>| {
-   |               +++++++++++++++
+LL |     let x = |r: Result<_, E>| {
+   |               ++++++++++++++
 
 error: aborting due to 1 previous error