File tree Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Expand file tree Collapse file tree 2 files changed +41
-2
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,30 @@ impl A {
77 //~^ ERROR can't use `Self` from outer item
88 //~| NOTE use of `Self` from outer item
99 //~| NOTE `Self` used in this inner function
10- //~| NOTE refer to the type directly here instead
10+ //~| HELP refer to the type directly here instead
1111 }
1212 }
1313}
1414
15+ enum MyEnum { }
16+
17+ impl MyEnum {
18+ //~^ NOTE `Self` type implicitly declared here, by this `impl`
19+ fn do_something ( result : impl FnOnce ( ) ) {
20+ result ( ) ;
21+ }
22+
23+ fn do_something_extra ( ) {
24+ fn inner ( ) {
25+ //~^ NOTE `Self` used in this inner function
26+ Self :: do_something ( move || { } ) ;
27+ //~^ ERROR can't use `Self` from outer item
28+ //~| NOTE use of `Self` from outer item
29+ //~| HELP refer to the type directly here instead
30+ MyEnum :: do_something ( move || { } ) ;
31+ }
32+ inner ( ) ;
33+ }
34+ }
35+
1536fn main ( ) { }
Original file line number Diff line number Diff line change @@ -15,6 +15,24 @@ LL - fn peach(this: &Self) {
1515LL + fn peach(this: &A) {
1616 |
1717
18- error: aborting due to 1 previous error
18+ error[E0401]: can't use `Self` from outer item
19+ --> $DIR/use-self-in-inner-fn.rs:26:13
20+ |
21+ LL | impl MyEnum {
22+ | ---- `Self` type implicitly declared here, by this `impl`
23+ ...
24+ LL | fn inner() {
25+ | ----- `Self` used in this inner function
26+ LL |
27+ LL | Self::do_something(move || {});
28+ | ^^^^^^^^^^^^^^^^^^ use of `Self` from outer item
29+ |
30+ help: refer to the type directly here instead
31+ |
32+ LL - Self::do_something(move || {});
33+ LL + MyEnum(move || {});
34+ |
35+
36+ error: aborting due to 2 previous errors
1937
2038For more information about this error, try `rustc --explain E0401`.
You can’t perform that action at this time.
0 commit comments