Skip to content

Commit 5f61830

Browse files
committed
Deduplicate some rustc_middle function bodies by calling the rustc_type_ir equivalent
1 parent b6d74b5 commit 5f61830

File tree

1 file changed

+3
-44
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+3
-44
lines changed

compiler/rustc_middle/src/ty/sty.rs

+3-44
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::iter;
88
use std::ops::{ControlFlow, Range};
99

1010
use hir::def::{CtorKind, DefKind};
11-
use rustc_abi::{ExternAbi, FIRST_VARIANT, FieldIdx, VariantIdx};
11+
use rustc_abi::{FIRST_VARIANT, FieldIdx, VariantIdx};
1212
use rustc_errors::{ErrorGuaranteed, MultiSpan};
1313
use rustc_hir as hir;
1414
use rustc_hir::LangItem;
@@ -1441,23 +1441,7 @@ impl<'tcx> Ty<'tcx> {
14411441

14421442
#[tracing::instrument(level = "trace", skip(tcx))]
14431443
pub fn fn_sig(self, tcx: TyCtxt<'tcx>) -> PolyFnSig<'tcx> {
1444-
match self.kind() {
1445-
FnDef(def_id, args) => tcx.fn_sig(*def_id).instantiate(tcx, args),
1446-
FnPtr(sig_tys, hdr) => sig_tys.with(*hdr),
1447-
Error(_) => {
1448-
// ignore errors (#54954)
1449-
Binder::dummy(ty::FnSig {
1450-
inputs_and_output: ty::List::empty(),
1451-
c_variadic: false,
1452-
safety: hir::Safety::Safe,
1453-
abi: ExternAbi::Rust,
1454-
})
1455-
}
1456-
Closure(..) => bug!(
1457-
"to get the signature of a closure, use `args.as_closure().sig()` not `fn_sig()`",
1458-
),
1459-
_ => bug!("Ty::fn_sig() called on non-fn type: {:?}", self),
1460-
}
1444+
rustc_type_ir::inherent::Ty::fn_sig(self, tcx)
14611445
}
14621446

14631447
#[inline]
@@ -2043,32 +2027,7 @@ impl<'tcx> Ty<'tcx> {
20432027
/// nested types may be further simplified, the outermost [`TyKind`] or
20442028
/// type constructor remains the same.
20452029
pub fn is_known_rigid(self) -> bool {
2046-
match self.kind() {
2047-
Bool
2048-
| Char
2049-
| Int(_)
2050-
| Uint(_)
2051-
| Float(_)
2052-
| Adt(_, _)
2053-
| Foreign(_)
2054-
| Str
2055-
| Array(_, _)
2056-
| Pat(_, _)
2057-
| Slice(_)
2058-
| RawPtr(_, _)
2059-
| Ref(_, _, _)
2060-
| FnDef(_, _)
2061-
| FnPtr(..)
2062-
| Dynamic(_, _, _)
2063-
| Closure(_, _)
2064-
| CoroutineClosure(_, _)
2065-
| Coroutine(_, _)
2066-
| CoroutineWitness(..)
2067-
| Never
2068-
| Tuple(_)
2069-
| UnsafeBinder(_) => true,
2070-
Error(_) | Infer(_) | Alias(_, _) | Param(_) | Bound(_, _) | Placeholder(_) => false,
2071-
}
2030+
rustc_type_ir::inherent::Ty::is_known_rigid(self)
20722031
}
20732032
}
20742033

0 commit comments

Comments
 (0)