Add test cases for cyclic specialization graph construction

This commit is contained in:
Michael Woerister 2017-05-16 15:04:32 +02:00
parent d731b04af1
commit 0a77a58857
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,34 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Formerly this ICEd with the following message:
// Tried to project an inherited associated type during coherence checking,
// which is currently not supported.
//
// No we expect to run into a more user-friendly cycle error instead.
#![feature(specialization)]
trait Trait<T> { type Assoc; }
//~^ unsupported cyclic reference between types/traits detected [E0391]
impl<T> Trait<T> for Vec<T> {
type Assoc = ();
}
impl Trait<u8> for Vec<u8> {}
impl<T> Trait<T> for String {
type Assoc = ();
}
impl Trait<<Vec<u8> as Trait<u8>>::Assoc> for String {}
fn main() {}

View File

@ -0,0 +1,33 @@
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Make sure we don't crash with a cycle error during coherence.
#![feature(specialization)]
trait Trait<T> {
type Assoc;
}
impl<T> Trait<T> for Vec<T> {
default type Assoc = ();
}
impl Trait<u8> for Vec<u8> {
type Assoc = u8;
}
impl<T> Trait<T> for String {
type Assoc = ();
}
impl Trait<<Vec<u8> as Trait<u8>>::Assoc> for String {}
fn main() {}