Rework rustc_dump_vtable
This commit is contained in:
parent
5a45ab9738
commit
08d7e9dfe5
23 changed files with 603 additions and 381 deletions
|
@ -12,7 +12,7 @@ use rustc_hir::intravisit::{Visitor, VisitorExt, walk_ty};
|
|||
use rustc_hir::{self as hir, AmbigArg, FnRetTy, GenericParamKind, Node};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_middle::ty::print::{PrintTraitRefExt as _, TraitRefPrintOnlyTraitPath};
|
||||
use rustc_middle::ty::{self, Binder, ClosureKind, FnSig, PolyTraitRef, Region, Ty, TyCtxt};
|
||||
use rustc_middle::ty::{self, Binder, ClosureKind, FnSig, Region, Ty, TyCtxt};
|
||||
use rustc_span::{BytePos, Ident, Span, Symbol, kw};
|
||||
|
||||
use crate::error_reporting::infer::ObligationCauseAsDiagArg;
|
||||
|
@ -22,15 +22,6 @@ use crate::fluent_generated as fluent;
|
|||
|
||||
pub mod note_and_explain;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(trait_selection_dump_vtable_entries)]
|
||||
pub struct DumpVTableEntries<'a> {
|
||||
#[primary_span]
|
||||
pub span: Span,
|
||||
pub trait_ref: PolyTraitRef<'a>,
|
||||
pub entries: String,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(trait_selection_unable_to_construct_constant_value)]
|
||||
pub struct UnableToConstructConstantValue<'a> {
|
||||
|
|
|
@ -11,11 +11,10 @@ use rustc_middle::query::Providers;
|
|||
use rustc_middle::ty::{
|
||||
self, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeVisitableExt, Upcast, VtblEntry,
|
||||
};
|
||||
use rustc_span::{DUMMY_SP, Span, sym};
|
||||
use rustc_span::DUMMY_SP;
|
||||
use smallvec::{SmallVec, smallvec};
|
||||
use tracing::debug;
|
||||
|
||||
use crate::errors::DumpVTableEntries;
|
||||
use crate::traits::{ObligationCtxt, impossible_predicates, is_vtable_safe_method};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
@ -192,15 +191,6 @@ fn maybe_iter<I: Iterator>(i: Option<I>) -> impl Iterator<Item = I::Item> {
|
|||
i.into_iter().flatten()
|
||||
}
|
||||
|
||||
fn dump_vtable_entries<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
sp: Span,
|
||||
trait_ref: ty::PolyTraitRef<'tcx>,
|
||||
entries: &[VtblEntry<'tcx>],
|
||||
) {
|
||||
tcx.dcx().emit_err(DumpVTableEntries { span: sp, trait_ref, entries: format!("{entries:#?}") });
|
||||
}
|
||||
|
||||
fn has_own_existential_vtable_entries(tcx: TyCtxt<'_>, trait_def_id: DefId) -> bool {
|
||||
own_existential_vtable_entries_iter(tcx, trait_def_id).next().is_some()
|
||||
}
|
||||
|
@ -317,11 +307,6 @@ fn vtable_entries<'tcx>(
|
|||
|
||||
let _ = prepare_vtable_segments(tcx, trait_ref, vtable_segment_callback);
|
||||
|
||||
if tcx.has_attr(trait_ref.def_id(), sym::rustc_dump_vtable) {
|
||||
let sp = tcx.def_span(trait_ref.def_id());
|
||||
dump_vtable_entries(tcx, sp, trait_ref, &entries);
|
||||
}
|
||||
|
||||
tcx.arena.alloc_from_iter(entries)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue