+use crate::hir;
use crate::hir::def_id::DefId;
use crate::ty::{self, BoundRegion, Region, Ty, TyCtxt};
-use std::borrow::Cow;
-use std::fmt;
+
+use errors::{Applicability, DiagnosticBuilder};
use rustc_target::spec::abi;
use syntax::ast;
use syntax::errors::pluralize;
-use errors::{Applicability, DiagnosticBuilder};
use syntax_pos::Span;
-use crate::hir;
+use std::borrow::Cow;
+use std::fmt;
#[derive(Clone, Copy, Debug, PartialEq, Eq, TypeFoldable)]
pub struct ExpectedFound<T> {
pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
match self.kind {
ty::Bool | ty::Char | ty::Int(_) |
- ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => format!("{}", self).into(),
- ty::Tuple(ref tys) if tys.is_empty() => format!("{}", self).into(),
+ ty::Uint(_) | ty::Float(_) | ty::Str | ty::Never => format!("`{}`", self).into(),
+ ty::Tuple(ref tys) if tys.is_empty() => format!("`{}`", self).into(),
ty::Adt(def, _) => format!("{} `{}`", def.descr(), tcx.def_path_str(def.did)).into(),
ty::Foreign(def_id) => format!("extern type `{}`", tcx.def_path_str(def_id)).into(),
if tymut_string != "_" && (
ty.is_simple_text() || tymut_string.len() < "mutable reference".len()
) {
- format!("&{}", tymut_string).into()
+ format!("`&{}`", tymut_string).into()
} else { // Unknown type name, it's long or has type arguments
match mutbl {
hir::Mutability::Mutable => "mutable reference",
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 `{}`", tcx.def_path_str(principal.def_id())).into()
} else {
"trait".into()
}