diff options
| author | Michael Goulet <michael@errs.io> | 2025-04-06 21:55:06 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2025-04-06 21:55:06 +0000 |
| commit | c8649a31a8eea7c4ed33d68d3fc3b71a2cffd119 (patch) | |
| tree | cb8131fdd917608fd2d0e527958a2ccadc32d3c1 /compiler/rustc_middle/src/ty | |
| parent | fd4dc18e684ffb8c000b053e4d34f412ee1d586a (diff) | |
| download | rust-c8649a31a8eea7c4ed33d68d3fc3b71a2cffd119.tar.gz rust-c8649a31a8eea7c4ed33d68d3fc3b71a2cffd119.zip | |
Stop calling source_span query in significant drop order code
Diffstat (limited to 'compiler/rustc_middle/src/ty')
| -rw-r--r-- | compiler/rustc_middle/src/ty/significant_drop_order.rs | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/compiler/rustc_middle/src/ty/significant_drop_order.rs b/compiler/rustc_middle/src/ty/significant_drop_order.rs index 4881d611c12..ce4208f2c44 100644 --- a/compiler/rustc_middle/src/ty/significant_drop_order.rs +++ b/compiler/rustc_middle/src/ty/significant_drop_order.rs @@ -143,25 +143,11 @@ pub fn ty_dtor_span<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Span> { | ty::UnsafeBinder(_) => None, ty::Adt(adt_def, _) => { - let did = adt_def.did(); - let try_local_did_span = |did: DefId| { - if let Some(local) = did.as_local() { - tcx.source_span(local) - } else { - tcx.def_span(did) - } - }; - let dtor = if let Some(dtor) = tcx.adt_destructor(did) { - dtor.did - } else if let Some(dtor) = tcx.adt_async_destructor(did) { - return Some(tcx.source_span(dtor.impl_did)); + if let Some(dtor) = tcx.adt_destructor(adt_def.did()) { + Some(tcx.def_span(tcx.parent(dtor.did))) } else { - return Some(try_local_did_span(did)); - }; - let def_key = tcx.def_key(dtor); - let Some(parent_index) = def_key.parent else { return Some(try_local_did_span(dtor)) }; - let parent_did = DefId { index: parent_index, krate: dtor.krate }; - Some(try_local_did_span(parent_did)) + Some(tcx.def_span(adt_def.did())) + } } ty::Coroutine(did, _) | ty::CoroutineWitness(did, _) |
