This commit is contained in:
Esteban Küber 2025-11-03 01:53:17 +00:00
parent ba2600e98e
commit 4af32ca72f
2 changed files with 41 additions and 2 deletions

View file

@ -7,9 +7,30 @@ impl A {
//~^ ERROR can't use `Self` from outer item
//~| NOTE use of `Self` from outer item
//~| NOTE `Self` used in this inner function
//~| NOTE refer to the type directly here instead
//~| HELP refer to the type directly here instead
}
}
}
enum MyEnum {}
impl MyEnum {
//~^ NOTE `Self` type implicitly declared here, by this `impl`
fn do_something(result: impl FnOnce()) {
result();
}
fn do_something_extra() {
fn inner() {
//~^ NOTE `Self` used in this inner function
Self::do_something(move || {});
//~^ ERROR can't use `Self` from outer item
//~| NOTE use of `Self` from outer item
//~| HELP refer to the type directly here instead
MyEnum::do_something(move || {});
}
inner();
}
}
fn main() {}

View file

@ -15,6 +15,24 @@ LL - fn peach(this: &Self) {
LL + fn peach(this: &A) {
|
error: aborting due to 1 previous error
error[E0401]: can't use `Self` from outer item
--> $DIR/use-self-in-inner-fn.rs:26:13
|
LL | impl MyEnum {
| ---- `Self` type implicitly declared here, by this `impl`
...
LL | fn inner() {
| ----- `Self` used in this inner function
LL |
LL | Self::do_something(move || {});
| ^^^^^^^^^^^^^^^^^^ use of `Self` from outer item
|
help: refer to the type directly here instead
|
LL - Self::do_something(move || {});
LL + MyEnum(move || {});
|
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0401`.