Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added ExactSizeIterator bound to return types #67125

Merged
merged 2 commits into from
Dec 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,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 @@ -2384,11 +2384,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