about summary refs log tree commit diff
diff options
context:
space:
mode:
authorkadmin <julianknodt@gmail.com>2020-08-06 00:23:17 +0000
committerkadmin <julianknodt@gmail.com>2020-08-09 07:41:26 +0000
commit4f461f5d1282ac58892b8985f1df7ea26df6613f (patch)
tree87c821de6f49045cc055bee22c0e59e8e88797b0
parent1ae1a6332c27fd5f384d3877cb2c4b546dd86c37 (diff)
downloadrust-4f461f5d1282ac58892b8985f1df7ea26df6613f.tar.gz
rust-4f461f5d1282ac58892b8985f1df7ea26df6613f.zip
Switched to unordered field in ParamKindOrd
Run fmt
-rw-r--r--src/librustc_ast/ast.rs6
-rw-r--r--src/librustc_ast_passes/ast_validation.rs8
-rw-r--r--src/librustc_typeck/astconv.rs12
3 files changed, 17 insertions, 9 deletions
diff --git a/src/librustc_ast/ast.rs b/src/librustc_ast/ast.rs
index 95e01f07e01..5e8066dd960 100644
--- a/src/librustc_ast/ast.rs
+++ b/src/librustc_ast/ast.rs
@@ -313,8 +313,7 @@ pub type GenericBounds = Vec<GenericBound>;
 pub enum ParamKindOrd {
     Lifetime,
     Type,
-    Const,
-    ConstUnordered,
+    Const { unordered: bool },
 }
 
 impl fmt::Display for ParamKindOrd {
@@ -322,8 +321,7 @@ impl fmt::Display for ParamKindOrd {
         match self {
             ParamKindOrd::Lifetime => "lifetime".fmt(f),
             ParamKindOrd::Type => "type".fmt(f),
-            ParamKindOrd::Const => "const".fmt(f),
-            ParamKindOrd::ConstUnordered => "const".fmt(f),
+            ParamKindOrd::Const { .. } => "const".fmt(f),
         }
     }
 }
diff --git a/src/librustc_ast_passes/ast_validation.rs b/src/librustc_ast_passes/ast_validation.rs
index 7179a59c0dd..a229987da76 100644
--- a/src/librustc_ast_passes/ast_validation.rs
+++ b/src/librustc_ast_passes/ast_validation.rs
@@ -735,7 +735,7 @@ fn validate_generic_param_order<'a>(
         }
         let max_param = &mut max_param;
         match max_param {
-            Some(ParamKindOrd::ConstUnordered) if kind != ParamKindOrd::Lifetime => (),
+            Some(ParamKindOrd::Const { unordered: true }) if kind != ParamKindOrd::Lifetime => (),
             Some(max_param) if *max_param > kind => {
                 let entry = out_of_order.entry(kind).or_insert((*max_param, vec![]));
                 entry.1.push(span);
@@ -1159,7 +1159,11 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
                     GenericParamKind::Type { default: _ } => (ParamKindOrd::Type, ident),
                     GenericParamKind::Const { ref ty, kw_span: _ } => {
                         let ty = pprust::ty_to_string(ty);
-                        (ParamKindOrd::Const, Some(format!("const {}: {}", param.ident, ty)))
+                        let unordered = self.session.features_untracked().const_generics;
+                        (
+                            ParamKindOrd::Const { unordered },
+                            Some(format!("const {}: {}", param.ident, ty)),
+                        )
                     }
                 };
                 (kind, Some(&*param.bounds), param.ident.span, ident)
diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs
index 79d2f104a52..becabe9c3b9 100644
--- a/src/librustc_typeck/astconv.rs
+++ b/src/librustc_typeck/astconv.rs
@@ -489,10 +489,11 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
             kind,
         );
 
+        let unordered = sess.features_untracked().const_generics;
         let kind_ord = match kind {
             "lifetime" => ParamKindOrd::Lifetime,
             "type" => ParamKindOrd::Type,
-            "constant" => ParamKindOrd::Const,
+            "constant" => ParamKindOrd::Const { unordered },
             // It's more concise to match on the string representation, though it means
             // the match is non-exhaustive.
             _ => bug!("invalid generic parameter kind {}", kind),
@@ -500,7 +501,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
         let arg_ord = match arg {
             GenericArg::Lifetime(_) => ParamKindOrd::Lifetime,
             GenericArg::Type(_) => ParamKindOrd::Type,
-            GenericArg::Const(_) => ParamKindOrd::Const,
+            GenericArg::Const(_) => ParamKindOrd::Const { unordered },
         };
 
         // This note will be true as long as generic parameters are strictly ordered by their kind.
@@ -672,7 +673,12 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                                                         ParamKindOrd::Type
                                                     }
                                                     GenericParamDefKind::Const => {
-                                                        ParamKindOrd::Const
+                                                        ParamKindOrd::Const {
+                                                            unordered: tcx
+                                                                .sess
+                                                                .features_untracked()
+                                                                .const_generics,
+                                                        }
                                                     }
                                                 },
                                                 param,