Skip to content

Commit 1eefab4

Browse files
committed
Fix tests for DynSized
1 parent 2d3e2b5 commit 1eefab4

17 files changed

+66
-146
lines changed

src/test/compile-fail/auxiliary/tdticc_coherence_lib.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(optin_builtin_traits, core)]
11+
#![feature(dynsized, optin_builtin_traits)]
1212
#![crate_type = "rlib"]
1313

14-
pub trait DefaultedTrait { }
14+
use std::marker::DynSized;
15+
16+
pub trait DefaultedTrait: ?DynSized { }
1517
impl DefaultedTrait for .. { }
1618

1719
pub struct Something<T> { t: T }

src/test/compile-fail/extern-types-not-sync-send.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@
1010

1111
// Make sure extern types are !Sync and !Send.
1212

13-
#![feature(extern_types)]
13+
#![feature(dynsized, extern_types)]
14+
15+
use std::marker::DynSized;
1416

1517
extern {
1618
type A;
1719
}
1820

19-
fn assert_sync<T: ?Sized + Sync>() { }
20-
fn assert_send<T: ?Sized + Send>() { }
21+
fn assert_sync<T: ?DynSized + Sync>() { }
22+
fn assert_send<T: ?DynSized + Send>() { }
2123

2224
fn main() {
2325
assert_sync::<A>();

src/test/compile-fail/extern-types-unsized.rs

+4-19
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,21 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Make sure extern types are !Sized.
11+
// Make sure extern types are !Sized and !DynSized.
1212

1313
#![feature(extern_types)]
1414

1515
extern {
1616
type A;
1717
}
1818

19-
struct Foo {
20-
x: u8,
21-
tail: A,
22-
}
23-
24-
struct Bar<T: ?Sized> {
25-
x: u8,
26-
tail: T,
27-
}
28-
2919
fn assert_sized<T>() { }
20+
fn assert_dynsized<T: ?Sized>() { }
3021

3122
fn main() {
3223
assert_sized::<A>();
3324
//~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied
3425

35-
assert_sized::<Foo>();
36-
//~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied
37-
38-
assert_sized::<Bar<A>>();
39-
//~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied
40-
41-
assert_sized::<Bar<Bar<A>>>();
42-
//~^ ERROR the trait bound `A: std::marker::Sized` is not satisfied
26+
assert_dynsized::<A>();
27+
//~^ ERROR the trait bound `A: std::marker::DynSized` is not satisfied
4328
}

src/test/compile-fail/maybe-bounds.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
trait Tr: ?Sized {} //~ ERROR `?Trait` is not permitted in supertraits
11+
#![feature(dynsized)]
12+
13+
use std::marker::DynSized;
14+
15+
trait Tr: ?Sized {} //~ ERROR `?Sized` is not permitted in supertraits
1216
//~^ NOTE traits are `?Sized` by default
1317

1418
type A1 = Tr + ?Sized; //~ ERROR `?Trait` is not permitted in trait object types
15-
type A2 = for<'a> Tr + ?Sized; //~ ERROR `?Trait` is not permitted in trait object types
19+
type A2 = Tr + ?DynSized; //~ ERROR `?Trait` is not permitted in trait object types
20+
type A3 = for<'a> Tr + ?Sized; //~ ERROR `?Trait` is not permitted in trait object types
1621

1722
fn main() {}

src/test/compile-fail/phantom-oibit.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
// the `PhantomData<T>` type itself (which almost always implements a "default" trait
1313
// (`impl Trait for ..`))
1414

15-
#![feature(optin_builtin_traits)]
15+
#![feature(dynsized, optin_builtin_traits)]
1616

17-
use std::marker::{PhantomData};
17+
use std::marker::{DynSized, PhantomData};
1818

19-
unsafe trait Zen {}
19+
unsafe trait Zen: ?DynSized {}
2020

2121
unsafe impl Zen for .. {}
2222

src/test/compile-fail/privacy-sanity.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(optin_builtin_traits)]
11+
#![feature(dynsized, optin_builtin_traits)]
1212

13-
trait MarkerTr {}
13+
use std::marker::DynSized;
14+
15+
trait MarkerTr: ?DynSized {}
1416
pub trait Tr {
1517
fn f();
1618
const C: u8;
@@ -38,7 +40,7 @@ pub extern "C" { //~ ERROR unnecessary visibility qualifier
3840
}
3941

4042
const MAIN: u8 = {
41-
trait MarkerTr {}
43+
trait MarkerTr: ?DynSized {}
4244
pub trait Tr {
4345
fn f();
4446
const C: u8;
@@ -69,7 +71,7 @@ const MAIN: u8 = {
6971
};
7072

7173
fn main() {
72-
trait MarkerTr {}
74+
trait MarkerTr: ?DynSized {}
7375
pub trait Tr {
7476
fn f();
7577
const C: u8;

src/test/compile-fail/typeck-default-trait-impl-constituent-types-2.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(optin_builtin_traits)]
11+
#![feature(dynsized, optin_builtin_traits)]
1212

13-
trait MyTrait {}
13+
use std::marker::DynSized;
14+
15+
trait MyTrait: ?DynSized {}
1416

1517
impl MyTrait for .. {}
1618

src/test/compile-fail/typeck-default-trait-impl-constituent-types.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(optin_builtin_traits)]
11+
#![feature(dynsized, optin_builtin_traits)]
1212

13-
trait MyTrait {}
13+
use std::marker::DynSized;
14+
15+
trait MyTrait: ?DynSized {}
1416

1517
impl MyTrait for .. {}
1618
impl<T> !MyTrait for *mut T {}

src/test/compile-fail/typeck-default-trait-impl-negation.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(optin_builtin_traits)]
11+
#![feature(dynsized, optin_builtin_traits)]
1212

13-
trait MyTrait {}
13+
use std::marker::DynSized;
14+
15+
trait MyTrait: ?DynSized {}
1416

1517
impl MyTrait for .. {}
1618

17-
unsafe trait MyUnsafeTrait {}
19+
unsafe trait MyUnsafeTrait: ?DynSized {}
1820

1921
unsafe impl MyUnsafeTrait for .. {}
2022

src/test/compile-fail/typeck-default-trait-impl-precedence.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
// other words, the `..` impl only applies if there are no existing
1414
// impls whose types unify.
1515

16-
#![feature(optin_builtin_traits)]
16+
#![feature(dynsized, optin_builtin_traits)]
1717

18-
trait Defaulted { }
18+
use std::marker::DynSized;
19+
20+
trait Defaulted: ?DynSized { }
1921
impl Defaulted for .. { }
2022
impl<'a,T:Signed> Defaulted for &'a T { }
2123
impl<'a,T:Signed> Defaulted for &'a mut T { }

src/test/run-pass/extern-types-manual-sync-send.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
// Test that unsafe impl for Sync/Send can be provided for extern types.
1212

13-
#![feature(extern_types)]
13+
#![feature(dynsized, extern_types)]
14+
15+
use std::marker::DynSized;
1416

1517
extern {
1618
type A;
@@ -19,8 +21,8 @@ extern {
1921
unsafe impl Sync for A { }
2022
unsafe impl Send for A { }
2123

22-
fn assert_sync<T: ?Sized + Sync>() { }
23-
fn assert_send<T: ?Sized + Send>() { }
24+
fn assert_sync<T: ?DynSized + Sync>() { }
25+
fn assert_send<T: ?DynSized + Send>() { }
2426

2527
fn main() {
2628
assert_sync::<A>();

src/test/run-pass/extern-types-pointer-cast.rs

-13
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,11 @@ extern {
1717
type A;
1818
}
1919

20-
struct Foo {
21-
x: u8,
22-
tail: A,
23-
}
24-
25-
struct Bar<T: ?Sized> {
26-
x: u8,
27-
tail: T,
28-
}
29-
3020
#[cfg(target_pointer_width = "32")]
3121
const MAGIC: usize = 0xdeadbeef;
3222
#[cfg(target_pointer_width = "64")]
3323
const MAGIC: usize = 0x12345678deadbeef;
3424

3525
fn main() {
3626
assert_eq!((MAGIC as *const A) as usize, MAGIC);
37-
assert_eq!((MAGIC as *const Foo) as usize, MAGIC);
38-
assert_eq!((MAGIC as *const Bar<A>) as usize, MAGIC);
39-
assert_eq!((MAGIC as *const Bar<Bar<A>>) as usize, MAGIC);
4027
}

src/test/run-pass/extern-types-size_of_val.rs

-26
This file was deleted.

src/test/run-pass/extern-types-thin-pointer.rs

+9-26
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,16 @@ extern {
1919
type A;
2020
}
2121

22-
struct Foo {
23-
x: u8,
24-
tail: A,
25-
}
26-
27-
struct Bar<T: ?Sized> {
28-
x: u8,
29-
tail: T,
30-
}
31-
32-
fn assert_thin<T: ?Sized>() {
33-
assert_eq!(size_of::<*const T>(), size_of::<*const ()>());
34-
assert_eq!(align_of::<*const T>(), align_of::<*const ()>());
35-
36-
assert_eq!(size_of::<*mut T>(), size_of::<*mut ()>());
37-
assert_eq!(align_of::<*mut T>(), align_of::<*mut ()>());
22+
fn main() {
23+
assert_eq!(size_of::<*const A>(), size_of::<*const ()>());
24+
assert_eq!(align_of::<*const A>(), align_of::<*const ()>());
3825

39-
assert_eq!(size_of::<&T>(), size_of::<&()>());
40-
assert_eq!(align_of::<&T>(), align_of::<&()>());
26+
assert_eq!(size_of::<*mut A>(), size_of::<*mut ()>());
27+
assert_eq!(align_of::<*mut A>(), align_of::<*mut ()>());
4128

42-
assert_eq!(size_of::<&mut T>(), size_of::<&mut ()>());
43-
assert_eq!(align_of::<&mut T>(), align_of::<&mut ()>());
44-
}
29+
assert_eq!(size_of::<&A>(), size_of::<&()>());
30+
assert_eq!(align_of::<&A>(), align_of::<&()>());
4531

46-
fn main() {
47-
assert_thin::<A>();
48-
assert_thin::<Foo>();
49-
assert_thin::<Bar<A>>();
50-
assert_thin::<Bar<Bar<A>>>();
32+
assert_eq!(size_of::<&mut A>(), size_of::<&mut ()>());
33+
assert_eq!(align_of::<&mut A>(), align_of::<&mut ()>());
5134
}

src/test/run-pass/issue-29516.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(optin_builtin_traits)]
11+
#![feature(dynsized, optin_builtin_traits)]
1212

13-
trait NotSame {}
13+
use std::marker::DynSized;
14+
15+
trait NotSame: ?DynSized {}
1416
impl NotSame for .. {}
1517
impl<A> !NotSame for (A, A) {}
1618

src/test/ui/on-unimplemented/multiple-impls.stderr

+1-25
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
77
= help: the trait `Index<u32>` is not implemented for `[i32]`
88
= note: required by `Index::index`
99

10-
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
11-
--> $DIR/multiple-impls.rs:43:5
12-
|
13-
43 | Index::index(&[] as &[i32], 2u32);
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait message
15-
|
16-
= help: the trait `Index<u32>` is not implemented for `[i32]`
17-
1810
error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied
1911
--> $DIR/multiple-impls.rs:49:5
2012
|
@@ -24,14 +16,6 @@ error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied
2416
= help: the trait `Index<Foo<u32>>` is not implemented for `[i32]`
2517
= note: required by `Index::index`
2618

27-
error[E0277]: the trait bound `[i32]: Index<Foo<u32>>` is not satisfied
28-
--> $DIR/multiple-impls.rs:49:5
29-
|
30-
49 | Index::index(&[] as &[i32], Foo(2u32));
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ on impl for Foo
32-
|
33-
= help: the trait `Index<Foo<u32>>` is not implemented for `[i32]`
34-
3519
error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied
3620
--> $DIR/multiple-impls.rs:55:5
3721
|
@@ -41,13 +25,5 @@ error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied
4125
= help: the trait `Index<Bar<u32>>` is not implemented for `[i32]`
4226
= note: required by `Index::index`
4327

44-
error[E0277]: the trait bound `[i32]: Index<Bar<u32>>` is not satisfied
45-
--> $DIR/multiple-impls.rs:55:5
46-
|
47-
55 | Index::index(&[] as &[i32], Bar(2u32));
48-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ on impl for Bar
49-
|
50-
= help: the trait `Index<Bar<u32>>` is not implemented for `[i32]`
51-
52-
error: aborting due to 6 previous errors
28+
error: aborting due to 3 previous errors
5329

src/test/ui/on-unimplemented/on-impl.stderr

+1-9
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,5 @@ error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
77
= help: the trait `Index<u32>` is not implemented for `[i32]`
88
= note: required by `Index::index`
99

10-
error[E0277]: the trait bound `[i32]: Index<u32>` is not satisfied
11-
--> $DIR/on-impl.rs:32:5
12-
|
13-
32 | Index::<u32>::index(&[1, 2, 3] as &[i32], 2u32);
14-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice
15-
|
16-
= help: the trait `Index<u32>` is not implemented for `[i32]`
17-
18-
error: aborting due to 2 previous errors
10+
error: aborting due to previous error
1911

0 commit comments

Comments
 (0)