Skip to content

Tweak impl signature mismatch errors involving RegionKind::ReVar lifetimes - #67460

Merged
bors merged 12 commits into
rust-lang:masterfrom
estebank:named-lts
May 30, 2020
Merged

Tweak impl signature mismatch errors involving RegionKind::ReVar lifetimes#67460
bors merged 12 commits into
rust-lang:masterfrom
estebank:named-lts

Conversation

@estebank

@estebankestebank commented Dec 20, 2019

Copy link
Copy Markdown
Contributor

Fix#66406, fix#72106.

error: `impl` item signature doesn't match `trait` item signature
--> $DIR/trait-param-without-lifetime-constraint.rs:14:5
|
LL | fn get_relation(&self) -> To;
| ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
|
= note: expected `fn(&Article) -> &ProofReader`
found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/trait-param-without-lifetime-constraint.rs:10:31
|
LL | fn get_relation(&self) -> To;
| ^^ consider borrowing this type parameter in the trait

r? @nikomatsakis

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 20, 2019
@estebank

Copy link
Copy Markdown
ContributorAuthor

CC @rust-lang/wg-diagnostics we should probably have a follow up to detect these cases in particular and explain that the self lifetime is not tied to the return type's lifetime in a clearer way.

@estebank

This comment has been minimized.

@estebank

Copy link
Copy Markdown
ContributorAuthor

New output:
Screen Shot 2019-12-22 at 1 53 29 PM
Screen Shot 2019-12-22 at 1 53 34 PM

@estebank
estebankforce-pushed the named-lts branch 2 times, most recently from 7bcc539 to a4967d9CompareDecember 22, 2019 22:09
@bors

This comment has been minimized.

@estebank
estebankforce-pushed the named-lts branch 2 times, most recently from 7ad6d8f to 7c00f7aCompareDecember 27, 2019 21:52
@estebankestebank changed the title Name RegionKind::ReVar lifetimes in diagnostics Teak impl signature mismatch errors involving RegionKind::ReVar lifetimesDec 27, 2019
@bors

This comment has been minimized.

@estebankestebank changed the title Teak impl signature mismatch errors involving RegionKind::ReVar lifetimesTweak impl signature mismatch errors involving RegionKind::ReVar lifetimesJan 7, 2020
@rust-highfive

This comment has been minimized.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this seems sort of misleading, no?

That is, I think the proper fix here is

impl<'a>HaveRelationship<&'aProofReader>forArticle{fnget_relation(&self) -> &'aProofReader{//~^ ERROR `impl` item signature doesn't match `trait` item signature&self.proof_reader}}

but I'm not sure how the new error would lead me there....

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

But that doesn't work either because HaveRelationship needs a lifetime so that get_relation takes a &'a self instead of &self. Shouldn't the correct change be?:

pubtraitHaveRelationship<'a,To:'a>{fnget_relation(&'aself) -> To;}impl<'a>HaveRelationship<'a,&'aProofReader>forArticle{fnget_relation(&'aself) -> &'aProofReader{&self.proof_reader}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's discuss this in the issue :)

@bors

bors commented Feb 4, 2020

Copy link
Copy Markdown
Collaborator

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

@estebank
estebankforce-pushed the named-lts branch 2 times, most recently from e2049ee to bcf34c7CompareFebruary 4, 2020 22:49
@bors

This comment has been minimized.

@Dylan-DPC-zzDylan-DPC-zz 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 Feb 14, 2020
@estebankestebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 17, 2020
@estebank
estebankforce-pushed the named-lts branch 2 times, most recently from 8fb857d to 63c56d4CompareFebruary 17, 2020 02:02
@estebank

Copy link
Copy Markdown
ContributorAuthor

@bors

bors commented May 28, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit f213acf has been approved by nikomatsakis

@borsbors 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 May 28, 2020
@estebank

Copy link
Copy Markdown
ContributorAuthor

@bors r=nikomatsakis

@nikomatsakis made tiny tweak to account for Self and fix #72106.

@bors

bors commented May 28, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit 1bd6970 has been approved by nikomatsakis

RalfJung added a commit to RalfJung/rust that referenced this pull request May 29, 2020
Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes
Fixrust-lang#66406, fixrust-lang#72106.
```
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/trait-param-without-lifetime-constraint.rs:14:5
|
LL | fn get_relation(&self) -> To;
| ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
|
= note: expected `fn(&Article) -> &ProofReader`
found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/trait-param-without-lifetime-constraint.rs:10:31
|
LL | fn get_relation(&self) -> To;
| ^^ consider borrowing this type parameter in the trait
```
r? @nikomatsakis
@RalfJungRalfJung mentioned this pull request May 29, 2020
RalfJung added a commit to RalfJung/rust that referenced this pull request May 29, 2020
Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes
Fixrust-lang#66406, fixrust-lang#72106.
```
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/trait-param-without-lifetime-constraint.rs:14:5
|
LL | fn get_relation(&self) -> To;
| ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
|
= note: expected `fn(&Article) -> &ProofReader`
found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/trait-param-without-lifetime-constraint.rs:10:31
|
LL | fn get_relation(&self) -> To;
| ^^ consider borrowing this type parameter in the trait
```
r? @nikomatsakis
@RalfJungRalfJung mentioned this pull request May 29, 2020
RalfJung added a commit to RalfJung/rust that referenced this pull request May 29, 2020
Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes
Fixrust-lang#66406, fixrust-lang#72106.
```
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/trait-param-without-lifetime-constraint.rs:14:5
|
LL | fn get_relation(&self) -> To;
| ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
|
= note: expected `fn(&Article) -> &ProofReader`
found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/trait-param-without-lifetime-constraint.rs:10:31
|
LL | fn get_relation(&self) -> To;
| ^^ consider borrowing this type parameter in the trait
```
r? @nikomatsakis
@RalfJungRalfJung mentioned this pull request May 29, 2020
@bors

bors commented May 29, 2020

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 1bd6970 with merge 7173e7b8fe4935c4d2567a0144469d4166541af5...

@Dylan-DPC-zz

Copy link
Copy Markdown

@bors retry yield

RalfJung added a commit to RalfJung/rust that referenced this pull request May 29, 2020
Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes
Fixrust-lang#66406, fixrust-lang#72106.
```
error: `impl` item signature doesn't match `trait` item signature
--> $DIR/trait-param-without-lifetime-constraint.rs:14:5
|
LL | fn get_relation(&self) -> To;
| ----------------------------- expected `fn(&Article) -> &ProofReader`
...
LL | fn get_relation(&self) -> &ProofReader {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&Article) -> &ProofReader`
|
= note: expected `fn(&Article) -> &ProofReader`
found `fn(&Article) -> &ProofReader`
help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
--> $DIR/trait-param-without-lifetime-constraint.rs:10:31
|
LL | fn get_relation(&self) -> To;
| ^^ consider borrowing this type parameter in the trait
```
r? @nikomatsakis
@RalfJungRalfJung mentioned this pull request May 29, 2020
@RalfJungRalfJung mentioned this pull request May 29, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request May 29, 2020
Rollup of 9 pull requests
Successful merges:
- rust-lang#67460 (Tweak impl signature mismatch errors involving `RegionKind::ReVar` lifetimes)
- rust-lang#71095 (impl From<[T; N]> for Box<[T]>)
- rust-lang#71500 (Make pointer offset methods/intrinsics const)
- rust-lang#71804 (linker: Support `-static-pie` and `-static -shared`)
- rust-lang#71862 (Implement RFC 2585: unsafe blocks in unsafe fn)
- rust-lang#72103 (borrowck `DefId` -> `LocalDefId`)
- rust-lang#72407 (Various minor improvements to Ipv6Addr::Display)
- rust-lang#72413 (impl Step for char (make Range*<char> iterable))
- rust-lang#72439 (NVPTX support for new asm!)
Failed merges:
r? @ghost
@bors

bors commented May 30, 2020

Copy link
Copy Markdown
Collaborator

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

@borsbors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 30, 2020
@bors
bors merged commit 8120780 into rust-lang:masterMay 30, 2020
@estebank
estebank deleted the named-lts branch November 9, 2023 05:16
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-authorStatus: This is awaiting some action (such as code changes or more information) from the author.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unhelpful error messages for trait with unbound lifetime Regression in helpful compiler error message when working with lifetimes

10 participants

@estebank@bors@rust-highfive@Centril@davidtwco@Dylan-DPC-zz@nikomatsakis@JohnCSimon@joelpalmer@Elinvynia