rustc: use Repr and UserString instead of ppaux::ty_to_string.
This commit is contained in:
parent
4e0cb86a5c
commit
96ad4a4863
28 changed files with 133 additions and 152 deletions
|
|
@ -31,7 +31,7 @@ use middle::privacy::{AllPublic, LastMod};
|
|||
use middle::subst;
|
||||
use middle::subst::VecPerParamSpace;
|
||||
use middle::ty::{self, Ty, MethodCall, MethodCallee, MethodOrigin};
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use syntax::{ast, ast_util, codemap, fold};
|
||||
use syntax::codemap::Span;
|
||||
|
|
@ -1624,7 +1624,7 @@ fn decode_side_tables(dcx: &DecodeContext,
|
|||
c::tag_table_node_type => {
|
||||
let ty = val_dsr.read_ty(dcx);
|
||||
debug!("inserting ty for node {}: {}",
|
||||
id, ty_to_string(dcx.tcx, ty));
|
||||
id, ty.repr(dcx.tcx));
|
||||
dcx.tcx.node_type_insert(id, ty);
|
||||
}
|
||||
c::tag_table_item_subst => {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ use syntax::print::pprust::pat_to_string;
|
|||
use syntax::parse::token;
|
||||
use syntax::ptr::P;
|
||||
use syntax::visit::{self, Visitor, FnKind};
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::UserString;
|
||||
use util::nodemap::FnvHashMap;
|
||||
|
||||
pub const DUMMY_WILD_PAT: &'static Pat = &Pat {
|
||||
|
|
@ -209,9 +209,8 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
|
|||
if !type_is_empty(cx.tcx, pat_ty) {
|
||||
// We know the type is inhabited, so this must be wrong
|
||||
span_err!(cx.tcx.sess, ex.span, E0002,
|
||||
"non-exhaustive patterns: type {} is non-empty",
|
||||
ty_to_string(cx.tcx, pat_ty)
|
||||
);
|
||||
"non-exhaustive patterns: type {} is non-empty",
|
||||
pat_ty.user_string(cx.tcx));
|
||||
}
|
||||
// If the type *is* empty, it's vacuously exhaustive
|
||||
return;
|
||||
|
|
@ -244,11 +243,11 @@ fn check_for_bindings_named_the_same_as_variants(cx: &MatchCheckCtxt, pat: &Pat)
|
|||
span_warn!(cx.tcx.sess, p.span, E0170,
|
||||
"pattern binding `{}` is named the same as one \
|
||||
of the variants of the type `{}`",
|
||||
&token::get_ident(ident.node), ty_to_string(cx.tcx, pat_ty));
|
||||
&token::get_ident(ident.node), pat_ty.user_string(cx.tcx));
|
||||
fileline_help!(cx.tcx.sess, p.span,
|
||||
"if you meant to match on a variant, \
|
||||
consider making the path in the pattern qualified: `{}::{}`",
|
||||
ty_to_string(cx.tcx, pat_ty), &token::get_ident(ident.node));
|
||||
pat_ty.user_string(cx.tcx), &token::get_ident(ident.node));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use middle::expr_use_visitor as euv;
|
|||
use middle::mem_categorization as mc;
|
||||
use middle::ty::ParameterEnvironment;
|
||||
use middle::ty;
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
|
|
@ -59,11 +59,11 @@ impl<'a, 'tcx> euv::Delegate<'tcx> for RvalueContextDelegate<'a, 'tcx> {
|
|||
span: Span,
|
||||
cmt: mc::cmt<'tcx>,
|
||||
_: euv::ConsumeMode) {
|
||||
debug!("consume; cmt: {:?}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty));
|
||||
debug!("consume; cmt: {:?}; type: {}", *cmt, cmt.ty.repr(self.tcx));
|
||||
if !ty::type_is_sized(Some(self.param_env), self.tcx, span, cmt.ty) {
|
||||
span_err!(self.tcx.sess, span, E0161,
|
||||
"cannot move a value of type {0}: the size of {0} cannot be statically determined",
|
||||
ty_to_string(self.tcx, cmt.ty));
|
||||
cmt.ty.user_string(self.tcx));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use self::UnsafeContext::*;
|
|||
use middle::def;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::ty::MethodCall;
|
||||
use util::ppaux;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::codemap::Span;
|
||||
|
|
@ -67,7 +67,7 @@ impl<'a, 'tcx> EffectCheckVisitor<'a, 'tcx> {
|
|||
_ => return
|
||||
};
|
||||
debug!("effect: checking index with base type {}",
|
||||
ppaux::ty_to_string(self.tcx, base_type));
|
||||
base_type.repr(self.tcx));
|
||||
match base_type.sty {
|
||||
ty::TyBox(ty) | ty::TyRef(_, ty::mt{ty, ..}) => if ty::TyStr == ty.sty {
|
||||
span_err!(self.tcx.sess, e.span, E0134,
|
||||
|
|
@ -143,7 +143,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
|||
let method_call = MethodCall::expr(expr.id);
|
||||
let base_type = self.tcx.method_map.borrow().get(&method_call).unwrap().ty;
|
||||
debug!("effect: method call case, base type is {}",
|
||||
ppaux::ty_to_string(self.tcx, base_type));
|
||||
base_type.repr(self.tcx));
|
||||
if type_is_unsafe_function(base_type) {
|
||||
self.require_unsafe(expr.span,
|
||||
"invocation of unsafe method")
|
||||
|
|
@ -152,7 +152,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
|||
ast::ExprCall(ref base, _) => {
|
||||
let base_type = ty::node_id_to_type(self.tcx, base.id);
|
||||
debug!("effect: call case, base type is {}",
|
||||
ppaux::ty_to_string(self.tcx, base_type));
|
||||
base_type.repr(self.tcx));
|
||||
if type_is_unsafe_function(base_type) {
|
||||
self.require_unsafe(expr.span, "call to unsafe function")
|
||||
}
|
||||
|
|
@ -160,7 +160,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> {
|
|||
ast::ExprUnary(ast::UnDeref, ref base) => {
|
||||
let base_type = ty::node_id_to_type(self.tcx, base.id);
|
||||
debug!("effect: unary case, base type is {}",
|
||||
ppaux::ty_to_string(self.tcx, base_type));
|
||||
base_type.repr(self.tcx));
|
||||
if let ty::TyRawPtr(_) = base_type.sty {
|
||||
self.require_unsafe(expr.span, "dereference of raw pointer")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ use syntax::ast;
|
|||
use syntax::codemap;
|
||||
use syntax::codemap::Span;
|
||||
use util::nodemap::FnvHashMap;
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
use self::combine::CombineFields;
|
||||
|
|
@ -862,8 +861,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
|
||||
ty_to_string(self.tcx,
|
||||
self.resolve_type_vars_if_possible(&t))
|
||||
self.resolve_type_vars_if_possible(&t).user_string(self.tcx)
|
||||
}
|
||||
|
||||
pub fn tys_to_string(&self, ts: &[Ty<'tcx>]) -> String {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,6 @@ use middle::ty;
|
|||
use middle::ty_fold::{self, TypeFoldable, TypeFolder};
|
||||
use middle::ty_walk::{self, TypeWalker};
|
||||
use util::ppaux::note_and_explain_region;
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::{Repr, UserString};
|
||||
use util::common::{memoized, ErrorReported};
|
||||
use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet};
|
||||
|
|
@ -3568,7 +3567,7 @@ pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
|
|||
TyArray(ty, _) | TySlice(ty) => ty,
|
||||
TyStr => mk_mach_uint(cx, ast::TyU8),
|
||||
_ => cx.sess.bug(&format!("sequence_element_type called on non-sequence value: {}",
|
||||
ty_to_string(cx, ty))),
|
||||
ty.user_string(cx))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4139,24 +4138,20 @@ pub fn is_ffi_safe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
|
|||
pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
|
||||
fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
|
||||
r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
debug!("type_requires({:?}, {:?})?",
|
||||
::util::ppaux::ty_to_string(cx, r_ty),
|
||||
::util::ppaux::ty_to_string(cx, ty));
|
||||
debug!("type_requires({}, {})?",
|
||||
r_ty.repr(cx), ty.repr(cx));
|
||||
|
||||
let r = r_ty == ty || subtypes_require(cx, seen, r_ty, ty);
|
||||
|
||||
debug!("type_requires({:?}, {:?})? {:?}",
|
||||
::util::ppaux::ty_to_string(cx, r_ty),
|
||||
::util::ppaux::ty_to_string(cx, ty),
|
||||
r);
|
||||
debug!("type_requires({}, {})? {:?}",
|
||||
r_ty.repr(cx), ty.repr(cx), r);
|
||||
return r;
|
||||
}
|
||||
|
||||
fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
|
||||
r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
debug!("subtypes_require({:?}, {:?})?",
|
||||
::util::ppaux::ty_to_string(cx, r_ty),
|
||||
::util::ppaux::ty_to_string(cx, ty));
|
||||
debug!("subtypes_require({}, {})?",
|
||||
r_ty.repr(cx), ty.repr(cx));
|
||||
|
||||
let r = match ty.sty {
|
||||
// fixed length vectors need special treatment compared to
|
||||
|
|
@ -4234,10 +4229,8 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
|
|||
}
|
||||
};
|
||||
|
||||
debug!("subtypes_require({:?}, {:?})? {:?}",
|
||||
::util::ppaux::ty_to_string(cx, r_ty),
|
||||
::util::ppaux::ty_to_string(cx, ty),
|
||||
r);
|
||||
debug!("subtypes_require({}, {})? {:?}",
|
||||
r_ty.repr(cx), ty.repr(cx), r);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
@ -4343,8 +4336,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
|||
fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
|
||||
seen: &mut Vec<Ty<'tcx>>,
|
||||
ty: Ty<'tcx>) -> Representability {
|
||||
debug!("is_type_structurally_recursive: {:?}",
|
||||
::util::ppaux::ty_to_string(cx, ty));
|
||||
debug!("is_type_structurally_recursive: {}", ty.repr(cx));
|
||||
|
||||
match ty.sty {
|
||||
TyStruct(did, _) | TyEnum(did, _) => {
|
||||
|
|
@ -4363,9 +4355,9 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
|||
match iter.next() {
|
||||
Some(&seen_type) => {
|
||||
if same_struct_or_enum_def_id(seen_type, did) {
|
||||
debug!("SelfRecursive: {:?} contains {:?}",
|
||||
::util::ppaux::ty_to_string(cx, seen_type),
|
||||
::util::ppaux::ty_to_string(cx, ty));
|
||||
debug!("SelfRecursive: {} contains {}",
|
||||
seen_type.repr(cx),
|
||||
ty.repr(cx));
|
||||
return SelfRecursive;
|
||||
}
|
||||
}
|
||||
|
|
@ -4383,9 +4375,9 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
|||
|
||||
for &seen_type in iter {
|
||||
if same_type(ty, seen_type) {
|
||||
debug!("ContainsRecursive: {:?} contains {:?}",
|
||||
::util::ppaux::ty_to_string(cx, seen_type),
|
||||
::util::ppaux::ty_to_string(cx, ty));
|
||||
debug!("ContainsRecursive: {} contains {}",
|
||||
seen_type.repr(cx),
|
||||
ty.repr(cx));
|
||||
return ContainsRecursive;
|
||||
}
|
||||
}
|
||||
|
|
@ -4405,16 +4397,14 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
|
|||
}
|
||||
}
|
||||
|
||||
debug!("is_type_representable: {:?}",
|
||||
::util::ppaux::ty_to_string(cx, ty));
|
||||
debug!("is_type_representable: {}", ty.repr(cx));
|
||||
|
||||
// To avoid a stack overflow when checking an enum variant or struct that
|
||||
// contains a different, structurally recursive type, maintain a stack
|
||||
// of seen types and check recursion for each of them (issues #3008, #3779).
|
||||
let mut seen: Vec<Ty> = Vec::new();
|
||||
let r = is_type_structurally_recursive(cx, sp, &mut seen, ty);
|
||||
debug!("is_type_representable: {:?} is {:?}",
|
||||
::util::ppaux::ty_to_string(cx, ty), r);
|
||||
debug!("is_type_representable: {} is {:?}", ty.repr(cx), r);
|
||||
r
|
||||
}
|
||||
|
||||
|
|
@ -4857,7 +4847,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
|
|||
span,
|
||||
&format!("the {}th autoderef failed: {}",
|
||||
i,
|
||||
ty_to_string(cx, adjusted_ty))
|
||||
adjusted_ty.user_string(cx))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -5102,10 +5092,8 @@ pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem])
|
|||
pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String {
|
||||
match ty.sty {
|
||||
TyBool | TyChar | TyInt(_) |
|
||||
TyUint(_) | TyFloat(_) | TyStr => {
|
||||
::util::ppaux::ty_to_string(cx, ty)
|
||||
}
|
||||
TyTuple(ref tys) if tys.is_empty() => ::util::ppaux::ty_to_string(cx, ty),
|
||||
TyUint(_) | TyFloat(_) | TyStr => ty.user_string(cx),
|
||||
TyTuple(ref tys) if tys.is_empty() => ty.user_string(cx),
|
||||
|
||||
TyEnum(id, _) => format!("enum `{}`", item_path_str(cx, id)),
|
||||
TyBox(_) => "box".to_string(),
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ pub fn mutability_to_string(m: ast::Mutability) -> String {
|
|||
pub fn mt_to_string<'tcx>(cx: &ctxt<'tcx>, m: &mt<'tcx>) -> String {
|
||||
format!("{}{}",
|
||||
mutability_to_string(m.mutbl),
|
||||
ty_to_string(cx, m.ty))
|
||||
m.ty.user_string(cx))
|
||||
}
|
||||
|
||||
pub fn vec_map_to_string<T, F>(ts: &[T], f: F) -> String where
|
||||
|
|
@ -196,7 +196,7 @@ pub fn vec_map_to_string<T, F>(ts: &[T], f: F) -> String where
|
|||
format!("[{}]", tstrs.connect(", "))
|
||||
}
|
||||
|
||||
pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
||||
fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
||||
fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>,
|
||||
opt_def_id: Option<ast::DefId>,
|
||||
unsafety: ast::Unsafety,
|
||||
|
|
@ -266,7 +266,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
s.push(bra);
|
||||
let strs = sig.0.inputs
|
||||
.iter()
|
||||
.map(|a| ty_to_string(cx, *a))
|
||||
.map(|a| a.user_string(cx))
|
||||
.collect::<Vec<_>>();
|
||||
s.push_str(&strs.connect(", "));
|
||||
if sig.0.variadic {
|
||||
|
|
@ -278,7 +278,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
ty::FnConverging(t) => {
|
||||
if !ty::type_is_nil(t) {
|
||||
s.push_str(" -> ");
|
||||
s.push_str(&ty_to_string(cx, t));
|
||||
s.push_str(& t.user_string(cx));
|
||||
}
|
||||
}
|
||||
ty::FnDiverging => {
|
||||
|
|
@ -307,12 +307,12 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
TyInt(t) => ast_util::int_ty_to_string(t, None).to_string(),
|
||||
TyUint(t) => ast_util::uint_ty_to_string(t, None).to_string(),
|
||||
TyFloat(t) => ast_util::float_ty_to_string(t).to_string(),
|
||||
TyBox(typ) => format!("Box<{}>", ty_to_string(cx, typ)),
|
||||
TyBox(typ) => format!("Box<{}>", typ.user_string(cx)),
|
||||
TyRawPtr(ref tm) => {
|
||||
format!("*{} {}", match tm.mutbl {
|
||||
ast::MutMutable => "mut",
|
||||
ast::MutImmutable => "const",
|
||||
}, ty_to_string(cx, tm.ty))
|
||||
}, tm.ty.user_string(cx))
|
||||
}
|
||||
TyRef(r, ref tm) => {
|
||||
let mut buf = "&".to_owned();
|
||||
|
|
@ -326,7 +326,7 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
TyTuple(ref elems) => {
|
||||
let strs = elems
|
||||
.iter()
|
||||
.map(|elem| ty_to_string(cx, *elem))
|
||||
.map(|elem| elem.user_string(cx))
|
||||
.collect::<Vec<_>>();
|
||||
match &strs[..] {
|
||||
[ref string] => format!("({},)", string),
|
||||
|
|
@ -375,10 +375,10 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
|
|||
})
|
||||
}
|
||||
TyArray(t, sz) => {
|
||||
format!("[{}; {}]", ty_to_string(cx, t), sz)
|
||||
format!("[{}; {}]", t.user_string(cx), sz)
|
||||
}
|
||||
TySlice(t) => {
|
||||
format!("[{}]", ty_to_string(cx, t))
|
||||
format!("[{}]", t.user_string(cx))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -475,7 +475,7 @@ fn parameterized<'tcx, GG>(cx: &ctxt<'tcx>,
|
|||
};
|
||||
|
||||
for t in &tps[..tps.len() - num_defaults] {
|
||||
strs.push(ty_to_string(cx, *t))
|
||||
strs.push(t.user_string(cx))
|
||||
}
|
||||
|
||||
for projection in projections {
|
||||
|
|
@ -581,6 +581,12 @@ impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx, T: ?Sized +UserString<'tcx>> UserString<'tcx> for &'a T {
|
||||
fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
UserString::user_string(*self, tcx)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx, T:UserString<'tcx>> UserString<'tcx> for Vec<T> {
|
||||
fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
let strs: Vec<String> =
|
||||
|
|
@ -672,7 +678,7 @@ impl<'tcx> Repr<'tcx> for ty::RegionParameterDef {
|
|||
|
||||
impl<'tcx> Repr<'tcx> for ty::TyS<'tcx> {
|
||||
fn repr(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
ty_to_string(tcx, self)
|
||||
self.user_string(tcx)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1290,9 +1296,9 @@ impl<'tcx> UserString<'tcx> for ty::TraitRef<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> UserString<'tcx> for Ty<'tcx> {
|
||||
impl<'tcx> UserString<'tcx> for ty::TyS<'tcx> {
|
||||
fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
|
||||
ty_to_string(tcx, *self)
|
||||
ty_to_string(tcx, self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use rustc::middle::cfg;
|
|||
use rustc::middle::cfg::graphviz::LabelledCFG;
|
||||
use rustc::session::Session;
|
||||
use rustc::session::config::Input;
|
||||
use rustc::util::ppaux;
|
||||
use rustc::util::ppaux::UserString;
|
||||
use rustc_borrowck as borrowck;
|
||||
use rustc_borrowck::graphviz as borrowck_dot;
|
||||
use rustc_resolve as resolve;
|
||||
|
|
@ -318,9 +318,7 @@ impl<'a, 'tcx> pprust::PpAnn for TypedAnnotation<'a, 'tcx> {
|
|||
try!(pp::word(&mut s.s, "as"));
|
||||
try!(pp::space(&mut s.s));
|
||||
try!(pp::word(&mut s.s,
|
||||
&ppaux::ty_to_string(
|
||||
&self.tcx,
|
||||
ty::expr_ty(&self.tcx, expr))));
|
||||
&ty::expr_ty(self.tcx, expr).user_string(self.tcx)));
|
||||
s.pclose()
|
||||
}
|
||||
_ => Ok(())
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use rustc_typeck::middle::infer;
|
|||
use rustc_typeck::middle::infer::lub::Lub;
|
||||
use rustc_typeck::middle::infer::glb::Glb;
|
||||
use rustc_typeck::middle::infer::sub::Sub;
|
||||
use rustc_typeck::util::ppaux::{ty_to_string, Repr, UserString};
|
||||
use rustc_typeck::util::ppaux::{Repr, UserString};
|
||||
use rustc::ast_map;
|
||||
use rustc::session::{self,config};
|
||||
use syntax::{abi, ast};
|
||||
|
|
@ -253,7 +253,7 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
|
|||
}
|
||||
|
||||
pub fn ty_to_string(&self, a: Ty<'tcx>) -> String {
|
||||
ty_to_string(self.infcx.tcx, a)
|
||||
a.user_string(self.infcx.tcx)
|
||||
}
|
||||
|
||||
pub fn t_fn(&self,
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ use middle::{def, pat_util, stability};
|
|||
use middle::const_eval::{eval_const_expr_partial, const_int, const_uint};
|
||||
use middle::cfg;
|
||||
use rustc::ast_map;
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::nodemap::{FnvHashMap, NodeSet};
|
||||
use util::ppaux::UserString;
|
||||
use lint::{Level, Context, LintPass, LintArray, Lint};
|
||||
|
||||
use std::collections::{HashSet, BitSet};
|
||||
|
|
@ -495,7 +495,7 @@ impl BoxPointers {
|
|||
});
|
||||
|
||||
if n_uniq > 0 {
|
||||
let s = ty_to_string(cx.tcx, ty);
|
||||
let s = ty.user_string(cx.tcx);
|
||||
let m = format!("type uses owned (Box type) pointers: {}", s);
|
||||
cx.span_lint(BOX_POINTERS, span, &m[..]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use middle::ty::{self, Ty};
|
|||
use rustc::ast_map::{PathElem, PathElems, PathName};
|
||||
use trans::{CrateContext, CrateTranslation, gensym_name};
|
||||
use util::common::time;
|
||||
use util::ppaux;
|
||||
use util::ppaux::UserString;
|
||||
use util::sha2::{Digest, Sha256};
|
||||
use util::fs::fix_windows_verbatim_for_gcc;
|
||||
use rustc_back::tempdir::TempDir;
|
||||
|
|
@ -347,8 +347,7 @@ pub fn mangle_exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, path: PathEl
|
|||
pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
||||
t: Ty<'tcx>,
|
||||
name: &str) -> String {
|
||||
let s = ppaux::ty_to_string(ccx.tcx(), t);
|
||||
let path = [PathName(token::intern(&s[..])),
|
||||
let path = [PathName(token::intern(&t.user_string(ccx.tcx()))),
|
||||
gensym_name(name)];
|
||||
let hash = get_symbol_hash(ccx, t);
|
||||
mangle(path.iter().cloned(), Some(&hash[..]))
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ use syntax::ptr::P;
|
|||
use super::span_utils::SpanUtils;
|
||||
use super::recorder::{Recorder, FmtStrs};
|
||||
|
||||
use util::ppaux;
|
||||
use util::ppaux::UserString;
|
||||
|
||||
macro_rules! down_cast_data {
|
||||
($id:ident, $kind:ident, $this:ident, $sp:expr) => {
|
||||
|
|
@ -287,10 +287,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
|
|||
collector.visit_pat(&arg.pat);
|
||||
let span_utils = self.span.clone();
|
||||
for &(id, ref p, _, _) in &collector.collected_paths {
|
||||
let typ =
|
||||
ppaux::ty_to_string(
|
||||
self.tcx,
|
||||
*self.tcx.node_types().get(&id).unwrap());
|
||||
let typ = self.tcx.node_types().get(&id).unwrap().user_string(self.tcx);
|
||||
// get the span only for the name of the variable (I hope the path is only ever a
|
||||
// variable name, but who knows?)
|
||||
self.fmt.formal_str(p.span,
|
||||
|
|
@ -1395,7 +1392,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DumpCsvVisitor<'l, 'tcx> {
|
|||
"<mutable>".to_string()
|
||||
};
|
||||
let types = self.tcx.node_types();
|
||||
let typ = ppaux::ty_to_string(self.tcx, *types.get(&id).unwrap());
|
||||
let typ = types.get(&id).unwrap().user_string(self.tcx);
|
||||
// Get the span only for the name of the variable (I hope the path
|
||||
// is only ever a variable name, but who knows?).
|
||||
let sub_span = self.span.span_for_last_ident(p.span);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ use syntax::parse::token::{self, get_ident, keywords};
|
|||
use syntax::visit::{self, Visitor};
|
||||
use syntax::print::pprust::ty_to_string;
|
||||
|
||||
use util::ppaux;
|
||||
use util::ppaux::UserString;
|
||||
|
||||
use self::span_utils::SpanUtils;
|
||||
|
||||
|
|
@ -292,9 +292,8 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
|
|||
let qualname = format!("::{}::{}",
|
||||
self.tcx.map.path_to_string(parent),
|
||||
name);
|
||||
let typ = ppaux::ty_to_string(&self.tcx,
|
||||
*self.tcx.node_types()
|
||||
.get(&field.node.id).unwrap());
|
||||
let typ = self.tcx.node_types().get(&field.node.id).unwrap()
|
||||
.user_string(self.tcx);
|
||||
let sub_span = self.span_utils.sub_span_before_token(field.span, token::Colon);
|
||||
Some(Data::VariableData(VariableData {
|
||||
id: field.node.id,
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ use trans::machine;
|
|||
use trans::monomorphize;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of;
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::Repr as PrettyPrintRepr;
|
||||
|
||||
type Hint = attr::ReprAttr;
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ pub fn represent_node<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
||||
t: Ty<'tcx>)
|
||||
-> Rc<Repr<'tcx>> {
|
||||
debug!("Representing: {}", ty_to_string(cx.tcx(), t));
|
||||
debug!("Representing: {}", t.repr(cx.tcx()));
|
||||
match cx.adt_reprs().borrow().get(&t) {
|
||||
Some(repr) => return repr.clone(),
|
||||
None => {}
|
||||
|
|
@ -382,7 +382,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
General(ity, fields, dtor_to_init_u8(dtor))
|
||||
}
|
||||
_ => cx.sess().bug(&format!("adt::represent_type called on non-ADT type: {}",
|
||||
ty_to_string(cx.tcx(), t)))
|
||||
t.repr(cx.tcx())))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ use trans::type_of;
|
|||
use trans::type_of::*;
|
||||
use trans::value::Value;
|
||||
use util::common::indenter;
|
||||
use util::ppaux::{Repr, ty_to_string};
|
||||
use util::ppaux::Repr;
|
||||
use util::sha2::Sha256;
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
|
|
@ -531,7 +531,7 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
|||
}
|
||||
_ => {
|
||||
cx.sess().unimpl(&format!("type in iter_structural_ty: {}",
|
||||
ty_to_string(cx.tcx(), t)))
|
||||
t.repr(cx.tcx())))
|
||||
}
|
||||
}
|
||||
return cx;
|
||||
|
|
@ -641,7 +641,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
|
|||
}
|
||||
_ => {
|
||||
cx.sess().bug(&format!("fail-if-zero on unexpected type: {}",
|
||||
ty_to_string(cx.tcx(), rhs_t)));
|
||||
rhs_t.repr(cx.tcx())));
|
||||
}
|
||||
};
|
||||
let bcx = with_cond(cx, is_zero, |bcx| {
|
||||
|
|
@ -1554,7 +1554,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
|
|||
};
|
||||
for monomorphized_arg_type in &monomorphized_arg_types {
|
||||
debug!("trans_closure: monomorphized_arg_type: {}",
|
||||
ty_to_string(ccx.tcx(), *monomorphized_arg_type));
|
||||
monomorphized_arg_type.repr(ccx.tcx()));
|
||||
}
|
||||
debug!("trans_closure: function lltype: {}",
|
||||
bcx.fcx.ccx.tn().val_to_string(bcx.fcx.llfn));
|
||||
|
|
@ -1758,7 +1758,7 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
|
|||
_ => ccx.sess().bug(
|
||||
&format!("trans_enum_variant_or_tuple_like_struct: \
|
||||
unexpected ctor return type {}",
|
||||
ty_to_string(ccx.tcx(), ctor_ty)))
|
||||
ctor_ty.repr(ccx.tcx())))
|
||||
};
|
||||
|
||||
let (arena, fcx): (TypedArena<_>, FunctionContext);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ use middle::ty::{self, Ty};
|
|||
use middle::ty::MethodCall;
|
||||
use rustc::ast_map;
|
||||
use util::ppaux::Repr;
|
||||
use util::ppaux::ty_to_string;
|
||||
|
||||
use syntax::abi as synabi;
|
||||
use syntax::ast;
|
||||
|
|
@ -1166,8 +1165,8 @@ pub fn trans_arg_datum<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
|||
let llformal_arg_ty = type_of::type_of_explicit_arg(ccx, formal_arg_ty);
|
||||
debug!("casting actual type ({}) to match formal ({})",
|
||||
bcx.val_to_string(val), bcx.llty_str(llformal_arg_ty));
|
||||
debug!("Rust types: {}; {}", ty_to_string(bcx.tcx(), arg_datum_ty),
|
||||
ty_to_string(bcx.tcx(), formal_arg_ty));
|
||||
debug!("Rust types: {}; {}", arg_datum_ty.repr(bcx.tcx()),
|
||||
formal_arg_ty.repr(bcx.tcx()));
|
||||
val = PointerCast(bcx, val, llformal_arg_ty);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ use trans::type_of;
|
|||
use middle::cast::{CastTy,IntTy};
|
||||
use middle::subst::Substs;
|
||||
use middle::ty::{self, Ty};
|
||||
use util::ppaux::{Repr, ty_to_string};
|
||||
use util::ppaux::Repr;
|
||||
use util::nodemap::NodeMap;
|
||||
|
||||
use std::iter::repeat;
|
||||
|
|
@ -68,7 +68,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
|
|||
_ => cx.sess().span_bug(lit.span,
|
||||
&format!("integer literal has type {} (expected int \
|
||||
or usize)",
|
||||
ty_to_string(cx.tcx(), lit_int_ty)))
|
||||
lit_int_ty.repr(cx.tcx())))
|
||||
}
|
||||
}
|
||||
ast::LitFloat(ref fs, t) => {
|
||||
|
|
@ -161,7 +161,7 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
}
|
||||
None => {
|
||||
cx.sess().bug(&format!("unexpected dereferenceable type {}",
|
||||
ty_to_string(cx.tcx(), ty)))
|
||||
ty.repr(cx.tcx())))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
llvm::LLVMDumpValue(C_undef(llty));
|
||||
}
|
||||
cx.sess().bug(&format!("const {} of type {} has size {} instead of {}",
|
||||
e.repr(cx.tcx()), ty_to_string(cx.tcx(), ety_adjusted),
|
||||
e.repr(cx.tcx()), ety_adjusted.repr(cx.tcx()),
|
||||
csize, tsize));
|
||||
}
|
||||
(llconst, ety_adjusted)
|
||||
|
|
@ -621,12 +621,12 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
_ => cx.sess().span_bug(base.span,
|
||||
&format!("index-expr base must be a vector \
|
||||
or string type, found {}",
|
||||
ty_to_string(cx.tcx(), bt)))
|
||||
bt.repr(cx.tcx())))
|
||||
},
|
||||
_ => cx.sess().span_bug(base.span,
|
||||
&format!("index-expr base must be a vector \
|
||||
or string type, found {}",
|
||||
ty_to_string(cx.tcx(), bt)))
|
||||
bt.repr(cx.tcx())))
|
||||
};
|
||||
|
||||
let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ use trans::expr;
|
|||
use trans::tvec;
|
||||
use trans::type_of;
|
||||
use middle::ty::{self, Ty};
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use std::fmt;
|
||||
use syntax::ast;
|
||||
|
|
@ -616,7 +616,7 @@ impl<'tcx, K: KindOps + fmt::Debug> Datum<'tcx, K> {
|
|||
pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
|
||||
format!("Datum({}, {}, {:?})",
|
||||
ccx.tn().val_to_string(self.val),
|
||||
ty_to_string(ccx.tcx(), self.ty),
|
||||
self.ty.repr(ccx.tcx()),
|
||||
self.kind)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use trans::type_::Type;
|
|||
use middle::ty::{self, Ty, ClosureTyper};
|
||||
use session::config::{self, FullDebugInfo};
|
||||
use util::nodemap::FnvHashMap;
|
||||
use util::ppaux;
|
||||
use util::ppaux::{Repr, UserString};
|
||||
use util::common::path2cstr;
|
||||
|
||||
use libc::{c_uint, c_longlong};
|
||||
|
|
@ -105,7 +105,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
metadata: DIType) {
|
||||
if self.type_to_metadata.insert(type_, metadata).is_some() {
|
||||
cx.sess().bug(&format!("Type metadata for Ty '{}' is already in the TypeMap!",
|
||||
ppaux::ty_to_string(cx.tcx(), type_)));
|
||||
type_.repr(cx.tcx())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -298,8 +298,7 @@ impl<'tcx> TypeMap<'tcx> {
|
|||
},
|
||||
_ => {
|
||||
cx.sess().bug(&format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
|
||||
&ppaux::ty_to_string(cx.tcx(), type_),
|
||||
type_.sty))
|
||||
type_.repr(cx.tcx()), type_.sty))
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -490,7 +489,7 @@ impl<'tcx> RecursiveTypeDescription<'tcx> {
|
|||
type_map.find_metadata_for_type(unfinished_type).is_none() {
|
||||
cx.sess().bug(&format!("Forward declaration of potentially recursive type \
|
||||
'{}' was not found in TypeMap!",
|
||||
ppaux::ty_to_string(cx.tcx(), unfinished_type))
|
||||
unfinished_type.repr(cx.tcx()))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -676,10 +675,9 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
let def_id = match trait_type.sty {
|
||||
ty::TyTrait(ref data) => data.principal_def_id(),
|
||||
_ => {
|
||||
let pp_type_name = ppaux::ty_to_string(cx.tcx(), trait_type);
|
||||
cx.sess().bug(&format!("debuginfo: Unexpected trait-object type in \
|
||||
trait_pointer_metadata(): {}",
|
||||
&pp_type_name[..]));
|
||||
trait_type.repr(cx.tcx())));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -841,7 +839,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
the debuginfo::TypeMap but it \
|
||||
was not. (Ty = {})",
|
||||
&unique_type_id_str[..],
|
||||
ppaux::ty_to_string(cx.tcx(), t));
|
||||
t.user_string(cx.tcx()));
|
||||
cx.sess().span_bug(usage_site_span, &error_message[..]);
|
||||
}
|
||||
};
|
||||
|
|
@ -856,7 +854,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
debuginfo::TypeMap. \
|
||||
UniqueTypeId={}, Ty={}",
|
||||
&unique_type_id_str[..],
|
||||
ppaux::ty_to_string(cx.tcx(), t));
|
||||
t.user_string(cx.tcx()));
|
||||
cx.sess().span_bug(usage_site_span, &error_message[..]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,10 @@ use super::namespace::crate_root_namespace;
|
|||
use trans::common::CrateContext;
|
||||
use middle::subst::{self, Substs};
|
||||
use middle::ty::{self, Ty, ClosureTyper};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use util::ppaux;
|
||||
|
||||
|
||||
// Compute the name of the type as it should be stored in debuginfo. Does not do
|
||||
|
|
@ -162,7 +163,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
|
|||
ty::TyProjection(..) |
|
||||
ty::TyParam(_) => {
|
||||
cx.sess().bug(&format!("debuginfo: Trying to create type name for \
|
||||
unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t)));
|
||||
unexpected type: {}", t.repr(cx.tcx())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ use trans::machine::*;
|
|||
use trans::monomorphize;
|
||||
use trans::type_of::{type_of, type_of_dtor, sizing_type_of, align_of};
|
||||
use trans::type_::Type;
|
||||
use util::ppaux::{self, Repr};
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use arena::TypedArena;
|
||||
use libc::c_uint;
|
||||
|
|
@ -205,10 +205,13 @@ impl<'tcx> DropGlueKind<'tcx> {
|
|||
}
|
||||
|
||||
fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
|
||||
let t_str = ppaux::ty_to_string(ccx.tcx(), self.ty());
|
||||
match *self {
|
||||
DropGlueKind::Ty(_) => format!("DropGlueKind::Ty({})", t_str),
|
||||
DropGlueKind::TyContents(_) => format!("DropGlueKind::TyContents({})", t_str),
|
||||
DropGlueKind::Ty(ty) => {
|
||||
format!("DropGlueKind::Ty({})", ty.repr(ccx.tcx()))
|
||||
}
|
||||
DropGlueKind::TyContents(ty) => {
|
||||
format!("DropGlueKind::TyContents({})", ty.repr(ccx.tcx()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ use middle::ty::{self, Ty};
|
|||
use syntax::abi::RustIntrinsic;
|
||||
use syntax::ast;
|
||||
use syntax::parse::token;
|
||||
use util::ppaux::{Repr, ty_to_string};
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
pub fn get_simple_intrinsic(ccx: &CrateContext, item: &ast::ForeignItem) -> Option<ValueRef> {
|
||||
let name = match &token::get_ident(item.ident)[..] {
|
||||
|
|
@ -121,10 +121,10 @@ pub fn check_intrinsics(ccx: &CrateContext) {
|
|||
transmute_restriction.span,
|
||||
&format!("transmute called on types with potentially different sizes: \
|
||||
{} (could be {} bit{}) to {} (could be {} bit{})",
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_from),
|
||||
transmute_restriction.original_from.user_string(ccx.tcx()),
|
||||
from_type_size as usize,
|
||||
if from_type_size == 1 {""} else {"s"},
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_to),
|
||||
transmute_restriction.original_to.user_string(ccx.tcx()),
|
||||
to_type_size as usize,
|
||||
if to_type_size == 1 {""} else {"s"}));
|
||||
} else {
|
||||
|
|
@ -132,10 +132,10 @@ pub fn check_intrinsics(ccx: &CrateContext) {
|
|||
transmute_restriction.span,
|
||||
&format!("transmute called on types with different sizes: \
|
||||
{} ({} bit{}) to {} ({} bit{})",
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_from),
|
||||
transmute_restriction.original_from.user_string(ccx.tcx()),
|
||||
from_type_size as usize,
|
||||
if from_type_size == 1 {""} else {"s"},
|
||||
ty_to_string(ccx.tcx(), transmute_restriction.original_to),
|
||||
transmute_restriction.original_to.user_string(ccx.tcx()),
|
||||
to_type_size as usize,
|
||||
if to_type_size == 1 {""} else {"s"}));
|
||||
}
|
||||
|
|
@ -405,7 +405,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||
}
|
||||
(_, "type_name") => {
|
||||
let tp_ty = *substs.types.get(FnSpace, 0);
|
||||
let ty_name = token::intern_and_get_ident(&ty_to_string(ccx.tcx(), tp_ty));
|
||||
let ty_name = token::intern_and_get_ident(&tp_ty.user_string(ccx.tcx()));
|
||||
C_str_slice(ccx, ty_name)
|
||||
}
|
||||
(_, "type_id") => {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ use trans::machine::llsize_of_alloc;
|
|||
use trans::type_::Type;
|
||||
use trans::type_of;
|
||||
use middle::ty::{self, Ty};
|
||||
use util::ppaux::ty_to_string;
|
||||
use util::ppaux::UserString;
|
||||
|
||||
use syntax::ast;
|
||||
use syntax::parse::token::InternedString;
|
||||
|
|
@ -42,7 +42,7 @@ struct VecTypes<'tcx> {
|
|||
impl<'tcx> VecTypes<'tcx> {
|
||||
pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
|
||||
format!("VecTypes {{unit_ty={}, llunit_ty={}}}",
|
||||
ty_to_string(ccx.tcx(), self.unit_ty),
|
||||
self.unit_ty.user_string(ccx.tcx()),
|
||||
ccx.tn().type_to_string(self.llunit_ty))
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ use trans::common::*;
|
|||
use trans::foreign;
|
||||
use trans::machine;
|
||||
use middle::ty::{self, RegionEscape, Ty};
|
||||
use util::ppaux;
|
||||
use util::ppaux::Repr;
|
||||
|
||||
use trans::type_::Type;
|
||||
|
|
@ -230,7 +229,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
|
|||
|
||||
ty::TyProjection(..) | ty::TyInfer(..) | ty::TyParam(..) | ty::TyError(..) => {
|
||||
cx.sess().bug(&format!("fictitious type {} in sizing_type_of()",
|
||||
ppaux::ty_to_string(cx.tcx(), t)))
|
||||
t.repr(cx.tcx())))
|
||||
}
|
||||
ty::TySlice(_) | ty::TyTrait(..) | ty::TyStr => unreachable!()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ use {CrateCtxt, lookup_full_def, require_same_types};
|
|||
use TypeAndSubsts;
|
||||
use lint;
|
||||
use util::common::{block_query, ErrorReported, indenter, loop_query};
|
||||
use util::ppaux::{self, Repr};
|
||||
use util::ppaux::{Repr, UserString};
|
||||
use util::nodemap::{DefIdMap, FnvHashMap, NodeMap};
|
||||
use util::lev_distance::lev_distance;
|
||||
|
||||
|
|
@ -1396,7 +1396,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
#[inline]
|
||||
pub fn write_ty(&self, node_id: ast::NodeId, ty: Ty<'tcx>) {
|
||||
debug!("write_ty({}, {}) in fcx {}",
|
||||
node_id, ppaux::ty_to_string(self.tcx(), ty), self.tag());
|
||||
node_id, ty.repr(self.tcx()), self.tag());
|
||||
self.inh.node_types.borrow_mut().insert(node_id, ty);
|
||||
}
|
||||
|
||||
|
|
@ -2746,7 +2746,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
|base_t, _| {
|
||||
match base_t.sty {
|
||||
ty::TyStruct(base_id, substs) => {
|
||||
debug!("struct named {}", ppaux::ty_to_string(tcx, base_t));
|
||||
debug!("struct named {}", base_t.repr(tcx));
|
||||
let fields = ty::lookup_struct_fields(tcx, base_id);
|
||||
fcx.lookup_field_ty(expr.span, base_id, &fields[..],
|
||||
field.node.name, &(*substs))
|
||||
|
|
@ -2850,7 +2850,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
ty::TyStruct(base_id, substs) => {
|
||||
tuple_like = ty::is_tuple_struct(tcx, base_id);
|
||||
if tuple_like {
|
||||
debug!("tuple struct named {}", ppaux::ty_to_string(tcx, base_t));
|
||||
debug!("tuple struct named {}", base_t.repr(tcx));
|
||||
let fields = ty::lookup_struct_fields(tcx, base_id);
|
||||
fcx.lookup_tup_field_ty(expr.span, base_id, &fields[..],
|
||||
idx.node, &(*substs))
|
||||
|
|
@ -3749,7 +3749,7 @@ fn check_expr_with_unifier<'a, 'tcx, F>(fcx: &FnCtxt<'a, 'tcx>,
|
|||
debug!("type of expr({}) {} is...", expr.id,
|
||||
syntax::print::pprust::expr_to_string(expr));
|
||||
debug!("... {}, expected is {}",
|
||||
ppaux::ty_to_string(tcx, fcx.expr_ty(expr)),
|
||||
fcx.expr_ty(expr).repr(tcx),
|
||||
expected.repr(tcx));
|
||||
|
||||
unifier();
|
||||
|
|
@ -4198,7 +4198,7 @@ pub fn check_instantiable(tcx: &ty::ctxt,
|
|||
"this type cannot be instantiated without an \
|
||||
instance of itself");
|
||||
fileline_help!(tcx.sess, sp, "consider using `Option<{}>`",
|
||||
ppaux::ty_to_string(tcx, item_ty));
|
||||
item_ty.repr(tcx));
|
||||
false
|
||||
} else {
|
||||
true
|
||||
|
|
@ -4950,7 +4950,7 @@ pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
|
|||
tps: &OwnedSlice<ast::TyParam>,
|
||||
ty: Ty<'tcx>) {
|
||||
debug!("check_bounds_are_used(n_tps={}, ty={})",
|
||||
tps.len(), ppaux::ty_to_string(ccx.tcx, ty));
|
||||
tps.len(), ty.repr(ccx.tcx));
|
||||
|
||||
// make a vector of booleans initially false, set to true when used
|
||||
if tps.is_empty() { return; }
|
||||
|
|
@ -5273,7 +5273,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
|
|||
fty,
|
||||
|| {
|
||||
format!("intrinsic has wrong type: expected `{}`",
|
||||
ppaux::ty_to_string(ccx.tcx, fty))
|
||||
fty.user_string(ccx.tcx))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ use middle::traits;
|
|||
use middle::ty::{self, ClosureTyper, ReScope, Ty, MethodCall};
|
||||
use middle::infer::{self, GenericKind};
|
||||
use middle::pat_util;
|
||||
use util::ppaux::{ty_to_string, Repr};
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
use std::mem;
|
||||
use syntax::{ast, ast_util};
|
||||
|
|
@ -1025,7 +1025,7 @@ fn type_of_node_must_outlive<'a, 'tcx>(
|
|||
|method_call| rcx.resolve_method_type(method_call));
|
||||
debug!("constrain_regions_in_type_of_node(\
|
||||
ty={}, ty0={}, id={}, minimum_lifetime={:?})",
|
||||
ty_to_string(tcx, ty), ty_to_string(tcx, ty0),
|
||||
ty.user_string(tcx), ty0.user_string(tcx),
|
||||
id, minimum_lifetime);
|
||||
type_must_outlive(rcx, origin, ty, minimum_lifetime);
|
||||
}
|
||||
|
|
@ -1178,7 +1178,7 @@ fn link_region_from_node_type<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
|
|||
let rptr_ty = rcx.resolve_node_type(id);
|
||||
if !ty::type_is_error(rptr_ty) {
|
||||
let tcx = rcx.fcx.ccx.tcx;
|
||||
debug!("rptr_ty={}", ty_to_string(tcx, rptr_ty));
|
||||
debug!("rptr_ty={}", rptr_ty.user_string(tcx));
|
||||
let r = ty::ty_region(tcx, span, rptr_ty);
|
||||
link_region(rcx, span, &r, ty::BorrowKind::from_mutbl(mutbl),
|
||||
cmt_borrowed);
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ use rscope::*;
|
|||
use rustc::ast_map;
|
||||
use util::common::{ErrorReported, memoized};
|
||||
use util::nodemap::{FnvHashMap, FnvHashSet};
|
||||
use util::ppaux;
|
||||
use util::ppaux::{Repr,UserString};
|
||||
use util::ppaux::{Repr, UserString};
|
||||
use write_ty_to_tcx;
|
||||
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
|
@ -2217,7 +2216,7 @@ fn check_method_self_type<'a, 'tcx, RS:RegionScope>(
|
|||
required_type_free,
|
||||
|| {
|
||||
format!("mismatched self type: expected `{}`",
|
||||
ppaux::ty_to_string(tcx, required_type))
|
||||
required_type.user_string(tcx))
|
||||
}));
|
||||
|
||||
// We could conceviably add more free-region relations here,
|
||||
|
|
|
|||
|
|
@ -109,8 +109,7 @@ use middle::ty::{self, Ty};
|
|||
use rustc::ast_map;
|
||||
use session::config;
|
||||
use util::common::time;
|
||||
use util::ppaux::Repr;
|
||||
use util::ppaux;
|
||||
use util::ppaux::{Repr, UserString};
|
||||
|
||||
use syntax::codemap::Span;
|
||||
use syntax::print::pprust::*;
|
||||
|
|
@ -149,7 +148,7 @@ pub struct CrateCtxt<'a, 'tcx: 'a> {
|
|||
|
||||
// Functions that write types into the node type table
|
||||
fn write_ty_to_tcx<'tcx>(tcx: &ty::ctxt<'tcx>, node_id: ast::NodeId, ty: Ty<'tcx>) {
|
||||
debug!("write_ty_to_tcx({}, {})", node_id, ppaux::ty_to_string(tcx, ty));
|
||||
debug!("write_ty_to_tcx({}, {})", node_id, ty.repr(tcx));
|
||||
assert!(!ty::type_needs_infer(ty));
|
||||
tcx.node_type_insert(node_id, ty);
|
||||
}
|
||||
|
|
@ -245,15 +244,14 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
|
|||
require_same_types(tcx, None, false, main_span, main_t, se_ty,
|
||||
|| {
|
||||
format!("main function expects type: `{}`",
|
||||
ppaux::ty_to_string(ccx.tcx, se_ty))
|
||||
se_ty.user_string(ccx.tcx))
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
tcx.sess.span_bug(main_span,
|
||||
&format!("main has a non-function type: found \
|
||||
`{}`",
|
||||
ppaux::ty_to_string(tcx,
|
||||
main_t)));
|
||||
main_t.repr(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -296,7 +294,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
|||
require_same_types(tcx, None, false, start_span, start_t, se_ty,
|
||||
|| {
|
||||
format!("start function expects type: `{}`",
|
||||
ppaux::ty_to_string(ccx.tcx, se_ty))
|
||||
se_ty.user_string(ccx.tcx))
|
||||
});
|
||||
|
||||
}
|
||||
|
|
@ -304,7 +302,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
|||
tcx.sess.span_bug(start_span,
|
||||
&format!("start has a non-function type: found \
|
||||
`{}`",
|
||||
ppaux::ty_to_string(tcx, start_t)));
|
||||
start_t.repr(tcx)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue