Skip to content

Commit 47b9a6f

Browse files
committed
auto merge of #16616 : pcwalton/rust/unboxed-closure-where-clause, r=nikomatsakis
signatures. Closes #16549. Closes #16564. r? @pnkfelix
2 parents 07d86b4 + 24a2137 commit 47b9a6f

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

src/librustc/middle/resolve_lifetime.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ impl<'a> LifetimeContext<'a> {
206206

207207
self.check_lifetime_names(&generics.lifetimes);
208208

209-
let referenced_idents = free_lifetimes(&generics.ty_params);
209+
let referenced_idents = free_lifetimes(&generics.ty_params,
210+
&generics.where_clause);
210211
debug!("pushing fn scope id={} due to fn item/method\
211212
referenced_idents={:?}",
212213
n,
@@ -403,7 +404,8 @@ fn search_lifetimes(lifetimes: &Vec<ast::LifetimeDef>,
403404
///////////////////////////////////////////////////////////////////////////
404405

405406
pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec<ast::LifetimeDef> {
406-
let referenced_idents = free_lifetimes(&generics.ty_params);
407+
let referenced_idents = free_lifetimes(&generics.ty_params,
408+
&generics.where_clause);
407409
if referenced_idents.is_empty() {
408410
return Vec::new();
409411
}
@@ -414,7 +416,9 @@ pub fn early_bound_lifetimes<'a>(generics: &'a ast::Generics) -> Vec<ast::Lifeti
414416
.collect()
415417
}
416418

417-
pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>) -> Vec<ast::Name> {
419+
pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>,
420+
where_clause: &ast::WhereClause)
421+
-> Vec<ast::Name> {
418422
/*!
419423
* Gathers up and returns the names of any lifetimes that appear
420424
* free in `ty_params`. Of course, right now, all lifetimes appear
@@ -426,6 +430,9 @@ pub fn free_lifetimes(ty_params: &OwnedSlice<ast::TyParam>) -> Vec<ast::Name> {
426430
for ty_param in ty_params.iter() {
427431
visit::walk_ty_param_bounds(&mut collector, &ty_param.bounds, ());
428432
}
433+
for predicate in where_clause.predicates.iter() {
434+
visit::walk_ty_param_bounds(&mut collector, &predicate.bounds, ());
435+
}
429436
return collector.names;
430437

431438
struct FreeLifetimeCollector {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn foo<'a, I>(mut it: I) where I: Iterator<&'a int> {}
12+
13+
fn main() {
14+
foo([1i, 2].iter());
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![feature(unboxed_closures)]
12+
13+
struct Bencher;
14+
15+
// ICE
16+
fn warm_up<'a, F>(f: F) where F: |&: &'a mut Bencher| {
17+
}
18+
19+
fn main() {
20+
// ICE trigger
21+
warm_up(|&: b: &mut Bencher| () );
22+
23+
// OK
24+
warm_up(|&: b| () );
25+
}
26+

0 commit comments

Comments
 (0)