None => {}
}
}
- ast::ItemDefaultImpl(unsafety, ref ast_trait_ref) => {
+ ast::ItemDefaultImpl(unsafety, _) => {
add_to_index(item, rbml_w, index);
rbml_w.start_tag(tag_items_data_item);
encode_def_id(rbml_w, def_id);
encode_name(rbml_w, item.ident.name);
encode_unsafety(rbml_w, unsafety);
- let trait_ref = ty::node_id_to_trait_ref(tcx, ast_trait_ref.ref_id);
+ let trait_ref = ty::impl_id_to_trait_ref(tcx, item.id);
encode_trait_ref(rbml_w, ecx, &*trait_ref, tag_item_trait_ref);
rbml_w.end_tag();
}
if id.krate == ast::LOCAL_CRATE {
debug!("(impl_trait_ref) searching for trait impl {:?}", id);
if let Some(ast_map::NodeItem(item)) = cx.map.find(id.node) {
- if let ast::ItemImpl(_, _, _, ref opt_trait, _, _) = item.node {
- opt_trait.as_ref().map(|_| {
- ty::impl_id_to_trait_ref(cx, id.node)
- })
- } else {
- None
- ast::ItemDefaultImpl(_, ref ast_trait_ref) => {
- Some(ty::node_id_to_trait_ref(cx, ast_trait_ref.ref_id))
- }
+ match item.node {
+ ast::ItemImpl(_, _, _, Some(_), _, _) |
+ ast::ItemDefaultImpl(..) => {
+ Some(ty::impl_id_to_trait_ref(cx, id.node))
+ }
+ _ => None
}
} else {
None
parent.clone()
}
- ItemImpl(..) => parent.clone(),
ItemDefaultImpl(_, _) |
+ ItemImpl(..) => parent.clone(),
ItemTrait(_, _, _, ref items) => {
let name_bindings =
}
ItemDefaultImpl(_, ref trait_ref) => {
- self.resolve_trait_reference(item.id, trait_ref, TraitImplementation);
+ self.with_optional_trait_ref(Some(trait_ref), |_| {});
}
ItemImpl(_, _,
ref generics,
}
fn with_optional_trait_ref<T, F>(&mut self,
- opt_trait_ref: &Option<TraitRef>,
+ opt_trait_ref: Option<&TraitRef>,
f: F) -> T where
F: FnOnce(&mut Resolver) -> T,
{
let mut new_val = None;
- if let Some(ref trait_ref) = *opt_trait_ref {
+ if let Some(trait_ref) = opt_trait_ref {
match self.resolve_trait_reference(trait_ref.ref_id, &trait_ref.path, 0) {
Ok(path_res) => {
self.record_def(trait_ref.ref_id, path_res);
this.visit_generics(generics);
// Resolve the trait reference, if necessary.
- this.with_optional_trait_ref(opt_trait_reference, |this| {
+ this.with_optional_trait_ref(opt_trait_reference.as_ref(), |this| {
// Resolve the self type.
this.visit_ty(self_type);
self.collected_paths.push((p.id, path.clone(), false, recorder::StructRef));
visit::walk_path(self, path);
- let def = self.analysis.ty_cx.def_map.borrow()[p.id];
+ let def = self.analysis.ty_cx.def_map.borrow()[p.id].full_def();
let struct_def = match def {
def::DefConst(..) => None,
def::DefVariant(_, variant_id, _) => Some(variant_id),
}
}
}
- ast::ItemDefaultImpl(_, ref ast_trait_ref) => {
+ ast::ItemDefaultImpl(..) => {
// "Trait" impl
debug!("coherence2::orphan check: default trait impl {}", item.repr(self.tcx));
- let trait_ref = ty::node_id_to_trait_ref(self.tcx, ast_trait_ref.ref_id);
+ let trait_ref = ty::impl_trait_ref(self.tcx, def_id).unwrap();
if trait_ref.def_id.krate != ast::LOCAL_CRATE {
span_err!(self.tcx.sess, item.span, E0318,
"cannot create default implementations for traits outside the \
&enum_definition.variants);
},
ast::ItemDefaultImpl(_, ref ast_trait_ref) => {
- let trait_ref = astconv::instantiate_trait_ref(ccx, &ExplicitRscope,
- ast_trait_ref, None, None);
+ let trait_ref = astconv::instantiate_trait_ref(ccx,
+ &ExplicitRscope,
+ ast_trait_ref,
+ Some(it.id),
+ None,
+ None);
ty::record_default_trait_implementation(tcx, trait_ref.def_id, local_def(it.id))
}