diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 5001e7a88bd93..abb67a6503e9b 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -206,7 +206,8 @@ impl<'a> LifetimeContext<'a> { self.check_lifetime_names(&generics.lifetimes); - let referenced_idents = free_lifetimes(&generics.ty_params); + let referenced_idents = free_lifetimes(&generics.ty_params, + &generics.where_clause); debug!("pushing fn scope id={} due to fn item/method\ referenced_idents={:?}", n, @@ -403,7 +404,8 @@ fn search_lifetimes(lifetimes: &Vec, /////////////////////////////////////////////////////////////////////////// pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec { - let referenced_idents = free_lifetimes(&generics.ty_params); + let referenced_idents = free_lifetimes(&generics.ty_params, + &generics.where_clause); if referenced_idents.is_empty() { return Vec::new(); } @@ -414,7 +416,9 @@ pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec) -> Vec { +pub fn free_lifetimes(ty_params: &OwnedSlice, + where_clause: &ast::WhereClause) + -> Vec { /*! * Gathers up and returns the names of any lifetimes that appear * free in `ty_params`. Of course, right now, all lifetimes appear @@ -426,6 +430,9 @@ pub fn free_lifetimes(ty_params: &OwnedSlice) -> Vec { for ty_param in ty_params.iter() { visit::walk_ty_param_bounds(&mut collector, &ty_param.bounds, ()); } + for predicate in where_clause.predicates.iter() { + visit::walk_ty_param_bounds(&mut collector, &predicate.bounds, ()); + } return collector.names; struct FreeLifetimeCollector { diff --git a/src/test/run-pass/where-clauses-lifetimes.rs b/src/test/run-pass/where-clauses-lifetimes.rs new file mode 100644 index 0000000000000..4adaf7a11e30f --- /dev/null +++ b/src/test/run-pass/where-clauses-lifetimes.rs @@ -0,0 +1,15 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo<'a, I>(mut it: I) where I: Iterator<&'a int> {} + +fn main() { + foo([1i, 2].iter()); +} diff --git a/src/test/run-pass/where-clauses-unboxed-closures.rs b/src/test/run-pass/where-clauses-unboxed-closures.rs new file mode 100644 index 0000000000000..ae005b4ae5306 --- /dev/null +++ b/src/test/run-pass/where-clauses-unboxed-closures.rs @@ -0,0 +1,26 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(unboxed_closures)] + +struct Bencher; + +// ICE +fn warm_up<'a, F>(f: F) where F: |&: &'a mut Bencher| { +} + +fn main() { + // ICE trigger + warm_up(|&: b: &mut Bencher| () ); + + // OK + warm_up(|&: b| () ); +} +