diff options
| author | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-02-16 16:05:08 +1100 |
|---|---|---|
| committer | Nicholas Nethercote <n.nethercote@gmail.com> | 2023-02-17 22:24:34 +1100 |
| commit | 2017aeff8887617fb7eef66d4b8dc81ca6e925c5 (patch) | |
| tree | ddb8be7f08e54a1c2ace316e414f0db3d43d968a /compiler/rustc_middle/src/ty | |
| parent | c8237db3eed2c91c14ce46b482b3d479a39d328d (diff) | |
| download | rust-2017aeff8887617fb7eef66d4b8dc81ca6e925c5.tar.gz rust-2017aeff8887617fb7eef66d4b8dc81ca6e925c5.zip | |
Use `IntoIterator` for `mk_fn_sig`.
This makes a lot of call sites nicer.
Diffstat (limited to 'compiler/rustc_middle/src/ty')
| -rw-r--r-- | compiler/rustc_middle/src/ty/context.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 7b4434a3843..e1a72c70145 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -1660,11 +1660,11 @@ impl<'tcx> TyCtxt<'tcx> { unsafety: hir::Unsafety, ) -> PolyFnSig<'tcx> { sig.map_bound(|s| { - let params_iter = match s.inputs()[0].kind() { - ty::Tuple(params) => params.into_iter(), + let params = match s.inputs()[0].kind() { + ty::Tuple(params) => *params, _ => bug!(), }; - self.mk_fn_sig(params_iter, s.output(), s.c_variadic, unsafety, abi::Abi::Rust) + self.mk_fn_sig(params, s.output(), s.c_variadic, unsafety, abi::Abi::Rust) }) } @@ -2215,6 +2215,11 @@ impl<'tcx> TyCtxt<'tcx> { if ts.is_empty() { List::empty() } else { self._intern_bound_variable_kinds(ts) } } + // Unlike various other `mk_*` functions, this one uses `I: IntoIterator` + // instead of `I: Iterator`. Unlike those other functions, this one doesn't + // have a `intern_fn_sig` variant that can be used for cases where `I` is + // something like a `Vec`. That's because of the need to combine `inputs` + // and `output`. pub fn mk_fn_sig<I, T>( self, inputs: I, @@ -2224,10 +2229,10 @@ impl<'tcx> TyCtxt<'tcx> { abi: abi::Abi, ) -> T::Output where - I: Iterator<Item = T>, + I: IntoIterator<Item = T>, T: CollectAndApply<Ty<'tcx>, ty::FnSig<'tcx>>, { - T::collect_and_apply(inputs.chain(iter::once(output)), |xs| ty::FnSig { + T::collect_and_apply(inputs.into_iter().chain(iter::once(output)), |xs| ty::FnSig { inputs_and_output: self.intern_type_list(xs), c_variadic, unsafety, |
