]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_typeck/src/variance/test.rs
Rollup merge of #95040 - frank-king:fix/94981, r=Mark-Simulacrum
[rust.git] / compiler / rustc_typeck / src / variance / test.rs
1 use rustc_errors::struct_span_err;
2 use rustc_middle::ty::TyCtxt;
3 use rustc_span::symbol::sym;
4
5 pub fn test_variance(tcx: TyCtxt<'_>) {
6     // For unit testing: check for a special "rustc_variance"
7     // attribute and report an error with various results if found.
8     for id in tcx.hir().items() {
9         if tcx.has_attr(id.def_id.to_def_id(), sym::rustc_variance) {
10             let variances_of = tcx.variances_of(id.def_id);
11             struct_span_err!(tcx.sess, tcx.def_span(id.def_id), E0208, "{:?}", variances_of).emit();
12         }
13     }
14 }