mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Split split_inputs_and_output
in two.
I think it's a little clearer and nicer that way.
This commit is contained in:
parent
3fc5469a8d
commit
8640998869
@ -1955,9 +1955,12 @@ impl<'tcx> Ty<'tcx> {
|
||||
}
|
||||
|
||||
impl<'tcx> rustc_type_ir::inherent::Tys<TyCtxt<'tcx>> for &'tcx ty::List<Ty<'tcx>> {
|
||||
fn split_inputs_and_output(self) -> (&'tcx [Ty<'tcx>], Ty<'tcx>) {
|
||||
let (output, inputs) = self.split_last().unwrap();
|
||||
(inputs, *output)
|
||||
fn inputs(self) -> &'tcx [Ty<'tcx>] {
|
||||
self.split_last().unwrap().1
|
||||
}
|
||||
|
||||
fn output(self) -> Ty<'tcx> {
|
||||
*self.split_last().unwrap().0
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,9 @@ pub trait Ty<I: Interner<Ty = Self>>:
|
||||
pub trait Tys<I: Interner<Tys = Self>>:
|
||||
Copy + Debug + Hash + Eq + SliceLike<Item = I::Ty> + TypeFoldable<I> + Default
|
||||
{
|
||||
fn split_inputs_and_output(self) -> (I::FnInputTys, I::Ty);
|
||||
fn inputs(self) -> I::FnInputTys;
|
||||
|
||||
fn output(self) -> I::Ty;
|
||||
}
|
||||
|
||||
pub trait Abi<I: Interner<Abi = Self>>: Copy + Debug + Hash + Eq + Relate<I> {
|
||||
|
@ -868,16 +868,12 @@ pub struct FnSig<I: Interner> {
|
||||
}
|
||||
|
||||
impl<I: Interner> FnSig<I> {
|
||||
pub fn split_inputs_and_output(self) -> (I::FnInputTys, I::Ty) {
|
||||
self.inputs_and_output.split_inputs_and_output()
|
||||
}
|
||||
|
||||
pub fn inputs(self) -> I::FnInputTys {
|
||||
self.split_inputs_and_output().0
|
||||
self.inputs_and_output.inputs()
|
||||
}
|
||||
|
||||
pub fn output(self) -> I::Ty {
|
||||
self.split_inputs_and_output().1
|
||||
self.inputs_and_output.output()
|
||||
}
|
||||
|
||||
pub fn is_fn_trait_compatible(self) -> bool {
|
||||
@ -935,7 +931,7 @@ impl<I: Interner> fmt::Debug for FnSig<I> {
|
||||
}
|
||||
|
||||
write!(f, "fn(")?;
|
||||
let (inputs, output) = sig.split_inputs_and_output();
|
||||
let inputs = sig.inputs();
|
||||
for (i, ty) in inputs.iter().enumerate() {
|
||||
if i > 0 {
|
||||
write!(f, ", ")?;
|
||||
@ -951,6 +947,7 @@ impl<I: Interner> fmt::Debug for FnSig<I> {
|
||||
}
|
||||
write!(f, ")")?;
|
||||
|
||||
let output = sig.output();
|
||||
match output.kind() {
|
||||
Tuple(list) if list.is_empty() => Ok(()),
|
||||
_ => write!(f, " -> {:?}", sig.output()),
|
||||
|
Loading…
Reference in New Issue
Block a user