Rollup merge of #123382 - compiler-errors:assert-fndef-kind, r=fmease
Assert `FnDef` kind Only found one bug, where we were using the variant def id rather than its ctor def id to make the `FnDef` for a `type_of` r? fmease
This commit is contained in:
commit
94c402733d
@ -474,9 +474,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::EarlyBinder<Ty
|
||||
VariantData::Unit(..) | VariantData::Struct { .. } => {
|
||||
tcx.type_of(tcx.hir().get_parent_item(hir_id)).instantiate_identity()
|
||||
}
|
||||
VariantData::Tuple(..) => {
|
||||
VariantData::Tuple(_, _, ctor) => {
|
||||
let args = ty::GenericArgs::identity_for_item(tcx, def_id);
|
||||
Ty::new_fn_def(tcx, def_id.to_def_id(), args)
|
||||
Ty::new_fn_def(tcx, ctor.to_def_id(), args)
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -11,7 +11,7 @@ use crate::ty::{
|
||||
};
|
||||
use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
|
||||
use crate::ty::{List, ParamEnv};
|
||||
use hir::def::DefKind;
|
||||
use hir::def::{CtorKind, DefKind};
|
||||
use rustc_data_structures::captures::Captures;
|
||||
use rustc_errors::{DiagArgValue, ErrorGuaranteed, IntoDiagArg, MultiSpan};
|
||||
use rustc_hir as hir;
|
||||
@ -1677,6 +1677,10 @@ impl<'tcx> Ty<'tcx> {
|
||||
def_id: DefId,
|
||||
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||
) -> Ty<'tcx> {
|
||||
debug_assert_matches!(
|
||||
tcx.def_kind(def_id),
|
||||
DefKind::AssocFn | DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn)
|
||||
);
|
||||
let args = tcx.check_and_mk_args(def_id, args);
|
||||
Ty::new(tcx, FnDef(def_id, args))
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user