Skip to main content

rustc_dump_variances_of_opaques

Attribute rustc_dump_variances_of_opaques 

Source
Expand description

Dumps the variances of opaque types in this crate.

See also the variances_of query.

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

§Example

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

#![feature(rustc_attrs)]
#![rustc_dump_variances_of_opaques]

trait Captures<'a> {}
impl<T> Captures<'_> for T {}

fn not_captured_early<'a: 'a>() -> impl Sized {}

fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}

fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}

fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}

produces:

error: ['a: *]
 --> $DIR/rustc_dump_variances_of_opaques.rs:10:36
  |
10 | fn not_captured_early<'a: 'a>() -> impl Sized {}
  |                                    ^^^^^^^^^^

error: ['a: *, 'a: o]
 --> $DIR/rustc_dump_variances_of_opaques.rs:12:32
  |
12 | fn captured_early<'a: 'a>() -> impl Sized + Captures<'a> {}
  |                                ^^^^^^^^^^^^^^^^^^^^^^^^^

error: []
 --> $DIR/rustc_dump_variances_of_opaques.rs:14:40
  |
14 | fn not_captured_late<'a>(_: &'a ()) -> impl Sized {}
  |                                        ^^^^^^^^^^

error: ['a: o]
 --> $DIR/rustc_dump_variances_of_opaques.rs:16:36
  |
16 | fn captured_late<'a>(_: &'a ()) -> impl Sized + Captures<'a> {}
  |                                    ^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 4 previous errors