Skip to content

Commit f7cb9a0

Browse files
authored
Merge pull request rust-lang#84 from oli-obk/master
rustup
2 parents 9322dec + 4ebf7bf commit f7cb9a0

File tree

4 files changed

+27
-26
lines changed

4 files changed

+27
-26
lines changed

src/interpreter/terminator/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc::ty::fold::TypeFoldable;
55
use rustc::ty::layout::Layout;
66
use rustc::ty::subst::{Substs, Kind};
77
use rustc::ty::{self, Ty, TyCtxt, BareFnTy};
8-
use std::rc::Rc;
98
use syntax::codemap::{DUMMY_SP, Span};
109
use syntax::{ast, attr};
1110

@@ -479,7 +478,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
479478

480479
_ => bug!("cannot convert {:?} to {:?}", closure_kind, trait_closure_kind),
481480
}
482-
Ok((vtable_closure.closure_def_id, vtable_closure.substs.func_substs))
481+
Ok((vtable_closure.closure_def_id, vtable_closure.substs.substs))
483482
}
484483

485484
traits::VtableFnPointer(vtable_fn_ptr) => {
@@ -715,7 +714,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
715714

716715
#[derive(Debug)]
717716
pub(super) struct ImplMethod<'tcx> {
718-
pub(super) method: Rc<ty::Method<'tcx>>,
717+
pub(super) method: ty::AssociatedItem,
719718
pub(super) substs: &'tcx Substs<'tcx>,
720719
pub(super) is_provided: bool,
721720
}
@@ -733,7 +732,7 @@ pub(super) fn get_impl_method<'a, 'tcx>(
733732
let trait_def_id = tcx.trait_id_of_impl(impl_def_id).unwrap();
734733
let trait_def = tcx.lookup_trait_def(trait_def_id);
735734

736-
match trait_def.ancestors(impl_def_id).fn_defs(tcx, name).next() {
735+
match trait_def.ancestors(impl_def_id).defs(tcx, name, ty::AssociatedKind::Method).next() {
737736
Some(node_item) => {
738737
let substs = tcx.infer_ctxt(None, None, Reveal::All).enter(|infcx| {
739738
let substs = substs.rebase_onto(tcx, trait_def_id, impl_substs);
@@ -770,7 +769,7 @@ pub fn find_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
770769
let trait_def_id = tcx.trait_id_of_impl(impl_def_id).unwrap();
771770
let trait_def = tcx.lookup_trait_def(trait_def_id);
772771

773-
match trait_def.ancestors(impl_def_id).fn_defs(tcx, name).next() {
772+
match trait_def.ancestors(impl_def_id).defs(tcx, name, ty::AssociatedKind::Method).next() {
774773
Some(node_item) => {
775774
let substs = tcx.infer_ctxt(None, None, Reveal::All).enter(|infcx| {
776775
let substs = substs.rebase_onto(tcx, trait_def_id, impl_substs);

src/interpreter/vtable.rs

+19-18
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rustc::hir::def_id::DefId;
22
use rustc::traits::{self, Reveal, SelectionContext};
3-
use rustc::ty::subst::{Substs, Subst};
3+
use rustc::ty::subst::Substs;
44
use rustc::ty;
55

66
use super::EvalContext;
@@ -35,7 +35,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
3535
self.get_vtable_methods(id, substs)
3636
.into_iter()
3737
.map(|opt_mth| opt_mth.map(|mth| {
38-
let fn_ty = self.tcx.erase_regions(&mth.method.fty);
38+
let fn_ty = self.tcx.item_type(mth.method.def_id);
39+
let fn_ty = match fn_ty.sty {
40+
ty::TyFnDef(_, _, fn_ty) => fn_ty,
41+
_ => bug!("bad function type: {}", fn_ty),
42+
};
43+
let fn_ty = self.tcx.erase_regions(&fn_ty);
3944
self.memory.create_fn_ptr(self.tcx, mth.method.def_id, mth.substs, fn_ty)
4045
}))
4146
.collect::<Vec<_>>()
@@ -85,8 +90,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
8590
self.memory.write_usize(vtable, 0)?;
8691
if let ty::TyAdt(adt_def, substs) = trait_ref.self_ty().sty {
8792
if let Some(drop_def_id) = adt_def.destructor() {
88-
let ty_scheme = self.tcx.lookup_item_type(drop_def_id);
89-
let fn_ty = match ty_scheme.ty.sty {
93+
let fn_ty = match self.tcx.item_type(drop_def_id).sty {
9094
ty::TyFnDef(_, _, fn_ty) => self.tcx.erase_regions(&fn_ty),
9195
_ => bug!("drop method is not a TyFnDef"),
9296
};
@@ -120,18 +124,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
120124

121125
self.tcx.populate_implementations_for_trait_if_necessary(trait_id);
122126

123-
let trait_item_def_ids = self.tcx.impl_or_trait_items(trait_id);
124-
trait_item_def_ids
125-
.iter()
126-
127+
self.tcx
128+
.associated_items(trait_id)
127129
// Filter out non-method items.
128-
.filter_map(|&trait_method_def_id| {
129-
let trait_method_type = match self.tcx.impl_or_trait_item(trait_method_def_id) {
130-
ty::MethodTraitItem(trait_method_type) => trait_method_type,
131-
_ => return None,
132-
};
133-
debug!("get_vtable_methods: trait_method_def_id={:?}",
134-
trait_method_def_id);
130+
.filter_map(|trait_method_type| {
131+
if trait_method_type.kind != ty::AssociatedKind::Method {
132+
return None;
133+
}
134+
debug!("get_vtable_methods: trait_method_type={:?}",
135+
trait_method_type);
135136

136137
let name = trait_method_type.name;
137138

@@ -146,7 +147,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
146147

147148
// the method may have some early-bound lifetimes, add
148149
// regions for those
149-
let method_substs = Substs::for_item(self.tcx, trait_method_def_id,
150+
let method_substs = Substs::for_item(self.tcx, trait_method_type.def_id,
150151
|_, _| self.tcx.mk_region(ty::ReErased),
151152
|_, _| self.tcx.types.err);
152153

@@ -162,8 +163,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
162163
// method could then never be called, so we do not want to
163164
// try and trans it, in that case. Issue #23435.
164165
if mth.is_provided {
165-
let predicates = mth.method.predicates.predicates.subst(self.tcx, mth.substs);
166-
if !self.normalize_and_test_predicates(predicates) {
166+
let predicates = self.tcx.item_predicates(trait_method_type.def_id).instantiate_own(self.tcx, mth.substs);
167+
if !self.normalize_and_test_predicates(predicates.predicates) {
167168
debug!("get_vtable_methods: predicates do not hold");
168169
return Some(None);
169170
}

src/memory.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> {
144144
});
145145
self.create_fn_alloc(FunctionDefinition {
146146
def_id: def_id,
147-
substs: substs.func_substs,
147+
substs: substs.substs,
148148
abi: fn_ty.abi,
149149
// FIXME: why doesn't this compile?
150150
//sig: tcx.erase_late_bound_regions(&fn_ty.sig),

tests/compiletest.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,9 @@ fn for_all_targets<F: FnMut(String)>(sysroot: &str, mut f: F) {
3434
continue;
3535
}
3636
let target = target.file_name().into_string().unwrap();
37-
if target == "etc" {
38-
continue;
37+
match &*target {
38+
"etc" | "src" => continue,
39+
_ => {},
3940
}
4041
let stderr = std::io::stderr();
4142
writeln!(stderr.lock(), "running tests for target {}", target).unwrap();

0 commit comments

Comments
 (0)