diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/middle/trans/expr.rs | 12 | ||||
| -rw-r--r-- | src/test/auxiliary/logging_right_crate.rs | 14 | ||||
| -rw-r--r-- | src/test/run-pass/logging-right-crate.rs | 30 |
3 files changed, 53 insertions, 3 deletions
diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index 995b2467888..0cf9c9a2242 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -119,6 +119,7 @@ use back::link; use lib::llvm::{ValueRef, llvm, SetLinkage, False}; use lib; use metadata::csearch; +use metadata::cstore; use middle::trans::_match; use middle::trans::adt; use middle::trans::asm; @@ -1797,9 +1798,14 @@ pub fn trans_log_level(bcx: @mut Block) -> DatumBlock { let ccx = bcx.ccx(); let (modpath, modname) = { - let path = &mut bcx.fcx.path; - let mut modpath = ~[path_mod(ccx.sess.ident_of(ccx.link_meta.name))]; - for e in path.iter() { + let srccrate = match ccx.external_srcs.find(&bcx.fcx.id) { + Some(&src) => { + cstore::get_crate_data(ccx.sess.cstore, src.crate).name + } + None => ccx.link_meta.name, + }; + let mut modpath = ~[path_mod(ccx.sess.ident_of(srccrate))]; + for e in bcx.fcx.path.iter() { match *e { path_mod(_) => { modpath.push(*e) } _ => {} diff --git a/src/test/auxiliary/logging_right_crate.rs b/src/test/auxiliary/logging_right_crate.rs new file mode 100644 index 00000000000..84bf6f0240f --- /dev/null +++ b/src/test/auxiliary/logging_right_crate.rs @@ -0,0 +1,14 @@ +// 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. + +pub fn foo<T>() { + fn death() -> int { fail2!() } + debug2!("{:?}", (||{ death() })()); +} diff --git a/src/test/run-pass/logging-right-crate.rs b/src/test/run-pass/logging-right-crate.rs new file mode 100644 index 00000000000..21b45cec235 --- /dev/null +++ b/src/test/run-pass/logging-right-crate.rs @@ -0,0 +1,30 @@ +// 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. + +// aux-build:logging_right_crate.rs +// xfail-fast +// exec-env:RUST_LOG=logging-right-crate=debug + +// This is a test for issue #3046 to make sure that when we monomorphize a +// function from one crate to another the right top-level logging name is +// preserved. +// +// It used to be the case that if logging were turned on for this crate, all +// monomorphized functions from other crates had logging turned on (their +// logging module names were all incorrect). This test ensures that this no +// longer happens by enabling logging for *this* crate and then invoking a +// function in an external crate which will fail when logging is enabled. + +extern mod logging_right_crate; + +fn main() { + // this function fails if logging is turned on + logging_right_crate::foo::<int>(); +} |
