]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/mod.rs
Remove E0308 note when primary label has all info
[rust.git] / src / librustc / ty / mod.rs
index 15a6056205426d9c51d36dd7fcc2f269aa918f34..5fc2812fd97db10d8fa1b4abaa93bc55d8b9690b 100644 (file)
@@ -63,7 +63,7 @@
 pub use self::sty::{ClosureSubsts, GeneratorSubsts, UpvarSubsts, TypeAndMut};
 pub use self::sty::{TraitRef, TyKind, PolyTraitRef};
 pub use self::sty::{ExistentialTraitRef, PolyExistentialTraitRef};
-pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const};
+pub use self::sty::{ExistentialProjection, PolyExistentialProjection, Const, ConstKind};
 pub use self::sty::{BoundRegion, EarlyBoundRegion, FreeRegion, Region};
 pub use self::sty::RegionKind;
 pub use self::sty::{TyVid, IntVid, FloatVid, ConstVid, RegionVid};
@@ -555,16 +555,29 @@ fn hash<H: Hasher>(&self, s: &mut H) {
 impl<'tcx> TyS<'tcx> {
     pub fn is_primitive_ty(&self) -> bool {
         match self.kind {
-            Bool |
-            Char |
-            Int(_) |
-            Uint(_) |
-            Float(_) |
-            Infer(InferTy::IntVar(_)) |
-            Infer(InferTy::FloatVar(_)) |
-            Infer(InferTy::FreshIntTy(_)) |
-            Infer(InferTy::FreshFloatTy(_)) => true,
-            Ref(_, x, _) => x.is_primitive_ty(),
+            Bool | Char | Str | Int(_) | Uint(_) | Float(_) |
+            Infer(InferTy::IntVar(_)) | Infer(InferTy::FloatVar(_)) |
+            Infer(InferTy::FreshIntTy(_)) | Infer(InferTy::FreshFloatTy(_)) => true,
+            _ => false,
+        }
+    }
+
+    pub fn is_simple_ty(&self) -> bool {
+        match self.kind {
+            Bool | Char | Str | Int(_) | Uint(_) | Float(_) |
+            Infer(InferTy::IntVar(_)) | Infer(InferTy::FloatVar(_)) |
+            Infer(InferTy::FreshIntTy(_)) | Infer(InferTy::FreshFloatTy(_)) => true,
+            Ref(_, x, _) | Array(x, _) | Slice(x) => x.peel_refs().is_simple_ty(),
+            Tuple(tys) if tys.is_empty() => true,
+            _ => false,
+        }
+    }
+
+    pub fn is_simple_text(&self) -> bool {
+        match self.kind {
+            Adt(_, substs) => substs.types().next().is_none(),
+            Ref(_, ty, _) => ty.is_simple_text(),
+            _ if self.is_simple_ty() => true,
             _ => false,
         }
     }