]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_middle/src/ty/generics.rs
Fmt and test revert
[rust.git] / compiler / rustc_middle / src / ty / generics.rs
index 79cd26f5668a13936cde730374aa78a7dbede1ae..d30a8693959f39a17a7c381fb702fa8bcc9792be 100644 (file)
@@ -18,7 +18,9 @@ pub enum GenericParamDefKind {
         object_lifetime_default: ObjectLifetimeDefault,
         synthetic: Option<hir::SyntheticTyParamKind>,
     },
-    Const,
+    Const {
+        has_default: bool,
+    },
 }
 
 impl GenericParamDefKind {
@@ -26,14 +28,14 @@ pub fn descr(&self) -> &'static str {
         match self {
             GenericParamDefKind::Lifetime => "lifetime",
             GenericParamDefKind::Type { .. } => "type",
-            GenericParamDefKind::Const => "constant",
+            GenericParamDefKind::Const { .. } => "constant",
         }
     }
     pub fn to_ord(&self, tcx: TyCtxt<'_>) -> ast::ParamKindOrd {
         match self {
             GenericParamDefKind::Lifetime => ast::ParamKindOrd::Lifetime,
             GenericParamDefKind::Type { .. } => ast::ParamKindOrd::Type,
-            GenericParamDefKind::Const => {
+            GenericParamDefKind::Const { .. } => {
                 ast::ParamKindOrd::Const { unordered: tcx.features().const_generics }
             }
         }
@@ -105,7 +107,7 @@ pub fn own_counts(&self) -> GenericParamCount {
             match param.kind {
                 GenericParamDefKind::Lifetime => own_counts.lifetimes += 1,
                 GenericParamDefKind::Type { .. } => own_counts.types += 1,
-                GenericParamDefKind::Const => own_counts.consts += 1,
+                GenericParamDefKind::Const { .. } => own_counts.consts += 1,
             }
         }
 
@@ -121,8 +123,8 @@ pub fn own_defaults(&self) -> GenericParamCount {
                 GenericParamDefKind::Type { has_default, .. } => {
                     own_defaults.types += has_default as usize;
                 }
-                GenericParamDefKind::Const => {
-                    // FIXME(const_generics:defaults)
+                GenericParamDefKind::Const { has_default } => {
+                    own_defaults.consts += has_default as usize;
                 }
             }
         }
@@ -146,7 +148,9 @@ pub fn requires_monomorphization(&self, tcx: TyCtxt<'tcx>) -> bool {
     pub fn own_requires_monomorphization(&self) -> bool {
         for param in &self.params {
             match param.kind {
-                GenericParamDefKind::Type { .. } | GenericParamDefKind::Const => return true,
+                GenericParamDefKind::Type { .. } | GenericParamDefKind::Const { .. } => {
+                    return true;
+                }
                 GenericParamDefKind::Lifetime => {}
             }
         }
@@ -189,7 +193,7 @@ pub fn type_param(&'tcx self, param: &ParamTy, tcx: TyCtxt<'tcx>) -> &'tcx Gener
     pub fn const_param(&'tcx self, param: &ParamConst, tcx: TyCtxt<'tcx>) -> &GenericParamDef {
         let param = self.param_at(param.index as usize, tcx);
         match param.kind {
-            GenericParamDefKind::Const => param,
+            GenericParamDefKind::Const { .. } => param,
             _ => bug!("expected const parameter, but found another generic parameter"),
         }
     }