Skip to content

Commit ed8f504

Browse files
committed
---
yaml --- r: 67511 b: refs/heads/master c: ea5f829 h: refs/heads/master i: 67509: c4e36dd 67507: e4cfecb 67503: 54ebd86 v: v3
1 parent 3bcf57f commit ed8f504

File tree

7 files changed

+79
-38
lines changed

7 files changed

+79
-38
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 5f59c46e0f5605a0cc90ebdb26b4d258a8f7b43a
2+
refs/heads/master: ea5f829307c3a4ba62f6d83e3c3cf0b6affc34f0
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 18e3db7392d2d0697b7e27d6d986139960144d85
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9

trunk/src/libextra/rc.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ impl<T> Rc<T> {
5353
}
5454

5555
impl<T: Send> Rc<T> {
56-
pub fn from_send(value: T) -> Rc<T> {
56+
pub fn from_owned(value: T) -> Rc<T> {
5757
unsafe { Rc::new(value) }
5858
}
5959
}
6060

6161
impl<T: Freeze> Rc<T> {
62-
pub fn from_freeze(value: T) -> Rc<T> {
62+
pub fn from_const(value: T) -> Rc<T> {
6363
unsafe { Rc::new(value) }
6464
}
6565
}
@@ -111,7 +111,7 @@ mod test_rc {
111111

112112
#[test]
113113
fn test_clone() {
114-
let x = Rc::from_send(Cell::new(5));
114+
let x = Rc::from_owned(Cell::new(5));
115115
let y = x.clone();
116116
do x.borrow().with_mut_ref |inner| {
117117
*inner = 20;
@@ -121,7 +121,7 @@ mod test_rc {
121121

122122
#[test]
123123
fn test_deep_clone() {
124-
let x = Rc::from_send(Cell::new(5));
124+
let x = Rc::from_owned(Cell::new(5));
125125
let y = x.deep_clone();
126126
do x.borrow().with_mut_ref |inner| {
127127
*inner = 20;
@@ -131,21 +131,21 @@ mod test_rc {
131131

132132
#[test]
133133
fn test_simple() {
134-
let x = Rc::from_freeze(5);
134+
let x = Rc::from_const(5);
135135
assert_eq!(*x.borrow(), 5);
136136
}
137137

138138
#[test]
139139
fn test_simple_clone() {
140-
let x = Rc::from_freeze(5);
140+
let x = Rc::from_const(5);
141141
let y = x.clone();
142142
assert_eq!(*x.borrow(), 5);
143143
assert_eq!(*y.borrow(), 5);
144144
}
145145

146146
#[test]
147147
fn test_destructor() {
148-
let x = Rc::from_send(~5);
148+
let x = Rc::from_owned(~5);
149149
assert_eq!(**x.borrow(), 5);
150150
}
151151
}
@@ -178,13 +178,13 @@ impl<T> RcMut<T> {
178178
}
179179

180180
impl<T: Send> RcMut<T> {
181-
pub fn from_send(value: T) -> RcMut<T> {
181+
pub fn from_owned(value: T) -> RcMut<T> {
182182
unsafe { RcMut::new(value) }
183183
}
184184
}
185185

186186
impl<T: Freeze> RcMut<T> {
187-
pub fn from_freeze(value: T) -> RcMut<T> {
187+
pub fn from_const(value: T) -> RcMut<T> {
188188
unsafe { RcMut::new(value) }
189189
}
190190
}
@@ -258,7 +258,7 @@ mod test_rc_mut {
258258

259259
#[test]
260260
fn test_clone() {
261-
let x = RcMut::from_send(5);
261+
let x = RcMut::from_owned(5);
262262
let y = x.clone();
263263
do x.with_mut_borrow |value| {
264264
*value = 20;
@@ -270,7 +270,7 @@ mod test_rc_mut {
270270

271271
#[test]
272272
fn test_deep_clone() {
273-
let x = RcMut::from_freeze(5);
273+
let x = RcMut::from_const(5);
274274
let y = x.deep_clone();
275275
do x.with_mut_borrow |value| {
276276
*value = 20;
@@ -282,7 +282,7 @@ mod test_rc_mut {
282282

283283
#[test]
284284
fn borrow_many() {
285-
let x = RcMut::from_send(5);
285+
let x = RcMut::from_owned(5);
286286
let y = x.clone();
287287

288288
do x.with_borrow |a| {
@@ -298,7 +298,7 @@ mod test_rc_mut {
298298

299299
#[test]
300300
fn modify() {
301-
let x = RcMut::from_freeze(5);
301+
let x = RcMut::from_const(5);
302302
let y = x.clone();
303303

304304
do y.with_mut_borrow |a| {
@@ -313,22 +313,22 @@ mod test_rc_mut {
313313

314314
#[test]
315315
fn release_immutable() {
316-
let x = RcMut::from_send(5);
316+
let x = RcMut::from_owned(5);
317317
do x.with_borrow |_| {}
318318
do x.with_mut_borrow |_| {}
319319
}
320320

321321
#[test]
322322
fn release_mutable() {
323-
let x = RcMut::from_freeze(5);
323+
let x = RcMut::from_const(5);
324324
do x.with_mut_borrow |_| {}
325325
do x.with_borrow |_| {}
326326
}
327327

328328
#[test]
329329
#[should_fail]
330330
fn frozen() {
331-
let x = RcMut::from_send(5);
331+
let x = RcMut::from_owned(5);
332332
let y = x.clone();
333333

334334
do x.with_borrow |_| {
@@ -340,7 +340,7 @@ mod test_rc_mut {
340340
#[test]
341341
#[should_fail]
342342
fn mutable_dupe() {
343-
let x = RcMut::from_freeze(5);
343+
let x = RcMut::from_const(5);
344344
let y = x.clone();
345345

346346
do x.with_mut_borrow |_| {
@@ -352,7 +352,7 @@ mod test_rc_mut {
352352
#[test]
353353
#[should_fail]
354354
fn mutable_freeze() {
355-
let x = RcMut::from_send(5);
355+
let x = RcMut::from_owned(5);
356356
let y = x.clone();
357357

358358
do x.with_mut_borrow |_| {
@@ -364,7 +364,7 @@ mod test_rc_mut {
364364
#[test]
365365
#[should_fail]
366366
fn restore_freeze() {
367-
let x = RcMut::from_freeze(5);
367+
let x = RcMut::from_const(5);
368368
let y = x.clone();
369369

370370
do x.with_borrow |_| {

trunk/src/librustc/middle/trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2460,7 +2460,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
24602460
// LLVM type is not fully determined by the Rust type.
24612461
let v = consts::const_expr(ccx, expr);
24622462
ccx.const_values.insert(id, v);
2463-
exprt = m == ast::m_mutbl;
2463+
exprt = (m == ast::m_mutbl || i.vis == ast::public);
24642464

24652465
unsafe {
24662466
let llty = llvm::LLVMTypeOf(v);

trunk/src/librustc/middle/trans/expr.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ return type, such as `while` loops or assignments (`a = b`).
115115

116116

117117
use back::abi;
118-
use lib::llvm::{ValueRef, llvm};
118+
use lib::llvm::{ValueRef, llvm, SetLinkage, ExternalLinkage};
119119
use lib;
120120
use metadata::csearch;
121121
use middle::trans::_match;
@@ -132,7 +132,6 @@ use middle::trans::consts;
132132
use middle::trans::controlflow;
133133
use middle::trans::datum::*;
134134
use middle::trans::debuginfo;
135-
use middle::trans::inline;
136135
use middle::trans::machine;
137136
use middle::trans::meth;
138137
use middle::trans::tvec;
@@ -148,7 +147,6 @@ use middle::trans::machine::llsize_of;
148147

149148
use middle::trans::type_::Type;
150149

151-
use std::cast::transmute;
152150
use std::hashmap::HashMap;
153151
use std::vec;
154152
use syntax::print::pprust::{expr_to_str};
@@ -936,20 +934,10 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock {
936934
//! Translates a reference to a path.
937935
938936
let _icx = push_ctxt("trans_def_lvalue");
939-
let ccx = bcx.ccx();
940937
match def {
941938
ast::def_static(did, _) => {
942939
let const_ty = expr_ty(bcx, ref_expr);
943940

944-
fn get_did(ccx: @mut CrateContext, did: ast::def_id)
945-
-> ast::def_id {
946-
if did.crate != ast::LOCAL_CRATE {
947-
inline::maybe_instantiate_inline(ccx, did)
948-
} else {
949-
did
950-
}
951-
}
952-
953941
fn get_val(bcx: @mut Block, did: ast::def_id, const_ty: ty::t)
954942
-> ValueRef {
955943
// For external constants, we don't inline.
@@ -976,16 +964,19 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: @ast::expr) -> DatumBlock {
976964
let symbol = csearch::get_symbol(
977965
bcx.ccx().sess.cstore,
978966
did);
979-
let llval = llvm::LLVMAddGlobal( bcx.ccx().llmod, llty.to_ref(),
980-
transmute::<&u8,*i8>(&symbol[0]));
967+
let llval = do symbol.as_c_str |buf| {
968+
llvm::LLVMAddGlobal(bcx.ccx().llmod,
969+
llty.to_ref(),
970+
buf)
971+
};
972+
SetLinkage(llval, ExternalLinkage);
981973
let extern_const_values = &mut bcx.ccx().extern_const_values;
982974
extern_const_values.insert(did, llval);
983975
llval
984976
}
985977
}
986978
}
987979

988-
let did = get_did(ccx, did);
989980
let val = get_val(bcx, did, const_ty);
990981
DatumBlock {
991982
bcx: bcx,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
pub static global: int = 3;
12+
13+
pub fn verify_same(a: &'static int) {
14+
let a = a as *int as uint;
15+
let b = &global as *int as uint;
16+
assert_eq!(a, b);
17+
}
18+
19+
condition!{ pub test: int -> (); }
20+
21+
pub fn raise() {
22+
test::cond.raise(3);
23+
}

trunk/src/test/compile-fail/rcmut-not-const-and-not-owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn o<T: Send>(_: &T) {}
1414
fn c<T: Freeze>(_: &T) {}
1515

1616
fn main() {
17-
let x = extra::rc::RcMut::from_send(0);
17+
let x = extra::rc::RcMut::from_owned(0);
1818
o(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Send`
1919
c(&x); //~ ERROR instantiating a type parameter with an incompatible type `extra::rc::RcMut<int>`, which does not fulfill `Freeze`
2020
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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+
// aux-build:xcrate_static_addresses.rs
13+
14+
extern mod xcrate_static_addresses;
15+
16+
use other = xcrate_static_addresses;
17+
18+
pub fn main() {
19+
other::verify_same(&other::global);
20+
21+
// Previously this fail'd because there were two addresses that were being
22+
// used when declaring constants.
23+
do other::test::cond.trap(|_| {
24+
}).inside {
25+
other::raise();
26+
}
27+
}

0 commit comments

Comments
 (0)