use syntax::ast_util::local_def;
use syntax::codemap::Span;
use syntax::parse::token::special_idents;
-use syntax::parse::token;
use syntax::ptr::P;
use syntax::visit;
fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
let tcx = ccx.tcx;
- debug!("convert: item {} with id {}", token::get_ident(it.ident), it.id);
+ debug!("convert: item {} with id {}", it.ident, it.id);
match it.node {
// These don't define types.
ast::ItemExternCrate(_) | ast::ItemUse(_) |
ty: selfty });
tcx.predicates.borrow_mut().insert(local_def(it.id),
ty_predicates.clone());
+ if let &Some(ref ast_trait_ref) = opt_trait_ref {
+ tcx.impl_trait_refs.borrow_mut().insert(
+ local_def(it.id),
+ Some(astconv::instantiate_mono_trait_ref(&ccx.icx(&ty_predicates),
+ &ExplicitRscope,
+ ast_trait_ref,
+ Some(selfty)))
+ );
+ } else {
+ tcx.impl_trait_refs.borrow_mut().insert(local_def(it.id), None);
+ }
+
// If there is a trait reference, treat the methods as always public.
// This is to work around some incorrect behavior in privacy checking:
}
}
- if let &Some(ref ast_trait_ref) = opt_trait_ref {
- tcx.impl_trait_refs.borrow_mut().insert(
- local_def(it.id),
- Some(astconv::instantiate_mono_trait_ref(&ccx.icx(&ty_predicates),
- &ExplicitRscope,
- ast_trait_ref,
- Some(selfty)))
- );
- } else {
- tcx.impl_trait_refs.borrow_mut().insert(local_def(it.id), None);
- }
-
enforce_impl_params_are_constrained(tcx,
generics,
local_def(it.id),
Some(prev_span) => {
span_err!(tcx.sess, f.span, E0124,
"field `{}` is already declared",
- token::get_name(result.name));
+ result.name);
span_note!(tcx.sess, *prev_span, "previously declared here");
true
},
// the node id for the Self type parameter.
let param_id = trait_id;
+ let parent = ccx.tcx.map.get_parent(param_id);
+
let def = ty::TypeParameterDef {
space: SelfSpace,
index: 0,
name: special_idents::type_self.name,
def_id: local_def(param_id),
- default_def_id: local_def(param_id),
+ default_def_id: local_def(parent),
default: None,
object_lifetime_default: ty::ObjectLifetimeDefault::BaseDefault,
};
compute_object_lifetime_default(ccx, param.id,
¶m.bounds, &ast_generics.where_clause);
+ let parent = tcx.map.get_parent(param.id);
+
let def = ty::TypeParameterDef {
space: space,
index: index,
name: param.ident.name,
def_id: local_def(param.id),
- // what do I return? should this be an option as well
- default_def_id: local_def(param.default.as_ref().map(|d| d.id).unwrap_or(param.id)),
+ default_def_id: local_def(parent),
default: default,
object_lifetime_default: object_lifetime_default,
};