= parse_repr_options (attrs, struct_decl.get_locus ());
auto *type = new TyTy::ADTType (
- struct_decl.get_mappings ().get_hirid (), mappings.get_next_hir_id (),
+ struct_decl.get_mappings ().get_hirid (),
+ struct_decl.get_mappings ().get_hirid (),
struct_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::TUPLE_STRUCT, std::move (variants),
std::move (substitutions), repr,
= parse_repr_options (attrs, struct_decl.get_locus ());
auto *type = new TyTy::ADTType (
- struct_decl.get_mappings ().get_hirid (), mappings.get_next_hir_id (),
+ struct_decl.get_mappings ().get_hirid (),
+ struct_decl.get_mappings ().get_hirid (),
struct_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::STRUCT_STRUCT, std::move (variants),
std::move (substitutions), repr,
// multi variant ADT
auto *type
= new TyTy::ADTType (enum_decl.get_mappings ().get_hirid (),
- mappings.get_next_hir_id (),
+ enum_decl.get_mappings ().get_hirid (),
enum_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::ENUM, std::move (variants),
std::move (substitutions));
auto *type
= new TyTy::ADTType (union_decl.get_mappings ().get_hirid (),
- mappings.get_next_hir_id (),
+ union_decl.get_mappings ().get_hirid (),
union_decl.get_identifier ().as_string (), ident,
TyTy::ADTType::ADTKind::UNION, std::move (variants),
std::move (substitutions));
--- /dev/null
+#[lang = "sized"]
+pub trait Sized {
+ // Empty.
+}
+
+#[lang = "fn_once"]
+pub trait FnOnce<Args> {
+ /// The returned type after the call operator is used.
+ #[lang = "fn_once_output"]
+ type Output;
+
+ /// Performs the call operation.
+ extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+}
+
+pub enum Ordering {
+ /// An ordering where a compared value is less than another.
+ Less = -1,
+ /// An ordering where a compared value is equal to another.
+ Equal = 0,
+ /// An ordering where a compared value is greater than another.
+ Greater = 1,
+}
+
+pub fn f<F: FnOnce(i32) -> Ordering>(g: F) -> Ordering {
+ g(1)
+}
--- /dev/null
+#[lang = "sized"]
+pub trait Sized {
+ // Empty.
+}
+
+#[lang = "fn_once"]
+pub trait FnOnce<Args> {
+ /// The returned type after the call operator is used.
+ #[lang = "fn_once_output"]
+ type Output;
+
+ /// Performs the call operation.
+ extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
+}
+
+pub enum Ordering {
+ /// An ordering where a compared value is less than another.
+ Less = -1,
+ /// An ordering where a compared value is equal to another.
+ Equal = 0,
+ /// An ordering where a compared value is greater than another.
+ Greater = 1,
+}
+
+pub fn max_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
+ match compare(&v1, &v2) {
+ Ordering::Less | Ordering::Equal => v2,
+ Ordering::Greater => v1,
+ }
+}
+
+pub fn min_by<T, F: FnOnce(&T, &T) -> Ordering>(v1: T, v2: T, compare: F) -> T {
+ match compare(&v1, &v2) {
+ Ordering::Less | Ordering::Equal => v1,
+ Ordering::Greater => v2,
+ }
+}