File tree Expand file tree Collapse file tree 2 files changed +43
-5
lines changed Expand file tree Collapse file tree 2 files changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -107,20 +107,22 @@ pub fn log(_level: u32, args: &fmt::Arguments) {
107107 let optional_task: Option < * mut Task > = Local :: try_unsafe_borrow ( ) ;
108108 match optional_task {
109109 Some ( local) => {
110+ // Lazily initialize the local task's logger
110111 match ( * local) . logger {
111112 // Use the available logger if we have one
112- Some ( ref mut logger) => return logger. log ( args) ,
113+ Some ( ref mut logger) => { logger. log ( args) ; }
113114 None => {
114115 let mut logger = StdErrLogger :: new ( ) ;
115116 logger. log ( args) ;
116117 ( * local) . logger = Some ( logger) ;
117118 }
118119 }
119120 }
120- None => { }
121+ // If there's no local task, then always log to stderr
122+ None => {
123+ let mut logger = StdErrLogger :: new ( ) ;
124+ logger. log ( args) ;
125+ }
121126 }
122- // There is no logger anywhere, just write to stderr
123- let mut logger = StdErrLogger :: new ( ) ;
124- logger. log ( args) ;
125127 }
126128}
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+ // xfail-fast
12+ // exec-env:RUST_LOG=debug
13+
14+ #[ feature( managed_boxes) ] ;
15+
16+ use std:: fmt;
17+
18+ struct Foo ( @mut int ) ;
19+
20+ impl fmt:: Default for Foo {
21+ fn fmt ( f : & Foo , _fmt : & mut fmt:: Formatter ) {
22+ assert ! ( * * * f == 0 ) ;
23+ * * * f = 1 ;
24+ }
25+ }
26+
27+ pub fn main ( ) {
28+ let ( p, c) = stream ( ) ;
29+ do spawn {
30+ let f = Foo ( @mut 0 ) ;
31+ debug ! ( "{}" , f) ;
32+ assert ! ( * * f == 1 ) ;
33+ c. send ( ( ) ) ;
34+ }
35+ p. recv ( ) ;
36+ }
You can’t perform that action at this time.
0 commit comments