Skip to content

Commit 404fd35

Browse files
committed
---
yaml --- r: 273165 b: refs/heads/beta c: e36620d h: refs/heads/master i: 273163: 8776fc6
1 parent 63c8556 commit 404fd35

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
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: d80189d305ce24b6a1fd83a4f724d17506b64a13
26+
refs/heads/beta: e36620dd9c29e39da688d87e1a6566710aa2ccc5
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/librustc/middle/traits/project.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ use std::rc::Rc;
3838
/// more or less conservative.
3939
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
4040
pub enum ProjectionMode {
41+
/// FIXME (#32205)
4142
/// At coherence-checking time, we're still constructing the
4243
/// specialization graph, and thus we only project project
4344
/// non-`default` associated types that are defined directly in
4445
/// the applicable impl. (This behavior should be improved over
4546
/// time, to allow for successful projections modulo cycles
4647
/// between different impls).
47-
// TODO: Add tracking issue to do better here.
4848
///
4949
/// Here's an example that will fail due to the restriction:
5050
///
@@ -66,7 +66,6 @@ pub enum ProjectionMode {
6666
///
6767
/// The projection would succeed if `Output` had been defined
6868
/// directly in the impl for `u8`.
69-
// TODO: Add test
7069
Topmost,
7170

7271
/// At type-checking time, we refuse to project any associated
@@ -91,7 +90,6 @@ pub enum ProjectionMode {
9190
/// fn main() {
9291
/// let <() as Assoc>::Output = true;
9392
/// }
94-
// TODO: Add test
9593
AnyFinal,
9694

9795
/// At trans time, all projections will succeed.
@@ -695,7 +693,34 @@ fn project_type<'cx,'tcx>(
695693
// at the topmost impl (we don't even consider the trait
696694
// itself) for the definition -- so we can fail to find a
697695
// definition of the type even if it exists.
698-
return None;
696+
697+
// For now, we just unconditionally ICE, because otherwise,
698+
// examples like the following will succeed:
699+
//
700+
// ```
701+
// trait Assoc {
702+
// type Output;
703+
// }
704+
//
705+
// impl<T> Assoc for T {
706+
// default type Output = bool;
707+
// }
708+
//
709+
// impl Assoc for u8 {}
710+
// impl Assoc for u16 {}
711+
//
712+
// trait Foo {}
713+
// impl Foo for <u8 as Assoc>::Output {}
714+
// impl Foo for <u16 as Assoc>::Output {}
715+
// return None;
716+
// }
717+
// ```
718+
//
719+
// The essential problem here is that the projection fails,
720+
// leaving two unnormalized types, which appear not to unify
721+
// -- so the overlap check succeeds, when it should fail.
722+
selcx.tcx().sess.bug("Tried to project an inherited associated type during \
723+
coherence checking, which is currently not supported.");
699724
}
700725
}
701726
}

branches/beta/src/test/compile-fail/private-in-public-warn.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,11 @@ mod aliases_pub {
198198
use self::m::PubTr as PrivUseAliasTr;
199199
type PrivAlias = m::Pub2;
200200
trait PrivTr {
201+
type AssocAlias;
202+
}
203+
impl PrivTr for Priv {
201204
type AssocAlias = m::Pub3;
202205
}
203-
impl PrivTr for Priv {}
204206

205207
pub fn f1(arg: PrivUseAlias) {} // OK
206208

@@ -245,9 +247,11 @@ mod aliases_priv {
245247
use self::PrivTr1 as PrivUseAliasTr;
246248
type PrivAlias = Priv2;
247249
trait PrivTr {
250+
type AssocAlias;
251+
}
252+
impl PrivTr for Priv {
248253
type AssocAlias = Priv3;
249254
}
250-
impl PrivTr for Priv {}
251255

252256
pub trait Tr1: PrivUseAliasTr {} //~ WARN private trait in public interface
253257
//~^ WARNING hard error

0 commit comments

Comments
 (0)