rollup merge of #18506 : nikomatsakis/assoc-type-bounds
This commit is contained in:
commit
eb793616dc
25 changed files with 519 additions and 433 deletions
24
src/test/compile-fail/associated-types-unsized.rs
Normal file
24
src/test/compile-fail/associated-types-unsized.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2014 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.
|
||||
|
||||
#![feature(associated_types)]
|
||||
|
||||
trait Get {
|
||||
type Sized? Value;
|
||||
fn get(&self) -> <Self as Get>::Value;
|
||||
}
|
||||
|
||||
fn foo<T:Get>(t: T) {
|
||||
let x = t.get(); //~ ERROR the trait `core::kinds::Sized` is not implemented
|
||||
}
|
||||
|
||||
fn main() {
|
||||
}
|
||||
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
// Regions that just appear in normal spots are contravariant:
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test2<'a, 'b, 'c> { //~ ERROR regions=[[-, -, -];[];[]]
|
||||
struct Test2<'a, 'b, 'c> { //~ ERROR regions=[[-, -, -];[];[];[]]
|
||||
x: &'a int,
|
||||
y: &'b [int],
|
||||
c: &'c str
|
||||
|
|
@ -23,7 +23,7 @@ struct Test2<'a, 'b, 'c> { //~ ERROR regions=[[-, -, -];[];[]]
|
|||
// Those same annotations in function arguments become covariant:
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test3<'a, 'b, 'c> { //~ ERROR regions=[[+, +, +];[];[]]
|
||||
struct Test3<'a, 'b, 'c> { //~ ERROR regions=[[+, +, +];[];[];[]]
|
||||
x: extern "Rust" fn(&'a int),
|
||||
y: extern "Rust" fn(&'b [int]),
|
||||
c: extern "Rust" fn(&'c str),
|
||||
|
|
@ -32,7 +32,7 @@ struct Test3<'a, 'b, 'c> { //~ ERROR regions=[[+, +, +];[];[]]
|
|||
// Mutability induces invariance:
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test4<'a, 'b:'a> { //~ ERROR regions=[[-, o];[];[]]
|
||||
struct Test4<'a, 'b:'a> { //~ ERROR regions=[[-, o];[];[];[]]
|
||||
x: &'a mut &'b int,
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ struct Test4<'a, 'b:'a> { //~ ERROR regions=[[-, o];[];[]]
|
|||
// contravariant context:
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test5<'a, 'b> { //~ ERROR regions=[[+, o];[];[]]
|
||||
struct Test5<'a, 'b> { //~ ERROR regions=[[+, o];[];[];[]]
|
||||
x: extern "Rust" fn(&'a mut &'b int),
|
||||
}
|
||||
|
||||
|
|
@ -50,21 +50,21 @@ struct Test5<'a, 'b> { //~ ERROR regions=[[+, o];[];[]]
|
|||
// argument list occurs in an invariant context.
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test6<'a, 'b> { //~ ERROR regions=[[-, o];[];[]]
|
||||
struct Test6<'a, 'b> { //~ ERROR regions=[[-, o];[];[];[]]
|
||||
x: &'a mut extern "Rust" fn(&'b int),
|
||||
}
|
||||
|
||||
// No uses at all is bivariant:
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test7<'a> { //~ ERROR regions=[[*];[];[]]
|
||||
struct Test7<'a> { //~ ERROR regions=[[*];[];[];[]]
|
||||
x: int
|
||||
}
|
||||
|
||||
// Try enums too.
|
||||
|
||||
#[rustc_variance]
|
||||
enum Test8<'a, 'b, 'c:'b> { //~ ERROR regions=[[+, -, o];[];[]]
|
||||
enum Test8<'a, 'b, 'c:'b> { //~ ERROR regions=[[+, -, o];[];[];[]]
|
||||
Test8A(extern "Rust" fn(&'a int)),
|
||||
Test8B(&'b [int]),
|
||||
Test8C(&'b mut &'c str),
|
||||
|
|
|
|||
|
|
@ -13,29 +13,29 @@
|
|||
// Try enums too.
|
||||
|
||||
#[rustc_variance]
|
||||
enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]]
|
||||
enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[];[]]
|
||||
Test8A(extern "Rust" fn(&'a int)),
|
||||
Test8B(&'b [int]),
|
||||
Test8C(&'b mut &'c str),
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[[*, o, -, +];[];[]]
|
||||
struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[[*, o, -, +];[];[];[]]
|
||||
f: Base<'z, 'y, 'x, 'w>
|
||||
}
|
||||
|
||||
#[rustc_variance] // Combine - and + to yield o
|
||||
struct Derived2<'a, 'b:'a, 'c> { //~ ERROR regions=[[o, o, *];[];[]]
|
||||
struct Derived2<'a, 'b:'a, 'c> { //~ ERROR regions=[[o, o, *];[];[];[]]
|
||||
f: Base<'a, 'a, 'b, 'c>
|
||||
}
|
||||
|
||||
#[rustc_variance] // Combine + and o to yield o (just pay attention to 'a here)
|
||||
struct Derived3<'a:'b, 'b, 'c> { //~ ERROR regions=[[o, -, *];[];[]]
|
||||
struct Derived3<'a:'b, 'b, 'c> { //~ ERROR regions=[[o, -, *];[];[];[]]
|
||||
f: Base<'a, 'b, 'a, 'c>
|
||||
}
|
||||
|
||||
#[rustc_variance] // Combine + and * to yield + (just pay attention to 'a here)
|
||||
struct Derived4<'a, 'b, 'c:'b> { //~ ERROR regions=[[+, -, o];[];[]]
|
||||
struct Derived4<'a, 'b, 'c:'b> { //~ ERROR regions=[[+, -, o];[];[];[]]
|
||||
f: Base<'a, 'b, 'c, 'a>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ use std::mem;
|
|||
trait T { fn foo(); }
|
||||
|
||||
#[rustc_variance]
|
||||
struct TOption<'a> { //~ ERROR regions=[[-];[];[]]
|
||||
struct TOption<'a> { //~ ERROR regions=[[-];[];[];[]]
|
||||
v: Option<Box<T + 'a>>,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue