Skip to content

Commit b4e2d75

Browse files
Assert FnDef only constructed with functions (or fn-like ctors)
1 parent 36b6f9b commit b4e2d75

File tree

1 file changed

+5
-1
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+5
-1
lines changed

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::ty::{
1111
};
1212
use crate::ty::{GenericArg, GenericArgs, GenericArgsRef};
1313
use crate::ty::{List, ParamEnv};
14-
use hir::def::DefKind;
14+
use hir::def::{CtorKind, DefKind};
1515
use rustc_data_structures::captures::Captures;
1616
use rustc_errors::{DiagArgValue, ErrorGuaranteed, IntoDiagArg, MultiSpan};
1717
use rustc_hir as hir;
@@ -1677,6 +1677,10 @@ impl<'tcx> Ty<'tcx> {
16771677
def_id: DefId,
16781678
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
16791679
) -> Ty<'tcx> {
1680+
debug_assert_matches!(
1681+
tcx.def_kind(def_id),
1682+
DefKind::AssocFn | DefKind::Fn | DefKind::Ctor(_, CtorKind::Fn)
1683+
);
16801684
let args = tcx.check_and_mk_args(def_id, args);
16811685
Ty::new(tcx, FnDef(def_id, args))
16821686
}

0 commit comments

Comments
 (0)