Flesh out tests
This commit is contained in:
parent
aebbd42460
commit
c0230f4a29
7 changed files with 101 additions and 4 deletions
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0282]: type annotations needed
|
||||||
|
--> $DIR/incomplete-infer-via-sized-wc.rs:15:5
|
||||||
|
|
|
||||||
|
LL | is_sized::<MaybeSized<_>>();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `is_sized`
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0282`.
|
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0282]: type annotations needed
|
||||||
|
--> $DIR/incomplete-infer-via-sized-wc.rs:15:5
|
||||||
|
|
|
||||||
|
LL | is_sized::<MaybeSized<_>>();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `is_sized`
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0282`.
|
19
tests/ui/traits/incomplete-infer-via-sized-wc.rs
Normal file
19
tests/ui/traits/incomplete-infer-via-sized-wc.rs
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
//@ revisions: current next
|
||||||
|
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||||
|
//@[next] compile-flags: -Znext-solver
|
||||||
|
|
||||||
|
// Exercises change in <https://github.com/rust-lang/rust/pull/138176>.
|
||||||
|
|
||||||
|
struct MaybeSized<T: ?Sized>(T);
|
||||||
|
|
||||||
|
fn is_sized<T: Sized>() -> Box<T> { todo!() }
|
||||||
|
|
||||||
|
fn foo<T: ?Sized>()
|
||||||
|
where
|
||||||
|
MaybeSized<T>: Sized,
|
||||||
|
{
|
||||||
|
is_sized::<MaybeSized<_>>();
|
||||||
|
//~^ ERROR type annotations needed
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -0,0 +1,28 @@
|
||||||
|
//@ check-pass
|
||||||
|
//@ revisions: current next
|
||||||
|
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||||
|
//@[next] compile-flags: -Znext-solver
|
||||||
|
|
||||||
|
// Exercises change in <https://github.com/rust-lang/rust/pull/138176>.
|
||||||
|
|
||||||
|
trait Trait<T>: Sized {}
|
||||||
|
impl<T> Trait<T> for T {}
|
||||||
|
|
||||||
|
fn is_sized<T: Sized>() {}
|
||||||
|
|
||||||
|
fn normal_ref<'a, 'b, T>()
|
||||||
|
where
|
||||||
|
&'a u32: Trait<T>,
|
||||||
|
{
|
||||||
|
is_sized::<&'b u32>();
|
||||||
|
}
|
||||||
|
|
||||||
|
struct MyRef<'a, U: ?Sized = ()>(&'a u32, U);
|
||||||
|
fn my_ref<'a, 'b, T>()
|
||||||
|
where
|
||||||
|
MyRef<'a>: Trait<T>,
|
||||||
|
{
|
||||||
|
is_sized::<MyRef<'b>>();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:7:23
|
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:13:23
|
||||||
|
|
|
|
||||||
LL | (MyType<'a, T>,): Sized,
|
LL | (MyType<'a, T>,): Sized,
|
||||||
| ^^^^^ lifetime mismatch
|
| ^^^^^ lifetime mismatch
|
||||||
|
@ -7,14 +7,14 @@ LL | (MyType<'a, T>,): Sized,
|
||||||
= note: expected trait `<MyType<'a, T> as Sized>`
|
= note: expected trait `<MyType<'a, T> as Sized>`
|
||||||
found trait `<MyType<'static, T> as Sized>`
|
found trait `<MyType<'static, T> as Sized>`
|
||||||
note: the lifetime `'a` as defined here...
|
note: the lifetime `'a` as defined here...
|
||||||
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:5:8
|
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:11:8
|
||||||
|
|
|
|
||||||
LL | fn foo<'a, T: ?Sized>()
|
LL | fn foo<'a, T: ?Sized>()
|
||||||
| ^^
|
| ^^
|
||||||
= note: ...does not necessarily outlive the static lifetime
|
= note: ...does not necessarily outlive the static lifetime
|
||||||
|
|
||||||
error: lifetime may not live long enough
|
error: lifetime may not live long enough
|
||||||
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:15:5
|
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:22:5
|
||||||
|
|
|
|
||||||
LL | fn foo<'a, T: ?Sized>()
|
LL | fn foo<'a, T: ?Sized>()
|
||||||
| -- lifetime `'a` defined here
|
| -- lifetime `'a` defined here
|
|
@ -0,0 +1,25 @@
|
||||||
|
error[E0478]: lifetime bound not satisfied
|
||||||
|
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:13:23
|
||||||
|
|
|
||||||
|
LL | (MyType<'a, T>,): Sized,
|
||||||
|
| ^^^^^
|
||||||
|
|
|
||||||
|
note: lifetime parameter instantiated with the lifetime `'a` as defined here
|
||||||
|
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:11:8
|
||||||
|
|
|
||||||
|
LL | fn foo<'a, T: ?Sized>()
|
||||||
|
| ^^
|
||||||
|
= note: but lifetime parameter must outlive the static lifetime
|
||||||
|
|
||||||
|
error: lifetime may not live long enough
|
||||||
|
--> $DIR/lifetime-incomplete-prefer-sized-builtin-over-wc.rs:22:5
|
||||||
|
|
|
||||||
|
LL | fn foo<'a, T: ?Sized>()
|
||||||
|
| -- lifetime `'a` defined here
|
||||||
|
...
|
||||||
|
LL | is_sized::<(MyType<'a, T>,)>();
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0478`.
|
|
@ -1,3 +1,9 @@
|
||||||
|
//@ revisions: current next
|
||||||
|
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||||
|
//@[next] compile-flags: -Znext-solver
|
||||||
|
|
||||||
|
// Exercises change in <https://github.com/rust-lang/rust/pull/138176>.
|
||||||
|
|
||||||
struct MyType<'a, T: ?Sized>(&'a (), T);
|
struct MyType<'a, T: ?Sized>(&'a (), T);
|
||||||
|
|
||||||
fn is_sized<T>() {}
|
fn is_sized<T>() {}
|
||||||
|
@ -5,7 +11,8 @@ fn is_sized<T>() {}
|
||||||
fn foo<'a, T: ?Sized>()
|
fn foo<'a, T: ?Sized>()
|
||||||
where
|
where
|
||||||
(MyType<'a, T>,): Sized,
|
(MyType<'a, T>,): Sized,
|
||||||
//~^ ERROR mismatched types
|
//[current]~^ ERROR mismatched types
|
||||||
|
//[next]~^^ ERROR lifetime bound not satisfied
|
||||||
MyType<'static, T>: Sized,
|
MyType<'static, T>: Sized,
|
||||||
{
|
{
|
||||||
// Preferring the builtin `Sized` impl of tuples
|
// Preferring the builtin `Sized` impl of tuples
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue