Support for shorter error messages that are aware of objects' cnames.
This commit is contained in:
parent
bcf04e253f
commit
0ce0c4c41a
@ -115,10 +115,17 @@ fn ty_to_str(&@t typ) -> str {
|
|||||||
option.t[ast.ident] ident,
|
option.t[ast.ident] ident,
|
||||||
vec[arg] inputs, @t output) -> str {
|
vec[arg] inputs, @t output) -> str {
|
||||||
auto f = fn_input_to_str;
|
auto f = fn_input_to_str;
|
||||||
auto s = "fn";
|
|
||||||
if (proto == ast.proto_iter) {
|
auto s;
|
||||||
s = "iter";
|
alt (proto) {
|
||||||
|
case (ast.proto_iter) {
|
||||||
|
s = "iter";
|
||||||
|
}
|
||||||
|
case (ast.proto_fn) {
|
||||||
|
s = "fn";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
alt (ident) {
|
alt (ident) {
|
||||||
case (some[ast.ident](?i)) {
|
case (some[ast.ident](?i)) {
|
||||||
s += " ";
|
s += " ";
|
||||||
@ -206,9 +213,16 @@ fn ty_to_str(&@t typ) -> str {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case (ty_obj(?meths)) {
|
case (ty_obj(?meths)) {
|
||||||
auto f = method_to_str;
|
alt (typ.cname) {
|
||||||
auto m = _vec.map[method,str](f, meths);
|
case (some[str](?cs)) {
|
||||||
s += "obj {\n\t" + _str.connect(m, "\n\t") + "\n}";
|
s += cs;
|
||||||
|
}
|
||||||
|
case (_) {
|
||||||
|
auto f = method_to_str;
|
||||||
|
auto m = _vec.map[method,str](f, meths);
|
||||||
|
s += "obj {\n\t" + _str.connect(m, "\n\t") + "\n}";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
case (ty_var(?v)) {
|
case (ty_var(?v)) {
|
||||||
|
@ -538,19 +538,22 @@ fn collect_item_types(session.session sess, @ast.crate crate)
|
|||||||
|
|
||||||
fn ty_of_obj(@ty_item_table id_to_ty_item,
|
fn ty_of_obj(@ty_item_table id_to_ty_item,
|
||||||
@ty_table item_to_ty,
|
@ty_table item_to_ty,
|
||||||
|
&ast.ident id,
|
||||||
&ast._obj obj_info) -> @ty.t {
|
&ast._obj obj_info) -> @ty.t {
|
||||||
auto f = bind ty_of_method(id_to_ty_item, item_to_ty, _);
|
auto f = bind ty_of_method(id_to_ty_item, item_to_ty, _);
|
||||||
auto methods =
|
auto methods =
|
||||||
_vec.map[@ast.method,method](f, obj_info.methods);
|
_vec.map[@ast.method,method](f, obj_info.methods);
|
||||||
|
|
||||||
auto t_obj = plain_ty(ty.ty_obj(ty.sort_methods(methods)));
|
auto t_obj = @rec(struct=ty.ty_obj(ty.sort_methods(methods)),
|
||||||
|
cname=some[str](id));
|
||||||
ret t_obj;
|
ret t_obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_of_obj_ctor(@ty_item_table id_to_ty_item,
|
fn ty_of_obj_ctor(@ty_item_table id_to_ty_item,
|
||||||
@ty_table item_to_ty,
|
@ty_table item_to_ty,
|
||||||
|
&ast.ident id,
|
||||||
&ast._obj obj_info) -> @ty.t {
|
&ast._obj obj_info) -> @ty.t {
|
||||||
auto t_obj = ty_of_obj(id_to_ty_item, item_to_ty, obj_info);
|
auto t_obj = ty_of_obj(id_to_ty_item, item_to_ty, id, obj_info);
|
||||||
let vec[arg] t_inputs = vec();
|
let vec[arg] t_inputs = vec();
|
||||||
for (ast.obj_field f in obj_info.fields) {
|
for (ast.obj_field f in obj_info.fields) {
|
||||||
auto g = bind getter(id_to_ty_item, item_to_ty, _);
|
auto g = bind getter(id_to_ty_item, item_to_ty, _);
|
||||||
@ -584,6 +587,7 @@ fn collect_item_types(session.session sess, @ast.crate crate)
|
|||||||
// TODO: handle ty-params
|
// TODO: handle ty-params
|
||||||
auto t_ctor = ty_of_obj_ctor(id_to_ty_item,
|
auto t_ctor = ty_of_obj_ctor(id_to_ty_item,
|
||||||
item_to_ty,
|
item_to_ty,
|
||||||
|
ident,
|
||||||
obj_info);
|
obj_info);
|
||||||
item_to_ty.insert(def_id, t_ctor);
|
item_to_ty.insert(def_id, t_ctor);
|
||||||
ret t_ctor;
|
ret t_ctor;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user