Only bug on self-not-mapped-to-def if no previous errors were present. Close #6642.
This commit is contained in:
parent
598072afa4
commit
0081961c57
@ -4812,9 +4812,13 @@ impl Resolver {
|
||||
DontAllowCapturingSelf) {
|
||||
Some(dl_def(def)) => return Some(def),
|
||||
_ => {
|
||||
self.session.span_bug(span,
|
||||
"self wasn't mapped to a \
|
||||
def?!")
|
||||
if self.session.has_errors() {
|
||||
// May happen inside a nested fn item, cf #6642.
|
||||
return None;
|
||||
} else {
|
||||
self.session.span_bug(span,
|
||||
"self wasn't mapped to a def?!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
src/test/compile-fail/issue-6642.rs
Normal file
21
src/test/compile-fail/issue-6642.rs
Normal file
@ -0,0 +1,21 @@
|
||||
// Copyright 2013 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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
struct A;
|
||||
impl A {
|
||||
fn m(&self) {
|
||||
fn x() {
|
||||
self.m()
|
||||
//~^ ERROR can't capture dynamic environment in a fn item
|
||||
//~^^ ERROR `self` is not allowed in this context
|
||||
}
|
||||
}
|
||||
}
|
||||
fn main() {}
|
Loading…
x
Reference in New Issue
Block a user