diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-09-21 23:39:15 +0200 |
|---|---|---|
| committer | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-10-24 00:32:03 +0200 |
| commit | 66995a6a71e2f5e194797cb846ce5866c4305f93 (patch) | |
| tree | 160c8ded6fb952adc0246000514b7fe66d612b8c | |
| parent | 1935ba658c576f14397c2c7a26a6642cf08f26a6 (diff) | |
| download | rust-66995a6a71e2f5e194797cb846ce5866c4305f93.tar.gz rust-66995a6a71e2f5e194797cb846ce5866c4305f93.zip | |
dedup GAT gate checks
| -rw-r--r-- | src/libsyntax/feature_gate/check.rs | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index 31fae7863fb..ab8781feef0 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -287,6 +287,25 @@ impl<'a> PostExpansionVisitor<'a> { err.emit(); } } + + fn check_gat(&self, generics: &ast::Generics, span: Span) { + if !generics.params.is_empty() { + gate_feature_post!( + &self, + generic_associated_types, + span, + "generic associated types are unstable" + ); + } + if !generics.where_clause.predicates.is_empty() { + gate_feature_post!( + &self, + generic_associated_types, + span, + "where clauses on associated types are unstable" + ); + } + } } impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { @@ -566,14 +585,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { gate_feature_post!(&self, associated_type_defaults, ti.span, "associated type defaults are unstable"); } - if !ti.generics.params.is_empty() { - gate_feature_post!(&self, generic_associated_types, ti.span, - "generic associated types are unstable"); - } - if !ti.generics.where_clause.predicates.is_empty() { - gate_feature_post!(&self, generic_associated_types, ti.span, - "where clauses on associated types are unstable"); - } + self.check_gat(&ti.generics, ti.span); } _ => {} } @@ -603,14 +615,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { ); } ast::ImplItemKind::TyAlias(_) => { - if !ii.generics.params.is_empty() { - gate_feature_post!(&self, generic_associated_types, ii.span, - "generic associated types are unstable"); - } - if !ii.generics.where_clause.predicates.is_empty() { - gate_feature_post!(&self, generic_associated_types, ii.span, - "where clauses on associated types are unstable"); - } + self.check_gat(&ii.generics, ii.span); } _ => {} } |
