Simplify some cfging
This commit is contained in:
parent
c9f8529793
commit
657dadf2cc
2 changed files with 11 additions and 17 deletions
|
|
@ -2016,7 +2016,12 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
true
|
||||
}
|
||||
|
||||
pub fn assert_args_compatible(self, def_id: DefId, args: &'tcx [ty::GenericArg<'tcx>]) {
|
||||
pub fn debug_assert_args_compatible(self, def_id: DefId, args: &'tcx [ty::GenericArg<'tcx>]) {
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if !self.check_args_compatible(def_id, args) {
|
||||
if let DefKind::AssocTy = self.def_kind(def_id)
|
||||
&& let DefKind::Impl { of_trait: false } = self.def_kind(self.parent(def_id))
|
||||
|
|
@ -2040,10 +2045,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||
) -> GenericArgsRef<'tcx> {
|
||||
let args = self.mk_args_from_iter(args.into_iter().map(Into::into));
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
self.assert_args_compatible(_def_id, args);
|
||||
}
|
||||
self.debug_assert_args_compatible(_def_id, args);
|
||||
args
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1624,9 +1624,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn new_adt(tcx: TyCtxt<'tcx>, def: AdtDef<'tcx>, args: GenericArgsRef<'tcx>) -> Ty<'tcx> {
|
||||
if cfg!(debug_assertions) {
|
||||
tcx.assert_args_compatible(def.did(), args);
|
||||
}
|
||||
tcx.debug_assert_args_compatible(def.did(), args);
|
||||
Ty::new(tcx, Adt(def, args))
|
||||
}
|
||||
|
||||
|
|
@ -1707,9 +1705,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
def_id: DefId,
|
||||
closure_args: GenericArgsRef<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
if cfg!(debug_assertions) {
|
||||
tcx.assert_args_compatible(def_id, closure_args);
|
||||
}
|
||||
tcx.debug_assert_args_compatible(def_id, closure_args);
|
||||
Ty::new(tcx, Closure(def_id, closure_args))
|
||||
}
|
||||
|
||||
|
|
@ -1719,9 +1715,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
def_id: DefId,
|
||||
closure_args: GenericArgsRef<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
if cfg!(debug_assertions) {
|
||||
tcx.assert_args_compatible(def_id, closure_args);
|
||||
}
|
||||
tcx.debug_assert_args_compatible(def_id, closure_args);
|
||||
Ty::new(tcx, CoroutineClosure(def_id, closure_args))
|
||||
}
|
||||
|
||||
|
|
@ -1731,9 +1725,7 @@ impl<'tcx> Ty<'tcx> {
|
|||
def_id: DefId,
|
||||
coroutine_args: GenericArgsRef<'tcx>,
|
||||
) -> Ty<'tcx> {
|
||||
if cfg!(debug_assertions) {
|
||||
tcx.assert_args_compatible(def_id, coroutine_args);
|
||||
}
|
||||
tcx.debug_assert_args_compatible(def_id, coroutine_args);
|
||||
Ty::new(tcx, Coroutine(def_id, coroutine_args))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue