Skip to content

Commit 4e52595

Browse files
committed
auto merge of #19242 : jakub-/rust/roll-up, r=jakub-
2 parents 220b99b + d6b023a commit 4e52595

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+578
-550
lines changed

configure

+14-15
Original file line numberDiff line numberDiff line change
@@ -546,22 +546,26 @@ CFG_TARGET=$(to_llvm_triple $CFG_TARGET)
546546
# there's no rpath. This is where the build system itself puts libraries;
547547
# --libdir is used to configure the installation directory.
548548
# FIXME: This needs to parameterized over target triples. Do it in platform.mk
549-
CFG_LIBDIR_RELATIVE=lib
550549
if [ "$CFG_OSTYPE" = "pc-windows-gnu" ]
551550
then
552551
CFG_LIBDIR_RELATIVE=bin
553-
CFG_LIBDIR="${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}"
554552
else
555-
valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries (ignored on windows platform)"
553+
CFG_LIBDIR_RELATIVE=lib
554+
fi
556555

557-
case "$CFG_LIBDIR" in
558-
"$CFG_PREFIX"/*) CAT_INC=2;;
559-
"$CFG_PREFIX"*) CAT_INC=1;;
560-
*)
561-
err "libdir must begin with the prefix. Use --prefix to set it accordingly.";;
562-
esac
556+
valopt libdir "${CFG_PREFIX}/${CFG_LIBDIR_RELATIVE}" "install libraries (do not set it on windows platform)"
557+
558+
case "$CFG_LIBDIR" in
559+
"$CFG_PREFIX"/*) CAT_INC=2;;
560+
"$CFG_PREFIX"*) CAT_INC=1;;
561+
*)
562+
err "libdir must begin with the prefix. Use --prefix to set it accordingly.";;
563+
esac
563564

564-
CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
565+
CFG_LIBDIR_RELATIVE=`echo ${CFG_LIBDIR} | cut -c$((${#CFG_PREFIX}+${CAT_INC}))-`
566+
567+
if [ "$CFG_OSTYPE" = "pc-windows-gnu" ] && [ "$CFG_LIBDIR_RELATIVE" != "bin" ]; then
568+
err "libdir on windows should be set to 'bin'"
565569
fi
566570

567571
if [ $HELP -eq 1 ]
@@ -711,11 +715,6 @@ then
711715
fi
712716
step_msg "using rustc at: ${CFG_LOCAL_RUST_ROOT} with version: $LRV"
713717
putvar CFG_LOCAL_RUST_ROOT
714-
else
715-
if [ ! -z "$CFG_LOCAL_RUST_ROOT" ]
716-
then
717-
warn "Use of --local-rust-root without --enable-local-rust"
718-
fi
719718
fi
720719

721720
# Force freebsd to build with clang; gcc doesn't like us there

mk/main.mk

+5-2
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,14 @@ endif
190190
# Target-and-rule "utility variables"
191191
######################################################################
192192

193-
define DEF_X
193+
define DEF_FOR_TARGET
194194
X_$(1) := $(CFG_EXE_SUFFIX_$(1))
195+
ifndef CFG_LLVM_TARGET_$(1)
196+
CFG_LLVM_TARGET_$(1) := $(1)
197+
endif
195198
endef
196199
$(foreach target,$(CFG_TARGET), \
197-
$(eval $(call DEF_X,$(target))))
200+
$(eval $(call DEF_FOR_TARGET,$(target))))
198201

199202
# "Source" files we generate in builddir along the way.
200203
GENERATED :=

mk/rt.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.ll $$(MKFILE_DEPS) \
7575
@mkdir -p $$(@D)
7676
@$$(call E, compile: $$@)
7777
$$(Q)$$(LLC_$$(CFG_BUILD)) $$(CFG_LLC_FLAGS_$(1)) \
78-
-filetype=obj -mtriple=$(1) -relocation-model=pic -o $$@ $$<
78+
-filetype=obj -mtriple=$$(CFG_LLVM_TARGET_$(1)) -relocation-model=pic -o $$@ $$<
7979

8080
$$(RT_OUTPUT_DIR_$(1))/%.o: $(S)src/rt/%.c $$(MKFILE_DEPS)
8181
@mkdir -p $$(@D)

mk/stage0.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ifdef CFG_ENABLE_LOCAL_RUST
2222
else
2323
$(Q)$(CFG_PYTHON) $(S)src/etc/get-snapshot.py $(CFG_BUILD) $(SNAPSHOT_FILE)
2424
endif
25-
$(Q)touch $@
25+
$(Q)if [ -e "$@" ]; then touch "$@"; else echo "ERROR: snapshot $@ not found"; exit 1; fi
2626

2727
# For other targets, let the host build the target:
2828

mk/target.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
116116
$$(foreach dep,$$(TOOL_DEPS_$(4)), \
117117
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \
118118
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
119-
| $$(TBIN$(1)_T_$(4)_H_$(3))/
119+
| $$(TBIN$(1)_T_$(2)_H_$(3))/
120120
@$$(call E, rustc: $$@)
121121
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg $(4)
122122

src/compiletest/errors.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::ascii::AsciiExt;
1112
use std::io::{BufferedReader, File};
1213
use regex::Regex;
1314

@@ -31,7 +32,7 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
3132
fn parse_expected(line_num: uint, line: &str, re: &Regex) -> Option<ExpectedError> {
3233
re.captures(line).and_then(|caps| {
3334
let adjusts = caps.name("adjusts").len();
34-
let kind = caps.name("kind").to_ascii().to_lowercase().into_string();
35+
let kind = caps.name("kind").to_ascii_lower();
3536
let msg = caps.name("msg").trim().to_string();
3637

3738
debug!("line={} kind={} msg={}", line_num, kind, msg);

src/compiletest/runtest.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
#[cfg(not(stage0))]
10+
1111
use self::TargetLocation::*;
1212

1313
use common::Config;
@@ -990,7 +990,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
990990
let i = s.chars();
991991
let c : Vec<char> = i.map( |c| {
992992
if c.is_ascii() {
993-
c.to_ascii().to_lowercase().to_char()
993+
c.to_ascii().to_lowercase().as_char()
994994
} else {
995995
c
996996
}
@@ -1161,7 +1161,7 @@ fn compile_test_(config: &Config, props: &TestProps,
11611161
let args = make_compile_args(config,
11621162
props,
11631163
link_args,
1164-
|a, b| ThisFile(make_exe_name(a, b)), testfile);
1164+
|a, b| TargetLocation::ThisFile(make_exe_name(a, b)), testfile);
11651165
compose_and_run_compiler(config, props, testfile, args, None)
11661166
}
11671167

@@ -1219,7 +1219,7 @@ fn compose_and_run_compiler(
12191219
crate_type,
12201220
|a,b| {
12211221
let f = make_lib_name(a, b, testfile);
1222-
ThisDirectory(f.dir_path())
1222+
TargetLocation::ThisDirectory(f.dir_path())
12231223
},
12241224
&abs_ab);
12251225
let auxres = compose_and_run(config,
@@ -1296,11 +1296,11 @@ fn make_compile_args(config: &Config,
12961296
args.push("prefer-dynamic".to_string());
12971297
}
12981298
let path = match xform_file {
1299-
ThisFile(path) => {
1299+
TargetLocation::ThisFile(path) => {
13001300
args.push("-o".to_string());
13011301
path
13021302
}
1303-
ThisDirectory(path) => {
1303+
TargetLocation::ThisDirectory(path) => {
13041304
args.push("--out-dir".to_string());
13051305
path
13061306
}
@@ -1672,7 +1672,8 @@ fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
16721672
let args = make_compile_args(config,
16731673
props,
16741674
link_args,
1675-
|a, b| ThisDirectory(output_base_name(a, b).dir_path()),
1675+
|a, b| TargetLocation::ThisDirectory(
1676+
output_base_name(a, b).dir_path()),
16761677
testfile);
16771678
compose_and_run_compiler(config, props, testfile, args, None)
16781679
}

src/driver/driver.rs

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![no_start]
12-
1311
#[cfg(rustdoc)]
1412
extern crate "rustdoc" as this;
1513

src/etc/lldb_rust_formatters.py

+21-31
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ def print_struct_val(val, internal_dict):
4343
return print_struct_val_starting_from(0, val, internal_dict)
4444

4545
def print_vec_slice_val(val, internal_dict):
46-
output = "&["
47-
4846
length = val.GetChildAtIndex(1).GetValueAsUnsigned()
4947

5048
data_ptr_val = val.GetChildAtIndex(0)
@@ -56,16 +54,12 @@ def print_vec_slice_val(val, internal_dict):
5654

5755
start_address = data_ptr_val.GetValueAsUnsigned()
5856

59-
for i in range(length):
57+
def render_element(i):
6058
address = start_address + i * element_type_size
61-
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type )
62-
output += print_val(element_val, internal_dict)
63-
64-
if i != length - 1:
65-
output += ", "
59+
element_val = val.CreateValueFromAddress( val.GetName() + ("[%s]" % i), address, element_type)
60+
return print_val(element_val, internal_dict)
6661

67-
output += "]"
68-
return output
62+
return "&[%s]" % (', '.join([render_element(i) for i in range(length)]))
6963

7064
def print_struct_val_starting_from(field_start_index, val, internal_dict):
7165
'''
@@ -77,39 +71,33 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
7771
t = val.GetType()
7872
has_field_names = type_has_field_names(t)
7973
type_name = extract_type_name(t.GetName())
80-
output = ""
81-
82-
if not type_name.startswith("("):
83-
# this is a tuple, so don't print the type name
84-
output += type_name
8574

8675
if has_field_names:
87-
output += " { \n"
76+
template = "%(type_name)s {\n%(body)s\n}"
77+
separator = ", \n"
8878
else:
89-
output += "("
79+
template = "%(type_name)s(%(body)s)"
80+
separator = ", "
81+
82+
if type_name.startswith("("):
83+
# this is a tuple, so don't print the type name
84+
type_name = ""
9085

9186
num_children = val.num_children
9287

93-
for child_index in range(field_start_index, num_children):
88+
def render_child(child_index):
89+
this = ""
9490
if has_field_names:
9591
field_name = t.GetFieldAtIndex(child_index).GetName()
96-
output += field_name + ": "
92+
this += field_name + ": "
9793

9894
field_val = val.GetChildAtIndex(child_index)
99-
output += print_val(field_val, internal_dict)
95+
return this + print_val(field_val, internal_dict)
10096

101-
if child_index != num_children - 1:
102-
output += ", "
103-
104-
if has_field_names:
105-
output += "\n"
106-
107-
if has_field_names:
108-
output += "}"
109-
else:
110-
output += ")"
97+
body = separator.join([render_child(idx) for idx in range(field_start_index, num_children)])
11198

112-
return output
99+
return template % {"type_name": type_name,
100+
"body": body}
113101

114102

115103
def print_enum_val(val, internal_dict):
@@ -243,3 +231,5 @@ def is_vec_slice(val):
243231

244232
type_name = extract_type_name(ty.GetName()).replace("&'static", "&").replace(" ", "")
245233
return type_name.startswith("&[") and type_name.endswith("]")
234+
235+
# vi: sw=2:ts=2

src/liballoc/arc.rs

+54-1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ impl<T> Arc<T> {
119119
}
120120
}
121121

122+
/// Get the number of weak references to this value.
123+
#[inline]
124+
#[experimental]
125+
pub fn weak_count<T>(this: &Arc<T>) -> uint { this.inner().weak.load(atomic::SeqCst) - 1 }
126+
127+
/// Get the number of strong references to this value.
128+
#[inline]
129+
#[experimental]
130+
pub fn strong_count<T>(this: &Arc<T>) -> uint { this.inner().strong.load(atomic::SeqCst) }
131+
122132
#[unstable = "waiting on stability of Clone"]
123133
impl<T> Clone for Arc<T> {
124134
/// Duplicate an atomically reference counted wrapper.
@@ -321,7 +331,7 @@ mod tests {
321331
use std::sync::atomic;
322332
use std::task;
323333
use std::vec::Vec;
324-
use super::{Arc, Weak};
334+
use super::{Arc, Weak, weak_count, strong_count};
325335
use std::sync::Mutex;
326336

327337
struct Canary(*mut atomic::AtomicUint);
@@ -465,6 +475,49 @@ mod tests {
465475
drop(arc_weak);
466476
}
467477

478+
#[test]
479+
fn test_strong_count() {
480+
let a = Arc::new(0u32);
481+
assert!(strong_count(&a) == 1);
482+
let w = a.downgrade();
483+
assert!(strong_count(&a) == 1);
484+
let b = w.upgrade().expect("");
485+
assert!(strong_count(&b) == 2);
486+
assert!(strong_count(&a) == 2);
487+
drop(w);
488+
drop(a);
489+
assert!(strong_count(&b) == 1);
490+
let c = b.clone();
491+
assert!(strong_count(&b) == 2);
492+
assert!(strong_count(&c) == 2);
493+
}
494+
495+
#[test]
496+
fn test_weak_count() {
497+
let a = Arc::new(0u32);
498+
assert!(strong_count(&a) == 1);
499+
assert!(weak_count(&a) == 0);
500+
let w = a.downgrade();
501+
assert!(strong_count(&a) == 1);
502+
assert!(weak_count(&a) == 1);
503+
let x = w.clone();
504+
assert!(weak_count(&a) == 2);
505+
drop(w);
506+
drop(x);
507+
assert!(strong_count(&a) == 1);
508+
assert!(weak_count(&a) == 0);
509+
let c = a.clone();
510+
assert!(strong_count(&a) == 2);
511+
assert!(weak_count(&a) == 0);
512+
let d = c.downgrade();
513+
assert!(weak_count(&c) == 1);
514+
assert!(strong_count(&c) == 2);
515+
516+
drop(a);
517+
drop(c);
518+
drop(d);
519+
}
520+
468521
#[test]
469522
fn show_arc() {
470523
let a = Arc::new(5u32);

src/liballoc/boxed.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use core::clone::Clone;
1515
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
1616
use core::default::Default;
1717
use core::fmt;
18-
use core::intrinsics;
1918
use core::kinds::Sized;
2019
use core::mem;
2120
use core::option::Option;
@@ -104,17 +103,14 @@ pub trait BoxAny {
104103
}
105104

106105
#[stable]
107-
impl BoxAny for Box<Any+'static> {
106+
impl BoxAny for Box<Any> {
108107
#[inline]
109-
fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any+'static>> {
108+
fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
110109
if self.is::<T>() {
111110
unsafe {
112111
// Get the raw representation of the trait object
113112
let to: TraitObject =
114-
*mem::transmute::<&Box<Any>, &TraitObject>(&self);
115-
116-
// Prevent destructor on self being run
117-
intrinsics::forget(self);
113+
mem::transmute::<Box<Any>, TraitObject>(self);
118114

119115
// Extract the data pointer
120116
Ok(mem::transmute(to.data))

0 commit comments

Comments
 (0)