Fix tests

Co-authored-by: Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>
This commit is contained in:
Michael Goulet
2023-08-12 10:13:47 -07:00
parent d0c826cfc2
commit 5c95e7743b
6 changed files with 21 additions and 24 deletions

View File

@@ -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() {}

View File

@@ -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`.

View File

@@ -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() {}

View File

@@ -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`.

View File

@@ -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);
}

View File

@@ -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