Skip to content

Commit 2e57d72

Browse files
sfackleralexcrichton
authored andcommitted
---
yaml --- r: 104139 b: refs/heads/try c: 6b429d0 h: refs/heads/master i: 104137: 2b7d373 104135: 74d3d2e v: v3
1 parent d0ac7a2 commit 2e57d72

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
@@ -2,7 +2,7 @@
22
refs/heads/master: 62f1d68439dcfd509eaca29887afa97f22938373
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6e7f170fedd3c526a643c0b2d13863acd982be02
5-
refs/heads/try: cfb87f10ec7d41d0e7f8c68fbb908fc195517d41
5+
refs/heads/try: 6b429d07c96c3e7cb3130c070d99651f29bded6c
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/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/try/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)