diff options
| author | Ralf Jung <post@ralfj.de> | 2023-09-09 17:39:53 +0200 | 
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-09-09 17:39:53 +0200 | 
| commit | c2a7e684cd43f449bc40a696dbf9b69ebccc33c3 (patch) | |
| tree | d3127cf14e679e075e02bb2c34f87f7e913a5c43 /compiler/rustc_passes/src/layout_test.rs | |
| parent | a5b031136702068e4a82d384fec1e66503974064 (diff) | |
| download | rust-c2a7e684cd43f449bc40a696dbf9b69ebccc33c3.tar.gz rust-c2a7e684cd43f449bc40a696dbf9b69ebccc33c3.zip | |
use hir_crate_items(()).definitions() instead of hir().items()
Diffstat (limited to 'compiler/rustc_passes/src/layout_test.rs')
| -rw-r--r-- | compiler/rustc_passes/src/layout_test.rs | 16 | 
1 files changed, 4 insertions, 12 deletions
| diff --git a/compiler/rustc_passes/src/layout_test.rs b/compiler/rustc_passes/src/layout_test.rs index 6dacac150d3..6403effe027 100644 --- a/compiler/rustc_passes/src/layout_test.rs +++ b/compiler/rustc_passes/src/layout_test.rs @@ -20,21 +20,13 @@ pub fn test_layout(tcx: TyCtxt<'_>) { // if the `rustc_attrs` feature is not enabled, don't bother testing layout return; } - for id in tcx.hir().items() { - for attr in tcx.get_attrs(id.owner_id, sym::rustc_layout) { - match tcx.def_kind(id.owner_id) { + for id in tcx.hir_crate_items(()).definitions() { + for attr in tcx.get_attrs(id, sym::rustc_layout) { + match tcx.def_kind(id) { DefKind::TyAlias { .. } | DefKind::Enum | DefKind::Struct | DefKind::Union => { - dump_layout_of(tcx, id.owner_id.def_id, attr); + dump_layout_of(tcx, id, attr); } _ => { - tcx.sess.emit_err(LayoutInvalidAttribute { span: tcx.def_span(id.owner_id) }); - } - } - } - if matches!(tcx.def_kind(id.owner_id), DefKind::Impl { .. }) { - // To find associated functions we need to go into the child items here. - for &id in tcx.associated_item_def_ids(id.owner_id) { - for _attr in tcx.get_attrs(id, sym::rustc_layout) { tcx.sess.emit_err(LayoutInvalidAttribute { span: tcx.def_span(id) }); } } | 
