Skip to content

Commit 65f0df5

Browse files
committed
---
yaml --- r: 273059 b: refs/heads/beta c: 3dd8b3e h: refs/heads/master i: 273057: db4925a 273055: ad27e4c
1 parent 29375ae commit 65f0df5

30 files changed

+128
-354
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 8788ffc670e981a195c771ab3c8530c72eb119d7
26+
refs/heads/beta: 3dd8b3ec9b66915dd33d7c5f9af7fbdc2dfea391
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/liballoc/boxed.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,14 +525,14 @@ impl<I: ExactSizeIterator + ?Sized> ExactSizeIterator for Box<I> {}
525525
/// }
526526
/// ```
527527
#[rustc_paren_sugar]
528-
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
528+
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "28796")]
529529
pub trait FnBox<A> {
530530
type Output;
531531

532532
fn call_box(self: Box<Self>, args: A) -> Self::Output;
533533
}
534534

535-
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
535+
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "28796")]
536536
impl<A, F> FnBox<A> for F where F: FnOnce<A>
537537
{
538538
type Output = F::Output;
@@ -542,7 +542,7 @@ impl<A, F> FnBox<A> for F where F: FnOnce<A>
542542
}
543543
}
544544

545-
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
545+
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "28796")]
546546
impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
547547
type Output = R;
548548

@@ -551,7 +551,7 @@ impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + 'a> {
551551
}
552552
}
553553

554-
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "0")]
554+
#[unstable(feature = "fnbox", reason = "Newly introduced", issue = "28796")]
555555
impl<'a, A, R> FnOnce<A> for Box<FnBox<A, Output = R> + Send + 'a> {
556556
type Output = R;
557557

branches/beta/src/librustc/dep_graph/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ pub enum DepNode {
5858
CoherenceCheckImpl(DefId),
5959
CoherenceOverlapCheck(DefId),
6060
CoherenceOverlapCheckSpecial(DefId),
61-
CoherenceOverlapInherentCheck(DefId),
6261
CoherenceOrphanCheck(DefId),
6362
Variance,
6463
WfCheck(DefId),

branches/beta/src/librustc/middle/infer/mod.rs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,14 @@ pub fn mk_eqty<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
458458
}
459459

460460
pub fn mk_eq_trait_refs<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
461-
a_is_expected: bool,
462-
origin: TypeOrigin,
463-
a: ty::TraitRef<'tcx>,
464-
b: ty::TraitRef<'tcx>)
465-
-> UnitResult<'tcx>
461+
a_is_expected: bool,
462+
origin: TypeOrigin,
463+
a: ty::TraitRef<'tcx>,
464+
b: ty::TraitRef<'tcx>)
465+
-> UnitResult<'tcx>
466466
{
467-
debug!("mk_eq_trait_refs({:?} = {:?})", a, b);
467+
debug!("mk_eq_trait_refs({:?} <: {:?})",
468+
a, b);
468469
cx.eq_trait_refs(a_is_expected, origin, a, b)
469470
}
470471

@@ -475,25 +476,11 @@ pub fn mk_sub_poly_trait_refs<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
475476
b: ty::PolyTraitRef<'tcx>)
476477
-> UnitResult<'tcx>
477478
{
478-
debug!("mk_sub_poly_trait_refs({:?} <: {:?})", a, b);
479+
debug!("mk_sub_poly_trait_refs({:?} <: {:?})",
480+
a, b);
479481
cx.sub_poly_trait_refs(a_is_expected, origin, a, b)
480482
}
481483

482-
pub fn mk_eq_impl_headers<'a, 'tcx>(cx: &InferCtxt<'a, 'tcx>,
483-
a_is_expected: bool,
484-
origin: TypeOrigin,
485-
a: &ty::ImplHeader<'tcx>,
486-
b: &ty::ImplHeader<'tcx>)
487-
-> UnitResult<'tcx>
488-
{
489-
debug!("mk_eq_impl_header({:?} = {:?})", a, b);
490-
match (a.trait_ref, b.trait_ref) {
491-
(Some(a_ref), Some(b_ref)) => mk_eq_trait_refs(cx, a_is_expected, origin, a_ref, b_ref),
492-
(None, None) => mk_eqty(cx, a_is_expected, origin, a.self_ty, b.self_ty),
493-
_ => cx.tcx.sess.bug("mk_eq_impl_headers given mismatched impl kinds"),
494-
}
495-
}
496-
497484
fn expected_found<T>(a_is_expected: bool,
498485
a: T,
499486
b: T)

branches/beta/src/librustc/middle/traits/coherence.rs

Lines changed: 69 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,29 @@
1010

1111
//! See `README.md` for high-level documentation
1212
13-
use super::{SelectionContext};
14-
use super::{Obligation, ObligationCause};
13+
use super::Normalized;
14+
use super::SelectionContext;
15+
use super::ObligationCause;
16+
use super::PredicateObligation;
17+
use super::project;
18+
use super::util;
1519

1620
use middle::cstore::LOCAL_CRATE;
1721
use middle::def_id::DefId;
18-
use middle::subst::TypeSpace;
22+
use middle::subst::{Subst, Substs, TypeSpace};
1923
use middle::ty::{self, Ty, TyCtxt};
2024
use middle::infer::{self, InferCtxt, TypeOrigin};
21-
use syntax::codemap::DUMMY_SP;
25+
use syntax::codemap::{DUMMY_SP, Span};
2226

2327
#[derive(Copy, Clone)]
2428
struct InferIsLocal(bool);
2529

26-
/// If there are types that satisfy both impls, returns an `ImplTy`
30+
/// If there are types that satisfy both impls, returns a `TraitRef`
2731
/// with those types substituted (by updating the given `infcx`)
2832
pub fn overlapping_impls<'cx, 'tcx>(infcx: &InferCtxt<'cx, 'tcx>,
2933
impl1_def_id: DefId,
3034
impl2_def_id: DefId)
31-
-> Option<ty::ImplHeader<'tcx>>
35+
-> Option<ty::TraitRef<'tcx>>
3236
{
3337
debug!("impl_can_satisfy(\
3438
impl1_def_id={:?}, \
@@ -41,28 +45,34 @@ pub fn overlapping_impls<'cx, 'tcx>(infcx: &InferCtxt<'cx, 'tcx>,
4145
}
4246

4347
/// Can both impl `a` and impl `b` be satisfied by a common type (including
44-
/// `where` clauses)? If so, returns an `ImplHeader` that unifies the two impls.
48+
/// `where` clauses)? If so, returns a `TraitRef` that unifies the two impls.
4549
fn overlap<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>,
4650
a_def_id: DefId,
4751
b_def_id: DefId)
48-
-> Option<ty::ImplHeader<'tcx>>
52+
-> Option<ty::TraitRef<'tcx>>
4953
{
5054
debug!("overlap(a_def_id={:?}, b_def_id={:?})",
5155
a_def_id,
5256
b_def_id);
5357

54-
let a_impl_header = ty::ImplHeader::with_fresh_ty_vars(selcx, a_def_id);
55-
let b_impl_header = ty::ImplHeader::with_fresh_ty_vars(selcx, b_def_id);
58+
let (a_trait_ref, a_obligations) = impl_trait_ref_and_oblig(selcx,
59+
a_def_id,
60+
util::fresh_type_vars_for_impl);
5661

57-
debug!("overlap: a_impl_header={:?}", a_impl_header);
58-
debug!("overlap: b_impl_header={:?}", b_impl_header);
62+
let (b_trait_ref, b_obligations) = impl_trait_ref_and_oblig(selcx,
63+
b_def_id,
64+
util::fresh_type_vars_for_impl);
65+
66+
debug!("overlap: a_trait_ref={:?} a_obligations={:?}", a_trait_ref, a_obligations);
67+
68+
debug!("overlap: b_trait_ref={:?} b_obligations={:?}", b_trait_ref, b_obligations);
5969

6070
// Do `a` and `b` unify? If not, no overlap.
61-
if let Err(_) = infer::mk_eq_impl_headers(selcx.infcx(),
62-
true,
63-
TypeOrigin::Misc(DUMMY_SP),
64-
&a_impl_header,
65-
&b_impl_header) {
71+
if let Err(_) = infer::mk_eq_trait_refs(selcx.infcx(),
72+
true,
73+
TypeOrigin::Misc(DUMMY_SP),
74+
a_trait_ref,
75+
b_trait_ref) {
6676
return None;
6777
}
6878

@@ -71,21 +81,17 @@ fn overlap<'cx, 'tcx>(selcx: &mut SelectionContext<'cx, 'tcx>,
7181
// Are any of the obligations unsatisfiable? If so, no overlap.
7282
let infcx = selcx.infcx();
7383
let opt_failing_obligation =
74-
a_impl_header.predicates
75-
.iter()
76-
.chain(&b_impl_header.predicates)
77-
.map(|p| infcx.resolve_type_vars_if_possible(p))
78-
.map(|p| Obligation { cause: ObligationCause::dummy(),
79-
recursion_depth: 0,
80-
predicate: p })
84+
a_obligations.iter()
85+
.chain(&b_obligations)
86+
.map(|o| infcx.resolve_type_vars_if_possible(o))
8187
.find(|o| !selcx.evaluate_obligation(o));
8288

8389
if let Some(failing_obligation) = opt_failing_obligation {
8490
debug!("overlap: obligation unsatisfiable {:?}", failing_obligation);
8591
return None
8692
}
8793

88-
Some(selcx.infcx().resolve_type_vars_if_possible(&a_impl_header))
94+
Some(selcx.infcx().resolve_type_vars_if_possible(&a_trait_ref))
8995
}
9096

9197
pub fn trait_ref_is_knowable<'tcx>(tcx: &TyCtxt<'tcx>, trait_ref: &ty::TraitRef<'tcx>) -> bool
@@ -119,6 +125,44 @@ pub fn trait_ref_is_knowable<'tcx>(tcx: &TyCtxt<'tcx>, trait_ref: &ty::TraitRef<
119125
orphan_check_trait_ref(tcx, trait_ref, InferIsLocal(true)).is_err()
120126
}
121127

128+
type SubstsFn = for<'a,'tcx> fn(infcx: &InferCtxt<'a, 'tcx>,
129+
span: Span,
130+
impl_def_id: DefId)
131+
-> Substs<'tcx>;
132+
133+
/// Instantiate fresh variables for all bound parameters of the impl
134+
/// and return the impl trait ref with those variables substituted.
135+
fn impl_trait_ref_and_oblig<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
136+
impl_def_id: DefId,
137+
substs_fn: SubstsFn)
138+
-> (ty::TraitRef<'tcx>,
139+
Vec<PredicateObligation<'tcx>>)
140+
{
141+
let impl_substs =
142+
&substs_fn(selcx.infcx(), DUMMY_SP, impl_def_id);
143+
let impl_trait_ref =
144+
selcx.tcx().impl_trait_ref(impl_def_id).unwrap();
145+
let impl_trait_ref =
146+
impl_trait_ref.subst(selcx.tcx(), impl_substs);
147+
let Normalized { value: impl_trait_ref, obligations: normalization_obligations1 } =
148+
project::normalize(selcx, ObligationCause::dummy(), &impl_trait_ref);
149+
150+
let predicates = selcx.tcx().lookup_predicates(impl_def_id);
151+
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
152+
let Normalized { value: predicates, obligations: normalization_obligations2 } =
153+
project::normalize(selcx, ObligationCause::dummy(), &predicates);
154+
let impl_obligations =
155+
util::predicates_for_generics(ObligationCause::dummy(), 0, &predicates);
156+
157+
let impl_obligations: Vec<_> =
158+
impl_obligations.into_iter()
159+
.chain(normalization_obligations1)
160+
.chain(normalization_obligations2)
161+
.collect();
162+
163+
(impl_trait_ref, impl_obligations)
164+
}
165+
122166
pub enum OrphanCheckErr<'tcx> {
123167
NoLocalInputType,
124168
UncoveredTy(Ty<'tcx>),

branches/beta/src/librustc/middle/traits/select.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
391391
// The result is "true" if the obligation *may* hold and "false" if
392392
// we can be sure it does not.
393393

394+
394395
/// Evaluates whether the obligation `obligation` can be satisfied (by any means).
395396
pub fn evaluate_obligation(&mut self,
396397
obligation: &PredicateObligation<'tcx>)

branches/beta/src/librustc/middle/ty/fold.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ pub trait TypeFolder<'tcx> : Sized {
146146
t.super_fold_with(self)
147147
}
148148

149-
fn fold_impl_header(&mut self, imp: &ty::ImplHeader<'tcx>) -> ty::ImplHeader<'tcx> {
150-
imp.super_fold_with(self)
151-
}
152-
153149
fn fold_substs(&mut self,
154150
substs: &subst::Substs<'tcx>)
155151
-> subst::Substs<'tcx> {

branches/beta/src/librustc/middle/ty/mod.rs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -152,41 +152,6 @@ impl ImplOrTraitItemContainer {
152152
}
153153
}
154154

155-
/// The "header" of an impl is everything outside the body: a Self type, a trait
156-
/// ref (in the case of a trait impl), and a set of predicates (from the
157-
/// bounds/where clauses).
158-
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
159-
pub struct ImplHeader<'tcx> {
160-
pub impl_def_id: DefId,
161-
pub self_ty: Ty<'tcx>,
162-
pub trait_ref: Option<TraitRef<'tcx>>,
163-
pub predicates: Vec<Predicate<'tcx>>,
164-
}
165-
166-
impl<'tcx> ImplHeader<'tcx> {
167-
pub fn with_fresh_ty_vars<'a>(selcx: &mut traits::SelectionContext<'a, 'tcx>,
168-
impl_def_id: DefId)
169-
-> ImplHeader<'tcx>
170-
{
171-
let tcx = selcx.tcx();
172-
let impl_generics = tcx.lookup_item_type(impl_def_id).generics;
173-
let impl_substs = selcx.infcx().fresh_substs_for_generics(DUMMY_SP, &impl_generics);
174-
175-
let header = ImplHeader {
176-
impl_def_id: impl_def_id,
177-
self_ty: tcx.lookup_item_type(impl_def_id).ty,
178-
trait_ref: tcx.impl_trait_ref(impl_def_id),
179-
predicates: tcx.lookup_predicates(impl_def_id).predicates.into_vec(),
180-
}.subst(tcx, &impl_substs);
181-
182-
let traits::Normalized { value: mut header, obligations } =
183-
traits::normalize(selcx, traits::ObligationCause::dummy(), &header);
184-
185-
header.predicates.extend(obligations.into_iter().map(|o| o.predicate));
186-
header
187-
}
188-
}
189-
190155
#[derive(Clone)]
191156
pub enum ImplOrTraitItem<'tcx> {
192157
ConstTraitItem(Rc<AssociatedConst<'tcx>>),

branches/beta/src/librustc/middle/ty/structural_impls.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -446,27 +446,6 @@ impl<'tcx> TypeFoldable<'tcx> for ty::TraitRef<'tcx> {
446446
}
447447
}
448448

449-
impl<'tcx> TypeFoldable<'tcx> for ty::ImplHeader<'tcx> {
450-
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
451-
ty::ImplHeader {
452-
impl_def_id: self.impl_def_id,
453-
self_ty: self.self_ty.fold_with(folder),
454-
trait_ref: self.trait_ref.map(|t| t.fold_with(folder)),
455-
predicates: self.predicates.iter().map(|p| p.fold_with(folder)).collect(),
456-
}
457-
}
458-
459-
fn fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
460-
folder.fold_impl_header(self)
461-
}
462-
463-
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
464-
self.self_ty.visit_with(visitor) ||
465-
self.trait_ref.map(|r| r.visit_with(visitor)).unwrap_or(false) ||
466-
self.predicates.iter().any(|p| p.visit_with(visitor))
467-
}
468-
}
469-
470449
impl<'tcx> TypeFoldable<'tcx> for ty::Region {
471450
fn super_fold_with<F: TypeFolder<'tcx>>(&self, _folder: &mut F) -> Self {
472451
*self

branches/beta/src/librustc_typeck/coherence/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ use CrateCtxt;
3535
use middle::infer::{self, InferCtxt, TypeOrigin, new_infer_ctxt};
3636
use std::cell::RefCell;
3737
use std::rc::Rc;
38-
use syntax::ast;
3938
use syntax::codemap::Span;
40-
use syntax::errors::DiagnosticBuilder;
4139
use util::nodemap::{DefIdMap, FnvHashMap};
4240
use rustc::dep_graph::DepNode;
4341
use rustc::front::map as hir_map;
@@ -521,13 +519,6 @@ fn enforce_trait_manually_implementable(tcx: &TyCtxt, sp: Span, trait_def_id: De
521519
err.emit();
522520
}
523521

524-
// Factored out into helper because the error cannot be defined in multiple locations.
525-
pub fn report_duplicate_item<'tcx>(tcx: &TyCtxt<'tcx>, sp: Span, name: ast::Name)
526-
-> DiagnosticBuilder<'tcx>
527-
{
528-
struct_span_err!(tcx.sess, sp, E0201, "duplicate definitions with name `{}`:", name)
529-
}
530-
531522
pub fn check_coherence(crate_context: &CrateCtxt) {
532523
let _task = crate_context.tcx.dep_graph.in_task(DepNode::Coherence);
533524
let infcx = new_infer_ctxt(crate_context.tcx, &crate_context.tcx.tables, None);

0 commit comments

Comments
 (0)