Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message for _ in function signature in impl Trait for Ty #95395

Merged
merged 2 commits into from
Apr 25, 2022

Conversation

compiler-errors
Copy link
Member

@compiler-errors compiler-errors commented Mar 28, 2022

Provides a replacement suggestion for when _ is present in the function signature for impl Trait for Ty, using the substitutions from the trait to compute the exact type.

Fixes #95097

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 28, 2022
@rust-highfive
Copy link
Collaborator

r? @wesleywiser

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 28, 2022
@compiler-errors compiler-errors changed the title Infer on impl for trait Better error message for _ in function signature in impl Trait for Ty Mar 28, 2022
@compiler-errors
Copy link
Member Author

r? rust-lang/compiler

@michaelwoerister
Copy link
Member

r? rust-lang/diagnostics

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some nits. r=me with those resolved

compiler/rustc_typeck/src/astconv/mod.rs Outdated Show resolved Hide resolved
compiler/rustc_typeck/src/astconv/mod.rs Outdated Show resolved Hide resolved
@oli-obk oli-obk added A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. labels Apr 23, 2022
@compiler-errors
Copy link
Member Author

rebased and comments addressed.

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Apr 24, 2022

📌 Commit 319fbe3 has been approved by oli-obk

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 24, 2022
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#95395 (Better error message for `_` in function signature in `impl Trait for Ty`)
 - rust-lang#96090 (Implement MIR opt unit tests)
 - rust-lang#96107 ([test] Add test cases for untested functions for VecDeque)
 - rust-lang#96212 (Use revisions instead of nll compare mode for `/regions/` ui tests)
 - rust-lang#96215 (Drop support for legacy PM with LLVM 15)
 - rust-lang#96366 (bootstrap: Remove dead code in rustdoc shim)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 76aa9e5 into rust-lang:master Apr 25, 2022
@rustbot rustbot added this to the 1.62.0 milestone Apr 25, 2022
@scottmcm
Copy link
Member

Thanks, @compiler-errors ! This looks great; I'm excited to try it.

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 26, 2022
…bank

Fix erased region escaping into wfcheck due to rust-lang#95395

We can just use `liberate_late_bound_regions` instead of `erase_late_bound_regions`... This gives us `ReEarlyBound` instead of `ReErased`, the former being something typeck actually knows how to deal with...

Fixes rust-lang#96381

Side-note: We only actually get far enough in the compiler pipeline to cause this ICE when we're invoking rustdoc. We actually abort rustc right before wfcheck because of the error that we emit (having `_` in the type signature). Why does rustdoc keep going even though we raise an error?
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Apr 26, 2022
…bank

Fix erased region escaping into wfcheck due to rust-lang#95395

We can just use `liberate_late_bound_regions` instead of `erase_late_bound_regions`... This gives us `ReEarlyBound` instead of `ReErased`, the former being something typeck actually knows how to deal with...

Fixes rust-lang#96381

Side-note: We only actually get far enough in the compiler pipeline to cause this ICE when we're invoking rustdoc. We actually abort rustc right before wfcheck because of the error that we emit (having `_` in the type signature). Why does rustdoc keep going even though we raise an error?
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Apr 27, 2022
…bank

Fix erased region escaping into wfcheck due to rust-lang#95395

We can just use `liberate_late_bound_regions` instead of `erase_late_bound_regions`... This gives us `ReEarlyBound` instead of `ReErased`, the former being something typeck actually knows how to deal with...

Fixes rust-lang#96381

Side-note: We only actually get far enough in the compiler pipeline to cause this ICE when we're invoking rustdoc. We actually abort rustc right before wfcheck because of the error that we emit (having `_` in the type signature). Why does rustdoc keep going even though we raise an error?
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 27, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#92569 (Improve Error Messaging for Unconstructed Structs and Enum Variants in Generic Contexts)
 - rust-lang#96370 (Cleanup `report_method_error` a bit)
 - rust-lang#96383 (Fix erased region escaping into wfcheck due to rust-lang#95395)
 - rust-lang#96385 (Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLL)
 - rust-lang#96410 (rustdoc: do not write `{{root}}` in `pub use ::foo` docs)
 - rust-lang#96430 (Fix handling of `!` in rustdoc search)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@compiler-errors compiler-errors deleted the infer-on-impl-for-trait branch August 11, 2023 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix`. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide a structured suggestion for _-as-parameter-type in trait impls
8 participants