Skip to content

Commit 28b112f

Browse files
authored
Rollup merge of #67125 - hashedone:master, r=petrochenkov
Added ExactSizeIterator bound to return types Fixes #66865
2 parents e775820 + 989bf84 commit 28b112f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/librustc/mir/mod.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,15 @@ impl<'tcx> Body<'tcx> {
278278

279279
/// Returns an iterator over all function arguments.
280280
#[inline]
281-
pub fn args_iter(&self) -> impl Iterator<Item = Local> {
281+
pub fn args_iter(&self) -> impl Iterator<Item = Local> + ExactSizeIterator {
282282
let arg_count = self.arg_count;
283-
(1..=arg_count).map(Local::new)
283+
(1..arg_count + 1).map(Local::new)
284284
}
285285

286286
/// Returns an iterator over all user-defined variables and compiler-generated temporaries (all
287287
/// locals that are neither arguments nor the return place).
288288
#[inline]
289-
pub fn vars_and_temps_iter(&self) -> impl Iterator<Item = Local> {
289+
pub fn vars_and_temps_iter(&self) -> impl Iterator<Item = Local> + ExactSizeIterator {
290290
let arg_count = self.arg_count;
291291
let local_count = self.local_decls.len();
292292
(arg_count + 1..local_count).map(Local::new)
@@ -2380,11 +2380,15 @@ impl<'tcx> UserTypeProjections {
23802380
UserTypeProjections { contents: projs.collect() }
23812381
}
23822382

2383-
pub fn projections_and_spans(&self) -> impl Iterator<Item = &(UserTypeProjection, Span)> {
2383+
pub fn projections_and_spans(&self)
2384+
-> impl Iterator<Item = &(UserTypeProjection, Span)> + ExactSizeIterator
2385+
{
23842386
self.contents.iter()
23852387
}
23862388

2387-
pub fn projections(&self) -> impl Iterator<Item = &UserTypeProjection> {
2389+
pub fn projections(&self)
2390+
-> impl Iterator<Item = &UserTypeProjection> + ExactSizeIterator
2391+
{
23882392
self.contents.iter().map(|&(ref user_type, _span)| user_type)
23892393
}
23902394

0 commit comments

Comments
 (0)