Skip to content

Commit 8640998

Browse files
committed
Split split_inputs_and_output in two.
I think it's a little clearer and nicer that way.
1 parent 3fc5469 commit 8640998

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

compiler/rustc_middle/src/ty/sty.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -1955,9 +1955,12 @@ impl<'tcx> Ty<'tcx> {
19551955
}
19561956

19571957
impl<'tcx> rustc_type_ir::inherent::Tys<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx>> {
1958-
fn split_inputs_and_output(self) -> (&'tcx [Ty<'tcx>], Ty<'tcx>) {
1959-
let (output, inputs) = self.split_last().unwrap();
1960-
(inputs, *output)
1958+
fn inputs(self) -> &'tcx [Ty<'tcx>] {
1959+
self.split_last().unwrap().1
1960+
}
1961+
1962+
fn output(self) -> Ty<'tcx> {
1963+
*self.split_last().unwrap().0
19611964
}
19621965
}
19631966

compiler/rustc_type_ir/src/inherent.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,9 @@ pub trait Ty<I: Interner<Ty = Self>>:
203203
pub trait Tys<I: Interner<Tys = Self>>:
204204
Copy + Debug + Hash + Eq + SliceLike<Item = I::Ty> + TypeFoldable<I> + Default
205205
{
206-
fn split_inputs_and_output(self) -> (I::FnInputTys, I::Ty);
206+
fn inputs(self) -> I::FnInputTys;
207+
208+
fn output(self) -> I::Ty;
207209
}
208210

209211
pub trait Abi<I: Interner<Abi = Self>>: Copy + Debug + Hash + Eq + Relate<I> {

compiler/rustc_type_ir/src/ty_kind.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -868,16 +868,12 @@ pub struct FnSig<I: Interner> {
868868
}
869869

870870
impl<I: Interner> FnSig<I> {
871-
pub fn split_inputs_and_output(self) -> (I::FnInputTys, I::Ty) {
872-
self.inputs_and_output.split_inputs_and_output()
873-
}
874-
875871
pub fn inputs(self) -> I::FnInputTys {
876-
self.split_inputs_and_output().0
872+
self.inputs_and_output.inputs()
877873
}
878874

879875
pub fn output(self) -> I::Ty {
880-
self.split_inputs_and_output().1
876+
self.inputs_and_output.output()
881877
}
882878

883879
pub fn is_fn_trait_compatible(self) -> bool {
@@ -935,7 +931,7 @@ impl<I: Interner> fmt::Debug for FnSig<I> {
935931
}
936932

937933
write!(f, "fn(")?;
938-
let (inputs, output) = sig.split_inputs_and_output();
934+
let inputs = sig.inputs();
939935
for (i, ty) in inputs.iter().enumerate() {
940936
if i > 0 {
941937
write!(f, ", ")?;
@@ -951,6 +947,7 @@ impl<I: Interner> fmt::Debug for FnSig<I> {
951947
}
952948
write!(f, ")")?;
953949

950+
let output = sig.output();
954951
match output.kind() {
955952
Tuple(list) if list.is_empty() => Ok(()),
956953
_ => write!(f, " -> {:?}", sig.output()),

0 commit comments

Comments
 (0)