Skip to content

Commit fa9ebfc

Browse files
committed
move compile-fail tests to ui tests
gets more comprehensive coverage in `ui`
1 parent 2223499 commit fa9ebfc

15 files changed

+125
-11
lines changed

src/test/ui/compare-method/proj-outlives-region.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0276]: impl has stricter requirements than trait
88
| ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `U: 'a`
99
|
1010
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
11-
= note: for more information, see issue #18937 <https://github.com/rust-lang/rust/issues/18937>
11+
= note: for more information, see issue #37166 <https://github.com/rust-lang/rust/issues/37166>
1212
note: lint level defined here
1313
--> $DIR/proj-outlives-region.rs:12:9
1414
|
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0276]: impl has stricter requirements than trait
2+
--> $DIR/region-extra-2.rs:19:5
3+
|
4+
15 | fn renew<'b: 'a>(self) -> &'b mut [T];
5+
| -------------------------------------- definition of `renew` from trait
6+
...
7+
19 | fn renew<'b: 'a>(self) -> &'b mut [T] where 'a: 'b {
8+
| ^ impl has extra requirement `'a: 'b`
9+
10+
error: aborting due to previous error
11+

src/test/ui/compare-method/region.rs renamed to src/test/ui/compare-method/region-extra.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@
1111
#![allow(dead_code)]
1212
#![deny(extra_requirement_in_impl)]
1313

14-
// Test that we elaborate `Type: 'region` constraints and infer various important things.
14+
// Test that you cannot add an extra where clause in the impl relating
15+
// two regions.
1516

1617
trait Master<'a, 'b> {
1718
fn foo();
1819
}
1920

20-
// `U: 'a` does not imply `V: 'a`
2121
impl<'a, 'b> Master<'a, 'b> for () {
2222
fn foo() where 'a: 'b { }
23-
//~^ ERROR parameter type `V` may not live long enough
2423
}
2524

2625
fn main() {

src/test/ui/compare-method/region.stderr renamed to src/test/ui/compare-method/region-extra.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0276]: impl has stricter requirements than trait
2-
--> $DIR/region.rs:22:5
2+
--> $DIR/region-extra.rs:22:5
33
|
4-
17 | fn foo();
4+
18 | fn foo();
55
| --------- definition of `foo` from trait
66
...
77
22 | fn foo() where 'a: 'b { }

src/test/ui/compare-method/region-unrelated.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ error[E0276]: impl has stricter requirements than trait
88
| ^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `V: 'a`
99
|
1010
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
11-
= note: for more information, see issue #18937 <https://github.com/rust-lang/rust/issues/18937>
11+
= note: for more information, see issue #37166 <https://github.com/rust-lang/rust/issues/37166>
1212
note: lint level defined here
1313
--> $DIR/region-unrelated.rs:12:9
1414
|

src/test/compile-fail/issue-2611-5.rs renamed to src/test/ui/compare-method/reordered-type-param.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// Tests that ty params get matched correctly when comparing
1212
// an impl against a trait
13+
//
14+
// cc #26111
1315

1416
trait A {
1517
fn b<C:Clone,D>(&self, x: C) -> C;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0053]: method `b` has an incompatible type for trait
2+
--> $DIR/reordered-type-param.rs:26:30
3+
|
4+
17 | fn b<C:Clone,D>(&self, x: C) -> C;
5+
| - type in trait
6+
...
7+
26 | fn b<F:Clone,G>(&self, _x: G) -> G { panic!() } //~ ERROR method `b` has an incompatible type
8+
| ^ expected type parameter, found a different type parameter
9+
|
10+
= note: expected type `fn(&E, F) -> F`
11+
= note: found type `fn(&E, G) -> G`
12+
13+
error: aborting due to previous error
14+

src/test/compile-fail/issue-2611-4.rs renamed to src/test/ui/compare-method/trait-bound-on-type-parameter.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Tests that an impl method's bounds aren't *more* restrictive
12-
// than the trait method it's implementing
11+
// Tests that impl can't add extra `F: Sync` bound aren't *more* restrictive
12+
// than the trait method it's implementing.
13+
//
14+
// Regr test for #26111.
1315

1416
trait A {
1517
fn b<C,D>(&self, x: C) -> C;
@@ -20,8 +22,7 @@ struct E {
2022
}
2123

2224
impl A for E {
23-
fn b<F: Sync, G>(&self, _x: F) -> F { panic!() }
24-
//~^ ERROR E0276
25+
fn b<F: Sync, G>(&self, _x: F) -> F { panic!() } //~ ERROR E0276
2526
}
2627

2728
fn main() {}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0276]: impl has stricter requirements than trait
2+
--> $DIR/trait-bound-on-type-parameter.rs:25:5
3+
|
4+
17 | fn b<C,D>(&self, x: C) -> C;
5+
| ---------------------------- definition of `b` from trait
6+
...
7+
25 | fn b<F: Sync, G>(&self, _x: F) -> F { panic!() } //~ ERROR E0276
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `F: std::marker::Sync`
9+
10+
error: aborting due to previous error
11+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
error[E0276]: impl has stricter requirements than trait
2+
--> $DIR/traits-misc-mismatch-1.rs:36:5
3+
|
4+
23 | fn test_error1_fn<T: Eq>(&self);
5+
| -------------------------------- definition of `test_error1_fn` from trait
6+
...
7+
36 | fn test_error1_fn<T: Ord>(&self) {}
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Ord`
9+
10+
error[E0276]: impl has stricter requirements than trait
11+
--> $DIR/traits-misc-mismatch-1.rs:40:5
12+
|
13+
24 | fn test_error2_fn<T: Eq + Ord>(&self);
14+
| -------------------------------------- definition of `test_error2_fn` from trait
15+
...
16+
40 | fn test_error2_fn<T: Eq + B>(&self) {}
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
18+
19+
error[E0276]: impl has stricter requirements than trait
20+
--> $DIR/traits-misc-mismatch-1.rs:44:5
21+
|
22+
25 | fn test_error3_fn<T: Eq + Ord>(&self);
23+
| -------------------------------------- definition of `test_error3_fn` from trait
24+
...
25+
44 | fn test_error3_fn<T: B + Eq>(&self) {}
26+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
27+
28+
error[E0276]: impl has stricter requirements than trait
29+
--> $DIR/traits-misc-mismatch-1.rs:54:5
30+
|
31+
28 | fn test_error5_fn<T: A>(&self);
32+
| ------------------------------- definition of `test_error5_fn` from trait
33+
...
34+
54 | fn test_error5_fn<T: B>(&self) {}
35+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: B`
36+
37+
error[E0276]: impl has stricter requirements than trait
38+
--> $DIR/traits-misc-mismatch-1.rs:60:5
39+
|
40+
30 | fn test_error7_fn<T: A>(&self);
41+
| ------------------------------- definition of `test_error7_fn` from trait
42+
...
43+
60 | fn test_error7_fn<T: A + Eq>(&self) {}
44+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::cmp::Eq`
45+
46+
error[E0276]: impl has stricter requirements than trait
47+
--> $DIR/traits-misc-mismatch-1.rs:63:5
48+
|
49+
31 | fn test_error8_fn<T: B>(&self);
50+
| ------------------------------- definition of `test_error8_fn` from trait
51+
...
52+
63 | fn test_error8_fn<T: C>(&self) {}
53+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: C`
54+
55+
error[E0276]: impl has stricter requirements than trait
56+
--> $DIR/traits-misc-mismatch-1.rs:76:5
57+
|
58+
72 | fn method<G:Getter<isize>>(&self);
59+
| ---------------------------------- definition of `method` from trait
60+
...
61+
76 | fn method<G: Getter<usize>>(&self) {}
62+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `G: Getter<usize>`
63+
64+
error: aborting due to 7 previous errors
65+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0276]: impl has stricter requirements than trait
2+
--> $DIR/traits-misc-mismatch-2.rs:23:5
3+
|
4+
19 | fn zip<B, U: Iterator<U>>(self, other: U) -> ZipIterator<Self, U>;
5+
| ------------------------------------------------------------------ definition of `zip` from trait
6+
...
7+
23 | fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<T, U> {
8+
| ^ impl has extra requirement `U: Iterator<B>`
9+
10+
error: aborting due to previous error
11+

0 commit comments

Comments
 (0)