Skip to content

Commit c0230f4

Browse files
Flesh out tests
1 parent aebbd42 commit c0230f4

7 files changed

+101
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/incomplete-infer-via-sized-wc.rs:15:5
3+
|
4+
LL | is_sized::<MaybeSized<_>>();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `is_sized`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0282`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/incomplete-infer-via-sized-wc.rs:15:5
3+
|
4+
LL | is_sized::<MaybeSized<_>>();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `is_sized`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0282`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
5+
// Exercises change in <https://github.com/rust-lang/rust/pull/138176>.
6+
7+
struct MaybeSized<T: ?Sized>(T);
8+
9+
fn is_sized<T: Sized>() -> Box<T> { todo!() }
10+
11+
fn foo<T: ?Sized>()
12+
where
13+
MaybeSized<T>: Sized,
14+
{
15+
is_sized::<MaybeSized<_>>();
16+
//~^ ERROR type annotations needed
17+
}
18+
19+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//@ check-pass
2+
//@ revisions: current next
3+
//@ ignore-compare-mode-next-solver (explicit revisions)
4+
//@[next] compile-flags: -Znext-solver
5+
6+
// Exercises change in <https://github.com/rust-lang/rust/pull/138176>.
7+
8+
trait Trait<T>: Sized {}
9+
impl<T> Trait<T> for T {}
10+
11+
fn is_sized<T: Sized>() {}
12+
13+
fn normal_ref<'a, 'b, T>()
14+
where
15+
&'a u32: Trait<T>,
16+
{
17+
is_sized::<&'b u32>();
18+
}
19+
20+
struct MyRef<'a, U: ?Sized = ()>(&'a u32, U);
21+
fn my_ref<'a, 'b, T>()
22+
where
23+
MyRef<'a>: Trait<T>,
24+
{
25+
is_sized::<MyRef<'b>>();
26+
}
27+
28+
fn main() {}

tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.stderr renamed to tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.current.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
error[E0308]: mismatched types
2-
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:7:23
2+
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:13:23
33
|
44
LL | (MyType<'a, T>,): Sized,
55
| ^^^^^ lifetime mismatch
66
|
77
= note: expected trait `<MyType<'a, T> as Sized>`
88
found trait `<MyType<'static, T> as Sized>`
99
note: the lifetime `'a` as defined here...
10-
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:5:8
10+
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:11:8
1111
|
1212
LL | fn foo<'a, T: ?Sized>()
1313
| ^^
1414
= note: ...does not necessarily outlive the static lifetime
1515

1616
error: lifetime may not live long enough
17-
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:15:5
17+
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:22:5
1818
|
1919
LL | fn foo<'a, T: ?Sized>()
2020
| -- lifetime `'a` defined here
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0478]: lifetime bound not satisfied
2+
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:13:23
3+
|
4+
LL | (MyType<'a, T>,): Sized,
5+
| ^^^^^
6+
|
7+
note: lifetime parameter instantiated with the lifetime `'a` as defined here
8+
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:11:8
9+
|
10+
LL | fn foo<'a, T: ?Sized>()
11+
| ^^
12+
= note: but lifetime parameter must outlive the static lifetime
13+
14+
error: lifetime may not live long enough
15+
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:22:5
16+
|
17+
LL | fn foo<'a, T: ?Sized>()
18+
| -- lifetime `'a` defined here
19+
...
20+
LL | is_sized::<(MyType<'a, T>,)>();
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
22+
23+
error: aborting due to 2 previous errors
24+
25+
For more information about this error, try `rustc --explain E0478`.

tests/ui/traits/lifetime-incomplete-prefer-sized-builtin-over-wc.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
//@ revisions: current next
2+
//@ ignore-compare-mode-next-solver (explicit revisions)
3+
//@[next] compile-flags: -Znext-solver
4+
5+
// Exercises change in <https://github.com/rust-lang/rust/pull/138176>.
6+
17
struct MyType<'a, T: ?Sized>(&'a (), T);
28

39
fn is_sized<T>() {}
410

511
fn foo<'a, T: ?Sized>()
612
where
713
(MyType<'a, T>,): Sized,
8-
//~^ ERROR mismatched types
14+
//[current]~^ ERROR mismatched types
15+
//[next]~^^ ERROR lifetime bound not satisfied
916
MyType<'static, T>: Sized,
1017
{
1118
// Preferring the builtin `Sized` impl of tuples

0 commit comments

Comments
 (0)