Don't just check params

This commit is contained in:
jackh726 2021-10-18 09:40:27 -04:00
parent c2da21063f
commit f9e14af7f0
3 changed files with 14 additions and 10 deletions

View file

@ -301,7 +301,6 @@ fn check_gat_where_clauses(
sig.output().visit_with(&mut visitor); sig.output().visit_with(&mut visitor);
let mut wf_tys = FxHashSet::default(); let mut wf_tys = FxHashSet::default();
wf_tys.extend(sig.inputs()); wf_tys.extend(sig.inputs());
// FIXME: normalize and add normalized inputs?
for (region, region_idx) in &visitor.regions { for (region, region_idx) in &visitor.regions {
for (ty, ty_idx) in &visitor.types { for (ty, ty_idx) in &visitor.types {
@ -423,12 +422,9 @@ impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
GenericArgKind::Lifetime(lt) => { GenericArgKind::Lifetime(lt) => {
self.regions.insert((lt, idx)); self.regions.insert((lt, idx));
} }
GenericArgKind::Type(t) => match t.kind() { GenericArgKind::Type(t) => {
ty::Param(_) => { self.types.insert((t, idx));
self.types.insert((t, idx)); }
}
_ => {}
},
_ => {} _ => {}
} }
} }

View file

@ -54,10 +54,10 @@ trait Deserializer4 {
struct Wrap<T>(T); struct Wrap<T>(T);
// Even though we might theoretically want `D: 'x`, because we pass `Wrap<T>` and // We pass `Wrap<T>` and we see `&'z Wrap<T>`, so we require `D: 'x`
// we see `&'z Wrap<T>`, we are conservative and only add bounds for direct params
trait Des { trait Des {
type Out<'x, D>; type Out<'x, D>;
//~^ Missing required bounds
fn des<'z, T>(&self, data: &'z Wrap<T>) -> Self::Out<'z, Wrap<T>>; fn des<'z, T>(&self, data: &'z Wrap<T>) -> Self::Out<'z, Wrap<T>>;
} }
/* /*

View file

@ -30,6 +30,14 @@ LL | type Out<'x, 'y>;
| | | |
| help: add the required where clauses: `where U: 'y, T: 'x` | help: add the required where clauses: `where U: 'y, T: 'x`
error: Missing required bounds on Out
--> $DIR/self-outlives-lint.rs:59:5
|
LL | type Out<'x, D>;
| ^^^^^^^^^^^^^^^-
| |
| help: add the required where clauses: `where D: 'x`
error: Missing required bounds on Out error: Missing required bounds on Out
--> $DIR/self-outlives-lint.rs:75:5 --> $DIR/self-outlives-lint.rs:75:5
| |
@ -46,5 +54,5 @@ LL | type Out<'x, D>;
| | | |
| help: add the required where clauses: `where D: 'x` | help: add the required where clauses: `where D: 'x`
error: aborting due to 6 previous errors error: aborting due to 7 previous errors