]> gcc.gnu.org Git - gcc.git/commitdiff
gccrs: Add coherence related lang_items
authorOwen Avery <powerboat9.gamer@gmail.com>
Tue, 7 Mar 2023 18:37:08 +0000 (13:37 -0500)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:21:08 +0000 (18:21 +0100)
gcc/rust/ChangeLog:

* util/rust-lang-item.h
(RustLangItem::ItemType): New enumerators.
(RustLangItem::Parse): Parse new enumerators.
(RustLangItem::ToString): Handle new enumerators.

gcc/testsuite/ChangeLog:

* rust/compile/lang-impl.rs: New test.

gcc/rust/util/rust-lang-item.h
gcc/testsuite/rust/compile/lang-impl.rs [new file with mode: 0644]

index 78b60096104b07094912c9be323f7a9142864220..d7f6ad186cdb0268b66489570bf446d62c97af75 100644 (file)
@@ -68,11 +68,6 @@ public:
     RANGE_INCLUSIVE,
     RANGE_TO_INCLUSIVE,
 
-    // https://github.com/rust-lang/rust/blob/master/library/core/src/ptr/const_ptr.rs
-    CONST_PTR,
-    MUT_PTR,
-    CONST_SLICE_PTR,
-
     // https://github.com/rust-lang/rust/blob/master/library/core/src/marker.rs
     PHANTOM_DATA,
 
@@ -85,6 +80,40 @@ public:
     CLONE,
     SIZED,
 
+    // https://github.com/Rust-GCC/gccrs/issues/1896
+    // https://github.com/rust-lang/rust/commit/afbecc0f68c4dcfc4878ba5bcb1ac942544a1bdc
+    // https://github.com/Rust-GCC/gccrs/issues/1494
+    // https://github.com/rust-lang/rust/blob/master/library/core/src/ptr/const_ptr.rs
+    SLICE_ALLOC,
+    SLICE_U8_ALLOC,
+    STR_ALLOC,
+    ARRAY,
+    BOOL,
+    CHAR,
+    F32,
+    F64,
+    I8,
+    I16,
+    I32,
+    I64,
+    I128,
+    ISIZE,
+    U8,
+    U16,
+    U32,
+    U64,
+    U128,
+    USIZE,
+    CONST_PTR,
+    CONST_SLICE_PTR,
+    MUT_PTR,
+    MUT_SLICE_PTR,
+    SLICE_U8,
+    SLICE,
+    STR,
+    F32_RUNTIME,
+    F64_RUNTIME,
+
     // delimiter
     UNKNOWN,
   };
@@ -219,18 +248,6 @@ public:
       {
        return ItemType::RANGE_TO_INCLUSIVE;
       }
-    else if (item.compare ("const_ptr") == 0)
-      {
-       return ItemType::CONST_PTR;
-      }
-    else if (item.compare ("mut_ptr") == 0)
-      {
-       return ItemType::MUT_PTR;
-      }
-    else if (item.compare ("const_slice_ptr") == 0)
-      {
-       return ItemType::CONST_SLICE_PTR;
-      }
     else if (item.compare ("phantom_data") == 0)
       {
        return ItemType::PHANTOM_DATA;
@@ -255,6 +272,122 @@ public:
       {
        return ItemType::SIZED;
       }
+    else if (item.compare ("slice_alloc") == 0)
+      {
+       return ItemType::SLICE_ALLOC;
+      }
+    else if (item.compare ("slice_u8_alloc") == 0)
+      {
+       return ItemType::SLICE_U8_ALLOC;
+      }
+    else if (item.compare ("str_alloc") == 0)
+      {
+       return ItemType::STR_ALLOC;
+      }
+    else if (item.compare ("array") == 0)
+      {
+       return ItemType::ARRAY;
+      }
+    else if (item.compare ("bool") == 0)
+      {
+       return ItemType::BOOL;
+      }
+    else if (item.compare ("char") == 0)
+      {
+       return ItemType::CHAR;
+      }
+    else if (item.compare ("f32") == 0)
+      {
+       return ItemType::F32;
+      }
+    else if (item.compare ("f64") == 0)
+      {
+       return ItemType::F64;
+      }
+    else if (item.compare ("i8") == 0)
+      {
+       return ItemType::I8;
+      }
+    else if (item.compare ("i16") == 0)
+      {
+       return ItemType::I16;
+      }
+    else if (item.compare ("i32") == 0)
+      {
+       return ItemType::I32;
+      }
+    else if (item.compare ("i64") == 0)
+      {
+       return ItemType::I64;
+      }
+    else if (item.compare ("i128") == 0)
+      {
+       return ItemType::I128;
+      }
+    else if (item.compare ("isize") == 0)
+      {
+       return ItemType::ISIZE;
+      }
+    else if (item.compare ("u8") == 0)
+      {
+       return ItemType::U8;
+      }
+    else if (item.compare ("u16") == 0)
+      {
+       return ItemType::U16;
+      }
+    else if (item.compare ("u32") == 0)
+      {
+       return ItemType::U32;
+      }
+    else if (item.compare ("u64") == 0)
+      {
+       return ItemType::U64;
+      }
+    else if (item.compare ("u128") == 0)
+      {
+       return ItemType::U128;
+      }
+    else if (item.compare ("usize") == 0)
+      {
+       return ItemType::USIZE;
+      }
+    else if (item.compare ("const_ptr") == 0)
+      {
+       return ItemType::CONST_PTR;
+      }
+    else if (item.compare ("const_slice_ptr") == 0)
+      {
+       return ItemType::CONST_SLICE_PTR;
+      }
+    else if (item.compare ("mut_ptr") == 0)
+      {
+       return ItemType::MUT_PTR;
+      }
+    else if (item.compare ("mut_slice_ptr") == 0)
+      {
+       return ItemType::MUT_SLICE_PTR;
+      }
+    else if (item.compare ("slice_u8") == 0)
+      {
+       return ItemType::SLICE_U8;
+      }
+    else if (item.compare ("slice") == 0)
+      {
+       return ItemType::SLICE;
+      }
+    else if (item.compare ("str") == 0)
+      {
+       return ItemType::STR;
+      }
+    else if (item.compare ("f32_runtime") == 0)
+      {
+       return ItemType::F32_RUNTIME;
+      }
+    else if (item.compare ("f64_runtime") == 0)
+      {
+       return ItemType::F64_RUNTIME;
+      }
 
     return ItemType::UNKNOWN;
   }
@@ -327,12 +460,6 @@ public:
        return "RangeInclusive";
       case RANGE_TO_INCLUSIVE:
        return "RangeToInclusive";
-      case CONST_PTR:
-       return "const_ptr";
-      case MUT_PTR:
-       return "mut_ptr";
-      case CONST_SLICE_PTR:
-       return "const_slice_ptr";
       case PHANTOM_DATA:
        return "phantom_data";
       case FN_ONCE:
@@ -345,6 +472,64 @@ public:
        return "clone";
       case SIZED:
        return "sized";
+      case SLICE_ALLOC:
+       return "slice_alloc";
+      case SLICE_U8_ALLOC:
+       return "slice_u8_alloc";
+      case STR_ALLOC:
+       return "str_alloc";
+      case ARRAY:
+       return "array";
+      case BOOL:
+       return "bool";
+      case CHAR:
+       return "char";
+      case F32:
+       return "f32";
+      case F64:
+       return "f64";
+      case I8:
+       return "i8";
+      case I16:
+       return "i16";
+      case I32:
+       return "i32";
+      case I64:
+       return "i64";
+      case I128:
+       return "i128";
+      case ISIZE:
+       return "isize";
+      case U8:
+       return "u8";
+      case U16:
+       return "u16";
+      case U32:
+       return "u32";
+      case U64:
+       return "u64";
+      case U128:
+       return "u128";
+      case USIZE:
+       return "usize";
+      case CONST_PTR:
+       return "const_ptr";
+      case CONST_SLICE_PTR:
+       return "const_slice_ptr";
+      case MUT_PTR:
+       return "mut_ptr";
+      case MUT_SLICE_PTR:
+       return "mut_slice_ptr";
+      case SLICE_U8:
+       return "slice_u8";
+      case SLICE:
+       return "slice";
+      case STR:
+       return "str";
+      case F32_RUNTIME:
+       return "f32_runtime";
+      case F64_RUNTIME:
+       return "f64_runtime";
 
       case UNKNOWN:
        return "<UNKNOWN>";
diff --git a/gcc/testsuite/rust/compile/lang-impl.rs b/gcc/testsuite/rust/compile/lang-impl.rs
new file mode 100644 (file)
index 0000000..cff74c2
--- /dev/null
@@ -0,0 +1,2 @@
+#[lang = "i8"]
+impl i32 {}
This page took 0.083145 seconds and 5 git commands to generate.