From ea0d99829da705377b7b690062401f772f0babe8 Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 5 Feb 2019 16:50:55 +0100 Subject: Add resolution errors for const generics Co-Authored-By: Gabriel Smith --- src/libsyntax/ast.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/libsyntax') diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 57a3bf86b0e..ab3883d2b9b 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -307,6 +307,26 @@ impl GenericBound { pub type GenericBounds = Vec; +/// Specifies the enforced ordering for generic parameters. In the future, +/// if we wanted to relax this order, we could override `PartialEq` and +/// `PartialOrd`, to allow the kinds to be unordered. +#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy)] +pub enum ParamKindOrd { + Lifetime, + Type, + Const, +} + +impl fmt::Display for ParamKindOrd { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + ParamKindOrd::Lifetime => "lifetime".fmt(f), + ParamKindOrd::Type => "type".fmt(f), + ParamKindOrd::Const => "const".fmt(f), + } + } +} + #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] pub enum GenericParamKind { /// A lifetime definition (e.g., `'a: 'b + 'c + 'd`). -- cgit 1.4.1-3-g733a5