Skip to main content

rustc_dump_def_path

Attribute rustc_dump_def_path 

Source
Expand description

Dumps the def path of the annotated item.

See also def_path_str and def_path_str_with_args.

See AttributeKind::RustcDumpDefPath for the internal representation of this attribute.

§Example

//@ dont-require-annotations: ERROR
//@ compile-flags: --crate-type lib -Z ui-testing=no
//@ build-fail

#![feature(rustc_attrs)]

#[rustc_dump_def_path]
fn main() {
    || {
        unsafe extern "C" {
            #[rustc_dump_def_path]
            static Foo: u8;
        }
    };
}

mod a {
    mod b {
        mod c {
            #[rustc_dump_def_path]
            fn d() {}
        }
    }
}

produces:

error: def-path(main)
--> $DIR/rustc_dump_def_path.rs:7:1
 |
7 | #[rustc_dump_def_path]
 | ^^^^^^^^^^^^^^^^^^^^^^

error: def-path(a::b::c::d)
 --> $DIR/rustc_dump_def_path.rs:20:13
  |
20 |             #[rustc_dump_def_path]
  |             ^^^^^^^^^^^^^^^^^^^^^^

error: def-path(main::{closure#0}::Foo)
 --> $DIR/rustc_dump_def_path.rs:11:13
  |
11 |             #[rustc_dump_def_path]
  |             ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 3 previous errors