mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
Fallout in tests
This commit is contained in:
parent
dd31bb24e8
commit
9b5accade7
@ -8,6 +8,6 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
pub trait TheTrait<T> : ::std::marker::PhantomFn<T> {
|
||||
pub trait TheTrait<T> {
|
||||
fn the_fn(&self);
|
||||
}
|
||||
|
@ -12,12 +12,8 @@
|
||||
#![no_std]
|
||||
#![feature(lang_items)]
|
||||
|
||||
#[lang="phantom_fn"]
|
||||
pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
|
||||
impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
|
||||
|
||||
#[lang="sized"]
|
||||
pub trait Sized : PhantomFn<Self> {}
|
||||
pub trait Sized { }
|
||||
|
||||
#[lang="panic"]
|
||||
fn panic(_: &(&'static str, &'static str, usize)) -> ! { loop {} }
|
||||
@ -29,7 +25,7 @@ extern fn stack_exhausted() {}
|
||||
extern fn eh_personality() {}
|
||||
|
||||
#[lang="copy"]
|
||||
pub trait Copy : PhantomFn<Self> {
|
||||
pub trait Copy {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,8 @@
|
||||
#![feature(no_std)]
|
||||
#![no_std]
|
||||
|
||||
#[lang="phantom_fn"]
|
||||
pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
|
||||
impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
|
||||
|
||||
#[lang="sized"]
|
||||
pub trait Sized : PhantomFn<Self> {
|
||||
pub trait Sized {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,7 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
trait FromStructReader<'a> : PhantomFn<(Self,&'a ())> { }
|
||||
trait FromStructReader<'a> { }
|
||||
trait ResponseHook {
|
||||
fn get<'a, T: FromStructReader<'a>>(&'a self);
|
||||
}
|
||||
|
@ -13,12 +13,8 @@
|
||||
#![feature(lang_items, start, no_std)]
|
||||
#![no_std]
|
||||
|
||||
#[lang="phantom_fn"]
|
||||
trait PhantomFn<A:?Sized,R:?Sized=()> { }
|
||||
impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
|
||||
|
||||
#[lang = "sized"]
|
||||
trait Sized : PhantomFn<Self> {}
|
||||
trait Sized { }
|
||||
|
||||
#[start]
|
||||
fn main(_: isize, _: *const *const u8) -> isize {
|
||||
|
@ -41,7 +41,7 @@ fn g<T>(val: T) {
|
||||
fn foo<'a>() {
|
||||
let t: S<&'a isize> = S(marker::PhantomData);
|
||||
let a = &t as &Gettable<&'a isize>;
|
||||
//~^ ERROR cannot infer
|
||||
//~^ ERROR does not fulfill
|
||||
}
|
||||
|
||||
fn foo2<'a>() {
|
||||
|
@ -12,18 +12,15 @@
|
||||
#![allow(dead_code)]
|
||||
#![deny(unsafe_code)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
struct Bar;
|
||||
struct Bar2;
|
||||
struct Bar3;
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
mod allowed_unsafe {
|
||||
use std::marker::PhantomFn;
|
||||
fn allowed() { unsafe {} }
|
||||
unsafe fn also_allowed() {}
|
||||
unsafe trait AllowedUnsafe : PhantomFn<Self> {}
|
||||
unsafe trait AllowedUnsafe { }
|
||||
unsafe impl AllowedUnsafe for super::Bar {}
|
||||
}
|
||||
|
||||
@ -34,7 +31,7 @@ macro_rules! unsafe_in_macro {
|
||||
}
|
||||
|
||||
unsafe fn baz() {} //~ ERROR: declaration of an `unsafe` function
|
||||
unsafe trait Foo : PhantomFn<Self> {} //~ ERROR: declaration of an `unsafe` trait
|
||||
unsafe trait Foo {} //~ ERROR: declaration of an `unsafe` trait
|
||||
unsafe impl Foo for Bar {} //~ ERROR: implementation of an `unsafe` trait
|
||||
|
||||
trait Baz {
|
||||
|
@ -13,12 +13,10 @@
|
||||
#![feature(rustc_attrs)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
trait Baz : PhantomFn<Self> {
|
||||
trait Baz {
|
||||
}
|
||||
|
||||
trait Bar<T> : PhantomFn<(Self, T)> {
|
||||
trait Bar<T> {
|
||||
}
|
||||
|
||||
fn make_bar<T:Bar<u32>>(t: &T) -> &Bar<u32> {
|
||||
|
@ -13,11 +13,8 @@
|
||||
|
||||
#![allow(unused)]
|
||||
|
||||
use std::marker;
|
||||
|
||||
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"]
|
||||
trait Foo<Bar, Baz, Quux>
|
||||
: marker::PhantomFn<(Self,Bar,Baz,Quux)>
|
||||
{}
|
||||
|
||||
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be built from an iterator over elements of type `{A}`"]
|
||||
@ -28,19 +25,16 @@ trait MyFromIterator<A> {
|
||||
|
||||
#[rustc_on_unimplemented] //~ ERROR this attribute must have a value
|
||||
trait BadAnnotation1
|
||||
: marker::MarkerTrait
|
||||
{}
|
||||
|
||||
#[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{C}>`"]
|
||||
//~^ ERROR there is no type parameter C on trait BadAnnotation2
|
||||
trait BadAnnotation2<A,B>
|
||||
: marker::PhantomFn<(Self,A,B)>
|
||||
{}
|
||||
|
||||
#[rustc_on_unimplemented = "Unimplemented trait error on `{Self}` with params `<{A},{B},{}>`"]
|
||||
//~^ only named substitution parameters are allowed
|
||||
trait BadAnnotation3<A,B>
|
||||
: marker::PhantomFn<(Self,A,B)>
|
||||
{}
|
||||
|
||||
pub fn main() {
|
||||
|
@ -11,11 +11,8 @@
|
||||
|
||||
#![feature(on_unimplemented)]
|
||||
|
||||
use std::marker;
|
||||
|
||||
#[rustc_on_unimplemented = "test error `{Self}` with `{Bar}` `{Baz}` `{Quux}`"]
|
||||
trait Foo<Bar, Baz, Quux>
|
||||
: marker::PhantomFn<(Self,Bar,Baz,Quux)>
|
||||
{}
|
||||
|
||||
fn foobar<U: Clone, T: Foo<u8, U, u32>>() -> T {
|
||||
|
@ -11,15 +11,11 @@
|
||||
#![feature(lang_items, start, no_std)]
|
||||
#![no_std] // makes debugging this test *a lot* easier (during resolve)
|
||||
|
||||
#[lang="phantom_fn"]
|
||||
pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
|
||||
impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
|
||||
|
||||
#[lang="sized"]
|
||||
pub trait Sized : PhantomFn<Self> {}
|
||||
pub trait Sized {}
|
||||
|
||||
#[lang="copy"]
|
||||
pub trait Copy : PhantomFn<Self> {}
|
||||
pub trait Copy {}
|
||||
|
||||
mod bar {
|
||||
// shouldn't bring in too much
|
||||
|
@ -11,12 +11,8 @@
|
||||
#![feature(lang_items, start, no_std)]
|
||||
#![no_std] // makes debugging this test *a lot* easier (during resolve)
|
||||
|
||||
#[lang="phantom_fn"]
|
||||
pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
|
||||
impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
|
||||
|
||||
#[lang = "sized"] pub trait Sized : PhantomFn<Self> {}
|
||||
#[lang="copy"] pub trait Copy : PhantomFn<Self> {}
|
||||
#[lang = "sized"] pub trait Sized {}
|
||||
#[lang="copy"] pub trait Copy {}
|
||||
|
||||
// Test to make sure that private items imported through globs remain private
|
||||
// when they're used.
|
||||
|
@ -15,11 +15,9 @@
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub trait TheTrait: PhantomFn<Self, Self> {
|
||||
pub trait TheTrait {
|
||||
type TheAssocType;
|
||||
}
|
||||
|
||||
|
@ -14,11 +14,9 @@
|
||||
#![allow(dead_code)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub trait TheTrait<'b> : PhantomFn<&'b Self,Self> {
|
||||
pub trait TheTrait<'b> {
|
||||
type TheAssocType;
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,9 @@
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub trait TheTrait: PhantomFn<Self, Self> {
|
||||
pub trait TheTrait {
|
||||
type TheAssocType;
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,9 @@
|
||||
#![allow(dead_code)]
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
pub trait TheTrait: PhantomFn<Self, Self> {
|
||||
pub trait TheTrait {
|
||||
type TheAssocType;
|
||||
}
|
||||
|
||||
|
@ -11,12 +11,10 @@
|
||||
#![feature(box_syntax)]
|
||||
#![allow(warnings)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
trait A<T> : PhantomFn<(Self,T)> { }
|
||||
trait A<T> { }
|
||||
struct B<'a, T>(&'a (A<T>+'a));
|
||||
|
||||
trait X : ::std::marker::MarkerTrait {}
|
||||
trait X { }
|
||||
|
||||
impl<'a, T> X for B<'a, T> {}
|
||||
|
||||
|
@ -10,12 +10,10 @@
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
trait A<T> : PhantomFn<(Self,T)> { }
|
||||
trait A<T> { }
|
||||
struct B<'a, T>(&'a (A<T>+'a));
|
||||
|
||||
trait X : PhantomFn<Self> {}
|
||||
trait X { }
|
||||
impl<'a, T> X for B<'a, T> {}
|
||||
|
||||
fn g<'a, T: 'static>(v: Box<A<T>+'a>) -> Box<X+'static> {
|
||||
|
@ -11,15 +11,13 @@
|
||||
#![feature(box_syntax)]
|
||||
#![allow(warnings)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
trait A<T> : PhantomFn<(Self,T)> {}
|
||||
trait A<T> { }
|
||||
struct B<'a, T>(&'a (A<T>+'a));
|
||||
|
||||
trait X : PhantomFn<Self> {}
|
||||
trait X { }
|
||||
impl<'a, T> X for B<'a, T> {}
|
||||
|
||||
fn h<'a, T, U>(v: Box<A<U>+'static>) -> Box<X+'static> {
|
||||
fn h<'a, T, U:'static>(v: Box<A<U>+'static>) -> Box<X+'static> {
|
||||
box B(&*v) as Box<X> //~ ERROR `*v` does not live long enough
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,10 @@
|
||||
|
||||
#![feature(box_syntax)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
trait A<T> : PhantomFn<(Self,T)> {}
|
||||
trait A<T> { }
|
||||
struct B<'a, T>(&'a (A<T>+'a));
|
||||
|
||||
trait X : PhantomFn<Self> {}
|
||||
trait X { }
|
||||
impl<'a, T> X for B<'a, T> {}
|
||||
|
||||
fn i<'a, T, U>(v: Box<A<U>+'a>) -> Box<X+'static> {
|
||||
|
@ -11,11 +11,7 @@
|
||||
#![feature(lang_items, no_std)]
|
||||
#![no_std]
|
||||
|
||||
#[lang="phantom_fn"]
|
||||
pub trait PhantomFn<T:?Sized> { }
|
||||
impl<T:?Sized, U:?Sized> PhantomFn<T> for U { }
|
||||
|
||||
#[lang="sized"] pub trait Sized : PhantomFn<Self> {}
|
||||
#[lang="sized"] pub trait Sized { }
|
||||
|
||||
// error-pattern:requires `start` lang_item
|
||||
|
||||
|
@ -13,8 +13,7 @@
|
||||
|
||||
use std::marker;
|
||||
|
||||
trait A : marker::PhantomFn<Self> {
|
||||
}
|
||||
trait A { }
|
||||
|
||||
trait B: A {}
|
||||
|
||||
|
@ -15,7 +15,6 @@ trait Iterator<A> {
|
||||
}
|
||||
|
||||
trait IteratorUtil<A>
|
||||
: ::std::marker::PhantomFn<(),A>
|
||||
{
|
||||
fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>;
|
||||
}
|
||||
|
@ -16,14 +16,12 @@
|
||||
#![feature(unboxed_closures)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
trait Foo<T> {
|
||||
type Output;
|
||||
fn dummy(&self, t: T, u: Self::Output);
|
||||
}
|
||||
|
||||
trait Eq<X: ?Sized> : PhantomFn<(Self,X)> { }
|
||||
trait Eq<X: ?Sized> { }
|
||||
impl<X: ?Sized> Eq<X> for X { }
|
||||
fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
|
||||
|
||||
|
@ -23,7 +23,7 @@ trait Foo<T> {
|
||||
fn dummy(&self, t: T);
|
||||
}
|
||||
|
||||
trait Eq<X: ?Sized> : marker::PhantomFn<(Self, X)> { }
|
||||
trait Eq<X: ?Sized> { }
|
||||
impl<X: ?Sized> Eq<X> for X { }
|
||||
fn eq<A: ?Sized,B: ?Sized +Eq<A>>() { }
|
||||
|
||||
|
@ -10,6 +10,9 @@
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
// This test was previously testing variance on traits.
|
||||
// But now that it is removed, both cases error.
|
||||
|
||||
trait Get<T> : 'static {
|
||||
fn get(&self, t: T);
|
||||
}
|
||||
@ -25,7 +28,8 @@ fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>)
|
||||
-> Box<Get<&'max i32>>
|
||||
where 'max : 'min
|
||||
{
|
||||
v
|
||||
// Previously OK:
|
||||
v //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -23,7 +23,9 @@ fn get_min_from_max<'min, 'max, G>()
|
||||
fn get_max_from_min<'min, 'max, G>()
|
||||
where 'max : 'min, G : Get<&'min i32>
|
||||
{
|
||||
impls_get::<G,&'max i32>()
|
||||
// Previously OK, but now an error because traits are invariant:
|
||||
|
||||
impls_get::<G,&'max i32>() //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn impls_get<G,T>() where G : Get<T> { }
|
||||
|
@ -23,7 +23,10 @@ fn get_min_from_max<'min, 'max, G>()
|
||||
fn get_max_from_min<'min, 'max, G>()
|
||||
where 'max : 'min, G : 'max, &'min G : Get
|
||||
{
|
||||
impls_get::<&'max G>();
|
||||
// Previously OK, but now error because traits are invariant with
|
||||
// respect to all inputs.
|
||||
|
||||
impls_get::<&'max G>(); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn impls_get<G>() where G : Get { }
|
||||
|
@ -18,7 +18,8 @@ fn get_min_from_max<'min, 'max>(v: Box<Get<&'max i32>>)
|
||||
-> Box<Get<&'min i32>>
|
||||
where 'max : 'min
|
||||
{
|
||||
v
|
||||
// Previously OK, now an error as traits are invariant.
|
||||
v //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn get_max_from_min<'min, 'max, G>(v: Box<Get<&'min i32>>)
|
||||
|
@ -17,7 +17,8 @@ trait Get<T> {
|
||||
fn get_min_from_max<'min, 'max, G>()
|
||||
where 'max : 'min, G : Get<&'max i32>
|
||||
{
|
||||
impls_get::<G,&'min i32>()
|
||||
// Previously OK, now an error as traits are invariant.
|
||||
impls_get::<G,&'min i32>() //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn get_max_from_min<'min, 'max, G>()
|
||||
|
@ -17,7 +17,8 @@ trait Get {
|
||||
fn get_min_from_max<'min, 'max, G>()
|
||||
where 'max : 'min, G : 'max, &'max G : Get
|
||||
{
|
||||
impls_get::<&'min G>();
|
||||
// Previously OK, now an error as traits are invariant.
|
||||
impls_get::<&'min G>(); //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn get_max_from_min<'min, 'max, G>()
|
||||
|
@ -13,11 +13,11 @@
|
||||
#![feature(rustc_attrs)]
|
||||
|
||||
#[rustc_variance]
|
||||
trait Foo: 'static { //~ ERROR types=[[];[-];[]]
|
||||
trait Foo: 'static { //~ ERROR types=[[];[o];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait Bar<T> { //~ ERROR types=[[+];[-];[]]
|
||||
trait Bar<T> { //~ ERROR types=[[o];[o];[]]
|
||||
fn do_it(&self)
|
||||
where T: 'static;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ struct Struct<'a, 'd> { //~ ERROR parameter `'d` is never used
|
||||
field: &'a [i32]
|
||||
}
|
||||
|
||||
trait Trait<'a, 'd> { //~ ERROR parameter `'d` is never used
|
||||
trait Trait<'a, 'd> { // OK on traits
|
||||
fn method(&'a self);
|
||||
}
|
||||
|
||||
|
@ -16,12 +16,12 @@
|
||||
// influence variance.
|
||||
|
||||
#[rustc_variance]
|
||||
trait Getter<T> { //~ ERROR types=[[+];[-];[]]
|
||||
trait Getter<T> { //~ ERROR types=[[o];[o];[]]
|
||||
fn get(&self) -> T;
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait Setter<T> { //~ ERROR types=[[-];[-];[]]
|
||||
trait Setter<T> { //~ ERROR types=[[o];[o];[]]
|
||||
fn get(&self, T);
|
||||
}
|
||||
|
||||
@ -37,16 +37,16 @@ enum TestEnum<U,T:Setter<U>> {//~ ERROR types=[[*, +];[];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait TestTrait<U,T:Setter<U>> { //~ ERROR types=[[-, +];[-];[]]
|
||||
trait TestTrait<U,T:Setter<U>> { //~ ERROR types=[[o, o];[o];[]]
|
||||
fn getter(&self, u: U) -> T;
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait TestTrait2<U> : Getter<U> { //~ ERROR types=[[+];[-];[]]
|
||||
trait TestTrait2<U> : Getter<U> { //~ ERROR types=[[o];[o];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait TestTrait3<U> { //~ ERROR types=[[-];[-];[]]
|
||||
trait TestTrait3<U> { //~ ERROR types=[[o];[o];[]]
|
||||
fn getter<T:Getter<U>>(&self);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
@ -8,22 +8,43 @@
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Issue #5781. Tests that subtyping is handled properly in trait matching.
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
trait Make<'a> {
|
||||
fn make(x: &'a mut isize) -> Self;
|
||||
#![allow(dead_code)]
|
||||
|
||||
// Get<T> is covariant in T
|
||||
trait Get<T> {
|
||||
fn get(&self) -> T;
|
||||
}
|
||||
|
||||
impl<'a> Make<'a> for &'a mut isize {
|
||||
fn make(x: &'a mut isize) -> &'a mut isize {
|
||||
x
|
||||
struct Cloner<T:Clone> {
|
||||
t: T
|
||||
}
|
||||
|
||||
impl<T:Clone> Get<T> for Cloner<T> {
|
||||
fn get(&self) -> T {
|
||||
self.t.clone()
|
||||
}
|
||||
}
|
||||
|
||||
fn f() -> &'static mut isize {
|
||||
let mut x = 1;
|
||||
let y: &'static mut isize = Make::make(&mut x); //~ ERROR `x` does not live long enough
|
||||
y
|
||||
fn get<'a, G>(get: &G) -> i32
|
||||
where G : Get<&'a i32>
|
||||
{
|
||||
// This fails to type-check because, without variance, we can't
|
||||
// use `G : Get<&'a i32>` as evidence that `G : Get<&'b i32>`,
|
||||
// even if `'a : 'b`.
|
||||
pick(get, &22) //~ ERROR cannot infer
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn pick<'b, G>(get: &'b G, if_odd: &'b i32) -> i32
|
||||
where G : Get<&'b i32>
|
||||
{
|
||||
let v = *get.get();
|
||||
if v % 2 != 0 { v } else { *if_odd }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Cloner { t: &23 };
|
||||
let y = get(&x);
|
||||
assert_eq!(y, 23);
|
||||
}
|
||||
|
@ -37,12 +37,12 @@ struct TestIndirect2<A:'static, B:'static> { //~ ERROR types=[[o, o];[];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait Getter<A> { //~ ERROR types=[[+];[-];[]]
|
||||
trait Getter<A> { //~ ERROR types=[[o];[o];[]]
|
||||
fn get(&self) -> A;
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait Setter<A> { //~ ERROR types=[[-];[o];[]]
|
||||
trait Setter<A> { //~ ERROR types=[[o];[o];[]]
|
||||
fn set(&mut self, a: A);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ trait GetterSetter<A> { //~ ERROR types=[[o];[o];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait GetterInTypeBound<A> { //~ ERROR types=[[-];[-];[]]
|
||||
trait GetterInTypeBound<A> { //~ ERROR types=[[o];[o];[]]
|
||||
// Here, the use of `A` in the method bound *does* affect
|
||||
// variance. Think of it as if the method requested a dictionary
|
||||
// for `T:Getter<A>`. Since this dictionary is an input, it is
|
||||
@ -63,12 +63,12 @@ trait GetterInTypeBound<A> { //~ ERROR types=[[-];[-];[]]
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
trait SetterInTypeBound<A> { //~ ERROR types=[[+];[-];[]]
|
||||
trait SetterInTypeBound<A> { //~ ERROR types=[[o];[o];[]]
|
||||
fn do_it<T:Setter<A>>(&self);
|
||||
}
|
||||
|
||||
#[rustc_variance]
|
||||
struct TestObject<A, R> { //~ ERROR types=[[-, +];[];[]]
|
||||
struct TestObject<A, R> { //~ ERROR types=[[o, o];[];[]]
|
||||
n: Box<Setter<A>+Send>,
|
||||
m: Box<Getter<R>+Send>,
|
||||
}
|
||||
|
@ -12,6 +12,6 @@
|
||||
|
||||
struct SomeStruct<'a> { x: u32 } //~ ERROR parameter `'a` is never used
|
||||
enum SomeEnum<'a> { Nothing } //~ ERROR parameter `'a` is never used
|
||||
trait SomeTrait<'a> { fn foo(&self); } //~ ERROR parameter `'a` is never used
|
||||
trait SomeTrait<'a> { fn foo(&self); } // OK on traits.
|
||||
|
||||
fn main() {}
|
||||
|
@ -21,10 +21,6 @@ enum SomeEnum<A> { Nothing }
|
||||
//~^ ERROR parameter `A` is never used
|
||||
//~| HELP PhantomData
|
||||
|
||||
trait SomeTrait<A> { fn foo(&self); }
|
||||
//~^ ERROR parameter `A` is never used
|
||||
//~| HELP PhantomFn
|
||||
|
||||
// Here T might *appear* used, but in fact it isn't.
|
||||
enum ListCell<T> {
|
||||
//~^ ERROR parameter `T` is never used
|
||||
|
@ -70,14 +70,10 @@ pub fn bar(a: i32x4, b: i32x4) -> i32x4 {
|
||||
}
|
||||
|
||||
#[lang = "sized"]
|
||||
pub trait Sized : PhantomFn<Self> {}
|
||||
pub trait Sized { }
|
||||
|
||||
#[lang = "copy"]
|
||||
pub trait Copy : PhantomFn<Self> {}
|
||||
|
||||
#[lang="phantom_fn"]
|
||||
pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
|
||||
impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
|
||||
pub trait Copy { }
|
||||
|
||||
mod core {
|
||||
pub mod marker {
|
||||
|
@ -11,15 +11,11 @@
|
||||
#![feature(lang_items, no_std)]
|
||||
#![no_std]
|
||||
|
||||
#[lang="phantom_fn"]
|
||||
trait PhantomFn<A:?Sized,R:?Sized=()> { }
|
||||
impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
|
||||
|
||||
#[lang="copy"]
|
||||
trait Copy : PhantomFn<Self> { }
|
||||
trait Copy { }
|
||||
|
||||
#[lang="sized"]
|
||||
trait Sized : PhantomFn<Self> { }
|
||||
trait Sized { }
|
||||
|
||||
#[lang="start"]
|
||||
fn start(_main: *const u8, _argc: isize, _argv: *const *const u8) -> isize { 0 }
|
||||
|
@ -16,7 +16,6 @@ trait Contravariant {
|
||||
}
|
||||
|
||||
impl Contravariant for for<'a,'b> fn(&'a u8, &'b u8) {
|
||||
//~^ ERROR E0119
|
||||
}
|
||||
|
||||
impl Contravariant for for<'a> fn(&'a u8, &'a u8) {
|
||||
@ -29,7 +28,6 @@ trait Covariant {
|
||||
}
|
||||
|
||||
impl Covariant for for<'a,'b> fn(&'a u8, &'b u8) {
|
||||
//~^ ERROR E0119
|
||||
}
|
||||
|
||||
impl Covariant for for<'a> fn(&'a u8, &'a u8) {
|
||||
@ -38,7 +36,7 @@ impl Covariant for for<'a> fn(&'a u8, &'a u8) {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
trait Invariant {
|
||||
fn foo(&self) -> Self { }
|
||||
fn foo(&self) { }
|
||||
}
|
||||
|
||||
impl Invariant for for<'a,'b> fn(&'a u8, &'b u8) {
|
@ -12,9 +12,7 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
trait Chromosome<X: Chromosome<i32>> : PhantomFn<(Self,X)> {
|
||||
trait Chromosome<X: Chromosome<i32>> {
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
use std::marker::{PhantomData, PhantomFn};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub struct Handle<T, I>(T, I);
|
||||
|
||||
@ -34,7 +34,7 @@ impl<D: Device, T> BufferHandle<D, T> {
|
||||
|
||||
pub type RawBufferHandle<D: Device> = Handle<<D as Device>::Buffer, String>;
|
||||
|
||||
pub trait Device: PhantomFn<Self> {
|
||||
pub trait Device {
|
||||
type Buffer;
|
||||
}
|
||||
|
||||
|
@ -27,9 +27,7 @@ pub trait Decoder<'v> {
|
||||
fn read(&mut self) -> Value<'v>;
|
||||
}
|
||||
|
||||
pub trait Decodable<'v, D: Decoder<'v>>
|
||||
: marker::PhantomFn<(), &'v isize>
|
||||
{
|
||||
pub trait Decodable<'v, D: Decoder<'v>> {
|
||||
fn decode(d: &mut D) -> Self;
|
||||
}
|
||||
|
||||
|
@ -12,17 +12,17 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
use std::marker::{PhantomData, PhantomFn};
|
||||
use std::marker::PhantomData;
|
||||
|
||||
trait T1 : PhantomFn<Self> { }
|
||||
pub trait T2 : PhantomFn<Self> { }
|
||||
trait T3<X: T1> : T2 + PhantomFn<X> { }
|
||||
trait T4<X: ?Sized> : PhantomFn<(Self,X)> {}
|
||||
trait T5<X: ?Sized, Y> : PhantomFn<(Self,X,Y)> {}
|
||||
trait T6<Y, X: ?Sized> : PhantomFn<(Self,X,Y)> {}
|
||||
trait T7<X: ?Sized, Y: ?Sized> : PhantomFn<(Self,X,Y)> {}
|
||||
trait T8<X: ?Sized+T2> : PhantomFn<(Self,X)> {}
|
||||
trait T9<X: T2 + ?Sized> : PhantomFn<(Self,X)> {}
|
||||
trait T1 { }
|
||||
pub trait T2 { }
|
||||
trait T3<X: T1> : T2 { }
|
||||
trait T4<X: ?Sized> { }
|
||||
trait T5<X: ?Sized, Y> { }
|
||||
trait T6<Y, X: ?Sized> { }
|
||||
trait T7<X: ?Sized, Y: ?Sized> { }
|
||||
trait T8<X: ?Sized+T2> { }
|
||||
trait T9<X: T2 + ?Sized> { }
|
||||
struct S1<X: ?Sized>(PhantomData<X>);
|
||||
enum E<X: ?Sized> { E1(PhantomData<X>) }
|
||||
impl <X: ?Sized> T1 for S1<X> {}
|
||||
|
@ -1,49 +0,0 @@
|
||||
// Copyright 2015 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.
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
// Get<T> is covariant in T
|
||||
trait Get<T> {
|
||||
fn get(&self) -> T;
|
||||
}
|
||||
|
||||
struct Cloner<T:Clone> {
|
||||
t: T
|
||||
}
|
||||
|
||||
impl<T:Clone> Get<T> for Cloner<T> {
|
||||
fn get(&self) -> T {
|
||||
self.t.clone()
|
||||
}
|
||||
}
|
||||
|
||||
fn get<'a, G>(get: &G) -> i32
|
||||
where G : Get<&'a i32>
|
||||
{
|
||||
// This call only type checks if we can use `G : Get<&'a i32>` as
|
||||
// evidence that `G : Get<&'b i32>` where `'a : 'b`.
|
||||
pick(get, &22)
|
||||
}
|
||||
|
||||
fn pick<'b, G>(get: &'b G, if_odd: &'b i32) -> i32
|
||||
where G : Get<&'b i32>
|
||||
{
|
||||
let v = *get.get();
|
||||
if v % 2 != 0 { v } else { *if_odd }
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = Cloner { t: &23 };
|
||||
let y = get(&x);
|
||||
assert_eq!(y, 23);
|
||||
}
|
@ -13,18 +13,13 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
use std::marker::PhantomFn;
|
||||
|
||||
static mut COUNT: u32 = 1;
|
||||
|
||||
trait Bar<'a>
|
||||
: PhantomFn<&'a ()>
|
||||
{
|
||||
trait Bar<'a> {
|
||||
fn bar(&self);
|
||||
}
|
||||
|
||||
trait Baz<'a>
|
||||
: PhantomFn<&'a ()>
|
||||
{
|
||||
fn baz(&self);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user