Skip to content

Commit 53e694e

Browse files
committed
Auto merge of #28190 - arielb1:generic-key-entry, r=eddyb
Fixes #28181 This may fix #28151 r? @pnkfelix
2 parents 205c356 + 16f75f7 commit 53e694e

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

src/librustc/middle/region.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,10 @@ impl RegionMaps {
317317
self.intern_code_extent(e, DUMMY_CODE_EXTENT)
318318
}
319319
pub fn lookup_code_extent(&self, e: CodeExtentData) -> CodeExtent {
320-
self.code_extent_interner.borrow()[&e]
320+
match self.code_extent_interner.borrow().get(&e) {
321+
Some(&d) => d,
322+
None => panic!("unknown code extent {:?}", e)
323+
}
321324
}
322325
pub fn node_extent(&self, n: ast::NodeId) -> CodeExtent {
323326
self.lookup_code_extent(CodeExtentData::Misc(n))
@@ -1069,7 +1072,7 @@ fn resolve_item(visitor: &mut RegionResolutionVisitor, item: &hir::Item) {
10691072
}
10701073

10711074
fn resolve_fn(visitor: &mut RegionResolutionVisitor,
1072-
_: FnKind,
1075+
kind: FnKind,
10731076
decl: &hir::FnDecl,
10741077
body: &hir::Block,
10751078
sp: Span,
@@ -1102,6 +1105,7 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor,
11021105
};
11031106

11041107
visit::walk_fn_decl(visitor, decl);
1108+
visit::walk_fn_kind(visitor, kind);
11051109

11061110
// The body of the every fn is a root scope.
11071111
visitor.cx = Context {

src/librustc_front/visit.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -580,13 +580,8 @@ pub fn walk_fn_decl<'v, V: Visitor<'v>>(visitor: &mut V, function_declaration: &
580580
walk_fn_ret_ty(visitor, &function_declaration.output)
581581
}
582582

583-
pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
584-
function_kind: FnKind<'v>,
585-
function_declaration: &'v FnDecl,
586-
function_body: &'v Block,
587-
_span: Span) {
588-
walk_fn_decl(visitor, function_declaration);
589-
583+
pub fn walk_fn_kind<'v, V: Visitor<'v>>(visitor: &mut V,
584+
function_kind: FnKind<'v>) {
590585
match function_kind {
591586
FnKind::ItemFn(_, generics, _, _, _, _) => {
592587
visitor.visit_generics(generics);
@@ -597,7 +592,15 @@ pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
597592
}
598593
FnKind::Closure(..) => {}
599594
}
595+
}
600596

597+
pub fn walk_fn<'v, V: Visitor<'v>>(visitor: &mut V,
598+
function_kind: FnKind<'v>,
599+
function_declaration: &'v FnDecl,
600+
function_body: &'v Block,
601+
_span: Span) {
602+
walk_fn_decl(visitor, function_declaration);
603+
walk_fn_kind(visitor, function_kind);
601604
visitor.visit_block(function_body)
602605
}
603606

src/test/run-pass/issue-28181.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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 bar<F>(f: F) -> usize where F: Fn([usize; 1]) -> usize { f([2]) }
12+
13+
fn main() {
14+
bar(|u| { u[0] });
15+
}

0 commit comments

Comments
 (0)