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.

15 lines
548 B
Rust
Raw Normal View History

use rustc_errors::struct_span_err;
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;
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.def_id.to_def_id(), sym::rustc_variance) {
let variances_of = tcx.variances_of(id.def_id);
struct_span_err!(tcx.sess, tcx.def_span(id.def_id), E0208, "{:?}", variances_of).emit();
}
}
}