rust/compiler/rustc_hir_analysis/src/variance/test.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
613 B
Rust
Raw Normal View History

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;
use crate::errors;
2019-06-21 21:49:03 +00:00
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.emit_err(errors::VariancesOf {
span: tcx.def_span(id.owner_id),
variances_of: format!("{variances_of:?}"),
});
}
}
}