(
&self,
diag: &mut Diag<'tcx, G>,
use_stack: &[UseSite<'tcx>],
)
| 87 | } |
| 88 | |
| 89 | pub fn note_use_stack<G: EmissionGuarantee>( |
| 90 | &self, |
| 91 | diag: &mut Diag<'tcx, G>, |
| 92 | use_stack: &[UseSite<'tcx>], |
| 93 | ) { |
| 94 | for site in use_stack.iter().rev() { |
| 95 | let def_id = site.instance.value.def_id(); |
| 96 | if self.is_lang_item(def_id, LangItem::DropInPlace) { |
| 97 | let ty = site.instance.value.args[0]; |
| 98 | diag.note(format!("which is called from drop glue of `{ty}`")); |
| 99 | continue; |
| 100 | } |
| 101 | |
| 102 | // Hide `drop()` call from stack as it's mostly noise. |
| 103 | if self.is_diagnostic_item(sym::mem_drop, def_id) { |
| 104 | continue; |
| 105 | } |
| 106 | |
| 107 | if diag.span.is_dummy() { |
| 108 | diag.span = site.kind.multispan(); |
| 109 | } else { |
| 110 | match &site.kind { |
| 111 | UseSiteKind::Call(span) => { |
| 112 | diag.span_note(*span, "which is called from here"); |
| 113 | } |
| 114 | UseSiteKind::Drop { |
| 115 | drop_span, |
| 116 | place_span, |
| 117 | } => { |
| 118 | let mut multispan = MultiSpan::from_span(*drop_span); |
| 119 | multispan.push_span_label(*place_span, "value being dropped is here"); |
| 120 | diag.span_note(multispan, "which is dropped here"); |
| 121 | } |
| 122 | UseSiteKind::PointerCoercion(span) => { |
| 123 | diag.span_note(*span, "which is used as a pointer here"); |
| 124 | } |
| 125 | UseSiteKind::Vtable(span) => { |
| 126 | diag.span_note(*span, "which is used as a vtable here"); |
| 127 | } |
| 128 | UseSiteKind::Other(span, other) => { |
| 129 | diag.span_note(*span, other.clone()); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | if !self.is_fully_polymorphic(site.instance) { |
| 135 | diag.note(format!("inside instance `{}`", PolyDisplay(&site.instance))); |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | } |
no test coverage detected