Skip to content

Commit 05b209d

Browse files
Rollup merge of #142417 - Kivooeo:tf12, r=jieyouxu
`tests/ui`: A New Order [12/N] Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of #133895. r? `@jieyouxu`
2 parents 15b227f + aac948b commit 05b209d

18 files changed

+162
-145
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Regression test for issue #22077
2+
//! lifetime parameters must be constrained in associated type definitions
3+
4+
trait Fun {
5+
type Output;
6+
fn call<'x>(&'x self) -> Self::Output;
7+
}
8+
9+
struct Holder {
10+
x: String,
11+
}
12+
13+
impl<'a> Fun for Holder {
14+
//~^ ERROR E0207
15+
type Output = &'a str;
16+
fn call<'b>(&'b self) -> &'b str {
17+
&self.x[..]
18+
}
19+
}
20+
21+
fn main() {}

tests/ui/impl-unused-rps-in-assoc-type.stderr renamed to tests/ui/associated-types/unconstrained-lifetime-assoc-type.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
2-
--> $DIR/impl-unused-rps-in-assoc-type.rs:11:6
2+
--> $DIR/unconstrained-lifetime-assoc-type.rs:13:6
33
|
44
LL | impl<'a> Fun for Holder {
55
| ^^ unconstrained lifetime parameter

tests/ui/inline-disallow-on-variant.rs renamed to tests/ui/attributes/inline-attribute-enum-variant-error.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Test that #[inline] attribute cannot be applied to enum variants
2+
13
enum Foo {
24
#[inline]
35
//~^ ERROR attribute should be applied

tests/ui/inline-disallow-on-variant.stderr renamed to tests/ui/attributes/inline-attribute-enum-variant-error.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0518]: attribute should be applied to function or closure
2-
--> $DIR/inline-disallow-on-variant.rs:2:5
2+
--> $DIR/inline-attribute-enum-variant-error.rs:4:5
33
|
44
LL | #[inline]
55
| ^^^^^^^^^

tests/ui/attributes/inline-main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//! Test that #[inline(always)] can be applied to main function
2+
3+
//@ run-pass
4+
5+
#[inline(always)]
6+
fn main() {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Test for unconstrained type parameters in inherent implementations
2+
3+
struct MyType;
4+
5+
struct MyType1<T>(T);
6+
7+
trait Bar {
8+
type Out;
9+
}
10+
11+
impl<T> MyType {
12+
//~^ ERROR the type parameter `T` is not constrained
13+
// T is completely unused - this should fail
14+
}
15+
16+
impl<T> MyType1<T> {
17+
// OK: T is used in the self type `MyType1<T>`
18+
}
19+
20+
impl<T, U> MyType1<T> {
21+
//~^ ERROR the type parameter `U` is not constrained
22+
// T is used in self type, but U is unconstrained - this should fail
23+
}
24+
25+
impl<T, U> MyType1<T>
26+
where
27+
T: Bar<Out = U>,
28+
{
29+
// OK: T is used in self type, U is constrained through the where clause
30+
}
31+
32+
fn main() {}

tests/ui/impl-unused-tps-inherent.stderr renamed to tests/ui/generics/unconstrained-type-params-inherent-impl.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates
2-
--> $DIR/impl-unused-tps-inherent.rs:9:6
2+
--> $DIR/unconstrained-type-params-inherent-impl.rs:11:6
33
|
44
LL | impl<T> MyType {
55
| ^ unconstrained type parameter
66

77
error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates
8-
--> $DIR/impl-unused-tps-inherent.rs:17:8
8+
--> $DIR/unconstrained-type-params-inherent-impl.rs:20:9
99
|
10-
LL | impl<T,U> MyType1<T> {
11-
| ^ unconstrained type parameter
10+
LL | impl<T, U> MyType1<T> {
11+
| ^ unconstrained type parameter
1212

1313
error: aborting due to 2 previous errors
1414

tests/ui/impl-unused-rps-in-assoc-type.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/ui/impl-unused-tps-inherent.rs

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/ui/implicit-method-bind.rs

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)