Skip to content

Commit e5753b4

Browse files
committed
Fixes after rebase
1 parent e36620d commit e5753b4

File tree

11 files changed

+47
-29
lines changed

11 files changed

+47
-29
lines changed

src/librustc/middle/traits/coherence.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
//! See `README.md` for high-level documentation
1212
1313
use super::{SelectionContext, Obligation, ObligationCause};
14-
use super::util;
1514

1615
use middle::cstore::LOCAL_CRATE;
1716
use middle::def_id::DefId;

src/librustc/middle/traits/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,10 @@ pub fn normalize_param_env_or_error<'a,'tcx>(unnormalized_env: ty::ParameterEnvi
433433

434434
let elaborated_env = unnormalized_env.with_caller_bounds(predicates);
435435

436-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(elaborated_env), ProjectionMode::AnyFinal);
436+
let infcx = infer::new_infer_ctxt(tcx,
437+
&tcx.tables,
438+
Some(elaborated_env),
439+
ProjectionMode::AnyFinal);
437440
let predicates = match fully_normalize(&infcx,
438441
cause,
439442
&infcx.parameter_environment.caller_bounds) {

src/librustc/middle/traits/project.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ fn confirm_impl_candidate<'cx,'tcx>(
11211121
tcx.types.err
11221122
});
11231123
let substs = translate_substs(selcx.infcx(), impl_def_id, substs, node_item.node);
1124-
(ty.subst(tcx, &substs), nested)
1124+
(ty.subst(tcx, substs), nested)
11251125
}
11261126
None => {
11271127
tcx.sess.span_bug(obligation.cause.span,
@@ -1135,7 +1135,9 @@ fn confirm_impl_candidate<'cx,'tcx>(
11351135
///
11361136
/// Based on the "projection mode", this lookup may in fact only examine the
11371137
/// topmost impl. See the comments for `ProjectionMode` for more details.
1138-
fn assoc_ty_def<'cx, 'tcx>(selcx: &SelectionContext<'cx, 'tcx>, impl_def_id: DefId, assoc_ty_name: ast::Name)
1138+
fn assoc_ty_def<'cx, 'tcx>(selcx: &SelectionContext<'cx, 'tcx>,
1139+
impl_def_id: DefId,
1140+
assoc_ty_name: ast::Name)
11391141
-> Option<specialization_graph::NodeItem<Rc<ty::AssociatedType<'tcx>>>>
11401142
{
11411143
let trait_def_id = selcx.tcx().impl_trait_ref(impl_def_id).unwrap().def_id;

src/librustc/middle/traits/specialize/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ pub struct Overlap<'a, 'tcx: 'a> {
7575
/// resolved.
7676
pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
7777
source_impl: DefId,
78-
source_substs: Substs<'tcx>,
78+
source_substs: &'tcx Substs<'tcx>,
7979
target_node: specialization_graph::Node)
80-
-> Substs<'tcx> {
80+
-> &'tcx Substs<'tcx> {
8181
let source_trait_ref = infcx.tcx
8282
.impl_trait_ref(source_impl)
8383
.unwrap()
@@ -111,7 +111,7 @@ pub fn translate_substs<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
111111
};
112112

113113
// directly inherent the method generics, since those do not vary across impls
114-
target_substs.with_method_from_subst(&source_substs)
114+
infcx.tcx.mk_substs(target_substs.with_method_from_subst(source_substs))
115115
}
116116

117117
/// Is impl1 a specialization of impl2?
@@ -164,7 +164,7 @@ pub fn specializes(tcx: &TyCtxt, impl1_def_id: DefId, impl2_def_id: DefId) -> bo
164164
};
165165
penv.caller_bounds.extend(normalization_obligations.into_iter().map(|o| o.predicate));
166166

167-
// Install the parameter environment, which means we take the predicates of impl1 as assumptions:
167+
// Install the parameter environment, taking the predicates of impl1 as assumptions:
168168
infcx.parameter_environment = penv;
169169

170170
// Attempt to prove that impl2 applies, given all of the above.
@@ -217,7 +217,7 @@ fn fulfill_implication<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
217217
infcx.parameter_environment.caller_bounds);
218218
Err(())
219219
} else {
220-
debug!("fulfill_implication: an impl for {:?} specializes {:?} (`where` clauses elided)",
220+
debug!("fulfill_implication: an impl for {:?} specializes {:?}",
221221
source_trait_ref,
222222
target_trait_ref);
223223

src/librustc/middle/traits/specialize/specialization_graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Graph {
9797
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None, ProjectionMode::Topmost);
9898
let overlap = traits::overlapping_impls(&infcx, possible_sibling, impl_def_id);
9999

100-
if let Some(trait_ref) = overlap {
100+
if let Some(impl_header) = overlap {
101101
let le = specializes(tcx, impl_def_id, possible_sibling);
102102
let ge = specializes(tcx, possible_sibling, impl_def_id);
103103

@@ -124,7 +124,7 @@ impl Graph {
124124
// overlap, but no specialization; error out
125125
return Err(Overlap {
126126
with_impl: possible_sibling,
127-
on_trait_ref: trait_ref,
127+
on_trait_ref: impl_header.trait_ref.unwrap(),
128128
in_context: infcx,
129129
});
130130
}

src/librustc_driver/test.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_typeck::middle::resolve_lifetime;
2222
use rustc_typeck::middle::stability;
2323
use rustc_typeck::middle::subst;
2424
use rustc_typeck::middle::subst::Subst;
25+
use rustc_typeck::middle::traits::ProjectionMode;
2526
use rustc_typeck::middle::ty::{self, Ty, TyCtxt, TypeFoldable};
2627
use rustc_typeck::middle::ty::relate::TypeRelation;
2728
use rustc_typeck::middle::infer::{self, TypeOrigin};
@@ -143,7 +144,10 @@ fn test_env<F>(source_string: &str,
143144
lang_items,
144145
index,
145146
|tcx| {
146-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, None);
147+
let infcx = infer::new_infer_ctxt(tcx,
148+
&tcx.tables,
149+
None,
150+
ProjectionMode::AnyFinal);
147151
body(Env { infcx: &infcx });
148152
let free_regions = FreeRegionMap::new();
149153
infcx.resolve_regions_and_report_errors(&free_regions,

src/librustc_mir/transform/type_check.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use rustc::dep_graph::DepNode;
1515
use rustc::middle::infer::{self, InferCtxt};
16-
use rustc::middle::traits;
16+
use rustc::middle::traits::{self, ProjectionMode};
1717
use rustc::middle::ty::fold::TypeFoldable;
1818
use rustc::middle::ty::{self, Ty, TyCtxt};
1919
use rustc::mir::repr::*;
@@ -582,7 +582,10 @@ impl<'tcx> MirPass<'tcx> for TypeckMir {
582582
}
583583
let _task = tcx.dep_graph.in_task(DepNode::MirTypeck(id));
584584
let param_env = ty::ParameterEnvironment::for_item(tcx, id);
585-
let infcx = infer::new_infer_ctxt(tcx, &tcx.tables, Some(param_env));
585+
let infcx = infer::new_infer_ctxt(tcx,
586+
&tcx.tables,
587+
Some(param_env),
588+
ProjectionMode::AnyFinal);
586589
let mut checker = TypeChecker::new(&infcx);
587590
{
588591
let mut verifier = TypeVerifier::new(&mut checker, mir);

src/librustc_trans/trans/collector.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ fn do_static_trait_method_dispatch<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
823823
impl_did,
824824
tcx.mk_substs(callee_substs),
825825
trait_method.name);
826-
Some((impl_method.method.def_id, impl_method.substs))
826+
Some((impl_method.method.def_id, &impl_method.substs))
827827
}
828828
// If we have a closure or a function pointer, we will also encounter
829829
// the concrete closure/function somewhere else (during closure or fn
@@ -983,7 +983,7 @@ fn create_trans_items_for_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
983983
if can_have_local_instance(ccx, impl_method.method.def_id) {
984984
Some(create_fn_trans_item(ccx,
985985
impl_method.method.def_id,
986-
impl_method.substs,
986+
&impl_method.substs,
987987
&Substs::trans_empty()))
988988
} else {
989989
None
@@ -1163,12 +1163,12 @@ fn create_trans_items_for_default_impls<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
11631163
// the method type from the impl to substitute into.
11641164
let mth = meth::get_impl_method(tcx,
11651165
impl_def_id,
1166-
callee_substs.clone(),
1166+
callee_substs,
11671167
default_impl.name);
11681168

11691169
assert!(mth.is_provided);
11701170

1171-
let predicates = mth.method.predicates.predicates.subst(tcx, mth.substs);
1171+
let predicates = mth.method.predicates.predicates.subst(tcx, &mth.substs);
11721172
if !normalize_and_test_predicates(ccx, predicates.into_vec()) {
11731173
continue;
11741174
}

src/librustc_trans/trans/meth.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use trans::machine;
3434
use trans::type_::Type;
3535
use trans::type_of::*;
3636
use middle::ty::{self, Ty, TyCtxt, TypeFoldable};
37-
use middle::ty::MethodCall;
3837

3938
use syntax::ast::{self, Name};
4039
use syntax::attr;
@@ -110,7 +109,7 @@ pub fn callee_for_trait_impl<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
110109
// those from the impl and those from the method:
111110
let impl_substs = vtable_impl.substs.with_method_from(&substs);
112111
let substs = ccx.tcx().mk_substs(impl_substs);
113-
let mth = get_impl_method(ccx.tcx(), impl_did, impl_substs, mname);
112+
let mth = get_impl_method(ccx.tcx(), impl_did, substs, mname);
114113

115114
// Translate the function, bypassing Callee::def.
116115
// That is because default methods have the same ID as the
@@ -318,7 +317,7 @@ pub fn get_vtable<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
318317
trans_fn_ref_with_substs(ccx,
319318
mth.method.def_id,
320319
None,
321-
mth.substs).val
320+
&mth.substs).val
322321
}
323322
None => nullptr
324323
}
@@ -431,7 +430,7 @@ pub fn get_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
431430

432431
// The substitutions we have are on the impl, so we grab
433432
// the method type from the impl to substitute into.
434-
let mth = get_impl_method(tcx, impl_id, substs.clone(), name);
433+
let mth = get_impl_method(tcx, impl_id, substs, name);
435434

436435
debug!("get_vtable_methods: mth={:?}", mth);
437436

@@ -441,7 +440,7 @@ pub fn get_vtable_methods<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
441440
// method could then never be called, so we do not want to
442441
// try and trans it, in that case. Issue #23435.
443442
if mth.is_provided {
444-
let predicates = mth.method.predicates.predicates.subst(tcx, mth.substs);
443+
let predicates = mth.method.predicates.predicates.subst(tcx, &mth.substs);
445444
if !normalize_and_test_predicates(ccx, predicates.into_vec()) {
446445
debug!("get_vtable_methods: predicates do not hold");
447446
return None;
@@ -473,14 +472,14 @@ fn opaque_method_ty<'tcx>(tcx: &TyCtxt<'tcx>, method_ty: &ty::BareFnTy<'tcx>)
473472
#[derive(Debug)]
474473
pub struct ImplMethod<'tcx> {
475474
pub method: Rc<ty::Method<'tcx>>,
476-
pub substs: Substs<'tcx>,
475+
pub substs: &'tcx Substs<'tcx>,
477476
pub is_provided: bool
478477
}
479478

480479
/// Locates the applicable definition of a method, given its name.
481480
pub fn get_impl_method<'tcx>(tcx: &TyCtxt<'tcx>,
482481
impl_def_id: DefId,
483-
substs: Substs<'tcx>,
482+
substs: &'tcx Substs<'tcx>,
484483
name: Name)
485484
-> ImplMethod<'tcx>
486485
{

src/librustc_typeck/coherence/overlap.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
//! constructor provide a method with the same name.
1414
1515
use middle::cstore::CrateStore;
16-
use middle::traits;
16+
use middle::def_id::DefId;
17+
use middle::traits::{self, ProjectionMode};
18+
use middle::infer;
1719
use middle::ty::{self, TyCtxt};
1820
use syntax::ast;
21+
use syntax::codemap::Span;
1922
use rustc::dep_graph::DepNode;
2023
use rustc_front::hir;
2124
use rustc_front::intravisit;
@@ -86,7 +89,10 @@ impl<'cx, 'tcx> OverlapChecker<'cx, 'tcx> {
8689

8790
for (i, &impl1_def_id) in impls.iter().enumerate() {
8891
for &impl2_def_id in &impls[(i+1)..] {
89-
let infcx = infer::new_infer_ctxt(self.tcx, &self.tcx.tables, None);
92+
let infcx = infer::new_infer_ctxt(self.tcx,
93+
&self.tcx.tables,
94+
None,
95+
ProjectionMode::Topmost);
9096
if traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id).is_some() {
9197
self.check_for_common_items_in_impls(impl1_def_id, impl2_def_id)
9298
}
@@ -117,7 +123,8 @@ impl<'cx, 'tcx,'v> intravisit::Visitor<'v> for OverlapChecker<'cx, 'tcx> {
117123
self.tcx.span_of_impl(impl_def_id).unwrap(), E0519,
118124
"redundant default implementations of trait `{}`:",
119125
trait_ref);
120-
err.span_note(self.tcx.span_of_impl(self.tcx.map.local_def_id(prev_id)).unwrap(),
126+
err.span_note(self.tcx.span_of_impl(self.tcx.map.local_def_id(prev_id))
127+
.unwrap(),
121128
"redundant implementation is here:");
122129
err.emit();
123130
}

src/librustc_typeck/collect.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ fn convert_item(ccx: &CrateCtxt, it: &hir::Item) {
804804

805805
convert_method(ccx, ImplContainer(def_id),
806806
impl_item.name, impl_item.id, method_vis,
807-
sig, impl_item.defaultness, selfty, &ty_generics, &ty_predicates);
807+
sig, impl_item.defaultness, selfty, &ty_generics,
808+
&ty_predicates);
808809
}
809810
}
810811

0 commit comments

Comments
 (0)