X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Flibrustc%2Fty%2Fdiagnostics.rs;h=d1eb21e25ffaf0183fb7d3e31fb873ee685b204b;hb=543b7d97d019bff882cc70cf2f8bdc317e7b840f;hp=3a55aefe85d3d48b072c56112bb0758988ef88f1;hpb=9860a4eeb7e555b3a137b2aa0cde818d44a608dc;p=rust.git diff --git a/src/librustc/ty/diagnostics.rs b/src/librustc/ty/diagnostics.rs index 3a55aefe85d..d1eb21e25ff 100644 --- a/src/librustc/ty/diagnostics.rs +++ b/src/librustc/ty/diagnostics.rs @@ -1,16 +1,23 @@ //! Diagnostics related methods for `TyS`. -use crate::ty::TyS; -use crate::ty::TyKind::*; use crate::ty::sty::InferTy; +use crate::ty::TyKind::*; +use crate::ty::TyS; impl<'tcx> TyS<'tcx> { /// Similar to `TyS::is_primitive`, but also considers inferred numeric values to be primitive. pub fn is_primitive_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, + Bool + | Char + | Str + | Int(_) + | Uint(_) + | Float(_) + | Infer(InferTy::IntVar(_)) + | Infer(InferTy::FloatVar(_)) + | Infer(InferTy::FreshIntTy(_)) + | Infer(InferTy::FreshFloatTy(_)) => true, _ => false, } } @@ -19,9 +26,16 @@ pub fn is_primitive_ty(&self) -> bool { /// description in error messages. This is used in the main error message. 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, + 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, @@ -43,13 +57,8 @@ pub fn is_simple_text(&self) -> bool { /// Whether the type can be safely suggested during error recovery. pub fn is_suggestable(&self) -> bool { match self.kind { - Opaque(..) | - FnDef(..) | - FnPtr(..) | - Dynamic(..) | - Closure(..) | - Infer(..) | - Projection(..) => false, + Opaque(..) | FnDef(..) | FnPtr(..) | Dynamic(..) | Closure(..) | Infer(..) + | Projection(..) => false, _ => true, } }