summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_hir_analysis/src/variance/test.rs
blob: 5feeb92d3378251e9e551acf2a435c9c24134c62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use rustc_middle::ty::TyCtxt;
use rustc_span::symbol::sym;

pub fn test_variance(tcx: TyCtxt<'_>) {
    // For unit testing: check for a special "rustc_variance"
    // attribute and report an error with various results if found.
    for id in tcx.hir().items() {
        if tcx.has_attr(id.owner_id.to_def_id(), sym::rustc_variance) {
            let variances_of = tcx.variances_of(id.owner_id);

            tcx.sess.struct_span_err(tcx.def_span(id.owner_id), format!("{variances_of:?}")).emit();
        }
    }
}