File tree Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Expand file tree Collapse file tree 2 files changed +72
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Regression test for issue #57642
2
+ // Tests that we reject a bad higher-ranked subtype
3
+ // with `#![feature(nll)]`
4
+
5
+ #![feature(nll)]
6
+
7
+ trait X {
8
+ type G;
9
+ fn make_g() -> Self::G;
10
+ }
11
+
12
+ impl<'a> X for fn(&'a ()) {
13
+ type G = &'a ();
14
+
15
+ fn make_g() -> Self::G {
16
+ &()
17
+ }
18
+ }
19
+
20
+ trait Y {
21
+ type F;
22
+ fn make_f() -> Self::F;
23
+ }
24
+
25
+ impl<T> Y for fn(T) {
26
+ type F = fn(T);
27
+
28
+ fn make_f() -> Self::F {
29
+ |_| {}
30
+ }
31
+ }
32
+
33
+ fn higher_ranked_region_has_lost_its_binder() {
34
+ let x = <fn (&())>::make_g(); //~ ERROR no function
35
+ }
36
+
37
+ fn magical() {
38
+ let x = <fn (&())>::make_f(); //~ ERROR no function
39
+ }
40
+
41
+ fn main() {}
Original file line number Diff line number Diff line change
1
+ error[E0599]: no function or associated item named `make_g` found for fn pointer `for<'r> fn(&'r ())` in the current scope
2
+ --> $DIR/issue-57642-higher-ranked-subtype.rs:34:25
3
+ |
4
+ LL | let x = <fn (&())>::make_g();
5
+ | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())`
6
+ |
7
+ = note: the method `make_g` exists but the following trait bounds were not satisfied:
8
+ `for<'r> fn(&'r ()): X`
9
+ = help: items from traits can only be used if the trait is implemented and in scope
10
+ note: `X` defines an item `make_g`, perhaps you need to implement it
11
+ --> $DIR/issue-57642-higher-ranked-subtype.rs:7:1
12
+ |
13
+ LL | trait X {
14
+ | ^^^^^^^
15
+
16
+ error[E0599]: no function or associated item named `make_f` found for fn pointer `for<'r> fn(&'r ())` in the current scope
17
+ --> $DIR/issue-57642-higher-ranked-subtype.rs:38:25
18
+ |
19
+ LL | let x = <fn (&())>::make_f();
20
+ | ^^^^^^ function or associated item not found in `for<'r> fn(&'r ())`
21
+ |
22
+ = help: items from traits can only be used if the trait is implemented and in scope
23
+ note: `Y` defines an item `make_f`, perhaps you need to implement it
24
+ --> $DIR/issue-57642-higher-ranked-subtype.rs:20:1
25
+ |
26
+ LL | trait Y {
27
+ | ^^^^^^^
28
+
29
+ error: aborting due to 2 previous errors
30
+
31
+ For more information about this error, try `rustc --explain E0599`.
You can’t perform that action at this time.
0 commit comments