-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Suggest adding a lifetime constraint for opaque type #67595
Suggest adding a lifetime constraint for opaque type #67595
Conversation
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.
r=me after dealing with the nitpicks
ce292d3
to
3f53c1a
Compare
3f53c1a
to
94089ad
Compare
@bors r+ |
📌 Commit 3e9d1cc has been approved by |
…long-enough, r=estebank Suggest adding a lifetime constraint for opaque type Fixes rust-lang#67577, where code like this: ``` struct List { data: Vec<String>, } impl List { fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref()) } } ``` will show this error: ``` Compiling playground v0.0.1 (/playground) error[E0597]: `prefix` does not live long enough --> src/lib.rs:6:47 | 5 | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { | -- lifetime `'a` defined here --------------------------- opaque type requires that `prefix` is borrowed for `'a` ... ``` but without suggesting the lovely `help: you can add a constraint..`. r? @estebank
Looks like this might need to be rebased atop master (see https://rust-lang.github.io/rust-log-analyzer/log-viewer/#https://dev.azure.com/rust-lang/e71b0ddf-dd27-435a-873c-e30f86eea377/_apis/build/builds/16871/logs/1534 from #67643 (comment)). @bors r- |
3e9d1cc
to
e9a9e07
Compare
region_name, | ||
), | ||
format!("{} + {}", snippet, suggestable_name), | ||
Applicability::Unspecified, |
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.
It seems that this fix can be applied automatically, isn't it?
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.
I used the same Applicability
as the other suggestions for impl Trait
lifetimes.
I don't think we can be sure this snippet will work (@estebank just fixed an issue with ;
for example)
…for "does not live long enough" error
e9a9e07
to
cd73034
Compare
@Mark-Simulacrum rebased and the CI is green 😄 |
@bors r=estebank Thanks! |
📌 Commit cd73034 has been approved by |
…, r=estebank Suggest adding a lifetime constraint for opaque type Fixes #67577, where code like this: ``` struct List { data: Vec<String>, } impl List { fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref()) } } ``` will show this error: ``` Compiling playground v0.0.1 (/playground) error[E0597]: `prefix` does not live long enough --> src/lib.rs:6:47 | 5 | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { | -- lifetime `'a` defined here --------------------------- opaque type requires that `prefix` is borrowed for `'a` ... ``` but without suggesting the lovely `help: you can add a constraint..`. r? @estebank
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
💔 Test failed - checks-azure |
cd73034
to
1a4f6b8
Compare
Ah it was |
@bors r=estebank |
📌 Commit 1a4f6b8 has been approved by |
…long-enough, r=estebank Suggest adding a lifetime constraint for opaque type Fixes rust-lang#67577, where code like this: ``` struct List { data: Vec<String>, } impl List { fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { self.data.iter().filter(|s| s.starts_with(prefix)).map(|s| s.as_ref()) } } ``` will show this error: ``` Compiling playground v0.0.1 (/playground) error[E0597]: `prefix` does not live long enough --> src/lib.rs:6:47 | 5 | fn started_with<'a>(&'a self, prefix: &'a str) -> impl Iterator<Item=&'a str> { | -- lifetime `'a` defined here --------------------------- opaque type requires that `prefix` is borrowed for `'a` ... ``` but without suggesting the lovely `help: you can add a constraint..`. r? @estebank
Rollup of 10 pull requests Successful merges: - #67450 (Allow for setting a ThinLTO import limit during bootstrap) - #67595 (Suggest adding a lifetime constraint for opaque type) - #67636 (allow rustfmt key in [build] section) - #67736 (Less-than is asymmetric, not antisymmetric) - #67762 (Add missing links for insecure_time) - #67783 (Warn for bindings named same as variants when matching against a borrow) - #67796 (Ensure that we process projections during MIR inlining) - #67807 (Use drop instead of the toilet closure `|_| ()`) - #67816 (Clean up err codes) - #67825 (Minor: change take() docs grammar to match other docs) Failed merges: r? @ghost
Fixes #67577, where code like this:
will show this error:
but without suggesting the lovely
help: you can add a constraint..
.r? @estebank