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

Add hint for missing lifetime bound on trait object when type alias is used #105345

Merged
merged 1 commit into from
Jan 26, 2023

Conversation

yanchen4791
Copy link
Contributor

Fix issue #103582.

The problem: When a type alias is used to specify the return type of the method in a trait impl, the suggestion for fixing the problem of "missing lifetime bound on trait object" of the trait impl will not be created. The issue caused by the code which searches for the return trait objects when constructing the hint suggestion is not able to find the trait objects since they are specified in the type alias path instead of the return path of the trait impl.

The solution: Trace the trait objects in the type alias path and provide them along with the alias span to generate the suggestion in case the type alias is used in return type of the method in the trait impl.

@rustbot
Copy link
Collaborator

rustbot commented Dec 6, 2022

r? @lcnr

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 6, 2022
@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Dec 6, 2022

r? types

@rustbot rustbot assigned jackh726 and unassigned lcnr Dec 6, 2022
compiler/rustc_borrowck/src/diagnostics/region_errors.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/ty/context.rs Outdated Show resolved Hide resolved
@jackh726 jackh726 added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 26, 2022
@bors
Copy link
Contributor

bors commented Jan 4, 2023

☔ The latest upstream changes (presumably #106432) made this pull request unmergeable. Please resolve the merge conflicts.

@bors
Copy link
Contributor

bors commented Jan 6, 2023

☔ The latest upstream changes (presumably #105805) made this pull request unmergeable. Please resolve the merge conflicts.

Copy link
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

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

Here's how I would clean this up

compiler/rustc_borrowck/src/diagnostics/region_errors.rs Outdated Show resolved Hide resolved
@yanchen4791 yanchen4791 force-pushed the issue-103582-fix branch 2 times, most recently from 11eba40 to 1c2f6bb Compare January 12, 2023 00:45
@yanchen4791 yanchen4791 force-pushed the issue-103582-fix branch 2 times, most recently from a08afc0 to 40b7613 Compare January 12, 2023 18:47
@bors
Copy link
Contributor

bors commented Jan 18, 2023

☔ The latest upstream changes (presumably #107021) made this pull request unmergeable. Please resolve the merge conflicts.

@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jan 24, 2023

📌 Commit 62a1e76 has been approved by jackh726

It is now in the queue for this repository.

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 24, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jan 24, 2023
…ckh726

Add hint for missing lifetime bound on trait object when type alias is used

Fix issue rust-lang#103582.

The problem: When a type alias is used to specify the return type of the method in a trait impl, the suggestion for fixing the problem of "missing lifetime bound on trait object" of the trait impl will not be created. The issue caused by the code which searches for the return trait objects when constructing the hint suggestion is not able to find the trait objects since they are specified in the type alias path instead of the return path of the trait impl.

The solution: Trace the trait objects in the type alias path and provide them along with the alias span to generate the suggestion in case the type alias is used in return type of the method in the trait impl.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 25, 2023
…ckh726

Add hint for missing lifetime bound on trait object when type alias is used

Fix issue rust-lang#103582.

The problem: When a type alias is used to specify the return type of the method in a trait impl, the suggestion for fixing the problem of "missing lifetime bound on trait object" of the trait impl will not be created. The issue caused by the code which searches for the return trait objects when constructing the hint suggestion is not able to find the trait objects since they are specified in the type alias path instead of the return path of the trait impl.

The solution: Trace the trait objects in the type alias path and provide them along with the alias span to generate the suggestion in case the type alias is used in return type of the method in the trait impl.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 25, 2023
…iaskrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#105345 (Add hint for missing lifetime bound on trait object when type alias is used)
 - rust-lang#106897 (Tweak E0597)
 - rust-lang#106944 (Suggest using a lock for `*Cell: Sync` bounds)
 - rust-lang#107239 (Bring tests back into rustc source tarball)
 - rust-lang#107244 (rustdoc: rearrange HTML in primitive reference links)
 - rust-lang#107255 (add test where we ignore hr implied bounds)
 - rust-lang#107256 (Delete `SimplifyArmIdentity` and `SimplifyBranchSame` mir opts)
 - rust-lang#107266 (rustdoc: prohibit scroll bar on source viewer in Safari)
 - rust-lang#107282 (erica solver: implement builtin `Pointee` trait impl candidates)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f21728f into rust-lang:master Jan 26, 2023
@rustbot rustbot added this to the 1.69.0 milestone Jan 26, 2023
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants