Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lcnr committed Nov 9, 2023
1 parent e3850f4 commit 28e5c95
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-coroutine.rs:5:13
--> $DIR/recursive-coroutine.rs:7:13
|
LL | fn foo() -> impl Coroutine<Yield = (), Return = ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/impl-trait/recursive-coroutine.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0720]: cannot resolve opaque type
--> $DIR/recursive-coroutine.rs:7:13
|
LL | fn foo() -> impl Coroutine<Yield = (), Return = ()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ recursive opaque type
...
LL | let mut gen = Box::pin(foo());
| ------- coroutine captures itself here

error: aborting due to previous error

For more information about this error, try `rustc --explain E0720`.
2 changes: 2 additions & 0 deletions tests/ui/impl-trait/recursive-coroutine.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next
#![feature(coroutines, coroutine_trait)]

use std::ops::{Coroutine, CoroutineState};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error: opaque type's hidden type cannot be another opaque type from the same scope
--> $DIR/two_tait_defining_each_other.rs:12:5
--> $DIR/two_tait_defining_each_other.rs:16:5
|
LL | x // A's hidden type is `Bar`, because all the hidden types of `B` are compared with each other
| ^ one of the two opaque types used here has to be outside its defining scope
|
note: opaque type whose hidden type is being assigned
--> $DIR/two_tait_defining_each_other.rs:4:10
--> $DIR/two_tait_defining_each_other.rs:8:10
|
LL | type B = impl Foo;
| ^^^^^^^^
note: opaque type being used as hidden type
--> $DIR/two_tait_defining_each_other.rs:3:10
--> $DIR/two_tait_defining_each_other.rs:7:10
|
LL | type A = impl Foo;
| ^^^^^^^^
Expand Down
6 changes: 5 additions & 1 deletion tests/ui/impl-trait/two_tait_defining_each_other.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next
//[next] check-pass

#![feature(type_alias_impl_trait)]

type A = impl Foo;
Expand All @@ -10,7 +14,7 @@ fn muh(x: A) -> B {
return Bar; // B's hidden type is Bar
}
x // A's hidden type is `Bar`, because all the hidden types of `B` are compared with each other
//~^ ERROR opaque type's hidden type cannot be another opaque type
//[current]~^ ERROR opaque type's hidden type cannot be another opaque type
}

struct Bar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
error: unconstrained opaque type
--> $DIR/two_tait_defining_each_other2.rs:3:10
--> $DIR/two_tait_defining_each_other2.rs:5:10
|
LL | type A = impl Foo;
| ^^^^^^^^
|
= note: `A` must be used in combination with a concrete type within the same module

error: opaque type's hidden type cannot be another opaque type from the same scope
--> $DIR/two_tait_defining_each_other2.rs:9:5
--> $DIR/two_tait_defining_each_other2.rs:11:5
|
LL | x // B's hidden type is A (opaquely)
| ^ one of the two opaque types used here has to be outside its defining scope
|
note: opaque type whose hidden type is being assigned
--> $DIR/two_tait_defining_each_other2.rs:4:10
--> $DIR/two_tait_defining_each_other2.rs:6:10
|
LL | type B = impl Foo;
| ^^^^^^^^
note: opaque type being used as hidden type
--> $DIR/two_tait_defining_each_other2.rs:3:10
--> $DIR/two_tait_defining_each_other2.rs:5:10
|
LL | type A = impl Foo;
| ^^^^^^^^
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0284]: type annotations needed: cannot satisfy `A <: B`
--> $DIR/two_tait_defining_each_other2.rs:11:5
|
LL | x // B's hidden type is A (opaquely)
| ^ cannot satisfy `A <: B`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0284`.
7 changes: 5 additions & 2 deletions tests/ui/impl-trait/two_tait_defining_each_other2.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next
#![feature(type_alias_impl_trait)]

type A = impl Foo; //~ ERROR unconstrained opaque type
type A = impl Foo; //[current]~ ERROR unconstrained opaque type
type B = impl Foo;

trait Foo {}

fn muh(x: A) -> B {
x // B's hidden type is A (opaquely)
//~^ ERROR opaque type's hidden type cannot be another opaque type
//[current]~^ ERROR opaque type's hidden type cannot be another opaque type
//[next]~^^ ERROR type annotations needed: cannot satisfy `A <: B`
}

struct Bar;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error: opaque type's hidden type cannot be another opaque type from the same scope
--> $DIR/two_tait_defining_each_other3.rs:10:16
--> $DIR/two_tait_defining_each_other3.rs:13:16
|
LL | return x; // B's hidden type is A (opaquely)
| ^ one of the two opaque types used here has to be outside its defining scope
|
note: opaque type whose hidden type is being assigned
--> $DIR/two_tait_defining_each_other3.rs:4:10
--> $DIR/two_tait_defining_each_other3.rs:7:10
|
LL | type B = impl Foo;
| ^^^^^^^^
note: opaque type being used as hidden type
--> $DIR/two_tait_defining_each_other3.rs:3:10
--> $DIR/two_tait_defining_each_other3.rs:6:10
|
LL | type A = impl Foo;
| ^^^^^^^^
Expand Down
5 changes: 4 additions & 1 deletion tests/ui/impl-trait/two_tait_defining_each_other3.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next
//[next] check-pass
#![feature(type_alias_impl_trait)]

type A = impl Foo;
Expand All @@ -8,7 +11,7 @@ trait Foo {}
fn muh(x: A) -> B {
if false {
return x; // B's hidden type is A (opaquely)
//~^ ERROR opaque type's hidden type cannot be another opaque type
//[current]~^ ERROR opaque type's hidden type cannot be another opaque type
}
Bar // A's hidden type is `Bar`, because all the return types are compared with each other
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// check-pass
// compile-flags: -Ztrait-solver=next

fn test<T: Iterator>(x: T::Item) -> impl Sized {
x
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
WARN rustc_trait_selection::traits::coherence expected an unknowable trait ref: <<LocalTy as Overflow>::Assoc as std::marker::Sized>
WARN rustc_trait_selection::traits::coherence expected an unknowable trait ref: <<LocalTy as Overflow>::Assoc as std::marker::Sized>
WARN rustc_trait_selection::traits::coherence expected an unknowable trait ref: <<LocalTy as Overflow>::Assoc as std::marker::Sized>
WARN rustc_trait_selection::traits::coherence expected an unknowable trait ref: <<LocalTy as Overflow>::Assoc as std::marker::Sized>
error[E0119]: conflicting implementations of trait `Trait` for type `<LocalTy as Overflow>::Assoc`
--> $DIR/trait_ref_is_knowable-norm-overflow.rs:17:1
|
Expand All @@ -11,7 +7,8 @@ LL | struct LocalTy;
LL | impl Trait for <LocalTy as Overflow>::Assoc {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<LocalTy as Overflow>::Assoc`
|
= note: upstream crates may add a new impl of trait `std::marker::Copy` for type `<LocalTy as Overflow>::Assoc` in future versions
= note: downstream crates may implement trait `std::marker::Sized` for type `<LocalTy as Overflow>::Assoc`
= note: downstream crates may implement trait `std::marker::Copy` for type `<LocalTy as Overflow>::Assoc`

error: aborting due to previous error

Expand Down
4 changes: 3 additions & 1 deletion tests/ui/type-alias-impl-trait/assoc-type-const.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Tests that we properly detect defining usages when using
// const generics in an associated opaque type
// check-pass

// check-pass
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next
#![feature(impl_trait_in_assoc_type)]

trait UnwrapItemsExt<'a, const C: usize> {
Expand Down
2 changes: 2 additions & 0 deletions tests/ui/type-alias-impl-trait/issue-78450.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// check-pass
// revisions: current next
//[next] compile-flags: -Ztrait-solver=next

#![feature(impl_trait_in_assoc_type)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0309]: the parameter type `T` may not live long enough
--> $DIR/wf-in-associated-type.rs:36:23
--> $DIR/wf-in-associated-type.rs:38:23
|
LL | impl<'a, T> Trait<'a, T> for () {
| -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
Expand All @@ -12,7 +12,7 @@ LL | impl<'a, T: 'a> Trait<'a, T> for () {
| ++++

error[E0309]: the parameter type `T` may not live long enough
--> $DIR/wf-in-associated-type.rs:36:23
--> $DIR/wf-in-associated-type.rs:38:23
|
LL | impl<'a, T> Trait<'a, T> for () {
| -- the parameter type `T` must be valid for the lifetime `'a` as defined here...
Expand Down
6 changes: 4 additions & 2 deletions tests/ui/type-alias-impl-trait/wf-in-associated-type.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// WF check for impl Trait in associated type position.
//
// revisions: pass fail
// revisions: pass pass_next fail
// [pass] check-pass
// [pass_next] compile-flags: -Ztrait-solver=next
// [pass_next] check-pass
// [fail] check-fail

#![feature(impl_trait_in_assoc_type)]

// The hidden type here (`&'a T`) requires proving `T: 'a`.
// We know it holds because of implied bounds from the impl header.
#[cfg(pass)]
#[cfg(any(pass, pass_next))]
mod pass {
trait Trait<Req> {
type Opaque1;
Expand Down

0 comments on commit 28e5c95

Please sign in to comment.