diff --git a/tests/ui/resolve/use-self-in-inner-fn.rs b/tests/ui/resolve/use-self-in-inner-fn.rs index ed64ee885271..1a11fe3a21b6 100644 --- a/tests/ui/resolve/use-self-in-inner-fn.rs +++ b/tests/ui/resolve/use-self-in-inner-fn.rs @@ -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() {} diff --git a/tests/ui/resolve/use-self-in-inner-fn.stderr b/tests/ui/resolve/use-self-in-inner-fn.stderr index 7f5217825c11..2266a31ebf04 100644 --- a/tests/ui/resolve/use-self-in-inner-fn.stderr +++ b/tests/ui/resolve/use-self-in-inner-fn.stderr @@ -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`.