Skip to content

Commit 5c95e77

Browse files
Fix tests
Co-authored-by: Ali MJ Al-Nasrawy <[email protected]>
1 parent d0c826c commit 5c95e77

6 files changed

+21
-24
lines changed

tests/ui/type-alias-impl-trait/coherence.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ fn use_alias<T>(val: T) -> AliasOfForeignType<T> {
1111
foreign_crate::ForeignType(val)
1212
}
1313

14-
impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {}
15-
//~^ ERROR the type parameter `T` is not constrained by the impl trait, self type, or predicates
14+
impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {}
15+
//~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
1616

1717
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1-
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2-
--> $DIR/coherence.rs:14:6
1+
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
2+
--> $DIR/coherence.rs:14:1
33
|
4-
LL | impl<T> foreign_crate::ForeignTrait for AliasOfForeignType<T> {}
5-
| ^ unconstrained type parameter
4+
LL | impl foreign_crate::ForeignTrait for AliasOfForeignType<()> {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------
6+
| | |
7+
| | `AliasOfForeignType<()>` is not defined in the current crate
8+
| impl doesn't use only types from inside the current crate
9+
|
10+
= note: define and implement a trait or new type instead
611

712
error: aborting due to previous error
813

9-
For more information about this error, try `rustc --explain E0207`.
14+
For more information about this error, try `rustc --explain E0117`.
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// check-pass
2+
13
// FIXME(type_alias_impl_trait): What does this test? This needs a comment
24
// explaining what we're worried about here.
35

@@ -8,8 +10,7 @@ fn foo<T>() -> Opaque<T> {
810
()
911
}
1012

11-
impl<T, V> Trait for (T, V, V, u32) {}
12-
impl<U, V> Trait for (Opaque<U>, V, i32, V) {}
13-
//~^ ERROR the type parameter `U` is not constrained by the impl trait, self type, or predicates
13+
impl<T, U, V> Trait for (T, U, V, V, u32) {}
14+
impl<U, V> Trait for (Opaque<U>, U, V, i32, V) {}
1415

1516
fn main() {}

tests/ui/type-alias-impl-trait/coherence_generalization.stderr

-9
This file was deleted.

tests/ui/type-alias-impl-trait/unconstrained-impl-param.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
use std::fmt::Display;
44

5-
type Opaque<'a> = impl Sized + 'static;
6-
fn define<'a>() -> Opaque<'a> {}
5+
type Opaque<X> = impl Sized + 'static;
6+
fn define<X>() -> Opaque<X> {}
77

88
trait Trait {
99
type Assoc: Display;
1010
}
11-
impl<'a> Trait for Opaque<'a> {
11+
impl<'a> Trait for Opaque<&'a str> {
1212
//~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
1313
type Assoc = &'a str;
1414
}
@@ -20,6 +20,6 @@ fn extend<T: Trait + 'static>(s: T::Assoc) -> Box<dyn Display> {
2020
}
2121

2222
fn main() {
23-
let val = extend::<Opaque<'_>>(&String::from("blah blah blah"));
23+
let val = extend::<Opaque<&'_ str>>(&String::from("blah blah blah"));
2424
println!("{}", val);
2525
}

tests/ui/type-alias-impl-trait/unconstrained-impl-param.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
22
--> $DIR/unconstrained-impl-param.rs:11:6
33
|
4-
LL | impl<'a> Trait for Opaque<'a> {
4+
LL | impl<'a> Trait for Opaque<&'a str> {
55
| ^^ unconstrained lifetime parameter
66

77
error: aborting due to previous error

0 commit comments

Comments
 (0)