Translate nested items in default methods

Closes #9123
This commit is contained in:
Alex Crichton 2013-09-13 01:42:44 -07:00
parent 19c0735231
commit 62ba835573
3 changed files with 44 additions and 0 deletions

View File

@ -87,6 +87,7 @@ use syntax::parse::token::{special_idents};
use syntax::print::pprust::stmt_to_str; use syntax::print::pprust::stmt_to_str;
use syntax::{ast, ast_util, codemap, ast_map}; use syntax::{ast, ast_util, codemap, ast_map};
use syntax::abi::{X86, X86_64, Arm, Mips}; use syntax::abi::{X86, X86_64, Arm, Mips};
use syntax::visit;
use syntax::visit::Visitor; use syntax::visit::Visitor;
pub use middle::trans::context::task_llcx; pub use middle::trans::context::task_llcx;
@ -2239,6 +2240,14 @@ pub fn trans_item(ccx: @mut CrateContext, item: &ast::item) {
trans_struct_def(ccx, struct_def); trans_struct_def(ccx, struct_def);
} }
} }
ast::item_trait(*) => {
// Inside of this trait definition, we won't be actually translating any
// functions, but the trait still needs to be walked. Otherwise default
// methods with items will not get translated and will cause ICE's when
// metadata time comes around.
let mut v = TransItemVisitor;
visit::walk_item(&mut v, item, ccx);
}
_ => {/* fall through */ } _ => {/* fall through */ }
} }
} }

View File

@ -0,0 +1,19 @@
// 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.
#[crate_type = "lib"];
pub trait X {
fn x() {
fn f() { }
f();
}
}

View File

@ -0,0 +1,16 @@
// 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.
// xfail-fast windows doesn't like aux-build
// aux-build:issue_9123.rs
extern mod issue_9123;
pub fn main() {}