Skip to content

Commit 58e55f5

Browse files
committed
---
yaml --- r: 146269 b: refs/heads/try2 c: 52f42f1 h: refs/heads/master i: 146267: 40e95d0 v: v3
1 parent 783b105 commit 58e55f5

File tree

35 files changed

+279
-289
lines changed

35 files changed

+279
-289
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 201cab84e8f12ec73131ac4908e6779b277449a2
8+
refs/heads/try2: 52f42f16387d0142944f376ea31c554c9caa2189
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libextra/future.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,9 @@ impl<A:Clone> Future<A> {
5151

5252
impl<A> Future<A> {
5353
/// Gets the value from this future, forcing evaluation.
54-
pub fn unwrap(self) -> A {
55-
let mut this = self;
56-
this.get_ref();
57-
let state = replace(&mut this.state, Evaluating);
54+
pub fn unwrap(mut self) -> A {
55+
self.get_ref();
56+
let state = replace(&mut self.state, Evaluating);
5857
match state {
5958
Forced(v) => v,
6059
_ => fail!( "Logic error." ),

branches/try2/src/librustc/lib/llvm.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,8 @@ pub mod llvm {
693693
pub fn LLVMAddReturnAttribute(Fn: ValueRef, PA: c_uint);
694694
pub fn LLVMRemoveReturnAttribute(Fn: ValueRef, PA: c_uint);
695695

696+
pub fn LLVMAddColdAttribute(Fn: ValueRef);
697+
696698
pub fn LLVMRemoveFunctionAttr(Fn: ValueRef,
697699
PA: c_ulonglong,
698700
HighPA: c_ulonglong);

branches/try2/src/librustc/middle/moves.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ impl VisitContext {
420420
// specified and (2) have a type that
421421
// moves-by-default:
422422
let consume_with = with_fields.iter().any(|tf| {
423-
!fields.iter().any(|f| f.ident.name == tf.ident.name) &&
423+
!fields.iter().any(|f| f.ident.node.name == tf.ident.name) &&
424424
ty::type_moves_by_default(self.tcx, tf.mt.ty)
425425
});
426426

branches/try2/src/librustc/middle/privacy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,15 +716,15 @@ impl<'self> Visitor<()> for PrivacyVisitor<'self> {
716716
match ty::get(ty::expr_ty(self.tcx, expr)).sty {
717717
ty::ty_struct(id, _) => {
718718
for field in (*fields).iter() {
719-
self.check_field(expr.span, id, field.ident);
719+
self.check_field(expr.span, id, field.ident.node);
720720
}
721721
}
722722
ty::ty_enum(_, _) => {
723723
match self.tcx.def_map.get_copy(&expr.id) {
724724
ast::DefVariant(_, variant_id, _) => {
725725
for field in fields.iter() {
726726
self.check_field(expr.span, variant_id,
727-
field.ident);
727+
field.ident.node);
728728
}
729729
}
730730
_ => self.tcx.sess.span_bug(expr.span,

branches/try2/src/librustc/middle/trans/base.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,19 +202,21 @@ pub fn get_extern_fn(externs: &mut ExternMap, llmod: ModuleRef, name: &str,
202202
f
203203
}
204204

205-
pub fn get_extern_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
206-
name: &str) -> ValueRef {
205+
fn get_extern_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
206+
name: &str, did: ast::DefId) -> ValueRef {
207207
match ccx.externs.find_equiv(&name) {
208208
Some(n) => return *n,
209209
None => ()
210210
}
211211
let f = decl_rust_fn(ccx, inputs, output, name);
212+
do csearch::get_item_attrs(ccx.tcx.cstore, did) |meta_items| {
213+
set_llvm_fn_attrs(meta_items.iter().map(|&x| attr::mk_attr(x)).to_owned_vec(), f)
214+
}
212215
ccx.externs.insert(name.to_owned(), f);
213216
f
214217
}
215218

216-
pub fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t,
217-
name: &str) -> ValueRef {
219+
fn decl_rust_fn(ccx: &mut CrateContext, inputs: &[ty::t], output: ty::t, name: &str) -> ValueRef {
218220
let llfty = type_of_rust_fn(ccx, inputs, output);
219221
let llfn = decl_cdecl_fn(ccx.llmod, name, llfty);
220222

@@ -481,6 +483,10 @@ pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
481483
if contains_name(attrs, "no_split_stack") {
482484
set_no_split_stack(llfn);
483485
}
486+
487+
if contains_name(attrs, "cold") {
488+
unsafe { llvm::LLVMAddColdAttribute(llfn) }
489+
}
484490
}
485491

486492
pub fn set_always_inline(f: ValueRef) {
@@ -840,7 +846,7 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
840846
ty::ty_bare_fn(ref fn_ty) => {
841847
match fn_ty.abis.for_arch(ccx.sess.targ_cfg.arch) {
842848
Some(Rust) | Some(RustIntrinsic) => {
843-
get_extern_rust_fn(ccx, fn_ty.sig.inputs, fn_ty.sig.output, name)
849+
get_extern_rust_fn(ccx, fn_ty.sig.inputs, fn_ty.sig.output, name, did)
844850
}
845851
Some(*) | None => {
846852
let c = foreign::llvm_calling_convention(ccx, fn_ty.abis);
@@ -851,7 +857,7 @@ pub fn trans_external_path(ccx: &mut CrateContext, did: ast::DefId, t: ty::t) ->
851857
}
852858
}
853859
ty::ty_closure(ref f) => {
854-
get_extern_rust_fn(ccx, f.sig.inputs, f.sig.output, name)
860+
get_extern_rust_fn(ccx, f.sig.inputs, f.sig.output, name, did)
855861
}
856862
_ => {
857863
let llty = type_of(ccx, t);
@@ -2864,6 +2870,8 @@ pub fn declare_intrinsics(llmod: ModuleRef) -> HashMap<&'static str, ValueRef> {
28642870
ifn!(intrinsics, "llvm.umul.with.overflow.i64",
28652871
[Type::i64(), Type::i64()], Type::struct_([Type::i64(), Type::i1()], false));
28662872

2873+
ifn!(intrinsics, "llvm.expect.i1", [Type::i1(), Type::i1()], Type::i1());
2874+
28672875
return intrinsics;
28682876
}
28692877

branches/try2/src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext,
508508
|discr, field_tys| {
509509
let cs = field_tys.iter().enumerate()
510510
.map(|(ix, &field_ty)| {
511-
match fs.iter().find(|f| field_ty.ident.name == f.ident.name) {
511+
match fs.iter().find(|f| field_ty.ident.name == f.ident.node.name) {
512512
Some(f) => const_expr(cx, (*f).expr),
513513
None => {
514514
match base_val {

branches/try2/src/librustc/middle/trans/expr.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,9 @@ fn trans_lvalue_unadjusted(bcx: @mut Block, expr: &ast::Expr) -> DatumBlock {
981981
debug!("trans_index: len {}", bcx.val_to_str(len));
982982

983983
let bounds_check = ICmp(bcx, lib::llvm::IntUGE, ix_val, len);
984-
let bcx = do with_cond(bcx, bounds_check) |bcx| {
984+
let expect = ccx.intrinsics.get_copy(&("llvm.expect.i1"));
985+
let expected = Call(bcx, expect, [bounds_check, C_i1(false)], []);
986+
let bcx = do with_cond(bcx, expected) |bcx| {
985987
controlflow::trans_fail_bounds_check(bcx, index_expr.span, ix_val, len)
986988
};
987989
let elt = InBoundsGEP(bcx, base, [ix_val]);
@@ -1209,7 +1211,7 @@ fn trans_rec_or_struct(bcx: @mut Block,
12091211
let numbered_fields = do fields.map |field| {
12101212
let opt_pos =
12111213
field_tys.iter().position(|field_ty|
1212-
field_ty.ident.name == field.ident.name);
1214+
field_ty.ident.name == field.ident.node.name);
12131215
match opt_pos {
12141216
Some(i) => {
12151217
need_base[i] = false;

branches/try2/src/librustc/middle/typeck/check/mod.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
20092009
}
20102010

20112011
fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
2012+
struct_ty: ty::t,
20122013
span: Span,
20132014
class_id: ast::DefId,
20142015
node_id: ast::NodeId,
@@ -2030,28 +2031,30 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
20302031
for field in ast_fields.iter() {
20312032
let mut expected_field_type = ty::mk_err();
20322033

2033-
let pair = class_field_map.find(&field.ident.name).map(|x| *x);
2034+
let pair = class_field_map.find(&field.ident.node.name).map(|x| *x);
20342035
match pair {
20352036
None => {
2036-
tcx.sess.span_err(
2037-
field.span,
2038-
format!("structure has no field named `{}`",
2039-
tcx.sess.str_of(field.ident)));
2037+
fcx.type_error_message(
2038+
field.ident.span,
2039+
|actual| {
2040+
format!("structure `{}` has no field named `{}`",
2041+
actual, tcx.sess.str_of(field.ident.node))
2042+
}, struct_ty, None);
20402043
error_happened = true;
20412044
}
20422045
Some((_, true)) => {
20432046
tcx.sess.span_err(
2044-
field.span,
2047+
field.ident.span,
20452048
format!("field `{}` specified more than once",
2046-
tcx.sess.str_of(field.ident)));
2049+
tcx.sess.str_of(field.ident.node)));
20472050
error_happened = true;
20482051
}
20492052
Some((field_id, false)) => {
20502053
expected_field_type =
20512054
ty::lookup_field_type(
20522055
tcx, class_id, field_id, &substitutions);
20532056
class_field_map.insert(
2054-
field.ident.name, (field_id, true));
2057+
field.ident.node.name, (field_id, true));
20552058
fields_found += 1;
20562059
}
20572060
}
@@ -2161,6 +2164,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
21612164
// Look up and check the fields.
21622165
let class_fields = ty::lookup_struct_fields(tcx, class_id);
21632166
check_struct_or_variant_fields(fcx,
2167+
struct_type,
21642168
span,
21652169
class_id,
21662170
id,
@@ -2248,6 +2252,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
22482252
// Look up and check the enum variant fields.
22492253
let variant_fields = ty::lookup_struct_fields(tcx, variant_id);
22502254
check_struct_or_variant_fields(fcx,
2255+
enum_type,
22512256
span,
22522257
variant_id,
22532258
id,

branches/try2/src/librustpkg/package_source.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,8 @@ impl PkgSrc {
422422
fail!("Bad kind in build_crates")
423423
});
424424
}
425+
debug!("Compiling crate {}; its output will be in {}",
426+
subpath.display(), sub_dir.display());
425427
let result = compile_crate(&subcx,
426428
exec,
427429
&id,
@@ -473,8 +475,8 @@ impl PkgSrc {
473475
let tests = self.tests.clone();
474476
let benchs = self.benchs.clone();
475477
debug!("Building libs in {}, destination = {}",
476-
self.destination_workspace.display(),
477-
self.destination_workspace.display());
478+
self.source_workspace.display(),
479+
self.build_workspace().display());
478480
self.build_crates(build_context,
479481
&mut deps,
480482
libs,

branches/try2/src/librustpkg/rustpkg.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,8 +587,6 @@ impl CtxMethods for BuildContext {
587587
build_inputs,
588588
&pkg_src.destination_workspace,
589589
&id).map(|s| Path::new(s.as_slice()));
590-
debug!("install: id = {}, about to call discover_outputs, {:?}",
591-
id.to_str(), result.map(|p| p.display().to_str()));
592590
installed_files = installed_files + result;
593591
note(format!("Installed package {} to {}",
594592
id.to_str(),

branches/try2/src/librustpkg/tests.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,30 @@ fn rust_path_hack_build_no_arg() {
15111511
assert!(!built_library_exists(&source_dir, "foo"));
15121512
}
15131513

1514+
#[test]
1515+
fn rust_path_hack_build_with_dependency() {
1516+
let foo_id = PkgId::new("foo");
1517+
let dep_id = PkgId::new("dep");
1518+
// Tests that when --rust-path-hack is in effect, dependencies get built
1519+
// into the destination workspace and not the source directory
1520+
let work_dir = create_local_package(&foo_id);
1521+
let work_dir = work_dir.path();
1522+
let dep_workspace = create_local_package(&dep_id);
1523+
let dep_workspace = dep_workspace.path();
1524+
let dest_workspace = mk_emptier_workspace("dep");
1525+
let dest_workspace = dest_workspace.path();
1526+
let source_dir = work_dir.join_many(["src", "foo-0.1"]);
1527+
writeFile(&source_dir.join("lib.rs"), "extern mod dep; pub fn f() { }");
1528+
let dep_dir = dep_workspace.join_many(["src", "dep-0.1"]);
1529+
let rust_path = Some(~[(~"RUST_PATH",
1530+
format!("{}:{}",
1531+
dest_workspace.display(),
1532+
dep_dir.display()))]);
1533+
command_line_test_with_env([~"build", ~"--rust-path-hack", ~"foo"], work_dir, rust_path);
1534+
assert_built_library_exists(dest_workspace, "dep");
1535+
assert!(!built_library_exists(dep_workspace, "dep"));
1536+
}
1537+
15141538
#[test]
15151539
fn rust_path_install_target() {
15161540
let dir_for_path = TempDir::new(

branches/try2/src/librustpkg/util.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -465,22 +465,31 @@ impl<'self> Visitor<()> for ViewItemVisitor<'self> {
465465
// Find all the workspaces in the RUST_PATH that contain this package.
466466
let workspaces = pkg_parent_workspaces(&self.context.context,
467467
&pkg_id);
468-
// Two cases:
468+
// Three cases:
469469
// (a) `workspaces` is empty. That means there's no local source
470470
// for this package. In that case, we pass the default workspace
471471
// into `PkgSrc::new`, so that if it exists as a remote repository,
472-
// its sources will be fetched into it.
473-
// (b) `workspaces` is non-empty -- we found a local source for this
474-
// package.
475-
let dest_workspace = if workspaces.is_empty() {
476-
default_workspace()
477-
} else { workspaces[0] };
472+
// its sources will be fetched into it. We also put the output in the
473+
// same workspace.
474+
// (b) We're using the Rust path hack. In that case, the output goes
475+
// in the destination workspace.
476+
// (c) `workspaces` is non-empty -- we found a local source for this
477+
// package and will build in that workspace.
478+
let (source_workspace, dest_workspace) = if workspaces.is_empty() {
479+
(default_workspace(), default_workspace())
480+
} else {
481+
if self.context.context.use_rust_path_hack {
482+
(workspaces[0], default_workspace())
483+
} else {
484+
(workspaces[0].clone(), workspaces[0])
485+
}
486+
};
478487
// In this case, the source and destination workspaces are the same:
479488
// Either it's a remote package, so the local sources don't exist
480489
// and the `PkgSrc` constructor will detect that;
481490
// or else it's already in a workspace and we'll build into that
482491
// workspace
483-
let pkg_src = PkgSrc::new(dest_workspace.clone(),
492+
let pkg_src = PkgSrc::new(source_workspace,
484493
dest_workspace,
485494
// Use the rust_path_hack to search for dependencies iff
486495
// we were already using it

branches/try2/src/libstd/rt/borrowck.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ pub fn clear_task_borrow_list() {
5757
let _ = try_take_task_borrow_list();
5858
}
5959

60+
#[cold]
6061
unsafe fn fail_borrowed(box: *mut raw::Box<()>, file: *c_char, line: size_t) -> ! {
6162
debug_borrow("fail_borrowed: ", box, 0, 0, file, line);
6263

0 commit comments

Comments
 (0)