Skip to content

Crate not found when using extern macro in another macro and invoked from another crate #44817

Open
@tikue

Description

@tikue
// -----------------------------------------------
// serde-test/src/lib.rs

//! This crate provides a macro that creates serializable structs.

#![feature(use_extern_macros)]

#[doc(hidden)]
pub extern crate serde_derive;

#[macro_export]
macro_rules! serde_test {
    () => {
        #[derive($crate::serde_derive::Deserialize, $crate::serde_derive::Serialize)]
        pub struct Serializable {
        }
    }
}

// -----------------------------------------------
// serde-test-test/Cargo.toml

[package]
name = "serde-test-test"
version = "0.1.0"
authors = ["Tim Kuehn <[email protected]>"]

[dependencies]
serde-test = { path = "../serde-test" }

// -----------------------------------------------
// serde-test-test/src/lib.rs

#![feature(use_extern_macros)]

#[macro_use]
extern crate serde_test;

serde_test! {}

In serde-test-test directory:

error[E0463]: can't find crate for `_serde`
 --> src/lib.rs:6:1
  |
6 | serde_test! {}
  | ^^^^^^^^^^^^^^ can't find crate
  |
  = note: this error originates in a macro outside of the current crate

error: aborting due to previous error

error: Could not compile `serde-test-test`.

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

This error goes away if you add serde = "*" to serde-test-test/Cargo.toml.

Metadata

Metadata

Assignees

Labels

A-decl-macros-2-0Area: Declarative macros 2.0 (#39412)C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions