Skip to content

Commit

Permalink
Only bug on self-not-mapped-to-def if no previous errors were present.
Browse files Browse the repository at this point in the history
…Close #6642.
  • Loading branch information
bblum committed Aug 21, 2013
1 parent 598072a commit 0081961
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/librustc/middle/resolve.rs
Expand Up @@ -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?!")
}
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/test/compile-fail/issue-6642.rs
@@ -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() {}

9 comments on commit 0081961

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at bblum@0081961

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging bblum/rust/scratch = 0081961 into auto

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 22, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bblum/rust/scratch = 0081961 merged ok, testing candidate = 859eb4dc

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 22, 2013

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from alexcrichton
at bblum@0081961

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging bblum/rust/scratch = 0081961 into auto

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bblum/rust/scratch = 0081961 merged ok, testing candidate = 5e5e2c7

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 23, 2013

@bors
Copy link
Contributor

@bors bors commented on 0081961 Aug 23, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 5e5e2c7

Please sign in to comment.