diff options
Diffstat (limited to 'src/test/ui/structs-enums/auxiliary')
14 files changed, 240 insertions, 0 deletions
diff --git a/src/test/ui/structs-enums/auxiliary/cci_class.rs b/src/test/ui/structs-enums/auxiliary/cci_class.rs new file mode 100644 index 000000000..de2945d74 --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/cci_class.rs @@ -0,0 +1,14 @@ +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} diff --git a/src/test/ui/structs-enums/auxiliary/cci_class_2.rs b/src/test/ui/structs-enums/auxiliary/cci_class_2.rs new file mode 100644 index 000000000..c3de3150e --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/cci_class_2.rs @@ -0,0 +1,19 @@ +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + + } + + impl cat { + pub fn speak(&self) {} + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} diff --git a/src/test/ui/structs-enums/auxiliary/cci_class_3.rs b/src/test/ui/structs-enums/auxiliary/cci_class_3.rs new file mode 100644 index 000000000..fb7fad0b5 --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/cci_class_3.rs @@ -0,0 +1,19 @@ +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + } + + impl cat { + pub fn speak(&mut self) { self.meows += 1; } + pub fn meow_count(&mut self) -> usize { self.meows } + } + + pub fn cat(in_x : usize, in_y : isize) -> cat { + cat { + meows: in_x, + how_hungry: in_y + } + } +} diff --git a/src/test/ui/structs-enums/auxiliary/cci_class_4.rs b/src/test/ui/structs-enums/auxiliary/cci_class_4.rs new file mode 100644 index 000000000..85aa3bc8c --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/cci_class_4.rs @@ -0,0 +1,41 @@ +pub mod kitties { + pub struct cat { + meows : usize, + + pub how_hungry : isize, + pub name : String, + } + + impl cat { + pub fn speak(&mut self) { self.meow(); } + + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } else { + println!("Not hungry!"); + return false; + } + } + } + + impl cat { + pub fn meow(&mut self) { + println!("Meow"); + self.meows += 1; + if self.meows % 5 == 0 { + self.how_hungry += 1; + } + } + } + + pub fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } + } +} diff --git a/src/test/ui/structs-enums/auxiliary/cci_class_6.rs b/src/test/ui/structs-enums/auxiliary/cci_class_6.rs new file mode 100644 index 000000000..35f93d0c6 --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/cci_class_6.rs @@ -0,0 +1,25 @@ +pub mod kitties { + + pub struct cat<U> { + info : Vec<U> , + meows : usize, + + pub how_hungry : isize, + } + + impl<U> cat<U> { + pub fn speak<T>(&mut self, stuff: Vec<T> ) { + self.meows += stuff.len(); + } + + pub fn meow_count(&mut self) -> usize { self.meows } + } + + pub fn cat<U>(in_x : usize, in_y : isize, in_info: Vec<U> ) -> cat<U> { + cat { + meows: in_x, + how_hungry: in_y, + info: in_info + } + } +} diff --git a/src/test/ui/structs-enums/auxiliary/cci_class_cast.rs b/src/test/ui/structs-enums/auxiliary/cci_class_cast.rs new file mode 100644 index 000000000..dfc3c56dd --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/cci_class_cast.rs @@ -0,0 +1,50 @@ +pub mod kitty { + use std::fmt; + + pub struct cat { + meows : usize, + pub how_hungry : isize, + pub name : String, + } + + impl fmt::Display for cat { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.name) + } + } + + impl cat { + fn meow(&mut self) { + println!("Meow"); + self.meows += 1; + if self.meows % 5 == 0 { + self.how_hungry += 1; + } + } + + } + + impl cat { + pub fn speak(&mut self) { self.meow(); } + + pub fn eat(&mut self) -> bool { + if self.how_hungry > 0 { + println!("OM NOM NOM"); + self.how_hungry -= 2; + return true; + } + else { + println!("Not hungry!"); + return false; + } + } + } + + pub fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { + cat { + meows: in_x, + how_hungry: in_y, + name: in_name + } + } +} diff --git a/src/test/ui/structs-enums/auxiliary/cci_class_trait.rs b/src/test/ui/structs-enums/auxiliary/cci_class_trait.rs new file mode 100644 index 000000000..2d02b591c --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/cci_class_trait.rs @@ -0,0 +1,5 @@ +pub mod animals { + pub trait noisy { + fn speak(&mut self); + } +} diff --git a/src/test/ui/structs-enums/auxiliary/empty-struct.rs b/src/test/ui/structs-enums/auxiliary/empty-struct.rs new file mode 100644 index 000000000..93275e714 --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/empty-struct.rs @@ -0,0 +1,9 @@ +pub struct XEmpty1 {} +pub struct XEmpty2; +pub struct XEmpty7(); + +pub enum XE { + XEmpty3 {}, + XEmpty4, + XEmpty6(), +} diff --git a/src/test/ui/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs b/src/test/ui/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs new file mode 100644 index 000000000..55e6b34ac --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/namespaced_enum_emulate_flat.rs @@ -0,0 +1,25 @@ +pub use Foo::*; + +pub enum Foo { + A, + B(isize), + C { a: isize }, +} + +impl Foo { + pub fn foo() {} +} + +pub mod nest { + pub use self::Bar::*; + + pub enum Bar { + D, + E(isize), + F { a: isize }, + } + + impl Bar { + pub fn foo() {} + } +} diff --git a/src/test/ui/structs-enums/auxiliary/namespaced_enums.rs b/src/test/ui/structs-enums/auxiliary/namespaced_enums.rs new file mode 100644 index 000000000..d3548c76c --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/namespaced_enums.rs @@ -0,0 +1,10 @@ +pub enum Foo { + A, + B(isize), + C { a: isize }, +} + +impl Foo { + pub fn foo() {} + pub fn bar(&self) {} +} diff --git a/src/test/ui/structs-enums/auxiliary/newtype_struct_xc.rs b/src/test/ui/structs-enums/auxiliary/newtype_struct_xc.rs new file mode 100644 index 000000000..9d1e0742e --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/newtype_struct_xc.rs @@ -0,0 +1,3 @@ +#![crate_type="lib"] + +pub struct Au(pub isize); diff --git a/src/test/ui/structs-enums/auxiliary/struct_destructuring_cross_crate.rs b/src/test/ui/structs-enums/auxiliary/struct_destructuring_cross_crate.rs new file mode 100644 index 000000000..3665ae7e8 --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/struct_destructuring_cross_crate.rs @@ -0,0 +1,6 @@ +#![crate_type="lib"] + +pub struct S { + pub x: isize, + pub y: isize, +} diff --git a/src/test/ui/structs-enums/auxiliary/struct_variant_xc_aux.rs b/src/test/ui/structs-enums/auxiliary/struct_variant_xc_aux.rs new file mode 100644 index 000000000..e919df611 --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/struct_variant_xc_aux.rs @@ -0,0 +1,8 @@ +#![crate_name="struct_variant_xc_aux"] +#![crate_type = "lib"] + +#[derive(Copy, Clone)] +pub enum Enum { + Variant(u8), + StructVariant { arg: u8 } +} diff --git a/src/test/ui/structs-enums/auxiliary/xcrate_struct_aliases.rs b/src/test/ui/structs-enums/auxiliary/xcrate_struct_aliases.rs new file mode 100644 index 000000000..bc8879aa3 --- /dev/null +++ b/src/test/ui/structs-enums/auxiliary/xcrate_struct_aliases.rs @@ -0,0 +1,6 @@ +pub struct S { + pub x: isize, + pub y: isize, +} + +pub type S2 = S; |