Skip to content

make help text for cannot find macro actionable #112091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

sladyn98
Copy link
Contributor

fix #102601

@rustbot
Copy link
Collaborator

rustbot commented May 30, 2023

r? @oli-obk

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 30, 2023
@sladyn98
Copy link
Contributor Author

This is to complete the work on PR #102881.
CC @compiler-errors Because you commented on the initial PR, wanted to get your review. Thanks in advance

@rust-log-analyzer

This comment has been minimized.

@sladyn98 sladyn98 requested a review from compiler-errors May 30, 2023 19:01
@compiler-errors
Copy link
Member

I guess this is fine.

This PR needs to be rebased then tests need to be updated.

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 15, 2023
@sladyn98
Copy link
Contributor Author

Yeah resolved the conflicts, waiting for CI to pass

@rust-log-analyzer

This comment has been minimized.

@sladyn98
Copy link
Contributor Author

error: cannot find type `FromOutside` in this scope
Error:   --> fake-test-src-base/proc-macro/generate-mod.rs:23:14
   |
LL |     #[derive(generate_mod::CheckDerive)] //~ ERROR cannot find type `FromOutside` in this scope
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #83583 <https://github.com/rust-lang/rust/issues/83583>
   = note: `#[deny(proc_macro_derive_resolution_fallback)]` on by default
   = note: this error originates in the derive macro `generate_mod::CheckDerive` (in Nightly builds, run with -Z macro-backtrace for more info)

Not really sure what this error means, I do not think it is related to the code change made here.

@compiler-errors
Copy link
Member

You need to bless the tests, I think.

@compiler-errors
Copy link
Member

Can you squash this into one commit?

@oli-obk
Copy link
Contributor

oli-obk commented Jun 21, 2023

r? @compiler-errors

@rustbot rustbot assigned compiler-errors and unassigned oli-obk Jun 21, 2023
@sladyn98 sladyn98 force-pushed the make-help-message-actionable-in-macro branch 2 times, most recently from 9a1a1f6 to 12418e6 Compare June 21, 2023 07:50
@compiler-errors
Copy link
Member

Merge commits are not typically allowed in PRs. You should be able to use a rebase in order to remove the merge commit from the history.

@sladyn98 sladyn98 force-pushed the make-help-message-actionable-in-macro branch from 9d592a8 to af3f222 Compare June 21, 2023 07:59
@sladyn98 sladyn98 force-pushed the make-help-message-actionable-in-macro branch from af3f222 to c9d48e0 Compare June 21, 2023 08:07
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-14 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
........................ii..............................................................  8800/15190
........................................................................................  8888/15190
........................................i...............................................  8976/15190
....................................................................................ii..  9064/15190
...............i...F..i..i..............................................................  9152/15190
........................................................................................  9328/15190
........................................................................................  9416/15190
........................................................................................  9504/15190
..............................................................................i..i......  9592/15190
---

---- [ui] tests/ui/empty/empty-macro-use.rs stdout ----
diff of stderr:

4 LL |     macro_two!();
6    |
-    = help: consider importing this macro:
-            use two_macros::macro_two;
+ help: consider importing this macro
+ help: consider importing this macro
9    |
10 LL + use two_macros::macro_two;


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/empty/empty-macro-use/empty-macro-use.stderr
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/empty/empty-macro-use/empty-macro-use.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args empty/empty-macro-use.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/empty/empty-macro-use.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/empty/empty-macro-use" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/empty/empty-macro-use/auxiliary"
stdout: none
--- stderr -------------------------------
error: cannot find macro `macro_two` in this scope
##[error]  --> fake-test-src-base/empty/empty-macro-use.rs:7:5
   |
LL |     macro_two!();
Build completed unsuccessfully in 0:10:50
   |
help: consider importing this macro
   |
   |
LL + use two_macros::macro_two;

error: aborting due to previous error
------------------------------------------

---
To only update this specific test, also pass `--test-args hygiene/no_implicit_prelude-2018.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/hygiene/no_implicit_prelude-2018.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/hygiene/no_implicit_prelude-2018" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/hygiene/no_implicit_prelude-2018/auxiliary" "--edition=2018"
stdout: none
error: cannot find macro `print` in this scope
error: cannot find macro `print` in this scope
##[error]  --> fake-test-src-base/hygiene/no_implicit_prelude-2018.rs:7:9
   |
LL |         print!(); //~ ERROR cannot find macro `print` in this scope
   |
help: consider importing this macro
   |
LL +     use std::print;
---

---- [ui] tests/ui/macros/issue-88228.rs stdout ----
diff of stderr:

4 LL |     bla!();
6    |
-    = help: consider importing this macro:
-    = help: consider importing this macro:
-            use crate::hey::bla;
+ help: consider importing this macro
9    |
10 LL + use crate::hey::bla;


24 LL | #[derive(Bla)]
26    |
-    = help: consider importing this derive macro:
-    = help: consider importing this derive macro:
-            use crate::hey::Bla;
+ help: consider importing this derive macro
29    |
30 LL + use crate::hey::Bla;


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/issue-88228/issue-88228.stderr
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/issue-88228/issue-88228.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args macros/issue-88228.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/macros/issue-88228.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/issue-88228" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/issue-88228/auxiliary" "-Z" "deduplicate-diagnostics=yes" "--edition=2018"
stdout: none
--- stderr -------------------------------
error: cannot find macro `bla` in this scope
##[error]  --> fake-test-src-base/macros/issue-88228.rs:20:5
   |
LL |     bla!();
   |
help: consider importing this macro
   |
   |
LL + use crate::hey::bla;

error: cannot find derive macro `println` in this scope
##[error]  --> fake-test-src-base/macros/issue-88228.rs:14:10
   |
   |
LL | #[derive(println)]
   |
   = note: `println` is in scope, but it is a function-like macro


error: cannot find derive macro `Bla` in this scope
##[error]  --> fake-test-src-base/macros/issue-88228.rs:10:10
   |
LL | #[derive(Bla)]
   |
help: consider importing this derive macro
   |
   |
LL + use crate::hey::Bla;

error: aborting due to 3 previous errors
------------------------------------------



---- [ui] tests/ui/macros/macro-use-wrong-name.rs stdout ----
diff of stderr:

9 LL | macro_rules! macro_one { () => ("one") }
10    | ---------------------- similarly named macro `macro_one` defined here
-    = help: consider importing this macro:
-            use two_macros::macro_two;
+ help: a macro with a similar name exists
14    |
---
To only update this specific test, also pass `--test-args macros/macro-use-wrong-name.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/macros/macro-use-wrong-name.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/macro-use-wrong-name" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/macro-use-wrong-name/auxiliary"
stdout: none
--- stderr -------------------------------
error: cannot find macro `macro_two` in this scope
##[error]  --> fake-test-src-base/macros/macro-use-wrong-name.rs:7:5
   |
LL |     macro_two!();
   |
   |
  ::: fake-test-src-base/macros/auxiliary/two_macros.rs:2:1
   |
LL | macro_rules! macro_one { () => ("one") }
   | ---------------------- similarly named macro `macro_one` defined here
help: a macro with a similar name exists
   |
LL |     macro_one!();
   |     ~~~~~~~~~
   |     ~~~~~~~~~
help: consider importing this macro
   |
LL + use two_macros::macro_two;

error: aborting due to previous error
------------------------------------------



---- [ui] tests/ui/missing/missing-macro-use.rs stdout ----
diff of stderr:

4 LL |     macro_two!();
6    |
-    = help: consider importing this macro:
-            use two_macros::macro_two;
+ help: consider importing this macro
+ help: consider importing this macro
9    |
10 LL + use two_macros::macro_two;


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/missing/missing-macro-use/missing-macro-use.stderr
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/missing/missing-macro-use/missing-macro-use.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args missing/missing-macro-use.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/missing/missing-macro-use.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/missing/missing-macro-use" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/missing/missing-macro-use/auxiliary"
stdout: none
--- stderr -------------------------------
error: cannot find macro `macro_two` in this scope
##[error]  --> fake-test-src-base/missing/missing-macro-use.rs:6:5
   |
LL |     macro_two!();
   |
help: consider importing this macro
   |
   |
LL + use two_macros::macro_two;

error: aborting due to previous error
------------------------------------------



---- [ui] tests/ui/proc-macro/derive-helper-shadowing.rs stdout ----
diff of stderr:

16 LL |             #[derive(GenHelperUse)]
18    |
-    = help: consider importing this attribute macro:
-            use empty_helper;
-            use empty_helper;
21    = note: this error originates in the derive macro `GenHelperUse` (in Nightly builds, run with -Z macro-backtrace for more info)
+ help: consider importing this attribute macro
23 LL +             use empty_helper;
24    |


32 LL |             gen_helper_use!();
34    |
-    = help: consider importing this attribute macro:
-            use crate::empty_helper;
-            use crate::empty_helper;
37    = note: this error originates in the macro `gen_helper_use` (in Nightly builds, run with -Z macro-backtrace for more info)
+ help: consider importing this attribute macro
39 LL +             use crate::empty_helper;
40    |



The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/proc-macro/derive-helper-shadowing/derive-helper-shadowing.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args proc-macro/derive-helper-shadowing.rs`

error: 1 errors occurred comparing output.
status: exit status: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/ui/proc-macro/derive-helper-shadowing.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "--sysroot" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Cstrip=debuginfo" "--remap-path-prefix=/checkout/tests/ui=fake-test-src-base" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/proc-macro/derive-helper-shadowing" "-A" "unused" "-Crpath" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/proc-macro/derive-helper-shadowing/auxiliary" "--edition=2018"
stdout: none
error: cannot use a derive helper attribute through an import
##[error]  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:42:15
   |
   |
LL |             #[renamed] //~ ERROR cannot use a derive helper attribute through an import
   |
note: the derive helper attribute imported here
  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:41:17
   |
   |
LL |             use empty_helper as renamed;
   |                 ^^^^^^^^^^^^^^^^^^^^^^^

error: cannot find attribute `empty_helper` in this scope
##[error]  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:38:22
   |
LL |             #[derive(GenHelperUse)] //~ ERROR cannot find attribute `empty_helper` in this scope
   |
   |
   = note: this error originates in the derive macro `GenHelperUse` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this attribute macro
LL +             use empty_helper;
   |


error: cannot find attribute `empty_helper` in this scope
##[error]  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:14:11
   |
LL |         #[empty_helper] //~ ERROR cannot find attribute `empty_helper` in this scope
...
...
LL |             gen_helper_use!();
   |
   |
   = note: this error originates in the macro `gen_helper_use` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider importing this attribute macro
LL +             use crate::empty_helper;
   |


error[E0659]: `empty_helper` is ambiguous
##[error]  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:26:13
   |
LL |         use empty_helper; //~ ERROR `empty_helper` is ambiguous
   |             ^^^^^^^^^^^^ ambiguous name
   |
   = note: ambiguous because of multiple potential import sources
note: `empty_helper` could refer to the derive helper attribute defined here
  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:22:10
   |
LL | #[derive(Empty)]
   |          ^^^^^
note: `empty_helper` could also refer to the attribute macro imported here
  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:10:5
   |
LL | use test_macros::empty_attr as empty_helper;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: use `crate::empty_helper` to refer to this attribute macro unambiguously

error[E0659]: `empty_helper` is ambiguous
##[error]  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:19:3
   |
LL | #[empty_helper] //~ ERROR `empty_helper` is ambiguous
   |   ^^^^^^^^^^^^ ambiguous name
   = note: ambiguous because of a name conflict with a derive helper attribute
   = note: ambiguous because of a name conflict with a derive helper attribute
note: `empty_helper` could refer to the derive helper attribute defined here
  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:22:10
   |
LL | #[derive(Empty)]
   |          ^^^^^
note: `empty_helper` could also refer to the attribute macro imported here
  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:10:5
   |
LL | use test_macros::empty_attr as empty_helper;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: use `crate::empty_helper` to refer to this attribute macro unambiguously
warning: derive helper attribute is used before it is introduced
##[warning]  --> fake-test-src-base/proc-macro/derive-helper-shadowing.rs:19:3
   |
   |
LL | #[empty_helper] //~ ERROR `empty_helper` is ambiguous
...
...
LL | #[derive(Empty)]
   |
   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
   = note: for more information, see issue #79202 <https://github.com/rust-lang/rust/issues/79202>
   = note: `#[warn(legacy_derive_helpers)]` on by default

@bors
Copy link
Collaborator

bors commented Jun 22, 2023

☔ The latest upstream changes (presumably #112686) made this pull request unmergeable. Please resolve the merge conflicts.

Comment on lines +7 to 11
= help: consider importing this macro:
use two_macros::macro_two;
|
LL + use two_macros::macro_two;
|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not quite sure how this happened given the logic change, but I would like us to avoid changing the message for the structured suggestion case.

@Dylan-DPC
Copy link
Member

@sladyn98 any updates on this? thanks

@Dylan-DPC
Copy link
Member

Closing this as inactive. Feel free to reöpen this pr or create a new pr if you get the time to work on this. Thanks

@Dylan-DPC Dylan-DPC closed this Oct 31, 2023
@Dylan-DPC Dylan-DPC added S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-inactive Status: Inactive and waiting on the author. This is often applied to closed PRs. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show an actionable help text to add a "use ..." on error "cannot find macro"
8 participants