Repository navigation
Conversation
Collaborator
|
rustbot has assigned @petrochenkov. Use Why was this reviewer chosen?The reviewer was selected based on:
|
Contributor
|
@rustbot reroll |
This comment was marked as resolved.
This comment was marked as resolved.
estebank
force-pushed
the
issue-101393
branch
from
September 13, 2026 23:40
381b334 to
79e8af9
Compare
This comment has been minimized.
This comment has been minimized.
When using `Self { ... }`, it introduces lifetime requirements from the `impl` that might be more strict than using the actual type's literal. We now point that out.
```
error: lifetime may not live long enough
--> $DIR/conflicting-lifetime-bounds-from-impl-in-self-literal.rs:21:25
|
LL | impl<'a> Path<'a> {
| -- lifetime `'a` defined here
...
LL | pub fn sub(&mut self) -> Path/*<'_>*/ {
| - let's call the lifetime of this reference `'1`
...
LL | Self {
| ---- requires lifetime `'a` from the `impl`
...
LL | string: self.string,
| ^^^^^^^^^^^ this usage requires that `'1` must outlive `'a`
|
help: consider using the type's name directly instead, to avoid conflicting lifetime bounds from the `impl`
|
LL - Self {
LL + Path {
|
```
…licit
```
error: lifetime may not live long enough
--> $DIR/conflicting-lifetime-bounds-from-impl-in-self-literal.rs:21:25
|
LL | impl<'a> Path<'a> {
| -- lifetime `'a` defined here
...
LL | pub fn sub(&mut self) -> Path {
| - ---- this returned type has an implicit lifetime `'1`
| |
| let's call the lifetime of this reference `'1`
...
LL | Self {
| ---- requires lifetime `'a` from the `impl`
...
LL | string: self.string,
| ^^^^^^^^^^^ this usage requires that `'1` must outlive `'a`
|
help: consider using the type's name directly instead, to avoid conflicting lifetime bounds from the `impl`
|
LL - Self {
LL + Path {
|
help: consider making explicit the implicit `'1` lifetime in the return type
|
LL | pub fn sub(&mut self) -> Path<'_> {
| ++++
```
estebank
force-pushed
the
issue-101393
branch
from
October 26, 2026 23:18
79e8af9 to
ec0dd46
Compare
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When using
Self { ... }, it introduces lifetime requirements from theimplthat might be more strict than using the actual type's literal. We now point that out. When the return type has a type with implicit lifetimes, point those out and suggest making them explicit.Fix #101393.