Skip to content

Commit

Permalink
Don't just check params
Browse files Browse the repository at this point in the history
  • Loading branch information
jackh726 committed Oct 18, 2021
1 parent c2da210 commit f9e14af
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
10 changes: 3 additions & 7 deletions compiler/rustc_typeck/src/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ fn check_gat_where_clauses(
sig.output().visit_with(&mut visitor);
let mut wf_tys = FxHashSet::default();
wf_tys.extend(sig.inputs());
// FIXME: normalize and add normalized inputs?

for (region, region_idx) in &visitor.regions {
for (ty, ty_idx) in &visitor.types {
Expand Down Expand Up @@ -423,12 +422,9 @@ impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
GenericArgKind::Lifetime(lt) => {
self.regions.insert((lt, idx));
}
GenericArgKind::Type(t) => match t.kind() {
ty::Param(_) => {
self.types.insert((t, idx));
}
_ => {}
},
GenericArgKind::Type(t) => {
self.types.insert((t, idx));
}
_ => {}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generic-associated-types/self-outlives-lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ trait Deserializer4 {

struct Wrap<T>(T);

// Even though we might theoretically want `D: 'x`, because we pass `Wrap<T>` and
// we see `&'z Wrap<T>`, we are conservative and only add bounds for direct params
// We pass `Wrap<T>` and we see `&'z Wrap<T>`, so we require `D: 'x`
trait Des {
type Out<'x, D>;
//~^ Missing required bounds
fn des<'z, T>(&self, data: &'z Wrap<T>) -> Self::Out<'z, Wrap<T>>;
}
/*
Expand Down
10 changes: 9 additions & 1 deletion src/test/ui/generic-associated-types/self-outlives-lint.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ LL | type Out<'x, 'y>;
| |
| 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
--> $DIR/self-outlives-lint.rs:75:5
|
Expand All @@ -46,5 +54,5 @@ LL | type Out<'x, D>;
| |
| help: add the required where clauses: `where D: 'x`

error: aborting due to 6 previous errors
error: aborting due to 7 previous errors

0 comments on commit f9e14af

Please sign in to comment.