Skip to content
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

error: cannot find macro panic in this scope #78333

Closed
phlopsi opened this issue Oct 24, 2020 · 0 comments · Fixed by #78343
Closed

error: cannot find macro panic in this scope #78333

phlopsi opened this issue Oct 24, 2020 · 0 comments · Fixed by #78343
Assignees
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@phlopsi
Copy link
Contributor

phlopsi commented Oct 24, 2020

I tried this code:

#![no_implicit_prelude]

fn main() {
    ::std::todo!();
    ::std::unimplemented!();
}

(Playground)

I expected to see this happen:
Successful compilation

Instead, this happened:

   Compiling playground v0.0.1 (/playground)
error: cannot find macro `panic` in this scope
 --> src/main.rs:4:5
  |
4 |     ::std::todo!();
  |     ^^^^^^^^^^^^^^^
  |
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: cannot find macro `panic` in this scope
 --> src/main.rs:5:5
  |
5 |     ::std::unimplemented!();
  |     ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

error: could not compile `playground`.

To learn more, run the command again with --verbose.

Meta

rustc --version --verbose Playground Stable Version:

1.47.0

The macros should be using $crate::panic!, instead of panic!.

@phlopsi phlopsi added the C-bug Category: This is a bug. label Oct 24, 2020
@camelid camelid added A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Oct 25, 2020
@camelid camelid self-assigned this Oct 25, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Oct 31, 2020
…u-se

Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Fixes rust-lang#78333.

-----

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 19, 2020
…u-se

Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Fixes rust-lang#78333.

-----

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Nov 19, 2020
…u-se

Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Fixes rust-lang#78333.

-----

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.
@bors bors closed this as completed in f32a0cc Nov 24, 2020
flip1995 pushed a commit to flip1995/rust that referenced this issue Dec 6, 2020
Qualify `panic!` as `core::panic!` in non-built-in `core` macros

Fixes rust-lang#78333.

-----

Otherwise code like this

    #![no_implicit_prelude]

    fn main() {
        ::std::todo!();
        ::std::unimplemented!();
    }

will fail to compile, which is unfortunate and presumably unintended.

This changes many invocations of `panic!` in a `macro_rules!` definition
to invocations of `$crate::panic!`, which makes the invocations hygienic.

Note that this does not make the built-in macro `assert!` hygienic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows C-bug Category: This is a bug. T-libs Relevant to the library team, which will review and decide on the PR/issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants