Skip to content

Commit cf7e825

Browse files
committedJul 26, 2015
Auto merge of #27272 - eefriedman:closure-const-crash, r=nikomatsakis
Fixes issue #27268. r? @nikomatsakis
2 parents a42e21d + eefeba0 commit cf7e825

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed
 

‎src/librustc_typeck/check/upvar.rs

+7-25
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,8 @@ impl<'a, 'tcx, 'v> Visitor<'v> for SeedBorrowKind<'a, 'tcx> {
9393
visit::walk_expr(self, expr);
9494
}
9595

96-
fn visit_fn(&mut self,
97-
fn_kind: visit::FnKind<'v>,
98-
decl: &'v ast::FnDecl,
99-
block: &'v ast::Block,
100-
span: Span,
101-
_id: ast::NodeId)
102-
{
103-
match fn_kind {
104-
visit::FkItemFn(..) | visit::FkMethod(..) => {
105-
// ignore nested fn items
106-
}
107-
visit::FkFnBlock => {
108-
visit::walk_fn(self, fn_kind, decl, block, span);
109-
}
110-
}
111-
}
96+
// Skip all items; they aren't in the same context.
97+
fn visit_item(&mut self, _: &'v ast::Item) { }
11298
}
11399

114100
impl<'a,'tcx> SeedBorrowKind<'a,'tcx> {
@@ -515,16 +501,12 @@ impl<'a, 'tcx, 'v> Visitor<'v> for AdjustBorrowKind<'a, 'tcx> {
515501
span: Span,
516502
id: ast::NodeId)
517503
{
518-
match fn_kind {
519-
visit::FkItemFn(..) | visit::FkMethod(..) => {
520-
// ignore nested fn items
521-
}
522-
visit::FkFnBlock => {
523-
visit::walk_fn(self, fn_kind, decl, body, span);
524-
self.analyze_closure(id, span, decl, body);
525-
}
526-
}
504+
visit::walk_fn(self, fn_kind, decl, body, span);
505+
self.analyze_closure(id, span, decl, body);
527506
}
507+
508+
// Skip all items; they aren't in the same context.
509+
fn visit_item(&mut self, _: &'v ast::Item) { }
528510
}
529511

530512
impl<'a,'tcx> euv::Delegate<'tcx> for AdjustBorrowKind<'a,'tcx> {

‎src/test/run-pass/issue-27268.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2015 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 main() {
12+
const _C: &'static Fn() = &||{};
13+
}

0 commit comments

Comments
 (0)