Uh oh!
There was an error while loading. Please reload this page.
Lint against single-use lifetime names - #46441
Conversation
There was a problem hiding this comment.
fixed formatting changes @oli-obk
There was a problem hiding this comment.
Please move the formatting changes into their own commit or undo them. It's very hard to see the non-formatting changes among them
nikomatsakis
commented
Dec 2, 2017
Regarding the formatting changes, what I usually find helpful is to have the first commit just rustfmt's the whole file, and then start from there. Then when you rebase, if you get conflicts in this commit, you can just take the "master" version of the code indiscriminately and then re-run rustfmt afterwards. (This...mostly works. Sometimes I find code gets duplicated.) |
0546196 to
fc727d6Comparegaurikholkar-zz
commented
Dec 2, 2017
I guess most of it is undone. Will take care of the rest in a separate commit |
@nikomatsakis@oli-obk I get this error |
gaurikholkar-zz
commented
Dec 4, 2017
Will fix the ui tests |
oli-obk
commented
Dec 4, 2017
They are failing with an ICE: |
gaurikholkar-zz
commented
Dec 4, 2017
Afk for a while. Will check as asap |
bors
commented
Dec 5, 2017
☔ The latest upstream changes (presumably #46305) made this pull request unmergeable. Please resolve the merge conflicts. |
gaurikholkar-zz
left a comment
There was a problem hiding this comment.
How do I write both the errors occuring on the same line on the .rs files for this test?
oli-obk
commented
Dec 5, 2017
You can write |
3cb47ef to
1cfe610Comparenikomatsakis
commented
Dec 8, 2017
So I feel like the new code is generating unexpected errors. I'm going to poke around a bit. |
I'm going to open a PR with just the resolve-lifetimes query work, so we can isolate what is affecting what. |
nikomatsakis
commented
Dec 11, 2017
Blocked on #46657 |
bors
commented
Dec 12, 2017
☔ The latest upstream changes (presumably #46657) made this pull request unmergeable. Please resolve the merge conflicts. |
nikomatsakis
commented
Dec 12, 2017
OK #46657 landed -- @gaurikholkar, can you rebase atop that? |
gaurikholkar-zz
commented
Dec 12, 2017
@nikomatsakis at it |
affef5e to
c84e49cComparegaurikholkar-zz
commented
Dec 14, 2017
@nikomatsakis build passed :) |
nikomatsakis
left a comment
There was a problem hiding this comment.
This is looking pretty good. I think we need a few more tests. It's probably not quite working right, but I'd be happy to get something landed and try to refine later.
There was a problem hiding this comment.
would do:
ifletSome(hir_lifetime) = this.tcx.hir.get(node_id){let span = hir_lifetime.span;let id = hir_lifetime.span;// existing code:debug!("id ={:?} span = {:?} hir_lifetime = {:?}",
node_id,
span,
hir_lifetime);
this.tcx.struct_span_lint_node(lint::builtin::SINGLE_USE_LIFETIME,
id,
span,&format!("lifetime name `{}` only used once",
hir_lifetime.unwrap().name.name())).emit();}There was a problem hiding this comment.
Nnit: removed handy debug output
There was a problem hiding this comment.
can you add a test
fnderef<'x>() -> &'xu32{22}Ideally, this would not warn, but I suspect your code will. I think that's ok, we can just add a comment like:
// FIXME(#44752) -- this scenario should not be warned
Here are some other scenarios. I will put down the behavior I think we eventually want, but it may not be the behavior that we currently have.
structFoo<'x>{x:&'xu32// no warning!}// Once #44524 is fixed, this should issue a warning. Hence, it's ok if it does so now, though perhaps a bit premature. impl<'y>Foo<'y>{fnmethod(){}}// Neither should issue a warning, as explicit lifetimes are mandatory in these cases:structFoo<'x>{x:&'xu32}enumBar<'x>{Variant(&'xu32)}// Should not issue a warning, as explicit lifetimes are mandatory in these cases:traitFoo<'x>{fnfoo(&self,arg:&'xu32);}nikomatsakis
commented
Dec 19, 2017
Oh, in my review, I realize I wasn't clear. The "Nit: formatting" bits was just meant to say that these changes weren't necessary, though also not harmful. Ideally they would be isolated into a separate commit (or else pulled out). |
001aa98 to
cfbff3dComparecfbff3d to
e741dadComparenikomatsakis
commented
Dec 19, 2017
@bors r+ |
bors
commented
Dec 19, 2017
📌 Commit e741dad has been approved by |
bors
commented
Dec 20, 2017
Lint against single-use lifetime names This is a fix for #44752 TO-DO - [x] change lint message - [x] add ui tests r? @nikomatsakis
bors
commented
Dec 20, 2017
☀️ Test successful - status-appveyor, status-travis |
This is a fix for #44752
TO-DO
r? @nikomatsakis