rustc: move the SelfSpace before TypeSpace in Substs.
This commit is contained in:
parent
e314636b86
commit
b354ae95a2
@ -182,7 +182,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
||||
let rps = self.region_vars_for_defs(obligation.cause.span, rps);
|
||||
let mut substs = subst::Substs::new(
|
||||
subst::VecPerParamSpace::empty(),
|
||||
subst::VecPerParamSpace::new(rps, Vec::new(), Vec::new()));
|
||||
subst::VecPerParamSpace::new(Vec::new(), rps, Vec::new()));
|
||||
self.type_vars_for_defs(obligation.cause.span,
|
||||
TypeSpace,
|
||||
&mut substs,
|
||||
|
@ -1602,7 +1602,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||
return;
|
||||
}
|
||||
};
|
||||
let target = obligation.predicate.0.input_types()[0];
|
||||
let target = obligation.predicate.skip_binder().input_types()[1];
|
||||
|
||||
debug!("assemble_candidates_for_unsizing(source={:?}, target={:?})",
|
||||
source, target);
|
||||
@ -2476,7 +2476,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
||||
// regions here. See the comment there for more details.
|
||||
let source = self.infcx.shallow_resolve(
|
||||
tcx.no_late_bound_regions(&obligation.self_ty()).unwrap());
|
||||
let target = self.infcx.shallow_resolve(obligation.predicate.0.input_types()[0]);
|
||||
let target = obligation.predicate.skip_binder().input_types()[1];
|
||||
let target = self.infcx.shallow_resolve(target);
|
||||
|
||||
debug!("confirm_builtin_unsize_candidate(source={:?}, target={:?})",
|
||||
source, target);
|
||||
|
@ -48,8 +48,8 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
|
||||
r: Vec<ty::Region>)
|
||||
-> Substs<'tcx>
|
||||
{
|
||||
Substs::new(VecPerParamSpace::new(t, Vec::new(), Vec::new()),
|
||||
VecPerParamSpace::new(r, Vec::new(), Vec::new()))
|
||||
Substs::new(VecPerParamSpace::new(vec![], t, vec![]),
|
||||
VecPerParamSpace::new(vec![], r, vec![]))
|
||||
}
|
||||
|
||||
pub fn new_trait(t: Vec<Ty<'tcx>>,
|
||||
@ -57,8 +57,8 @@ impl<'a, 'gcx, 'tcx> Substs<'tcx> {
|
||||
s: Ty<'tcx>)
|
||||
-> Substs<'tcx>
|
||||
{
|
||||
Substs::new(VecPerParamSpace::new(t, vec!(s), Vec::new()),
|
||||
VecPerParamSpace::new(r, Vec::new(), Vec::new()))
|
||||
Substs::new(VecPerParamSpace::new(vec![s], t, vec![]),
|
||||
VecPerParamSpace::new(vec![], r, vec![]))
|
||||
}
|
||||
|
||||
pub fn empty() -> Substs<'tcx> {
|
||||
@ -169,28 +169,28 @@ impl<'tcx> Decodable for &'tcx Substs<'tcx> {
|
||||
#[derive(PartialOrd, Ord, PartialEq, Eq, Copy,
|
||||
Clone, Hash, RustcEncodable, RustcDecodable, Debug)]
|
||||
pub enum ParamSpace {
|
||||
TypeSpace, // Type parameters attached to a type definition, trait, or impl
|
||||
SelfSpace, // Self parameter on a trait
|
||||
TypeSpace, // Type parameters attached to a type definition, trait, or impl
|
||||
FnSpace, // Type parameters attached to a method or fn
|
||||
}
|
||||
|
||||
impl ParamSpace {
|
||||
pub fn all() -> [ParamSpace; 3] {
|
||||
[TypeSpace, SelfSpace, FnSpace]
|
||||
[SelfSpace, TypeSpace, FnSpace]
|
||||
}
|
||||
|
||||
pub fn to_uint(self) -> usize {
|
||||
match self {
|
||||
TypeSpace => 0,
|
||||
SelfSpace => 1,
|
||||
SelfSpace => 0,
|
||||
TypeSpace => 1,
|
||||
FnSpace => 2,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_uint(u: usize) -> ParamSpace {
|
||||
match u {
|
||||
0 => TypeSpace,
|
||||
1 => SelfSpace,
|
||||
0 => SelfSpace,
|
||||
1 => TypeSpace,
|
||||
2 => FnSpace,
|
||||
_ => bug!("Invalid ParamSpace: {}", u)
|
||||
}
|
||||
@ -209,19 +209,19 @@ pub struct VecPerParamSpace<T> {
|
||||
// Here is how the representation corresponds to the abstraction
|
||||
// i.e. the "abstraction function" AF:
|
||||
//
|
||||
// AF(self) = (self.content[..self.type_limit],
|
||||
// self.content[self.type_limit..self.self_limit],
|
||||
// self.content[self.self_limit..])
|
||||
type_limit: usize,
|
||||
// AF(self) = (self.content[..self.self_limit],
|
||||
// self.content[self.self_limit..self.type_limit],
|
||||
// self.content[self.type_limit..])
|
||||
self_limit: usize,
|
||||
type_limit: usize,
|
||||
content: Vec<T>,
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "[{:?};{:?};{:?}]",
|
||||
self.get_slice(TypeSpace),
|
||||
self.get_slice(SelfSpace),
|
||||
self.get_slice(TypeSpace),
|
||||
self.get_slice(FnSpace))
|
||||
}
|
||||
}
|
||||
@ -229,44 +229,44 @@ impl<T: fmt::Debug> fmt::Debug for VecPerParamSpace<T> {
|
||||
impl<T> VecPerParamSpace<T> {
|
||||
fn limits(&self, space: ParamSpace) -> (usize, usize) {
|
||||
match space {
|
||||
TypeSpace => (0, self.type_limit),
|
||||
SelfSpace => (self.type_limit, self.self_limit),
|
||||
FnSpace => (self.self_limit, self.content.len()),
|
||||
SelfSpace => (0, self.self_limit),
|
||||
TypeSpace => (self.self_limit, self.type_limit),
|
||||
FnSpace => (self.type_limit, self.content.len()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn empty() -> VecPerParamSpace<T> {
|
||||
VecPerParamSpace {
|
||||
type_limit: 0,
|
||||
self_limit: 0,
|
||||
type_limit: 0,
|
||||
content: Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
/// `t` is the type space.
|
||||
/// `s` is the self space.
|
||||
/// `t` is the type space.
|
||||
/// `f` is the fn space.
|
||||
pub fn new(t: Vec<T>, s: Vec<T>, f: Vec<T>) -> VecPerParamSpace<T> {
|
||||
let type_limit = t.len();
|
||||
let self_limit = type_limit + s.len();
|
||||
pub fn new(s: Vec<T>, t: Vec<T>, f: Vec<T>) -> VecPerParamSpace<T> {
|
||||
let self_limit = s.len();
|
||||
let type_limit = self_limit + t.len();
|
||||
|
||||
let mut content = t;
|
||||
content.extend(s);
|
||||
let mut content = s;
|
||||
content.extend(t);
|
||||
content.extend(f);
|
||||
|
||||
VecPerParamSpace {
|
||||
type_limit: type_limit,
|
||||
self_limit: self_limit,
|
||||
type_limit: type_limit,
|
||||
content: content,
|
||||
}
|
||||
}
|
||||
|
||||
fn new_internal(content: Vec<T>, type_limit: usize, self_limit: usize)
|
||||
fn new_internal(content: Vec<T>, self_limit: usize, type_limit: usize)
|
||||
-> VecPerParamSpace<T>
|
||||
{
|
||||
VecPerParamSpace {
|
||||
type_limit: type_limit,
|
||||
self_limit: self_limit,
|
||||
type_limit: type_limit,
|
||||
content: content,
|
||||
}
|
||||
}
|
||||
@ -278,8 +278,8 @@ impl<T> VecPerParamSpace<T> {
|
||||
pub fn push(&mut self, space: ParamSpace, value: T) {
|
||||
let (_, limit) = self.limits(space);
|
||||
match space {
|
||||
TypeSpace => { self.type_limit += 1; self.self_limit += 1; }
|
||||
SelfSpace => { self.self_limit += 1; }
|
||||
SelfSpace => { self.type_limit += 1; self.self_limit += 1; }
|
||||
TypeSpace => { self.type_limit += 1; }
|
||||
FnSpace => { }
|
||||
}
|
||||
self.content.insert(limit, value);
|
||||
@ -302,8 +302,8 @@ impl<T> VecPerParamSpace<T> {
|
||||
None
|
||||
} else {
|
||||
match space {
|
||||
TypeSpace => { self.type_limit -= 1; self.self_limit -= 1; }
|
||||
SelfSpace => { self.self_limit -= 1; }
|
||||
SelfSpace => { self.type_limit -= 1; self.self_limit -= 1; }
|
||||
TypeSpace => { self.type_limit -= 1; }
|
||||
FnSpace => {}
|
||||
}
|
||||
if self.content.is_empty() {
|
||||
@ -388,8 +388,7 @@ impl<T> VecPerParamSpace<T> {
|
||||
pub fn all_vecs<P>(&self, mut pred: P) -> bool where
|
||||
P: FnMut(&[T]) -> bool,
|
||||
{
|
||||
let spaces = [TypeSpace, SelfSpace, FnSpace];
|
||||
spaces.iter().all(|&space| { pred(self.get_slice(space)) })
|
||||
ParamSpace::all().iter().all(|&space| { pred(self.get_slice(space)) })
|
||||
}
|
||||
|
||||
pub fn all<P>(&self, pred: P) -> bool where P: FnMut(&T) -> bool {
|
||||
@ -407,8 +406,8 @@ impl<T> VecPerParamSpace<T> {
|
||||
pub fn map<U, P>(&self, pred: P) -> VecPerParamSpace<U> where P: FnMut(&T) -> U {
|
||||
let result = self.iter().map(pred).collect();
|
||||
VecPerParamSpace::new_internal(result,
|
||||
self.type_limit,
|
||||
self.self_limit)
|
||||
self.self_limit,
|
||||
self.type_limit)
|
||||
}
|
||||
|
||||
pub fn map_enumerated<U, P>(&self, pred: P) -> VecPerParamSpace<U> where
|
||||
@ -416,8 +415,8 @@ impl<T> VecPerParamSpace<T> {
|
||||
{
|
||||
let result = self.iter_enumerated().map(pred).collect();
|
||||
VecPerParamSpace::new_internal(result,
|
||||
self.type_limit,
|
||||
self.self_limit)
|
||||
self.self_limit,
|
||||
self.type_limit)
|
||||
}
|
||||
|
||||
pub fn with_slice(mut self, space: ParamSpace, slice: &[T])
|
||||
|
@ -675,8 +675,8 @@ pub fn custom_coerce_unsize_info<'scx, 'tcx>(scx: &SharedCrateContext<'scx, 'tcx
|
||||
source_ty: Ty<'tcx>,
|
||||
target_ty: Ty<'tcx>)
|
||||
-> CustomCoerceUnsized {
|
||||
let trait_substs = Substs::new(subst::VecPerParamSpace::new(vec![target_ty],
|
||||
vec![source_ty],
|
||||
let trait_substs = Substs::new(subst::VecPerParamSpace::new(vec![source_ty],
|
||||
vec![target_ty],
|
||||
Vec::new()),
|
||||
subst::VecPerParamSpace::empty());
|
||||
|
||||
|
@ -2797,7 +2797,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
let rps = self.region_vars_for_defs(span, rps);
|
||||
let mut substs = subst::Substs::new(
|
||||
VecPerParamSpace::empty(),
|
||||
VecPerParamSpace::new(rps, Vec::new(), Vec::new()));
|
||||
VecPerParamSpace::new(Vec::new(), rps, Vec::new()));
|
||||
self.type_vars_for_defs(span, ParamSpace::TypeSpace, &mut substs, tps);
|
||||
let substd_ty = self.instantiate_type_scheme(span, &substs, &raw_ty);
|
||||
|
||||
|
@ -37,7 +37,7 @@ impl SomeGenericTrait<u64> for i32 {
|
||||
|
||||
// For the non-generic foo(), we should generate a codegen-item even if it
|
||||
// is not called anywhere
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::foo[0]<u64, i32>
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::foo[0]<i32, u64>
|
||||
}
|
||||
|
||||
// Non-generic impl of generic trait
|
||||
@ -54,16 +54,16 @@ fn main() {
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeTrait[0]::bar[0]<i8, &str>
|
||||
let _ = 2i8.bar("&str");
|
||||
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::bar[0]<u64, i32, char>
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::bar[0]<i32, u64, char>
|
||||
0i32.bar(0u64, 'c');
|
||||
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::bar[0]<u64, i32, &str>
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::bar[0]<i32, u64, &str>
|
||||
0i32.bar(0u64, "&str");
|
||||
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::bar[0]<i8, u32, &[char; 1]>
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::bar[0]<u32, i8, &[char; 1]>
|
||||
0u32.bar(0i8, &['c']);
|
||||
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::bar[0]<i16, u32, ()>
|
||||
//~ TRANS_ITEM fn trait_method_default_impl::SomeGenericTrait[0]::bar[0]<u32, i16, ()>
|
||||
0u32.bar(0i16, ());
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,12 @@ trait Trait<'a> {
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct Foo<'a, T : Trait<'a>> { //~ ERROR ItemVariances(types=[[+];[];[]], regions=[[-];[];[]])
|
||||
struct Foo<'a, T : Trait<'a>> { //~ ERROR ItemVariances(types=[[];[+];[]], regions=[[];[-];[]])
|
||||
field: (T, &'a ())
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct Bar<'a, T : Trait<'a>> { //~ ERROR ItemVariances(types=[[o];[];[]], regions=[[o];[];[]])
|
||||
struct Bar<'a, T : Trait<'a>> { //~ ERROR ItemVariances(types=[[];[o];[]], regions=[[];[o];[]])
|
||||
field: <T as Trait<'a>>::Type
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ use std::cell::Cell;
|
||||
// For better or worse, associated types are invariant, and hence we
|
||||
// get an invariant result for `'a`.
|
||||
#[rustc_variance]
|
||||
struct Foo<'a> { //~ ERROR regions=[[o];[];[]]
|
||||
struct Foo<'a> { //~ ERROR regions=[[];[o];[]]
|
||||
x: Box<Fn(i32) -> &'a i32 + 'static>
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_variance]
|
||||
trait Foo: 'static { //~ ERROR types=[[];[o];[]]
|
||||
trait Foo: 'static { //~ ERROR types=[[o];[];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
|
@ -16,7 +16,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 isize,
|
||||
y: &'b [isize],
|
||||
c: &'c str
|
||||
@ -25,7 +25,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 isize),
|
||||
y: extern "Rust" fn(&'b [isize]),
|
||||
c: extern "Rust" fn(&'c str),
|
||||
@ -34,7 +34,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 isize,
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ struct Test4<'a, 'b:'a> { //~ ERROR regions=[[-, o];[];[]]
|
||||
// contravariant context:
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test5<'a, 'b:'a> { //~ ERROR regions=[[+, o];[];[]]
|
||||
struct Test5<'a, 'b:'a> { //~ ERROR regions=[[];[+, o];[]]
|
||||
x: extern "Rust" fn(&'a mut &'b isize),
|
||||
}
|
||||
|
||||
@ -52,14 +52,14 @@ struct Test5<'a, 'b:'a> { //~ ERROR regions=[[+, o];[];[]]
|
||||
// argument list occurs in an invariant context.
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test6<'a, 'b:'a> { //~ ERROR regions=[[-, o];[];[]]
|
||||
struct Test6<'a, 'b:'a> { //~ ERROR regions=[[];[-, o];[]]
|
||||
x: &'a mut extern "Rust" fn(&'b isize),
|
||||
}
|
||||
|
||||
// No uses at all is bivariant:
|
||||
|
||||
#[rustc_variance]
|
||||
struct Test7<'a> { //~ ERROR regions=[[*];[];[]]
|
||||
struct Test7<'a> { //~ ERROR regions=[[];[*];[]]
|
||||
//~^ ERROR parameter `'a` is never used
|
||||
x: isize
|
||||
}
|
||||
@ -67,7 +67,7 @@ struct Test7<'a> { //~ ERROR regions=[[*];[];[]]
|
||||
// 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 isize)),
|
||||
Test8B(&'b [isize]),
|
||||
Test8C(&'b mut &'c str),
|
||||
|
@ -15,7 +15,7 @@
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_variance]
|
||||
enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]]
|
||||
enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[];[+, -, o, *];[]]
|
||||
//~^ ERROR parameter `'d` is never used
|
||||
Test8A(extern "Rust" fn(&'a isize)),
|
||||
Test8B(&'b [isize]),
|
||||
@ -23,25 +23,25 @@ enum Base<'a, 'b, 'c:'b, 'd> { //~ ERROR regions=[[+, -, o, *];[];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[[*, o, -, +];[];[]]
|
||||
struct Derived1<'w, 'x:'y, 'y, 'z> { //~ ERROR regions=[[];[*, o, -, +];[]]
|
||||
//~^ ERROR parameter `'w` is never used
|
||||
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, *];[]]
|
||||
//~^ ERROR parameter `'c` is never used
|
||||
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, -, *];[]]
|
||||
//~^ ERROR parameter `'c` is never used
|
||||
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>
|
||||
}
|
||||
|
||||
|
@ -25,18 +25,18 @@ trait Setter<T> { //~ ERROR types=[[o];[o];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestStruct<U,T:Setter<U>> { //~ ERROR types=[[+, +];[];[]]
|
||||
struct TestStruct<U,T:Setter<U>> { //~ ERROR types=[[];[+, +];[]]
|
||||
t: T, u: U
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
enum TestEnum<U,T:Setter<U>> {//~ ERROR types=[[*, +];[];[]]
|
||||
enum TestEnum<U,T:Setter<U>> {//~ ERROR types=[[];[*, +];[]]
|
||||
//~^ ERROR parameter `U` is never used
|
||||
Foo(T)
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait TestTrait<U,T:Setter<U>> { //~ ERROR types=[[o, o];[o];[]]
|
||||
trait TestTrait<U,T:Setter<U>> { //~ ERROR types=[[o];[o, o];[]]
|
||||
fn getter(&self, u: U) -> T;
|
||||
}
|
||||
|
||||
@ -50,13 +50,13 @@ trait TestTrait3<U> { //~ ERROR types=[[o];[o];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestContraStruct<U,T:Setter<U>> { //~ ERROR types=[[*, +];[];[]]
|
||||
struct TestContraStruct<U,T:Setter<U>> { //~ ERROR types=[[];[*, +];[]]
|
||||
//~^ ERROR parameter `U` is never used
|
||||
t: T
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestBox<U,T:Getter<U>+Setter<U>> { //~ ERROR types=[[*, +];[];[]]
|
||||
struct TestBox<U,T:Getter<U>+Setter<U>> { //~ ERROR types=[[];[*, +];[]]
|
||||
//~^ ERROR parameter `U` is never used
|
||||
t: T
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use std::mem;
|
||||
trait T { fn foo(&self); }
|
||||
|
||||
#[rustc_variance]
|
||||
struct TOption<'a> { //~ ERROR regions=[[-];[];[]]
|
||||
struct TOption<'a> { //~ ERROR regions=[[];[-];[]]
|
||||
v: Option<Box<T + 'a>>,
|
||||
}
|
||||
|
||||
|
@ -14,24 +14,24 @@
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestImm<A, B> { //~ ERROR types=[[+, +];[];[]]
|
||||
struct TestImm<A, B> { //~ ERROR types=[[];[+, +];[]]
|
||||
x: A,
|
||||
y: B,
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestMut<A, B:'static> { //~ ERROR types=[[+, o];[];[]]
|
||||
struct TestMut<A, B:'static> { //~ ERROR types=[[];[+, o];[]]
|
||||
x: A,
|
||||
y: &'static mut B,
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestIndirect<A:'static, B:'static> { //~ ERROR types=[[+, o];[];[]]
|
||||
struct TestIndirect<A:'static, B:'static> { //~ ERROR types=[[];[+, o];[]]
|
||||
m: TestMut<A, B>
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestIndirect2<A:'static, B:'static> { //~ ERROR types=[[o, o];[];[]]
|
||||
struct TestIndirect2<A:'static, B:'static> { //~ ERROR types=[[];[o, o];[]]
|
||||
n: TestMut<A, B>,
|
||||
m: TestMut<B, A>
|
||||
}
|
||||
@ -68,7 +68,7 @@ trait SetterInTypeBound<A> { //~ ERROR types=[[o];[o];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestObject<A, R> { //~ ERROR types=[[o, o];[];[]]
|
||||
struct TestObject<A, R> { //~ ERROR types=[[];[o, o];[]]
|
||||
n: Box<Setter<A>+Send>,
|
||||
m: Box<Getter<R>+Send>,
|
||||
}
|
||||
|
@ -17,32 +17,32 @@ use std::cell::Cell;
|
||||
// not considered bivariant.
|
||||
|
||||
#[rustc_variance]
|
||||
struct InvariantMut<'a,A:'a,B:'a> { //~ ERROR types=[[o, o];[];[]], regions=[[-];[];[]]
|
||||
struct InvariantMut<'a,A:'a,B:'a> { //~ ERROR types=[[];[o, o];[]], regions=[[];[-];[]]
|
||||
t: &'a mut (A,B)
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct InvariantCell<A> { //~ ERROR types=[[o];[];[]]
|
||||
struct InvariantCell<A> { //~ ERROR types=[[];[o];[]]
|
||||
t: Cell<A>
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct InvariantIndirect<A> { //~ ERROR types=[[o];[];[]]
|
||||
struct InvariantIndirect<A> { //~ ERROR types=[[];[o];[]]
|
||||
t: InvariantCell<A>
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct Covariant<A> { //~ ERROR types=[[+];[];[]]
|
||||
struct Covariant<A> { //~ ERROR types=[[];[+];[]]
|
||||
t: A, u: fn() -> A
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct Contravariant<A> { //~ ERROR types=[[-];[];[]]
|
||||
struct Contravariant<A> { //~ ERROR types=[[];[-];[]]
|
||||
t: fn(A)
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
enum Enum<A,B,C> { //~ ERROR types=[[+, -, o];[];[]]
|
||||
enum Enum<A,B,C> { //~ ERROR types=[[];[+, -, o];[]]
|
||||
Foo(Covariant<A>),
|
||||
Bar(Contravariant<B>),
|
||||
Zed(Covariant<C>,Contravariant<C>)
|
||||
|
Loading…
x
Reference in New Issue
Block a user