diff options
| author | Michael Goulet <michael@errs.io> | 2023-08-12 10:13:47 -0700 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-08-12 17:18:46 +0000 |
| commit | 5c95e7743bd488d575d914ec79c29dff884d0865 (patch) | |
| tree | f5af1fb16bf1f3ffd905dbb169adfadef65800aa | |
| parent | d0c826cfc2a1d52061a5c72d2dd78a06b51374ce (diff) | |
| download | rust-5c95e7743bd488d575d914ec79c29dff884d0865.tar.gz rust-5c95e7743bd488d575d914ec79c29dff884d0865.zip | |
Fix tests
Co-authored-by: Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>
6 files changed, 21 insertions, 24 deletions
diff --git a/tests/ui/type-alias-impl-trait/coherence.rs b/tests/ui/type-alias-impl-trait/coherence.rs index 1c0f83d6c12..1700c800e31 100644 --- a/tests/ui/type-alias-impl-trait/coherence.rs +++ b/tests/ui/type-alias-impl-trait/coherence.rs @@ -11,7 +11,7 @@ fn use_alias<T>(val: T) -> AliasOfForeignType<T> { foreign_crate::ForeignType(val) } -impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {} -//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates +impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {} +//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types fn main() {} diff --git a/tests/ui/type-alias-impl-trait/coherence.stderr b/tests/ui/type-alias-impl-trait/coherence.stderr index 6ede0fa14ba..36bbb985ef0 100644 --- a/tests/ui/type-alias-impl-trait/coherence.stderr +++ b/tests/ui/type-alias-impl-trait/coherence.stderr @@ -1,9 +1,14 @@ -error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates - --> $DIR/coherence.rs:14:6 +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/coherence.rs:14:1 | -LL | impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {} - | ^ unconstrained type parameter +LL | impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------------------- + | | | + | | `AliasOfForeignType<()>` is not defined in the current crate + | impl doesn't use only types from inside the current crate + | + = note: define and implement a trait or new type instead error: aborting due to previous error -For more information about this error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0117`. diff --git a/tests/ui/type-alias-impl-trait/coherence_generalization.rs b/tests/ui/type-alias-impl-trait/coherence_generalization.rs index 0e9e0e23270..1ec8877eaeb 100644 --- a/tests/ui/type-alias-impl-trait/coherence_generalization.rs +++ b/tests/ui/type-alias-impl-trait/coherence_generalization.rs @@ -1,3 +1,5 @@ +// check-pass + // FIXME(type_alias_impl_trait): What does this test? This needs a comment // explaining what we're worried about here. @@ -8,8 +10,7 @@ fn foo<T>() -> Opaque<T> { () } -impl<T, V> Trait for (T, V, V, u32) {} -impl<U, V> Trait for (Opaque<U>, V, i32, V) {} -//~^ ERROR the type parameter `U` is not constrained by the impl trait, self type, or predicates +impl<T, U, V> Trait for (T, U, V, V, u32) {} +impl<U, V> Trait for (Opaque<U>, U, V, i32, V) {} fn main() {} diff --git a/tests/ui/type-alias-impl-trait/coherence_generalization.stderr b/tests/ui/type-alias-impl-trait/coherence_generalization.stderr deleted file mode 100644 index d5148fbdacf..00000000000 --- a/tests/ui/type-alias-impl-trait/coherence_generalization.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/coherence_generalization.rs:12:6 - | -LL | impl<U, V> Trait for (Opaque<U>, V, i32, V) {} - | ^ unconstrained type parameter - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs index 288e7d34b48..b3510067047 100644 --- a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs +++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs @@ -2,13 +2,13 @@ use std::fmt::Display; -type Opaque<'a> = impl Sized + 'static; -fn define<'a>() -> Opaque<'a> {} +type Opaque<X> = impl Sized + 'static; +fn define<X>() -> Opaque<X> {} trait Trait { type Assoc: Display; } -impl<'a> Trait for Opaque<'a> { +impl<'a> Trait for Opaque<&'a str> { //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates type Assoc = &'a str; } @@ -20,6 +20,6 @@ fn extend<T: Trait + 'static>(s: T::Assoc) -> Box<dyn Display> { } fn main() { - let val = extend::<Opaque<'_>>(&String::from("blah blah blah")); + let val = extend::<Opaque<&'_ str>>(&String::from("blah blah blah")); println!("{}", val); } diff --git a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr index 6fe265c5e20..65139307f8e 100644 --- a/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr +++ b/tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr @@ -1,7 +1,7 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates --> $DIR/unconstrained-impl-param.rs:11:6 | -LL | impl<'a> Trait for Opaque<'a> { +LL | impl<'a> Trait for Opaque<&'a str> { | ^^ unconstrained lifetime parameter error: aborting due to previous error |
