add tests for the arbitrary_self_types, which won't pass yet
This commit is contained in:
parent
7ade24f672
commit
edc8c760e0
|
@ -0,0 +1,11 @@
|
|||
#![feature(arbitrary_self_types)]
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
struct Foo;
|
||||
|
||||
impl Foo {
|
||||
fn foo(self: Rc<Self>) {} //~ ERROR arbitrary self types are only allowed for trait methods
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,42 @@
|
|||
#![feature(arbitrary_self_types)]
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
trait Foo {
|
||||
fn foo(self: Rc<Self>) -> usize;
|
||||
}
|
||||
|
||||
trait Bar {
|
||||
fn foo(self: Rc<Self>) -> usize where Self: Sized;
|
||||
fn bar(self: Box<Self>) -> usize;
|
||||
}
|
||||
|
||||
impl Foo for usize {
|
||||
fn foo(self: Rc<Self>) -> usize {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl Bar for usize {
|
||||
fn foo(self: Rc<Self>) -> usize {
|
||||
*self
|
||||
}
|
||||
|
||||
fn bar(self: Box<Self>) -> usize {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
fn make_foo() {
|
||||
let x = Box::new(5usize) as Box<Foo>;
|
||||
//~^ ERROR E0038
|
||||
//~| NOTE the method `foo` has an arbitrary self type
|
||||
//~| NOTE the trait `Foo` cannot be made into an object
|
||||
}
|
||||
|
||||
fn make_bar() {
|
||||
let x = Box::new(5usize) as Box<Bar>;
|
||||
x.bar();
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -0,0 +1,17 @@
|
|||
use std::rc::Rc;
|
||||
|
||||
trait Foo {
|
||||
fn foo(self: Rc<Box<Self>>); //~ ERROR arbitrary self types are unstable
|
||||
}
|
||||
|
||||
struct Bar;
|
||||
|
||||
impl Foo for Bar {
|
||||
fn foo(self: Rc<Box<Self>>) {} //~ ERROR arbitrary self types are unstable
|
||||
}
|
||||
|
||||
impl Bar {
|
||||
fn bar(self: Box<Rc<Self>>) {} //~ ERROR arbitrary self types are unstable
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue