Skip to content

Commit d3c96ff

Browse files
committed
tests: worse diagnostics, but basically same errors
1 parent 78705b5 commit d3c96ff

39 files changed

+463
-437
lines changed

src/test/ui/associated-types/associated-types-eq-hr.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,35 @@ fn tuple_four<T>()
7777
// not ok for tuple, two lifetimes, and lifetime matching is invariant
7878
}
7979

80-
pub fn main() {
80+
pub fn call_foo() {
8181
foo::<IntStruct>();
8282
foo::<UintStruct>(); //~ ERROR type mismatch
83+
}
8384

85+
pub fn call_bar() {
8486
bar::<IntStruct>(); //~ ERROR type mismatch
8587
bar::<UintStruct>();
88+
}
8689

90+
pub fn call_tuple_one() {
8791
tuple_one::<Tuple>();
88-
//~^ ERROR E0277
89-
//~| ERROR type mismatch
92+
//~^ ERROR E0495
93+
//~| ERROR E0495
94+
}
9095

96+
pub fn call_tuple_two() {
9197
tuple_two::<Tuple>();
92-
//~^ ERROR E0277
93-
//~| ERROR type mismatch
98+
//~^ ERROR E0495
99+
//~| ERROR E0495
100+
}
94101

102+
pub fn call_tuple_three() {
95103
tuple_three::<Tuple>();
104+
}
96105

106+
pub fn call_tuple_four() {
97107
tuple_four::<Tuple>();
98-
//~^ ERROR E0277
108+
//~^ ERROR E0495
99109
}
110+
111+
fn main() { }

src/test/ui/associated-types/associated-types-eq-hr.stderr

Lines changed: 42 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ LL | | }
1717
| |_^
1818

1919
error[E0271]: type mismatch resolving `for<'x> <IntStruct as TheTrait<&'x isize>>::A == &'x usize`
20-
--> $DIR/associated-types-eq-hr.rs:84:5
20+
--> $DIR/associated-types-eq-hr.rs:86:5
2121
|
2222
LL | bar::<IntStruct>(); //~ ERROR type mismatch
2323
| ^^^^^^^^^^^^^^^^ expected isize, found usize
@@ -34,93 +34,67 @@ LL | | // ok for UintStruct, but not IntStruct
3434
LL | | }
3535
| |_^
3636

37-
error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied
38-
--> $DIR/associated-types-eq-hr.rs:87:5
37+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
38+
--> $DIR/associated-types-eq-hr.rs:91:5
3939
|
4040
LL | tuple_one::<Tuple>();
41-
| ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple`
42-
|
43-
= help: the following implementations were found:
44-
<Tuple as TheTrait<(&'a isize, &'a isize)>>
45-
note: required by `tuple_one`
46-
--> $DIR/associated-types-eq-hr.rs:56:1
41+
| ^^^^^^^^^^^^^^^^^^
4742
|
48-
LL | / fn tuple_one<T>()
49-
LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>
50-
LL | | {
51-
LL | | // not ok for tuple, two lifetimes and we pick first
52-
LL | | }
53-
| |_^
43+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:20), 'x) })...
44+
= note: ...but the lifetime must also be valid for lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:21), 'y) })...
45+
= note: ...so that the types are compatible:
46+
expected TheTrait<(&'x isize, &'y isize)>
47+
found TheTrait<(&isize, &isize)>
5448

55-
error[E0271]: type mismatch resolving `for<'x, 'y> <Tuple as TheTrait<(&'x isize, &'y isize)>>::A == &'x isize`
56-
--> $DIR/associated-types-eq-hr.rs:87:5
49+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
50+
--> $DIR/associated-types-eq-hr.rs:91:5
5751
|
5852
LL | tuple_one::<Tuple>();
59-
| ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime
60-
|
61-
note: required by `tuple_one`
62-
--> $DIR/associated-types-eq-hr.rs:56:1
53+
| ^^^^^^^^^^^^^^^^^^
6354
|
64-
LL | / fn tuple_one<T>()
65-
LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'x isize>
66-
LL | | {
67-
LL | | // not ok for tuple, two lifetimes and we pick first
68-
LL | | }
69-
| |_^
55+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U2, name: BrNamed(crate0:DefIndex(1:20), 'x) })...
56+
= note: ...but the lifetime must also be valid for lifetime RePlaceholder(Placeholder { universe: U2, name: BrNamed(crate0:DefIndex(1:21), 'y) })...
57+
= note: ...so that the types are compatible:
58+
expected TheTrait<(&'x isize, &'y isize)>
59+
found TheTrait<(&isize, &isize)>
7060

71-
error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied
72-
--> $DIR/associated-types-eq-hr.rs:91:5
61+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
62+
--> $DIR/associated-types-eq-hr.rs:97:5
7363
|
7464
LL | tuple_two::<Tuple>();
75-
| ^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple`
76-
|
77-
= help: the following implementations were found:
78-
<Tuple as TheTrait<(&'a isize, &'a isize)>>
79-
note: required by `tuple_two`
80-
--> $DIR/associated-types-eq-hr.rs:62:1
65+
| ^^^^^^^^^^^^^^^^^^
8166
|
82-
LL | / fn tuple_two<T>()
83-
LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>
84-
LL | | {
85-
LL | | // not ok for tuple, two lifetimes and we pick second
86-
LL | | }
87-
| |_^
67+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:23), 'x) })...
68+
= note: ...but the lifetime must also be valid for lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:24), 'y) })...
69+
= note: ...so that the types are compatible:
70+
expected TheTrait<(&'x isize, &'y isize)>
71+
found TheTrait<(&isize, &isize)>
8872

89-
error[E0271]: type mismatch resolving `for<'x, 'y> <Tuple as TheTrait<(&'x isize, &'y isize)>>::A == &'y isize`
90-
--> $DIR/associated-types-eq-hr.rs:91:5
73+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
74+
--> $DIR/associated-types-eq-hr.rs:97:5
9175
|
9276
LL | tuple_two::<Tuple>();
93-
| ^^^^^^^^^^^^^^^^^^ expected bound lifetime parameter 'x, found concrete lifetime
77+
| ^^^^^^^^^^^^^^^^^^
9478
|
95-
note: required by `tuple_two`
96-
--> $DIR/associated-types-eq-hr.rs:62:1
97-
|
98-
LL | / fn tuple_two<T>()
99-
LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize), A = &'y isize>
100-
LL | | {
101-
LL | | // not ok for tuple, two lifetimes and we pick second
102-
LL | | }
103-
| |_^
79+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U2, name: BrNamed(crate0:DefIndex(1:23), 'x) })...
80+
= note: ...but the lifetime must also be valid for lifetime RePlaceholder(Placeholder { universe: U2, name: BrNamed(crate0:DefIndex(1:24), 'y) })...
81+
= note: ...so that the types are compatible:
82+
expected TheTrait<(&'x isize, &'y isize)>
83+
found TheTrait<(&isize, &isize)>
10484

105-
error[E0277]: the trait bound `for<'x, 'y> Tuple: TheTrait<(&'x isize, &'y isize)>` is not satisfied
106-
--> $DIR/associated-types-eq-hr.rs:97:5
85+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements
86+
--> $DIR/associated-types-eq-hr.rs:107:5
10787
|
10888
LL | tuple_four::<Tuple>();
109-
| ^^^^^^^^^^^^^^^^^^^ the trait `for<'x, 'y> TheTrait<(&'x isize, &'y isize)>` is not implemented for `Tuple`
110-
|
111-
= help: the following implementations were found:
112-
<Tuple as TheTrait<(&'a isize, &'a isize)>>
113-
note: required by `tuple_four`
114-
--> $DIR/associated-types-eq-hr.rs:74:1
89+
| ^^^^^^^^^^^^^^^^^^^
11590
|
116-
LL | / fn tuple_four<T>()
117-
LL | | where T : for<'x,'y> TheTrait<(&'x isize, &'y isize)>
118-
LL | | {
119-
LL | | // not ok for tuple, two lifetimes, and lifetime matching is invariant
120-
LL | | }
121-
| |_^
91+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:28), 'x) })...
92+
= note: ...but the lifetime must also be valid for lifetime RePlaceholder(Placeholder { universe: U1, name: BrNamed(crate0:DefIndex(1:29), 'y) })...
93+
= note: ...so that the types are compatible:
94+
expected TheTrait<(&'x isize, &'y isize)>
95+
found TheTrait<(&isize, &isize)>
12296

12397
error: aborting due to 7 previous errors
12498

125-
Some errors occurred: E0271, E0277.
99+
Some errors occurred: E0271, E0495.
126100
For more information about an error, try `rustc --explain E0271`.
Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
error[E0271]: type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _`
1+
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
22
--> $DIR/higher-ranked-projection.rs:25:5
33
|
44
LL | foo(());
5-
| ^^^ expected bound lifetime parameter 'a, found concrete lifetime
5+
| ^^^
66
|
7-
note: required by `foo`
8-
--> $DIR/higher-ranked-projection.rs:14:1
7+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U2, name: BrNamed(crate0:DefIndex(1:12), 'a) })...
8+
= note: ...so that the types are compatible:
9+
expected Mirror
10+
found Mirror
11+
note: but, the lifetime must be valid for the expression at 25:5...
12+
--> $DIR/higher-ranked-projection.rs:25:5
913
|
10-
LL | / fn foo<U, T>(_t: T)
11-
LL | | where for<'a> &'a T: Mirror<Image=U>
12-
LL | | {}
13-
| |__^
14+
LL | foo(());
15+
| ^^^
16+
note: ...so type `fn(()) {foo::<&(), ()>}` of expression is valid during the expression
17+
--> $DIR/higher-ranked-projection.rs:25:5
18+
|
19+
LL | foo(());
20+
| ^^^
1421

1522
error: aborting due to previous error
1623

17-
For more information about this error, try `rustc --explain E0271`.
24+
For more information about this error, try `rustc --explain E0495`.

src/test/ui/associated-types/higher-ranked-projection.good.stderr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ error: compilation successful
33
|
44
LL | / fn main() { //[good]~ ERROR compilation successful
55
LL | | foo(());
6-
LL | | //[bad]~^ ERROR type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _`
7-
LL | | //[bad]~| expected bound lifetime parameter 'a, found concrete lifetime
6+
LL | | //[bad]~^ ERROR E0495
87
LL | | }
98
| |_^
109

src/test/ui/associated-types/higher-ranked-projection.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ fn foo<U, T>(_t: T)
2323
#[rustc_error]
2424
fn main() { //[good]~ ERROR compilation successful
2525
foo(());
26-
//[bad]~^ ERROR type mismatch resolving `for<'a> <&'a _ as Mirror>::Image == _`
27-
//[bad]~| expected bound lifetime parameter 'a, found concrete lifetime
26+
//[bad]~^ ERROR E0495
2827
}

src/test/ui/closure-expected-type/expect-fn-supply-fn.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,24 @@ fn expect_free_supply_bound() {
2828
// Here, we are given a function whose region is bound at closure level,
2929
// but we expect one bound in the argument. Error results.
3030
with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
31-
//~^ ERROR type mismatch in closure arguments
31+
//~^ ERROR mismatched types
3232
}
3333

3434
fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) {
3535
// Here, we are given a `fn(&u32)` but we expect a `fn(&'x
3636
// u32)`. In principle, this could be ok, but we demand equality.
3737
with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
38-
//~^ ERROR type mismatch in closure arguments
38+
//~^ ERROR mismatched types
3939
}
4040

4141
fn expect_bound_supply_free_from_closure() {
4242
// A variant on the previous test. Here, the region `'a` will be
4343
// bound at the closure level, but we expect something bound at
4444
// the argument level.
4545
type Foo<'a> = fn(&'a u32);
46-
with_closure_expecting_fn_with_bound_region(|_x: Foo<'_>, y| {});
47-
//~^ ERROR type mismatch in closure arguments
46+
with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
47+
//~^ ERROR cannot infer
48+
});
4849
}
4950

5051
fn expect_bound_supply_bound<'x>(x: &'x u32) {

src/test/ui/closure-expected-type/expect-fn-supply-fn.stderr

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -36,58 +36,61 @@ note: ...does not necessarily outlive the anonymous lifetime #2 defined on the b
3636
LL | with_closure_expecting_fn_with_free_region(|x: fn(&'x u32), y| {});
3737
| ^^^^^^^^^^^^^^^^^^^^^^
3838

39-
error[E0631]: type mismatch in closure arguments
40-
--> $DIR/expect-fn-supply-fn.rs:30:5
39+
error[E0308]: mismatched types
40+
--> $DIR/expect-fn-supply-fn.rs:30:52
41+
|
42+
LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
43+
| ^^^^^^^^ lifetime mismatch
44+
|
45+
= note: expected type `fn(&u32)`
46+
found type `for<'r> fn(&'r u32)`
47+
= note: lifetime RePlaceholder(Placeholder { universe: U2, name: BrAnon(0) })...
48+
note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 30:48
49+
--> $DIR/expect-fn-supply-fn.rs:30:48
4150
|
4251
LL | with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
43-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `fn(for<'r> fn(&'r u32), _) -> _`
44-
| |
45-
| expected signature of `for<'a, 'r> fn(fn(&'a u32), &'r i32) -> _`
46-
|
47-
note: required by `with_closure_expecting_fn_with_free_region`
48-
--> $DIR/expect-fn-supply-fn.rs:1:1
49-
|
50-
LL | / fn with_closure_expecting_fn_with_free_region<F>(_: F)
51-
LL | | where F: for<'a> FnOnce(fn(&'a u32), &i32)
52-
LL | | {
53-
LL | | }
54-
| |_^
52+
| ^^^^^^^^^^^^^^^^^^^
5553

56-
error[E0631]: type mismatch in closure arguments
57-
--> $DIR/expect-fn-supply-fn.rs:37:5
54+
error[E0308]: mismatched types
55+
--> $DIR/expect-fn-supply-fn.rs:37:53
5856
|
5957
LL | with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
60-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ------------------- found signature of `fn(fn(&'x u32), _) -> _`
61-
| |
62-
| expected signature of `for<'r> fn(for<'s> fn(&'s u32), &'r i32) -> _`
63-
|
64-
note: required by `with_closure_expecting_fn_with_bound_region`
65-
--> $DIR/expect-fn-supply-fn.rs:6:1
66-
|
67-
LL | / fn with_closure_expecting_fn_with_bound_region<F>(_: F)
68-
LL | | where F: FnOnce(fn(&u32), &i32)
69-
LL | | {
70-
LL | | }
71-
| |_^
58+
| ^^^^^^^^^^^ lifetime mismatch
59+
|
60+
= note: expected type `for<'r> fn(&'r u32)`
61+
found type `fn(&'x u32)`
62+
= note: lifetime RePlaceholder(Placeholder { universe: U3, name: BrAnon(0) })...
63+
note: ...does not necessarily outlive the lifetime 'x as defined on the function body at 34:37
64+
--> $DIR/expect-fn-supply-fn.rs:34:37
65+
|
66+
LL | fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) {
67+
| ^^
7268

73-
error[E0631]: type mismatch in closure arguments
74-
--> $DIR/expect-fn-supply-fn.rs:46:5
75-
|
76-
LL | with_closure_expecting_fn_with_bound_region(|_x: Foo<'_>, y| {});
77-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ---------------- found signature of `for<'r> fn(fn(&'r u32), _) -> _`
78-
| |
79-
| expected signature of `for<'r> fn(for<'s> fn(&'s u32), &'r i32) -> _`
80-
|
81-
note: required by `with_closure_expecting_fn_with_bound_region`
82-
--> $DIR/expect-fn-supply-fn.rs:6:1
83-
|
84-
LL | / fn with_closure_expecting_fn_with_bound_region<F>(_: F)
85-
LL | | where F: FnOnce(fn(&u32), &i32)
86-
LL | | {
87-
LL | | }
88-
| |_^
69+
error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in function call due to conflicting requirements
70+
--> $DIR/expect-fn-supply-fn.rs:46:53
71+
|
72+
LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
73+
| ^^^^^^^
74+
|
75+
= note: first, the lifetime cannot outlive lifetime RePlaceholder(Placeholder { universe: U3, name: BrAnon(0) })...
76+
= note: ...so that the types are compatible:
77+
expected for<'r> fn(&'r u32)
78+
found fn(&u32)
79+
note: but, the lifetime must be valid for the expression at 46:65...
80+
--> $DIR/expect-fn-supply-fn.rs:46:65
81+
|
82+
LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
83+
| _________________________________________________________________^
84+
LL | | //~^ ERROR cannot infer
85+
LL | | });
86+
| |_____^
87+
note: ...so that the type `fn(&u32)` will meet its required lifetime bounds
88+
--> $DIR/expect-fn-supply-fn.rs:46:53
89+
|
90+
LL | with_closure_expecting_fn_with_bound_region(|x: Foo<'_>, y| {
91+
| ^^^^^^^
8992

9093
error: aborting due to 5 previous errors
9194

92-
Some errors occurred: E0308, E0631.
95+
Some errors occurred: E0308, E0495.
9396
For more information about an error, try `rustc --explain E0308`.

src/test/ui/generator/auto-trait-regions.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ fn main() {
2727
yield;
2828
assert_foo(x);
2929
};
30-
assert_foo(gen); //~ ERROR the trait bound `No: Foo` is not satisfied
30+
assert_foo(gen);
31+
//~^ ERROR mismatched types
32+
//~| ERROR mismatched types
3133

3234
// Allow impls which matches any lifetime
3335
let x = &OnlyFooIfRef(No);
@@ -44,5 +46,7 @@ fn main() {
4446
yield;
4547
assert_foo(a);
4648
};
47-
assert_foo(gen); //~ ERROR the requirement `for<'r, 's> 'r : 's` is not satisfied
49+
assert_foo(gen);
50+
//~^ ERROR E0495
51+
//~| ERROR E0495
4852
}

0 commit comments

Comments
 (0)