Skip to content

Unresolved macro panic! with inner module #16511

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

Closed
lnicola opened this issue Feb 8, 2024 · 5 comments · Fixed by #16679
Closed

Unresolved macro panic! with inner module #16511

lnicola opened this issue Feb 8, 2024 · 5 comments · Fixed by #16679
Labels
C-bug Category: bug

Comments

@lnicola
Copy link
Member

lnicola commented Feb 8, 2024

fn main() {}

#[test_log::test]
fn foo() {}
@lnicola lnicola added the C-bug Category: bug label Feb 8, 2024
@lnicola
Copy link
Member Author

lnicola commented Feb 8, 2024

The macro expands to an inner module:

fn foo() {
    mod init {
        pub fn init() {
            panic!("test-log");
        }
    }
    init::init();
}

which seems to break all sorts of things, not just panic!.

@Veykril
Copy link
Member

Veykril commented Feb 8, 2024

r-a expands that to

// Recursive expansion of test macro
// ==================================

#[::core::prelude::v1::test]
fn foo() {
    mod init {
        pub fn init() {
            {
                let mut env_logger_builder = ::test_log::env_logger::builder();
                let _ = env_logger_builder.is_test(true).try_init();
            }
        }
    }
    init::init();
    {}
}

for me 🤔 no panic in sight (and no diagnostics either) test-log = "0.2.14"

@lnicola
Copy link
Member Author

lnicola commented Feb 8, 2024

Sorry, you need features = ["trace"]. Anyway, the minimized test case has no dependencies.

@lnicola lnicola changed the title Unresolved macro panic! with #[test_log::test] Unresolved macro panic! with inner module Feb 8, 2024
@lnicola
Copy link
Member Author

lnicola commented Feb 8, 2024

Also this:

image

@Veykril
Copy link
Member

Veykril commented Feb 8, 2024

arguably that shouldn't be valid Rust

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants