Skip to content

Commit c2aaba9

Browse files
committed
Specifically gating generic_associated_types feature on associated Type declarations
1 parent e565b5b commit c2aaba9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/libsyntax/feature_gate.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1617,13 +1617,17 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
16171617
gate_feature_post!(&self, const_fn, ti.span, "const fn is unstable");
16181618
}
16191619
}
1620-
ast::TraitItemKind::Type(_, Some(_)) => {
1621-
gate_feature_post!(&self, associated_type_defaults, ti.span,
1622-
"associated type defaults are unstable");
1623-
}
1624-
_ if ti.generics.is_parameterized() => {
1625-
gate_feature_post!(&self, generic_associated_types, ti.span,
1626-
"generic associated types are unstable");
1620+
ast::TraitItemKind::Type(_, default) => {
1621+
// We use two if statements instead of something like match guards so that both
1622+
// of these errors can be emitted if both cases apply.
1623+
if default.is_some() {
1624+
gate_feature_post!(&self, associated_type_defaults, ti.span,
1625+
"associated type defaults are unstable");
1626+
}
1627+
if ti.generics.is_parameterized() {
1628+
gate_feature_post!(&self, generic_associated_types, ti.span,
1629+
"generic associated types are unstable");
1630+
}
16271631
}
16281632
_ => {}
16291633
}
@@ -1643,7 +1647,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
16431647
gate_feature_post!(&self, const_fn, ii.span, "const fn is unstable");
16441648
}
16451649
}
1646-
_ if ii.generics.is_parameterized() => {
1650+
ast::ImplItemKind::Type(_) if ii.generics.is_parameterized() => {
16471651
gate_feature_post!(&self, generic_associated_types, ii.span,
16481652
"generic associated types are unstable");
16491653
}

0 commit comments

Comments
 (0)