]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/ty/error.rs
Rollup merge of #68738 - kennytm:derive-clone-eq-for-fromutf8error, r=sfackler
[rust.git] / src / librustc / ty / error.rs
index f7612874e05b6b9b9ee5a455707eb27447cbf155..0282f409b328d620bc158df4370c9adcf1098edc 100644 (file)
@@ -15,6 +15,16 @@ pub struct ExpectedFound<T> {
     pub found: T,
 }
 
+impl<T> ExpectedFound<T> {
+    pub fn new(a_is_expected: bool, a: T, b: T) -> Self {
+        if a_is_expected {
+            ExpectedFound { expected: a, found: b }
+        } else {
+            ExpectedFound { expected: b, found: a }
+        }
+    }
+}
+
 // Data structures used in type unification
 #[derive(Clone, Debug, TypeFoldable)]
 pub enum TypeError<'tcx> {
@@ -244,9 +254,9 @@ pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
             ty::FnPtr(_) => "fn pointer".into(),
             ty::Dynamic(ref inner, ..) => {
                 if let Some(principal) = inner.principal() {
-                    format!("trait `{}`", tcx.def_path_str(principal.def_id())).into()
+                    format!("trait object `dyn {}`", tcx.def_path_str(principal.def_id())).into()
                 } else {
-                    "trait".into()
+                    "trait object".into()
                 }
             }
             ty::Closure(..) => "closure".into(),