-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support lifetime suggestion for method
This includes a change to the way lifetime names are generated. Say we figure that `[#0, 'a, 'b]` have to be the same lifetimes, then instead of just generating a new lifetime `'c` like before to replace them, we would reuse `'a`. This is done so that when the lifetime name comes from an impl, we don't give something that's completely off, and we don't have to do much work to figure out where the name came from. For example, for the following code snippet: ```rust struct Baz<'x> { bar: &'x int } impl<'x> Baz<'x> { fn baz1(&self) -> &int { self.bar } } ``` `[#1, 'x]` (where `#1` is BrAnon(1) and refers to lifetime of `&int`) have to be marked the same lifetime. With the old method, we would generate a new lifetime `'a` and suggest `fn baz1(&self) -> &'a int` or `fn baz1<'a>(&self) -> &'a int`, both of which are wrong.
- Loading branch information
Showing
3 changed files
with
199 additions
and
57 deletions.
There are no files selected for viewing
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
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
Oops, something went wrong.
79d1e5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from nmatsakis
at ktt3ja@79d1e5d
79d1e5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging ktt3ja/rust/lifetime-suggestion-method = 79d1e5d into auto
79d1e5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ktt3ja/rust/lifetime-suggestion-method = 79d1e5d merged ok, testing candidate = 10f94e3
79d1e5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all tests pass:
success: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/5260
success: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/5256
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/4349
success: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/4362
success: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/5358
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/4445
success: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/4453
success: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/5360
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/4445
success: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/4451
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/4515
success: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/2245
success: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/5355
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-c/builds/4452
success: http://buildbot.rust-lang.org/builders/auto-win-32-nopt-t/builds/4465
79d1e5d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fast-forwarding master to auto = 10f94e3