-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Fix late-bound ICE in dyn
return type suggestion
#95603
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rustbot
added
the
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
label
Apr 2, 2022
(rust-highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Apr 2, 2022
cjgillot
reviewed
Apr 2, 2022
compiler-errors
force-pushed
the
dyn-return
branch
from
April 2, 2022 22:14
5d95a4c
to
a9c915d
Compare
This comment has been minimized.
This comment has been minimized.
compiler-errors
force-pushed
the
dyn-return
branch
from
April 2, 2022 22:30
a9c915d
to
b899251
Compare
Thanks for the PR, @compiler-errors! This looks like r? rust-lang/diagnostics to me. |
oooh nice @bors r+ |
📌 Commit b899251 has been approved by |
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 4, 2022
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Apr 4, 2022
Fix late-bound ICE in `dyn` return type suggestion This fixes the root-cause of the attached issues -- the root problem is that we're using the return type from a signature with late-bound instead of early-bound regions. The change on line 1087 (`let Some(liberated_sig) = typeck_results.liberated_fn_sigs().get(fn_hir_id) else { return false; };`) makes sure we're grabbing the _right_ return type for this suggestion to check the `dyn` predicates with. Fixes rust-lang#91801 Fixes rust-lang#91803 This fix also includes some drive-by changes, specifically: 1. Don't suggest boxing when we have `-> dyn Trait` and are already returning `Box<T>` where `T: Trait` (before we always boxed the value). 2. Suggestion applies even when the return type is a type alias (e.g. `type Foo = dyn Trait`). This does cause the suggestion to expand to the aliased type, but I think it's still beneficial. 3. Split up the multipart suggestion because there's a 6-line max in the printed output... I am open to splitting out the above changes, if we just want to fix the ICE first. cc: `@terrarier2111` and rust-lang#92289
Dylan-DPC
added a commit
to Dylan-DPC/rust
that referenced
this pull request
Apr 4, 2022
Fix late-bound ICE in `dyn` return type suggestion This fixes the root-cause of the attached issues -- the root problem is that we're using the return type from a signature with late-bound instead of early-bound regions. The change on line 1087 (`let Some(liberated_sig) = typeck_results.liberated_fn_sigs().get(fn_hir_id) else { return false; };`) makes sure we're grabbing the _right_ return type for this suggestion to check the `dyn` predicates with. Fixes rust-lang#91801 Fixes rust-lang#91803 This fix also includes some drive-by changes, specifically: 1. Don't suggest boxing when we have `-> dyn Trait` and are already returning `Box<T>` where `T: Trait` (before we always boxed the value). 2. Suggestion applies even when the return type is a type alias (e.g. `type Foo = dyn Trait`). This does cause the suggestion to expand to the aliased type, but I think it's still beneficial. 3. Split up the multipart suggestion because there's a 6-line max in the printed output... I am open to splitting out the above changes, if we just want to fix the ICE first. cc: ``@terrarier2111`` and rust-lang#92289
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 5, 2022
Rollup of 7 pull requests Successful merges: - rust-lang#91873 (Mention implementers of unsatisfied trait) - rust-lang#95588 (explicitly distinguish pointer::addr and pointer::expose_addr) - rust-lang#95603 (Fix late-bound ICE in `dyn` return type suggestion) - rust-lang#95620 (interpret: remove MemoryExtra in favor of giving access to the Machine) - rust-lang#95630 (Update `NonNull` pointer provenance methods' documentation) - rust-lang#95631 (Refactor: remove unnecessary nested blocks) - rust-lang#95642 (`CandidateSource::XCandidate` -> `CandidateSource::X`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the root-cause of the attached issues -- the root problem is that we're using the return type from a signature with late-bound instead of early-bound regions. The change on line 1087 (
let Some(liberated_sig) = typeck_results.liberated_fn_sigs().get(fn_hir_id) else { return false; };
) makes sure we're grabbing the right return type for this suggestion to check thedyn
predicates with.Fixes #91801
Fixes #91803
This fix also includes some drive-by changes, specifically:
-> dyn Trait
and are already returningBox<T>
whereT: Trait
(before we always boxed the value).type Foo = dyn Trait
). This does cause the suggestion to expand to the aliased type, but I think it's still beneficial.I am open to splitting out the above changes, if we just want to fix the ICE first.
cc: @terrarier2111 and #92289