Remove virtual
struct tests
This commit is contained in:
parent
403cd40e6a
commit
17da4c761d
12 changed files with 1 additions and 323 deletions
|
@ -1,18 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
|
||||
struct S6 : int; //~ ERROR super-struct could not be resolved
|
||||
|
||||
pub fn main() {
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
struct S2 : S0 { //~ ERROR super-struct could not be resolved
|
||||
f2: int,
|
||||
}
|
||||
|
||||
trait T {}
|
||||
|
||||
struct S3 : T { //~ ERROR super-struct is not a struct type
|
||||
f3: int,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
virtual struct S1 {
|
||||
f1: int,
|
||||
}
|
||||
|
||||
struct S6 : S1 {
|
||||
f2: int,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let s = S6{f2: 3}; //~ ERROR missing field: `f1`
|
||||
let s = S6{f1: 3}; //~ ERROR missing field: `f2`
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
// With lifetime parameters.
|
||||
struct S5<'a> : S4 { //~ ERROR wrong number of lifetime parameters: expected 1, found 0
|
||||
f4: int,
|
||||
}
|
||||
|
||||
virtual struct S4<'a> {
|
||||
f3: &'a int,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance on structs from another crate.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
// aux-build:inherit_struct_lib.rs
|
||||
extern crate inherit_struct_lib;
|
||||
|
||||
struct S3 : inherit_struct_lib::S1; //~ ERROR super-struct is defined in a different crate
|
||||
|
||||
pub fn main() {
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test privacy and struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
mod Foo {
|
||||
pub virtual struct S1 {
|
||||
pub f1: int,
|
||||
f2: int,
|
||||
}
|
||||
}
|
||||
|
||||
struct S2 : Foo::S1 {
|
||||
pub f3: int,
|
||||
}
|
||||
|
||||
impl S2 {
|
||||
fn new() -> S2 {
|
||||
S2{f1: 3, f2: 4, f3: 5} //~ ERROR field `f2` of struct `S2` is private
|
||||
}
|
||||
|
||||
fn bar(&self) {
|
||||
self.f3;
|
||||
self.f1;
|
||||
self.f2; //~ ERROR field `f2` of struct `S2` is private
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let s = S2{f1: 3, f2: 4, f3: 5}; //~ ERROR field `f2` of struct `S2` is private
|
||||
s.f3;
|
||||
s.f1;
|
||||
s.f2; //~ ERROR field `f2` of struct `S2` is private
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
virtual trait Foo {} //~ ERROR `virtual` keyword may only be used with `struct`
|
||||
virtual enum Bar {} //~ ERROR `virtual` keyword may only be used with `struct`
|
||||
virtual fn baz() {} //~ ERROR `virtual` keyword may only be used with `struct`
|
||||
|
||||
pub fn main() {
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// ignore-test FIXME: #13991
|
||||
|
||||
|
||||
// Test struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
virtual struct S1 {
|
||||
f1: int,
|
||||
}
|
||||
|
||||
virtual struct S6 : S1 {
|
||||
f2: int,
|
||||
}
|
||||
|
||||
struct S7 : S1 {
|
||||
f1: int, //~ ERROR field `f1` hides field declared in super-struct
|
||||
}
|
||||
|
||||
struct S8 : S6 {
|
||||
f1: int, //~ ERROR field `f1` hides field declared in super-struct
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
struct s9;
|
||||
struct s10 : s9; //~ ERROR struct inheritance is only allowed from virtual structs
|
||||
|
||||
pub fn main() {
|
||||
}
|
|
@ -75,9 +75,6 @@
|
|||
// gdb-command:print 'simple-struct::PADDING_AT_END'
|
||||
// gdb-check:$18 = {x = -27, y = 28}
|
||||
|
||||
// gdb-command:print inheriting
|
||||
// gdb-check:$19 = {a = 10019, b = -10020, x = -10016, y = -10017.5, z = 10018}
|
||||
|
||||
|
||||
// === LLDB TESTS ==================================================================================
|
||||
|
||||
|
@ -101,7 +98,6 @@
|
|||
// lldb-command:print padding_at_end
|
||||
// lldb-check:[...]$5 = PaddingAtEnd { x: -10014, y: 10015 }
|
||||
|
||||
#![feature(struct_inherit)];
|
||||
#![allow(unused_variable)];
|
||||
#![allow(dead_code)];
|
||||
|
||||
|
@ -110,7 +106,7 @@ struct NoPadding16 {
|
|||
y: i16
|
||||
}
|
||||
|
||||
virtual struct NoPadding32 {
|
||||
struct NoPadding32 {
|
||||
x: i32,
|
||||
y: f32,
|
||||
z: u32
|
||||
|
@ -173,11 +169,6 @@ static mut PADDING_AT_END: PaddingAtEnd = PaddingAtEnd {
|
|||
y: 14
|
||||
};
|
||||
|
||||
struct Inheriting : NoPadding32 {
|
||||
a: u16,
|
||||
b: i16
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let no_padding16 = NoPadding16 { x: 10000, y: -10001 };
|
||||
let no_padding32 = NoPadding32 { x: -10002, y: -10003.5, z: 10004 };
|
||||
|
@ -187,8 +178,6 @@ fn main() {
|
|||
let internal_padding = InternalPadding { x: 10012, y: -10013 };
|
||||
let padding_at_end = PaddingAtEnd { x: -10014, y: 10015 };
|
||||
|
||||
let inheriting = Inheriting { a: 10019, b: -10020, x: -10016, y: -10017.5, z: 10018 };
|
||||
|
||||
unsafe {
|
||||
NO_PADDING_16.x = 100;
|
||||
NO_PADDING_16.y = -101;
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance.
|
||||
#![feature(struct_inherit)]
|
||||
|
||||
virtual struct S1 {
|
||||
f1: int,
|
||||
}
|
||||
|
||||
virtual struct S2 : S1 {
|
||||
f2: int,
|
||||
}
|
||||
|
||||
struct S3 : S2 {
|
||||
f3: int,
|
||||
}
|
||||
|
||||
// With lifetime parameters.
|
||||
struct S5<'a> : S4<'a> {
|
||||
f4: int,
|
||||
}
|
||||
|
||||
virtual struct S4<'a> {
|
||||
f3: &'a int,
|
||||
}
|
||||
|
||||
// With type parameters.
|
||||
struct S7<T> : S6<T> {
|
||||
f4: int,
|
||||
}
|
||||
|
||||
virtual struct S6<T> {
|
||||
f3: T,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let s = S2{f1: 115, f2: 113};
|
||||
assert!(s.f1 == 115);
|
||||
assert!(s.f2 == 113);
|
||||
|
||||
let s = S3{f1: 15, f2: 13, f3: 17};
|
||||
assert!(s.f1 == 15);
|
||||
assert!(s.f2 == 13);
|
||||
assert!(s.f3 == 17);
|
||||
|
||||
let s = S5{f3: &5, f4: 3};
|
||||
assert!(*s.f3 == 5);
|
||||
assert!(s.f4 == 3);
|
||||
|
||||
let s = S7{f3: 5u, f4: 3};
|
||||
assert!(s.f3 == 5u);
|
||||
assert!(s.f4 == 3);
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
// 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.
|
||||
|
||||
// Test struct inheritance on structs from another crate.
|
||||
|
||||
// aux-build:inherit_struct_lib.rs
|
||||
extern crate inherit_struct_lib;
|
||||
|
||||
pub fn main() {
|
||||
let s = inherit_struct_lib::S2{f1: 115, f2: 113};
|
||||
assert!(s.f1 == 115);
|
||||
assert!(s.f2 == 113);
|
||||
|
||||
assert!(inherit_struct_lib::glob_s.f1 == 32);
|
||||
assert!(inherit_struct_lib::glob_s.f2 == -45);
|
||||
|
||||
inherit_struct_lib::test_s2(s);
|
||||
}
|
Loading…
Add table
Reference in a new issue