annotate stricter lifetimes on LateLintPass methods to allow them to forward to a Visitor#38191
annotate stricter lifetimes on LateLintPass methods to allow them to forward to a Visitor#38191bors merged 3 commits intorust-lang:masterfrom
Conversation
…forward to a Visitor
|
r? @eddyb Not sure of this. Sort of makes sense. |
src/librustc/lint/mod.rs
Outdated
| @@ -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 Visitor impls 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> for T {
fn as_foo<'a>(&'a mut self) -> &'a mut Foo<'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, |
src/librustc_lint/bad_style.rs
Outdated
| fn check_generics(&mut self, cx: &LateContext, it: &hir::Generics) { | ||
| fn check_generics(&mut self, | ||
| cx: &LateContext<'a, 'tcx>, | ||
| it: &'tcx hir::Generics) { |
|
I think some of the indentation changes from adding |
9f3757c to
b650bbe
Compare
b650bbe to
0f7a18b
Compare
|
cleaned up all the |
|
This also blocks Servo. |
|
Would appreciate a quick review here :) |
|
@nikomatsakis this was what I was just talking about |
|
@bors r+ p=1 (unbreaking Servo) |
|
📌 Commit 0f7a18b has been approved by |
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