mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00

spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
16 lines
571 B
Rust
16 lines
571 B
Rust
use rustc_errors::struct_span_err;
|
|
use rustc_middle::ty::TyCtxt;
|
|
use rustc_span::symbol::sym;
|
|
|
|
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);
|
|
struct_span_err!(tcx.sess, tcx.def_span(id.owner_id), E0208, "{:?}", variances_of)
|
|
.emit();
|
|
}
|
|
}
|
|
}
|