• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use rustc_middle::ty::TyCtxt;
2 use rustc_span::symbol::sym;
3 
4 use crate::errors;
5 
test_variance(tcx: TyCtxt<'_>)6 pub fn test_variance(tcx: TyCtxt<'_>) {
7     // For unit testing: check for a special "rustc_variance"
8     // attribute and report an error with various results if found.
9     for id in tcx.hir().items() {
10         if tcx.has_attr(id.owner_id, sym::rustc_variance) {
11             let variances_of = tcx.variances_of(id.owner_id);
12 
13             tcx.sess.emit_err(errors::VariancesOf {
14                 span: tcx.def_span(id.owner_id),
15                 variances_of: format!("{variances_of:?}"),
16             });
17         }
18     }
19 }
20