Skip to content

Commit 00c2ecf

Browse files
sfackleralexcrichton
authored andcommitted
---
yaml --- r: 108242 b: refs/heads/dist-snap c: 6b429d0 h: refs/heads/master v: v3
1 parent a6a0c86 commit 00c2ecf

File tree

5 files changed

+64
-12
lines changed

5 files changed

+64
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: f64fdf524a434f0e5cd0bc91d09c144723f3c90d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: cfb87f10ec7d41d0e7f8c68fbb908fc195517d41
9+
refs/heads/dist-snap: 6b429d07c96c3e7cb3130c070d99651f29bded6c
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/src/libsyntax/ext/base.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use parse::token::{InternedString, intern, str_to_ident};
2020
use util::small_vector::SmallVector;
2121

2222
use std::hashmap::HashMap;
23-
use std::unstable::dynamic_lib::DynamicLibrary;
2423

2524
// new-style macro! tt code:
2625
//
@@ -143,16 +142,13 @@ pub struct BlockInfo {
143142
macros_escape : bool,
144143
// what are the pending renames?
145144
pending_renames : RenameList,
146-
// references for crates loaded in this scope
147-
macro_crates: ~[DynamicLibrary],
148145
}
149146

150147
impl BlockInfo {
151148
pub fn new() -> BlockInfo {
152149
BlockInfo {
153150
macros_escape: false,
154151
pending_renames: ~[],
155-
macro_crates: ~[],
156152
}
157153
}
158154
}
@@ -551,10 +547,6 @@ impl SyntaxEnv {
551547
self.find_escape_frame().map.insert(k, v);
552548
}
553549

554-
pub fn insert_macro_crate(&mut self, lib: DynamicLibrary) {
555-
self.find_escape_frame().info.macro_crates.push(lib);
556-
}
557-
558550
pub fn info<'a>(&'a mut self) -> &'a mut BlockInfo {
559551
&mut self.chain[self.chain.len()-1].info
560552
}

branches/dist-snap/src/libsyntax/ext/expand.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -28,6 +28,7 @@ use visit;
2828
use visit::Visitor;
2929
use util::small_vector::SmallVector;
3030

31+
use std::cast;
3132
use std::vec;
3233
use std::unstable::dynamic_lib::DynamicLibrary;
3334
use std::os;
@@ -469,9 +470,12 @@ fn load_extern_macros(crate: &ast::ViewItem, fld: &mut MacroExpander) {
469470
};
470471
fld.extsbox.insert(name, extension);
471472
});
472-
}
473473

474-
fld.extsbox.insert_macro_crate(lib);
474+
// Intentionally leak the dynamic library. We can't ever unload it
475+
// since the library can do things that will outlive the expansion
476+
// phase (e.g. make an @-box cycle or launch a task).
477+
cast::forget(lib);
478+
}
475479
}
476480

477481
// expand a stmt
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2014 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+
// force-host
12+
13+
#[feature(macro_registrar)];
14+
15+
extern mod syntax;
16+
17+
use std::any::Any;
18+
use std::local_data;
19+
use syntax::ast::Name;
20+
use syntax::ext::base::SyntaxExtension;
21+
22+
struct Foo {
23+
foo: int
24+
}
25+
26+
impl Drop for Foo {
27+
fn drop(&mut self) {}
28+
}
29+
30+
#[macro_registrar]
31+
pub fn registrar(_: |Name, SyntaxExtension|) {
32+
local_data_key!(foo: ~Any);
33+
local_data::set(foo, ~Foo { foo: 10 } as ~Any);
34+
}
35+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2014 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+
// aux-build:macro_crate_outlive_expansion_phase.rs
12+
// ignore-stage1
13+
// ignore-fast
14+
// ignore-android
15+
16+
#[feature(phase)];
17+
18+
#[phase(syntax)]
19+
extern mod macro_crate_outlive_expansion_phase;
20+
21+
pub fn main() {}

0 commit comments

Comments
 (0)