File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -4812,9 +4812,13 @@ impl Resolver {
4812
4812
DontAllowCapturingSelf ) {
4813
4813
Some ( dl_def( def) ) => return Some ( def) ,
4814
4814
_ => {
4815
- self . session . span_bug ( span,
4816
- "self wasn't mapped to a \
4817
- def?!")
4815
+ if self . session . has_errors ( ) {
4816
+ // May happen inside a nested fn item, cf #6642.
4817
+ return None ;
4818
+ } else {
4819
+ self . session . span_bug ( span,
4820
+ "self wasn't mapped to a def?!" )
4821
+ }
4818
4822
}
4819
4823
}
4820
4824
}
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 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
+ struct A ;
12
+ impl A {
13
+ fn m ( & self ) {
14
+ fn x ( ) {
15
+ self . m ( )
16
+ //~^ ERROR can't capture dynamic environment in a fn item
17
+ //~^^ ERROR `self` is not allowed in this context
18
+ }
19
+ }
20
+ }
21
+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments