rust/tests/ui/inference/issue-72690.stderr
Esteban Küber 796be88062 Use fn ptr signature instead of {closure@..} in infer error
When suggesting a type on inference error, do not use `{closure@..}`.
Instead, replace with an appropriate `fn` ptr.

On the error message, use `short_ty_string` and write long types to
disk.

```
error[E0284]: type annotations needed for `Select<{closure@lib.rs:2782:13}, _, Expression<'_>, _>`
  --> crates/lang/src/parser.rs:41:13
   |
41 |         let lit = select! {
   |             ^^^
42 |             Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()),
   |                                                                                                  ---- type must be known at this point
   |
   = note: the full type name has been written to '/home/gh-estebank/iowo/target/debug/deps/lang-e2d6e25819442273.long-type-4587393693885174369.txt'
   = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan`
help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified
   |
41 |         let lit: Select<for<'a, 'b> fn(tokens::Token<'_>, &'a mut MapExtra<'_, 'b, _, _>) -> Option<Expression<'_>>, _, Expression<'_>, _> = select! {
   |                +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
```

instead of

```
error[E0284]: type annotations needed for `Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _>`
  --> crates/lang/src/parser.rs:41:13
   |
41 |         let lit = select! {
   |             ^^^
42 |             Token::Int(i) = e => Expression::new(Expr::Lit(ast::Lit::Int(i.parse().unwrap())), e.span()),
   |                                                                                                  ---- type must be known at this point
   |
   = note: cannot satisfy `<_ as chumsky::input::Input<'_>>::Span == SimpleSpan`
help: consider giving `lit` an explicit type, where the type for type parameter `I` is specified
   |
41 |         let lit: Select<{closure@/home/gh-estebank/.cargo/registry/src/index.crates.io-6f17d22bba15001f/chumsky-1.0.0-alpha.6/src/lib.rs:2782:13: 2782:28}, _, Expression<'_>, _> = select! {
   |                ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
```

Fix #123630.
2024-04-10 00:41:27 +00:00

228 lines
8.0 KiB
Plaintext

error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:7:5
|
LL | String::from("x".as_ref());
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:7:22
|
LL | String::from("x".as_ref());
| ^^^^^^
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
|
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:12:9
|
LL | |x| String::from("x".as_ref());
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:12:26
|
LL | |x| String::from("x".as_ref());
| ^^^^^^
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
|
LL | |x| String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed for `&_`
--> $DIR/issue-72690.rs:17:9
|
LL | let _ = "x".as_ref();
| ^ ------ type must be known at this point
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: consider giving this pattern a type, where the type for type parameter `T` is specified
|
LL | let _: &T = "x".as_ref();
| ++++
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:21:5
|
LL | String::from("x".as_ref());
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:21:22
|
LL | String::from("x".as_ref());
| ^^^^^^
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
|
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:28:5
|
LL | String::from("x".as_ref());
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:28:22
|
LL | String::from("x".as_ref());
| ^^^^^^
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
|
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:37:5
|
LL | String::from("x".as_ref());
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:37:22
|
LL | String::from("x".as_ref());
| ^^^^^^
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
|
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:46:5
|
LL | String::from("x".as_ref());
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:46:22
|
LL | String::from("x".as_ref());
| ^^^^^^
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
|
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:53:5
|
LL | String::from("x".as_ref());
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:53:22
|
LL | String::from("x".as_ref());
| ^^^^^^
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
|
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:62:5
|
LL | String::from("x".as_ref());
| ^^^^^^ cannot infer type for reference `&_`
|
= note: multiple `impl`s satisfying `String: From<&_>` found in the `alloc` crate:
- impl From<&String> for String;
- impl From<&str> for String;
error[E0283]: type annotations needed
--> $DIR/issue-72690.rs:62:22
|
LL | String::from("x".as_ref());
| ^^^^^^
|
= note: multiple `impl`s satisfying `str: AsRef<_>` found in the following crates: `core`, `std`:
- impl AsRef<OsStr> for str;
- impl AsRef<Path> for str;
- impl AsRef<[u8]> for str;
- impl AsRef<str> for str;
help: try using a fully qualified path to specify the expected types
|
LL | String::from(<str as AsRef<T>>::as_ref("x"));
| ++++++++++++++++++++++++++ ~
error: aborting due to 17 previous errors
For more information about this error, try `rustc --explain E0283`.