Stream: general

Topic: get span from an AssociatedItem

mikeyhew (Dec 19 2018 at 22:50, on Zulip):

I'm replacing bug! with delay_span_bug and need to pass a span. I have an &ty::AssociatedItem<'tcx>, how do I get the span from that? It has a def_id field, so presumably there is some function you can pass that to to get a span but I'm having a hard time finding it

mikeyhew (Dec 19 2018 at 23:35, on Zulip):

OK it's pretty simple: tcx.def_span(def_id). According to @Alexander Regueiro on Discord, it might only work when the def id is local to the current crate, but it works for the code I'm working on.

Last update: Jan 21 2020 at 06:40UTC