Skip to content

Commit

Permalink
Assert that ADTs have the right number of substs
Browse files Browse the repository at this point in the history
  • Loading branch information
compiler-errors committed Mar 30, 2024
1 parent faae5f1 commit 5e2c549
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/rustc_middle/src/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1624,6 +1624,13 @@ impl<'tcx> Ty<'tcx> {

#[inline]
pub fn new_adt(tcx: TyCtxt<'tcx>, def: AdtDef<'tcx>, args: GenericArgsRef<'tcx>) -> Ty<'tcx> {
debug_assert_eq!(
tcx.generics_of(def.did()).count(),
args.len(),
"wrong number of args for ADT: {:#?} vs {:#?}",
tcx.generics_of(def.did()).params,
args
);
Ty::new(tcx, Adt(def, args))
}

Expand Down

0 comments on commit 5e2c549

Please sign in to comment.