-
Notifications
You must be signed in to change notification settings - Fork 13.4k
rustc's help: try
suggestions can be syntactically incorrect rust, even when suggesting specific rust code as an error solution
#122569
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
Useful tool to fix these kinds of bugs: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/trait.IsSuggestable.html#tymethod.is_suggestable |
estebank
added a commit
to estebank/rust
that referenced
this issue
Mar 20, 2024
…thod call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
estebank
added a commit
to estebank/rust
that referenced
this issue
Mar 21, 2024
…thod call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 21, 2024
Replace closures with `_` when suggesting fully qualified path for method call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this issue
Mar 21, 2024
Replace closures with `_` when suggesting fully qualified path for method call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 21, 2024
Replace closures with `_` when suggesting fully qualified path for method call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this issue
Mar 21, 2024
Replace closures with `_` when suggesting fully qualified path for method call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Mar 21, 2024
Rollup merge of rust-lang#122799 - estebank:issue-122569, r=fee1-dead Replace closures with `_` when suggesting fully qualified path for method call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Apr 4, 2024
…thod call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
flip1995
pushed a commit
to flip1995/rust
that referenced
this issue
Apr 4, 2024
Replace closures with `_` when suggesting fully qualified path for method call ``` error[E0283]: type annotations needed --> $DIR/into-inference-needs-type.rs:12:10 | LL | .into()?; | ^^^^ | = note: cannot satisfy `_: From<...>` = note: required for `FilterMap<...>` to implement `Into<_>` help: try using a fully qualified path to specify the expected types | LL ~ let list = <FilterMap<Map<std::slice::Iter<'_, &str>, _>, _> as Into<T>>::into(vec LL | .iter() LL | .map(|s| s.strip_prefix("t")) LL ~ .filter_map(Option::Some))?; | ``` Fix rust-lang#122569.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Uh oh!
There was an error while loading. Please reload this page.
Discovered by a rust beginner...
Code
Current output
Desired output
Perhaps an output like for the similar error
error[E0283]: type annotations needed
would be better. It is also suggestion specific rust code but it is clear that this is pseudocode.For example like:
Rationale and extra context
I expect
rustc
to generate at least syntactically correct rust if it is providing a suggestion of rust code, especially since rustc is the judge of syntax.For many classes of errors, the
help
is prose or pseudocode and not a specific rust code suggestion. In this example afully qualified path to specify the expected types
is not valid rust.The closure "type" with file line numbers is not a helpful suggestion.
Other cases
Here's the (sanitized) error i got while working on my production codebase. Notice it is an
E0282
error instead ofE0283
- I couldn't reproduce my production error exactly with my minimal example.Rust Version
> rustc --version --verbose rustc 1.76.0 (07dca489a 2024-02-04) binary: rustc commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce commit-date: 2024-02-04 host: aarch64-apple-darwin release: 1.76.0 LLVM version: 17.0.6
Anything else?
No response
The text was updated successfully, but these errors were encountered: