Uh oh!
There was an error while loading. Please reload this page.
annotate stricter lifetimes on LateLintPass methods to allow them to forward to a Visitor - #38191
Conversation
…forward to a Visitor
Manishearth
commented
Dec 6, 2016
r? @eddyb Not sure of this. Sort of makes sense. |
| @@ -131,51 +131,104 @@ pub trait LintPass { | |||
| // contains a few lint-specific methods with no equivalent in `Visitor`. | |||
| pub trait LateLintPass: LintPass { | |||
There was a problem hiding this comment.
Could you add the lifetimes to the trait? That way they don't pollute the method generics.
I'm not sure in what conditions they don't need to show up in types in the method signatures in an impl - see how some of the Visitorimpls get away with it, although here it's trickier - it'd be nice if most of them didn't need to be changed.
There was a problem hiding this comment.
I might just be failing at HKL, but I can't create a Box<for<'a, 'tcx: 'a> LateLintPass<'a, 'tcx>>, because the outlives bound is ignored
I have a workaround, but it'll require an intermediate helper trait. (see minimal example of workaround: https://is.gd/OnC7RS)
There was a problem hiding this comment.
Bleah I forgot about trait objects. Can the Helper trait have a single blanket impl proxying to the trait with the lifetime paramters?
There was a problem hiding this comment.
I can almost do it (https://is.gd/TrZudu), I'm not sure why Rust can't figure out that a lifetime on a generic bound in the trait generics will outlive the lifetime of a method argument:
impl<'b,'tcx:'b,T:Foo<'b,'tcx>>Helper<'tcx>forT{fnas_foo<'a>(&'amutself) -> &'amutFoo<'a,'tcx>where'tcx:'a{self}}note: the lifetime 'a as defined on the block at 17:72...
note: ...does not necessarily outlive the lifetime 'b as defined on the block at 17:72
it works now, I tested it against clippy, |
| fn check_generics(&mut self, cx: &LateContext, it: &hir::Generics) { | ||
| fn check_generics(&mut self, | ||
| cx: &LateContext<'a, 'tcx>, | ||
| it: &'tcx hir::Generics) { |
eddyb
commented
Dec 7, 2016
I think some of the indentation changes from adding |
oli-obk
commented
Dec 7, 2016
cleaned up all the |
nox
commented
Dec 7, 2016
This also blocks Servo. |
Ms2ger
commented
Dec 7, 2016
Would appreciate a quick review here :) |
Ms2ger
commented
Dec 7, 2016
@nikomatsakis this was what I was just talking about |
eddyb
commented
Dec 7, 2016
@bors r+ p=1 (unbreaking Servo) |
bors
commented
Dec 7, 2016
📌 Commit 0f7a18b has been approved by |
bors
commented
Dec 7, 2016
annotate stricter lifetimes on LateLintPass methods to allow them to forward to a Visitor this unblocks clippy (rustup blocked after #37918) clippy has lots of lints that internally call an `intravisit::Visitor`, but the current lifetimes on `LateLintPass` methods conflicted with the required lifetimes (there was no connection between the HIR elements and the `TyCtxt`) r? @Manishearth
this unblocks clippy (rustup blocked after #37918)
clippy has lots of lints that internally call an
intravisit::Visitor, but the current lifetimes onLateLintPassmethods conflicted with the required lifetimes (there was no connection between the HIR elements and theTyCtxt)r? @Manishearth