Skip to content

Commit

Permalink
Rollup merge of #67125 - hashedone:master, r=petrochenkov
Browse files Browse the repository at this point in the history
Added ExactSizeIterator bound to return types

Fixes #66865
  • Loading branch information
tmandry authored Dec 9, 2019
2 parents e775820 + 989bf84 commit 28b112f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,15 @@ impl<'tcx> Body<'tcx> {

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

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

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

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

Expand Down

0 comments on commit 28b112f

Please sign in to comment.