-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 ambiguous cases of multiple & in elided self lifetimes #117967
Merged
Merged
Commits on May 22, 2024
-
Ambiguous Self lifetimes: don't elide.
struct Concrete(u32); impl Concrete { fn m(self: &Box<Self>) -> &u32 { &self.0 } } resulted in a confusing error. impl Concrete { fn n(self: &Box<&Self>) -> &u32 { &self.0 } } resulted in no error or warning, despite apparent ambiguity over the elided lifetime. This commit changes two aspects of the behavior. Previously, when examining the self type, we considered lifetimes only if they were immediately adjacent to Self. We now consider lifetimes anywhere in the self type. Secondly, if more than one lifetime is discovered in the self type, we disregard it as a possible lifetime elision candidate. This is a compatibility break, and in fact has required some changes to tests which assumed the earlier behavior. Fixes rust-lang#117715
Configuration menu - View commit details
-
Copy full SHA for 8d1958f - Browse repository at this point
Copy the full SHA 8d1958fView commit details -
Do not elide if there's ambiguity in self lifetime.
This makes a small change as requested in code review, such that if there's ambiguity in the self lifetime, we avoid lifetime elision entirely instead of considering using lifetimes from any of the other parameters. For example, impl Something { fn method(self: &Box<&Self>, something_else: &u32) -> &u32 { ... } } in standard Rust would have assumed the return lifetime was that of &Self; with this PR prior to this commit would have chosen the lifetime of 'something_else', and after this commit would give an error message explaining that the lifetime is ambiguous.
Configuration menu - View commit details
-
Copy full SHA for e62599f - Browse repository at this point
Copy the full SHA e62599fView commit details
Commits on May 31, 2024
-
Adjust crash bug to still reproduce.
This test reproduces a rustc ICE. Unfortunately, the changes to lifetime elision mask the original ICE bug by making this function signature illegal. However, by simplifying the signature we can regain the original ICE.
Configuration menu - View commit details
-
Copy full SHA for 6287c94 - Browse repository at this point
Copy the full SHA 6287c94View commit details -
I think that this test is supposed to be a treereduced version of 122903-1.rs, but is actually identical.
Configuration menu - View commit details
-
Copy full SHA for 8c17777 - Browse repository at this point
Copy the full SHA 8c17777View commit details
Commits on Jun 4, 2024
-
Configuration menu - View commit details
-
Copy full SHA for c20a90f - Browse repository at this point
Copy the full SHA c20a90fView commit details
Commits on Jun 5, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 386838d - Browse repository at this point
Copy the full SHA 386838dView commit details
Commits on Jun 10, 2024
-
Elision: consider lifetimes from &T iff T has Self
Change the algorithm which determines whether a self lifetime can be used for return type lifetime elision, such that we consider lifetimes attached to any reference in the self type, so long as Self can be found anywhere inside the type of that reference.
Configuration menu - View commit details
-
Copy full SHA for a22130e - Browse repository at this point
Copy the full SHA a22130eView commit details
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.