Skip to main content

rustc_attr_ir/
attribute_docs.rs

1macro_rules! include_example {
2    ($name:literal) => {
3        concat!(
4            "```rust,compile_fail\n",
5            include_str!(concat!("../../../tests/ui/attributes/doc_examples/", $name, ".rs")),
6            "```\n",
7            "produces:\n",
8            " ```text\n",
9            include_str!(concat!("../../../tests/ui/attributes/doc_examples/", $name, ".stderr")),
10            "```\n",
11        )
12    };
13}
14
15#[cfg_attr(not(bootstrap), doc(attribute = "rustc_dump_clauses"))]
16/// Dumps the list of [`ty::Clause`]s as computed by the [`clauses_of`] query.
17///
18/// See [`AttributeKind::RustcDumpClauses`] for the internal representation of this attribute.
19///
20/// # Example
21///
22#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n//@ normalize-stderr: \"DefId\\((\\d+):(\\d+)\" -> \"DefId(..:..\"\n//@ normalize-stderr: \"\\[[A-Fa-f0-9]{4}\\]\" -> \"[....]\"\n\n#![feature(negative_impls)]\n#![feature(rustc_attrs)]\n\n#[rustc_dump_clauses]\nfn function<T: Send>(_t: T) {}\n\n#[rustc_dump_clauses]\ntrait Trait: Sync {\n    #[rustc_dump_clauses]\n    type Assoc;\n}\n\n#[rustc_dump_clauses]\nstruct X<\'a, T: ?Sized, I: Iterator> {\n    x: &\'a T,\n    y: &\'a I::Item,\n}\n\n#[rustc_dump_clauses]\nimpl<T: ?Sized, I> !Sync for X<\'_, T, I> {}\n```\nproduces:\n ```text\nerror: rustc_dump_clauses\n  --> $DIR/rustc_dump_clauses.rs:10:1\n   |\n10 | fn function<T: Send>(_t: T) {}\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: Binder { value: TraitClause(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: TraitClause(<T as std::marker::Send>, polarity:Positive), bound_vars: [] }\n\nerror: rustc_dump_clauses\n  --> $DIR/rustc_dump_clauses.rs:13:1\n   |\n13 | trait Trait: Sync {\n   | ^^^^^^^^^^^^^^^^^\n   |\n   = note: Binder { value: TraitClause(<Self as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: TraitClause(<Self as std::marker::Sync>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: TraitClause(<Self as Trait>, polarity:Positive), bound_vars: [] }\n\nerror: rustc_dump_clauses\n  --> $DIR/rustc_dump_clauses.rs:19:1\n   |\n19 | struct X<\'a, T: ?Sized, I: Iterator> {\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: Binder { value: TraitClause(<T as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: TraitClause(<I as std::marker::Sized>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: TraitClause(<I as std::iter::Iterator>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: OutlivesClause(T/#1, \'a/#0), bound_vars: [] }\n   = note: Binder { value: OutlivesClause(Alias(No, Alias { kind: Projection { def_id: DefId(..:.. ~ core[....]::iter::traits::iterator::Iterator::Item) }, args: [I/#2], .. }), \'a/#0), bound_vars: [] }\n\nerror: rustc_dump_clauses\n  --> $DIR/rustc_dump_clauses.rs:25:1\n   |\n25 | impl<T: ?Sized, I> !Sync for X<\'_, T, I> {}\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: Binder { value: TraitClause(<T as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: TraitClause(<I as std::marker::Sized>, polarity:Positive), bound_vars: [] }\n\nerror: rustc_dump_clauses\n  --> $DIR/rustc_dump_clauses.rs:15:5\n   |\n15 |     type Assoc;\n   |     ^^^^^^^^^^\n   |\n   = note: Binder { value: TraitClause(<Self as std::marker::MetaSized>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: TraitClause(<Self as std::marker::Sync>, polarity:Positive), bound_vars: [] }\n   = note: Binder { value: TraitClause(<Self as Trait>, polarity:Positive), bound_vars: [] }\n\nerror: aborting due to 5 previous errors\n\n```\n"include_example!("rustc_dump_clauses")]
23///
24/// # Example: super trait bounds are not elaborated
25///
26#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_clauses]\nfn foo<T: Copy>(t: &T) -> T {\n    *t\n}\n```\nproduces:\n ```text\nerror: rustc_dump_clauses\n --> $DIR/rustc_dump_clauses_super_trait.rs:7:1\n  |\n7 | fn foo<T: Copy>(t: &T) -> T {\n  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  |\n  = note: Binder { value: TraitClause(<T as std::marker::Sized>, polarity:Positive), bound_vars: [] }\n  = note: Binder { value: TraitClause(<T as std::marker::Copy>, polarity:Positive), bound_vars: [] }\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_clauses_super_trait")]
27///
28/// [`clauses_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.clauses_of
29/// [`ty::Clause`]: ../rustc_middle/ty/struct.Clause.html
30const _: () = ();
31
32#[doc(attribute = "rustc_dump_def_parents")]
33/// Dumps the parents of the annotated item and of any anonymous constants contained within it.
34///
35/// See also [`opt_parent`](../rustc_middle/ty/struct.TyCtxt.html#method.opt_parent).
36///
37/// See [`AttributeKind::RustcDumpDefParents`] for the internal representation of this attribute.
38///
39/// # Example
40///
41#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\nfn parent() {\n    #[rustc_dump_def_parents]\n    fn child() {}\n}\n\nstruct Struct<const N: usize>;\n\nconst CONST: Struct<42> = Struct::<\n    {\n        #[rustc_dump_def_parents]\n        fn baby() {}\n\n        42\n    },\n>;\n```\nproduces:\n ```text\nerror: rustc_dump_def_parents: DefId(0:4 ~ rustc_dump_def_parents[9c2e]::parent::child)\n  --> $DIR/rustc_dump_def_parents.rs:8:5\n   |\n 8 |     fn child() {}\n   |     ^^^^^^^^^^\n   |\nnote: DefId(0:3 ~ rustc_dump_def_parents[9c2e]::parent)\n  --> $DIR/rustc_dump_def_parents.rs:6:1\n   |\n 6 | fn parent() {\n   | ^^^^^^^^^^^\nnote: DefId(0:0 ~ rustc_dump_def_parents[9c2e])\n  --> $DIR/rustc_dump_def_parents.rs:4:1\n   |\n 4 | / #![feature(rustc_attrs)]\n 5 | |\n 6 | | fn parent() {\n 7 | |     #[rustc_dump_def_parents]\n...  |\n19 | |     },\n20 | | >;\n   | |__^\n\nerror: rustc_dump_def_parents: DefId(0:11 ~ rustc_dump_def_parents[9c2e]::CONST::{constant#1}::baby)\n  --> $DIR/rustc_dump_def_parents.rs:16:9\n   |\n16 |         fn baby() {}\n   |         ^^^^^^^^^\n   |\nnote: DefId(0:10 ~ rustc_dump_def_parents[9c2e]::CONST::{constant#1})\n  --> $DIR/rustc_dump_def_parents.rs:14:5\n   |\n14 | /     {\n15 | |         #[rustc_dump_def_parents]\n16 | |         fn baby() {}\n...  |\n19 | |     },\n   | |_____^\nnote: DefId(0:8 ~ rustc_dump_def_parents[9c2e]::CONST)\n  --> $DIR/rustc_dump_def_parents.rs:13:1\n   |\n13 | const CONST: Struct<42> = Struct::<\n   | ^^^^^^^^^^^^^^^^^^^^^^^\nnote: DefId(0:0 ~ rustc_dump_def_parents[9c2e])\n  --> $DIR/rustc_dump_def_parents.rs:4:1\n   |\n 4 | / #![feature(rustc_attrs)]\n 5 | |\n 6 | | fn parent() {\n 7 | |     #[rustc_dump_def_parents]\n...  |\n19 | |     },\n20 | | >;\n   | |__^\n\nerror: aborting due to 2 previous errors\n\n```\n"include_example!("rustc_dump_def_parents")]
42const _: () = ();
43
44#[doc(attribute = "rustc_dump_def_path")]
45/// Dumps the def path of the annotated item.
46///
47/// See also [`def_path_str`] and [`def_path_str_with_args`].
48///
49/// See [`AttributeKind::RustcDumpDefPath`] for the internal representation of this attribute.
50///
51/// # Example
52///
53#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n//@ build-fail\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_def_path]\nfn main() {\n    || {\n        unsafe extern \"C\" {\n            #[rustc_dump_def_path]\n            static Foo: u8;\n        }\n    };\n}\n\nmod a {\n    mod b {\n        mod c {\n            #[rustc_dump_def_path]\n            fn d() {}\n        }\n    }\n}\n```\nproduces:\n ```text\nerror: def-path(main)\n --> $DIR/rustc_dump_def_path.rs:7:1\n  |\n7 | #[rustc_dump_def_path]\n  | ^^^^^^^^^^^^^^^^^^^^^^\n\nerror: def-path(a::b::c::d)\n  --> $DIR/rustc_dump_def_path.rs:20:13\n   |\n20 |             #[rustc_dump_def_path]\n   |             ^^^^^^^^^^^^^^^^^^^^^^\n\nerror: def-path(main::{closure#0}::Foo)\n  --> $DIR/rustc_dump_def_path.rs:11:13\n   |\n11 |             #[rustc_dump_def_path]\n   |             ^^^^^^^^^^^^^^^^^^^^^^\n\nerror: aborting due to 3 previous errors\n\n```\n"include_example!("rustc_dump_def_path")]
54///
55/// [`def_path_str`]: ../rustc_middle/ty/struct.TyCtxt.html#method.def_path_str
56/// [`def_path_str_with_args`]: ../rustc_middle/ty/struct.TyCtxt.html#method.def_path_str_with_args
57const _: () = ();
58
59#[doc(attribute = "rustc_dump_generics")]
60/// Dumps the generics of the annotated item.
61///
62/// See [`generics_of`] and [`ty::Generics`] for what "generics" means here.
63///
64/// See [`AttributeKind::RustcDumpGenerics`] for the internal representation of this attribute.
65///
66/// # Example
67///
68#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n//@ normalize-stderr: \"DefId\\((\\d+):(\\d+)\" -> \"DefId(..:..\"\n//@ normalize-stderr: \"\\[[A-Fa-f0-9]{4}\\]\" -> \"[....]\"\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_generics]\nstruct Struct<\'lifetime, const CONST: usize, GENERIC> {\n    stuff: &\'lifetime [GENERIC; CONST],\n}\n```\nproduces:\n ```text\nerror: rustc_dump_generics: DefId(..:.. ~ rustc_dump_generics[....]::Struct)\n --> $DIR/rustc_dump_generics.rs:9:1\n  |\n9 | struct Struct<\'lifetime, const CONST: usize, GENERIC> {\n  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  |\nnote: Generics {\n          parent: None,\n          parent_count: 0,\n          own_params: [\n              GenericParamDef {\n                  name: \"\'lifetime\",\n                  def_id: DefId(..:.. ~ rustc_dump_generics[....]::Struct::\'lifetime),\n                  index: 0,\n                  pure_wrt_drop: false,\n                  kind: Lifetime,\n              },\n              GenericParamDef {\n                  name: \"CONST\",\n                  def_id: DefId(..:.. ~ rustc_dump_generics[....]::Struct::CONST),\n                  index: 1,\n                  pure_wrt_drop: false,\n                  kind: Const {\n                      has_default: false,\n                  },\n              },\n              GenericParamDef {\n                  name: \"GENERIC\",\n                  def_id: DefId(..:.. ~ rustc_dump_generics[....]::Struct::GENERIC),\n                  index: 2,\n                  pure_wrt_drop: false,\n                  kind: Type {\n                      has_default: false,\n                      synthetic: false,\n                  },\n              },\n          ],\n          param_def_id_to_index: [\n              (\n                  DefId(..:.. ~ rustc_dump_generics[....]::Struct::\'lifetime),\n                  0,\n              ),\n              (\n                  DefId(..:.. ~ rustc_dump_generics[....]::Struct::CONST),\n                  1,\n              ),\n              (\n                  DefId(..:.. ~ rustc_dump_generics[....]::Struct::GENERIC),\n                  2,\n              ),\n          ],\n          has_self: false,\n          has_late_bound_regions: None,\n      }\n --> $DIR/rustc_dump_generics.rs:9:1\n  |\n9 | struct Struct<\'lifetime, const CONST: usize, GENERIC> {\n  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_generics")]
69///
70/// [`generics_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.generics_of
71/// [`ty::Generics`]: ../rustc_middle/ty/struct.Generics.html
72const _: () = ();
73
74#[doc(attribute = "rustc_dump_hidden_type_of_opaques")]
75/// Dumps the hidden types of the opaque items in this crate.
76///
77/// This ends up calling the [`type_of`] query, which, for opaque types, reveals their hidden types.
78///
79/// See [`AttributeKind::RustcDumpHiddenTypeOfOpaques`] for the internal representation of this attribute.
80///
81/// # Example
82///
83#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no -Z verbose-internals\n\n#![feature(rustc_attrs)]\n#![rustc_dump_hidden_type_of_opaques]\n\ntrait Foo {\n    fn hello(&self) -> impl Sized;\n}\n\nfn hello<\'s, T: Foo>(x: &\'s T) -> impl Sized + use<\'s, T> {\n    x.hello()\n}\n```\nproduces:\n ```text\nerror: <T as Foo>::hello::{anon_assoc#0}<\'s/#1>\n  --> $DIR/rustc_dump_hidden_type_of_opaques.rs:11:35\n   |\n11 | fn hello<\'s, T: Foo>(x: &\'s T) -> impl Sized + use<\'s, T> {\n   |                                   ^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_hidden_type_of_opaques")]
84///
85/// [`type_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.type_of
86const _: () = ();
87
88#[doc(attribute = "rustc_dump_inferred_outlives")]
89/// Dumps the inferred outlives-clauses of the annotated item.
90///
91/// See also the [`inferred_outlives_of`] query.
92///
93/// See [`AttributeKind::RustcDumpInferredOutlives`] for the internal representation of this attribute.
94///
95/// # Example
96///
97#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\ntrait Trait<\'x, T>\nwhere\n    T: \'x,\n{\n    type Type;\n}\n\n#[rustc_dump_inferred_outlives]\nstruct Foo<\'a, A, B>\nwhere\n    A: Trait<\'a, B>,\n{\n    foo: <A as Trait<\'a, B>>::Type,\n}\n```\nproduces:\n ```text\nerror: rustc_dump_inferred_outlives\n  --> $DIR/rustc_dump_inferred_outlives.rs:14:1\n   |\n14 | struct Foo<\'a, A, B>\n   | ^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: B: \'a\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_inferred_outlives")]
98///
99/// [`inferred_outlives_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.inferred_outlives_of
100const _: () = ();
101
102#[doc(attribute = "rustc_dump_item_bounds")]
103/// Dumps the item bounds of the annotated item.
104///
105/// This ends up calling the [`item_bounds`] query and prints the [`ty::Clause`] of the item.
106///
107/// See [`AttributeKind::RustcDumpItemBounds`] for the internal representation of this attribute.
108///
109/// # Example
110///
111#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\ntrait Trait<T> {\n    #[rustc_dump_item_bounds]\n    type Assoc: PartialEq<String>;\n}\n```\nproduces:\n ```text\nerror: rustc_dump_item_bounds\n --> $DIR/rustc_dump_item_bounds.rs:8:5\n  |\n8 |     type Assoc: PartialEq<String>;\n  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  |\n  = note: Binder { value: TraitClause(<<Self as Trait<T>>::Assoc as std::cmp::PartialEq<std::string::String>>, polarity:Positive), bound_vars: [] }\n  = note: Binder { value: TraitClause(<<Self as Trait<T>>::Assoc as std::marker::Sized>, polarity:Positive), bound_vars: [] }\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_item_bounds")]
112///
113/// [`item_bounds`]: ../rustc_middle/ty/struct.TyCtxt.html#method.item_bounds
114/// [`ty::Clause`]: ../rustc_middle/ty/struct.Clause.html
115const _: () = ();
116
117#[doc(attribute = "rustc_dump_layout")]
118/// Dumps the layout of the annotated item.
119///
120/// This ends up calling the [`layout_of`] query to get the [`Layout`] of the annotated item. If used
121/// with the `debug` modifier, it will print the entirety of `Layout`. Other modifiers will print
122/// only parts of it.
123///
124/// See [`AttributeKind::RustcDumpLayout`] for the internal representation of this attribute.
125///
126/// # Example: `debug`
127///
128#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n//@ normalize-stderr: \"randomization_seed: \\d+\" -> \"randomization_seed: $$SEED\"\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_layout(debug)]\npub union Union {\n    Float: f32,\n    Int: u32,\n}\n```\nproduces:\n ```text\nerror: layout_of(Union) = Layout {\n           size: Size(4 bytes),\n           align: AbiAlign {\n               abi: Align(4 bytes),\n           },\n           backend_repr: Memory {\n               sized: true,\n           },\n           fields: Union(\n               2,\n           ),\n           largest_niche: None,\n           uninhabited: false,\n           variants: Single {\n               index: 0,\n           },\n           max_repr_align: None,\n           unadjusted_abi_align: Align(4 bytes),\n           randomization_seed: $SEED,\n       }\n --> $DIR/rustc_dump_layout_debug.rs:8:1\n  |\n8 | pub union Union {\n  | ^^^^^^^^^^^^^^^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_layout_debug")]
129///
130/// # Example: `largest_niche`
131///
132#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_layout(largest_niche)]\ntype Alias = Option<char>;\n```\nproduces:\n ```text\nerror: largest_niche: Some(Niche { offset: Size(0 bytes), value: u32, valid_range: (..=1114111) | (4294967295..) })\n --> $DIR/rustc_dump_layout_largest_niche.rs:7:1\n  |\n7 | type Alias = Option<char>;\n  | ^^^^^^^^^^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_layout_largest_niche")]
133///
134/// # Example: `size`
135///
136#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_layout(size)]\ntype ID = std::any::TypeId;\n```\nproduces:\n ```text\nerror: size: Size(16 bytes)\n --> $DIR/rustc_dump_layout_size.rs:7:1\n  |\n7 | type ID = std::any::TypeId;\n  | ^^^^^^^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_layout_size")]
137///
138/// # Example: `align`
139///
140#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_layout(align)]\nenum Enum {\n    Bytes([u8; 4]),\n    Int(u32),\n}\n```\nproduces:\n ```text\nerror: align: Align(4 bytes)\n --> $DIR/rustc_dump_layout_align.rs:7:1\n  |\n7 | enum Enum {\n  | ^^^^^^^^^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_layout_align")]
141///
142/// # Example: `backend_repr`
143///
144#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n#![feature(portable_simd)]\n\n#[rustc_dump_layout(backend_repr)]\ntype Simd = std::simd::u32x4;\n```\nproduces:\n ```text\nerror: backend_repr: SimdVector { element: u32 is .., count: BackendLaneCount(4) }\n --> $DIR/rustc_dump_layout_backend_repr.rs:8:1\n  |\n8 | type Simd = std::simd::u32x4;\n  | ^^^^^^^^^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_layout_backend_repr")]
145///
146/// # Example: `homogeneous_aggregate`
147///
148#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_layout(homogeneous_aggregate)]\n#[repr(C)]\nstruct Struct {\n    field: [u8; 32],\n    unit: (),\n}\n```\nproduces:\n ```text\nerror: homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Integer, size: Size(1 bytes) }))\n --> $DIR/rustc_dump_layout_homogeneous_aggregate.rs:8:1\n  |\n8 | struct Struct {\n  | ^^^^^^^^^^^^^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_layout_homogeneous_aggregate")]
149///
150/// [`layout_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.layout_of
151/// [`Layout`]: rustc_abi::Layout
152const _: () = ();
153
154#[doc(attribute = "rustc_dump_object_lifetime_defaults")]
155/// Dumps the trait object lifetime defaults induced by the type parameters of the annotated item.
156///
157/// It will dump this information separately for each type parameter of the annotated item.
158///
159/// See also the [`object_lifetime_default`] query.
160///
161/// See [`AttributeKind::RustcDumpObjectLifetimeDefaults`] for the internal representation of this attribute.
162///
163/// # Example
164///
165#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_object_lifetime_defaults]\nstruct Ref<\'a, T: \'a>(&\'a T);\n```\nproduces:\n ```text\nerror: \'a\n --> $DIR/rustc_dump_object_lifetime_defaults.rs:7:16\n  |\n7 | struct Ref<\'a, T: \'a>(&\'a T);\n  |                ^\n\nerror: aborting due to 1 previous error\n\n```\n"include_example!("rustc_dump_object_lifetime_defaults")]
166///
167/// [`object_lifetime_default`]: ../rustc_middle/ty/struct.TyCtxt.html#method.object_lifetime_default
168const _: () = ();
169
170#[doc(attribute = "rustc_dump_symbol_name")]
171/// Dumps the symbol name of the annotated item, also demangling it if necessary.
172///
173/// See also the [`symbol_name`] query.
174///
175/// See [`AttributeKind::RustcDumpSymbolName`] for the internal representation of this attribute.
176///
177/// # Example
178///
179#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n//@ build-fail\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_symbol_name]\nfn mangled() {}\n\n#[rustc_dump_symbol_name]\n#[unsafe(no_mangle)]\nfn no_mangle() {}\n\nunsafe extern \"C\" {\n    #[rustc_dump_symbol_name]\n    fn abort();\n}\n```\nproduces:\n ```text\nerror: symbol-name(_RNvCsCRATE_HASH_22rustc_dump_symbol_name7mangled)\n --> $DIR/rustc_dump_symbol_name.rs:7:1\n  |\n7 | #[rustc_dump_symbol_name]\n  | ^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: demangling(rustc_dump_symbol_name[6981ee133444a33d]::mangled)\n --> $DIR/rustc_dump_symbol_name.rs:7:1\n  |\n7 | #[rustc_dump_symbol_name]\n  | ^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: demangling-alt(rustc_dump_symbol_name::mangled)\n --> $DIR/rustc_dump_symbol_name.rs:7:1\n  |\n7 | #[rustc_dump_symbol_name]\n  | ^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: symbol-name(no_mangle)\n  --> $DIR/rustc_dump_symbol_name.rs:10:1\n   |\n10 | #[rustc_dump_symbol_name]\n   | ^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: symbol-name(abort)\n  --> $DIR/rustc_dump_symbol_name.rs:15:5\n   |\n15 |     #[rustc_dump_symbol_name]\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: aborting due to 5 previous errors\n\n```\n"include_example!("rustc_dump_symbol_name")]
180///
181/// [`symbol_name`]: ../rustc_middle/ty/struct.TyCtxt.html#method.symbol_name
182const _: () = ();
183
184#[doc(attribute = "rustc_dump_variances")]
185/// Dumps the variances of the annotated item.
186///
187/// See also the [`variances_of`] query and [`ty::Variance`].
188///
189/// See [`AttributeKind::RustcDumpVariances`] for the internal representation of this attribute.
190///
191/// # Example
192///
193#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_variances]\nstruct Ref<\'a, T> {\n    r: &\'a T,\n}\n\n#[rustc_dump_variances]\nstruct RefMut<\'a, T> {\n    r: &\'a mut T,\n}\n\n#[rustc_dump_variances]\nstruct CellRef<\'a, T> {\n    r: &\'a core::cell::UnsafeCell<T>,\n}\n\n#[rustc_dump_variances]\nfn x<T, U>(_t: T) -> U {\n    todo!()\n}\n```\nproduces:\n ```text\nerror: [\'a: +, T: +]\n --> $DIR/rustc_dump_variances.rs:7:1\n  |\n7 | struct Ref<\'a, T> {\n  | ^^^^^^^^^^^^^^^^^\n\nerror: [\'a: +, T: o]\n  --> $DIR/rustc_dump_variances.rs:12:1\n   |\n12 | struct RefMut<\'a, T> {\n   | ^^^^^^^^^^^^^^^^^^^^\n\nerror: [\'a: +, T: o]\n  --> $DIR/rustc_dump_variances.rs:17:1\n   |\n17 | struct CellRef<\'a, T> {\n   | ^^^^^^^^^^^^^^^^^^^^^\n\nerror: [T: -, U: +]\n  --> $DIR/rustc_dump_variances.rs:22:1\n   |\n22 | fn x<T, U>(_t: T) -> U {\n   | ^^^^^^^^^^^^^^^^^^^^^^\n\nerror: aborting due to 4 previous errors\n\n```\n"include_example!("rustc_dump_variances")]
194///
195/// [`variances_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.variances_of
196/// [`ty::Variance`]: ../rustc_middle/ty/enum.Variance.html
197const _: () = ();
198
199#[doc(attribute = "rustc_dump_variances_of_opaques")]
200/// Dumps the variances of opaque types in this crate.
201///
202/// See also the [`variances_of`] query.
203///
204/// See [`AttributeKind::RustcDumpVariancesOfOpaques`] for the internal representation of this attribute.
205///
206/// # Example
207///
208#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n#![rustc_dump_variances_of_opaques]\n\ntrait Captures<\'a> {}\nimpl<T> Captures<\'_> for T {}\n\nfn not_captured_early<\'a: \'a>() -> impl Sized {}\n\nfn captured_early<\'a: \'a>() -> impl Sized + Captures<\'a> {}\n\nfn not_captured_late<\'a>(_: &\'a ()) -> impl Sized {}\n\nfn captured_late<\'a>(_: &\'a ()) -> impl Sized + Captures<\'a> {}\n```\nproduces:\n ```text\nerror: [\'a: *]\n  --> $DIR/rustc_dump_variances_of_opaques.rs:10:36\n   |\n10 | fn not_captured_early<\'a: \'a>() -> impl Sized {}\n   |                                    ^^^^^^^^^^\n\nerror: [\'a: *, \'a: o]\n  --> $DIR/rustc_dump_variances_of_opaques.rs:12:32\n   |\n12 | fn captured_early<\'a: \'a>() -> impl Sized + Captures<\'a> {}\n   |                                ^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: []\n  --> $DIR/rustc_dump_variances_of_opaques.rs:14:40\n   |\n14 | fn not_captured_late<\'a>(_: &\'a ()) -> impl Sized {}\n   |                                        ^^^^^^^^^^\n\nerror: [\'a: o]\n  --> $DIR/rustc_dump_variances_of_opaques.rs:16:36\n   |\n16 | fn captured_late<\'a>(_: &\'a ()) -> impl Sized + Captures<\'a> {}\n   |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^\n\nerror: aborting due to 4 previous errors\n\n```\n"include_example!("rustc_dump_variances_of_opaques")]
209///
210/// [`variances_of`]: ../rustc_middle/ty/struct.TyCtxt.html#method.variances_of
211const _: () = ();
212
213#[doc(attribute = "rustc_dump_vtable")]
214/// Dumps the virtual method table ("vtable") of the annotated item.
215///
216/// See also the [`vtable_entries`] query.
217///
218/// See [`AttributeKind::RustcDumpVtable`] for the internal representation of this attribute.
219///
220/// # Example
221///
222#[doc = "```rust,compile_fail\n//@ dont-require-annotations: ERROR\n//@ compile-flags: --crate-type lib -Z ui-testing=no\n\n#![feature(rustc_attrs)]\n\n#[rustc_dump_vtable]\ntype X = dyn Send;\n\n#[rustc_dump_vtable]\ntype Y = dyn core::any::Any;\n\nstruct C;\n\n#[rustc_dump_vtable]\nimpl Iterator for C {\n    type Item = ();\n    fn next(&mut self) -> Option<Self::Item> {\n        Some(())\n    }\n}\n```\nproduces:\n ```text\nerror: vtable entries: [\n           MetadataDropInPlace,\n           MetadataSize,\n           MetadataAlign,\n       ]\n --> $DIR/rustc_dump_vtable.rs:7:1\n  |\n7 | type X = dyn Send;\n  | ^^^^^^\n\nerror: vtable entries: [\n           MetadataDropInPlace,\n           MetadataSize,\n           MetadataAlign,\n           Method(<dyn Any as Any>::type_id - shim(reify)),\n       ]\n  --> $DIR/rustc_dump_vtable.rs:10:1\n   |\n10 | type Y = dyn core::any::Any;\n   | ^^^^^^\n\nerror: vtable entries: [\n           MetadataDropInPlace,\n           MetadataSize,\n           MetadataAlign,\n           Method(<C as Iterator>::next),\n           Method(<C as Iterator>::size_hint),\n           Method(<C as Iterator>::advance_by),\n           Method(<C as Iterator>::nth),\n       ]\n  --> $DIR/rustc_dump_vtable.rs:15:1\n   |\n15 | impl Iterator for C {\n   | ^^^^^^^^^^^^^^^^^^^\n\nerror: aborting due to 3 previous errors\n\n```\n"include_example!("rustc_dump_vtable")]
223///
224/// [`vtable_entries`]: ../rustc_middle/ty/struct.TyCtxt.html#method.vtable_entries
225const _: () = ();