Skip to content

derive(Debug) silently does nothing for extern_types #46663

@crumblingstatue

Description

@crumblingstatue
// Library code
#![feature(extern_types)]

extern "C" {
    #[derive(Debug)]
    pub type Bar;
}

// User code
fn main() {
    let b = 0x0 as *const Bar;
    println!("{:?}", &*b);
}

Error:

error[E0277]: the trait bound `Bar: std::fmt::Debug` is not satisfied
  --> foo.rs:12:19
   |
12 |     println!("{:?}", &*b);
   |                      ^^^ `Bar` cannot be formatted using `:?`; if it is defined in your crate, add `#[derive(Debug)]` or manually implement it

If possible, it should at least emit a warning or something. At the very least, missing_debug_implementations should trigger if #[derive(Debug)] can not produce a compile error in case it can't generate an implementation. See #46662.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-FFIArea: Foreign function interface (FFI)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)C-bugCategory: This is a bug.F-extern_types`#![feature(extern_types)]`requires-nightlyThis issue requires a nightly compiler in some way.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions