Skip to content

Commit

Permalink
Fix fallout from rebasing.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Feb 24, 2015
1 parent 8501c9d commit 72d5f39
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/librustc/metadata/encoder.rs
Expand Up @@ -1193,15 +1193,15 @@ fn encode_info_for_item(ecx: &EncodeContext,
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_family(rbml_w, 'd');
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();
}
Expand Down
15 changes: 6 additions & 9 deletions src/librustc/middle/ty.rs
Expand Up @@ -5116,15 +5116,12 @@ pub fn impl_trait_ref<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
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
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/build_reduced_graph.rs
Expand Up @@ -504,8 +504,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
parent.clone()
}

ItemImpl(..) => parent.clone(),
ItemDefaultImpl(_, _) |
ItemImpl(..) => parent.clone(),

ItemTrait(_, _, _, ref items) => {
let name_bindings =
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_resolve/lib.rs
Expand Up @@ -2772,7 +2772,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}

ItemDefaultImpl(_, ref trait_ref) => {
self.resolve_trait_reference(item.id, trait_ref, TraitImplementation);
self.with_optional_trait_ref(Some(trait_ref), |_| {});
}
ItemImpl(_, _,
ref generics,
Expand Down Expand Up @@ -3022,12 +3022,12 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}

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);
Expand Down Expand Up @@ -3057,7 +3057,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
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);

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/save/mod.rs
Expand Up @@ -1004,7 +1004,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
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),
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/coherence/orphan.rs
Expand Up @@ -93,10 +93,10 @@ impl<'cx, 'tcx,'v> visit::Visitor<'v> for OrphanChecker<'cx, 'tcx> {
}
}
}
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 \
Expand Down
8 changes: 6 additions & 2 deletions src/librustc_typeck/collect.rs
Expand Up @@ -649,8 +649,12 @@ fn convert_item(ccx: &CollectCtxt, it: &ast::Item) {
&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))
}
Expand Down

0 comments on commit 72d5f39

Please sign in to comment.