2020-03-29 15:19:48 +00:00
|
|
|
use rustc_middle::ty::TyCtxt;
|
2020-01-01 18:30:57 +00:00
|
|
|
use rustc_span::symbol::sym;
|
2017-04-25 09:45:59 +00:00
|
|
|
|
2019-06-21 21:49:03 +00:00
|
|
|
pub fn test_variance(tcx: TyCtxt<'_>) {
|
2022-04-28 02:03:57 +00:00
|
|
|
// 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() {
|
2022-10-27 03:02:18 +00:00
|
|
|
if tcx.has_attr(id.owner_id.to_def_id(), sym::rustc_variance) {
|
|
|
|
let variances_of = tcx.variances_of(id.owner_id);
|
2023-01-16 10:30:50 +00:00
|
|
|
|
|
|
|
tcx.sess.struct_span_err(tcx.def_span(id.owner_id), format!("{variances_of:?}")).emit();
|
2017-04-25 09:45:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|