Restrict some queries by def-kind more
This commit is contained in:
parent
e643f59f6d
commit
14d1215719
6 changed files with 43 additions and 26 deletions
|
@ -14,6 +14,7 @@
|
|||
//! At present, however, we do run collection across all items in the
|
||||
//! crate as a kind of pass. This should eventually be factored away.
|
||||
|
||||
use std::assert_matches::assert_matches;
|
||||
use std::cell::Cell;
|
||||
use std::iter;
|
||||
use std::ops::Bound;
|
||||
|
@ -1344,7 +1345,8 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<'_, ty::PolyFn
|
|||
compute_sig_of_foreign_fn_decl(tcx, def_id, sig.decl, abi, sig.header.safety())
|
||||
}
|
||||
|
||||
Ctor(data) | Variant(hir::Variant { data, .. }) if data.ctor().is_some() => {
|
||||
Ctor(data) => {
|
||||
assert_matches!(data.ctor(), Some(_));
|
||||
let adt_def_id = tcx.hir_get_parent_item(hir_id).def_id.to_def_id();
|
||||
let ty = tcx.type_of(adt_def_id).instantiate_identity();
|
||||
let inputs = data.fields().iter().map(|f| tcx.type_of(f.def_id).instantiate_identity());
|
||||
|
|
|
@ -44,13 +44,13 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] {
|
|||
return &[];
|
||||
}
|
||||
|
||||
match tcx.def_kind(item_def_id) {
|
||||
let kind = tcx.def_kind(item_def_id);
|
||||
match kind {
|
||||
DefKind::Fn
|
||||
| DefKind::AssocFn
|
||||
| DefKind::Enum
|
||||
| DefKind::Struct
|
||||
| DefKind::Union
|
||||
| DefKind::Variant
|
||||
| DefKind::Ctor(..) => {
|
||||
// These are inferred.
|
||||
let crate_map = tcx.crate_variances(());
|
||||
|
@ -89,7 +89,11 @@ fn variances_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Variance] {
|
|||
}
|
||||
|
||||
// Variance not relevant.
|
||||
span_bug!(tcx.def_span(item_def_id), "asked to compute variance for wrong kind of item");
|
||||
span_bug!(
|
||||
tcx.def_span(item_def_id),
|
||||
"asked to compute variance for {}",
|
||||
kind.descr(item_def_id.to_def_id())
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue