Skip to content

Commit 400e76e

Browse files
---
yaml --- r: 147326 b: refs/heads/try2 c: 0f98cb4 h: refs/heads/master v: v3
1 parent 53d8309 commit 400e76e

File tree

39 files changed

+621
-223
lines changed

39 files changed

+621
-223
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: c33573440b61acf154a1cee55413d02f9835c9aa
8+
refs/heads/try2: 0f98cb41988d1fdd0cb33fb274253cba3bde5cfa
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ extern mod extra; // equivalent to: extern mod extra = "extra";
790790
791791
extern mod rustextra = "extra"; // linking to 'extra' under another name
792792
793-
extern mod foo = "some/where/rust-foo#foo:1.0"; // a full package ID for rustpkg
793+
extern mod foo = "some/where/foo#1.0"; // a full package ID for rustpkg
794794
~~~~
795795

796796
##### Use declarations

branches/try2/src/etc/vim/syntax/rust.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ syn keyword rustEnumVariant Ok Err
6666

6767
" Types and traits {{{3
6868
syn keyword rustTrait Any AnyOwnExt AnyRefExt AnyMutRefExt
69-
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr IntoBytes
69+
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr ToBytesConsume
7070
syn keyword rustTrait Bool
7171
syn keyword rustTrait ToCStr
7272
syn keyword rustTrait Char
@@ -94,7 +94,7 @@ syn keyword rustTrait Buffer Writer Reader Seek
9494
syn keyword rustTrait SendStr SendStrOwned SendStrStatic IntoSendStr
9595
syn keyword rustTrait Str StrVector StrSlice OwnedStr
9696
syn keyword rustTrait IterBytes
97-
syn keyword rustTrait ToStr IntoStr
97+
syn keyword rustTrait ToStr ToStrConsume
9898
syn keyword rustTrait CopyableTuple ImmutableTuple
9999
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
100100
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8

branches/try2/src/libextra/bitv.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -932,8 +932,7 @@ impl<'a> Iterator<uint> for BitvSetIterator<'a> {
932932
mod tests {
933933
use extra::test::BenchHarness;
934934

935-
use bitv::{Bitv, SmallBitv, BigBitv, BitvSet, from_bools, from_fn,
936-
from_bytes};
935+
use bitv::*;
937936
use bitv;
938937

939938
use std::uint;

branches/try2/src/libextra/btree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ impl<K: Clone + TotalOrd, V: Clone> Clone for BranchElt<K, V> {
407407
#[cfg(test)]
408408
mod test_btree{
409409

410-
use super::{BTree, LeafElt};
410+
use super::*;
411411

412412
///Tests the functionality of the add methods (which are unfinished).
413413
#[test]

branches/try2/src/libextra/sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ impl Sem<~[WaitQueue]> {
329329
****************************************************************************/
330330

331331
/// A counting, blocking, bounded-waiting semaphore.
332-
pub struct Semaphore { priv sem: Sem<()> }
332+
struct Semaphore { priv sem: Sem<()> }
333333

334334

335335
impl Clone for Semaphore {

branches/try2/src/libextra/test.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,7 @@ fn should_sort_failures_before_printing_them() {
670670
use std::io::Decorator;
671671
use std::io::mem::MemWriter;
672672
use std::str;
673+
fn dummy() {}
673674

674675
let test_a = TestDesc {
675676
name: StaticTestName("a"),
@@ -1295,6 +1296,8 @@ mod tests {
12951296
12961297
#[test]
12971298
pub fn filter_for_ignored_option() {
1299+
fn dummy() {}
1300+
12981301
// When we run ignored tests the test filter should filter out all the
12991302
// unignored tests and flip the ignore flag on the rest to false
13001303
@@ -1438,7 +1441,6 @@ mod tests {
14381441
assert_eq!(diff2.len(), 7);
14391442
}
14401443
1441-
#[test]
14421444
pub fn ratchet_test() {
14431445
14441446
let dpth = TempDir::new("test-ratchet").expect("missing test for ratchet");

branches/try2/src/libextra/treemap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ impl<T: TotalOrd> Extendable<T> for TreeSet<T> {
884884
#[cfg(test)]
885885
mod test_treemap {
886886

887-
use super::{TreeMap, TreeNode};
887+
use super::*;
888888

889889
use std::rand::Rng;
890890
use std::rand;

branches/try2/src/librustc/back/link.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,17 @@ pub fn link_binary(sess: Session,
728728
obj_filename: &Path,
729729
out_filename: &Path,
730730
lm: &LinkMeta) -> ~[Path] {
731+
// If we're generating a test executable, then ignore all other output
732+
// styles at all other locations
733+
let outputs = if sess.opts.test {
734+
~[session::OutputExecutable]
735+
} else {
736+
(*sess.outputs).clone()
737+
};
738+
731739
let mut out_filenames = ~[];
732-
for &output in sess.outputs.iter() {
733-
let out_file = link_binary_output(sess, trans, output, obj_filename,
734-
out_filename, lm);
740+
for output in outputs.move_iter() {
741+
let out_file = link_binary_output(sess, trans, output, obj_filename, out_filename, lm);
735742
out_filenames.push(out_file);
736743
}
737744

branches/try2/src/librustc/driver/session.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,25 +405,20 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: || -> ~str) -> T {
405405
}
406406

407407
pub fn building_library(options: &options, crate: &ast::Crate) -> bool {
408-
if options.test { return false }
409408
for output in options.outputs.iter() {
410409
match *output {
411410
OutputExecutable => {}
412411
OutputStaticlib | OutputDylib | OutputRlib => return true
413412
}
414413
}
414+
if options.test { return false }
415415
match syntax::attr::first_attr_value_str_by_name(crate.attrs, "crate_type") {
416416
Some(s) => "lib" == s || "rlib" == s || "dylib" == s || "staticlib" == s,
417417
_ => false
418418
}
419419
}
420420

421421
pub fn collect_outputs(options: &options, crate: &ast::Crate) -> ~[OutputStyle] {
422-
// If we're generating a test executable, then ignore all other output
423-
// styles at all other locations
424-
if options.test {
425-
return ~[OutputExecutable];
426-
}
427422
let mut base = options.outputs.clone();
428423
let mut iter = crate.attrs.iter().filter_map(|a| {
429424
if "crate_type" == a.name() {

branches/try2/src/librustc/middle/borrowck/check_loans.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl<'a> CheckLoanCtxt<'a> {
238238
self.bccx.loan_path_to_str(new_loan.loan_path)));
239239
self.bccx.span_note(
240240
old_loan.span,
241-
format!("previous borrow of `{}` as mutable occurs here",
241+
format!("second borrow of `{}` as mutable occurs here",
242242
self.bccx.loan_path_to_str(new_loan.loan_path)));
243243
return false;
244244
}
@@ -253,7 +253,7 @@ impl<'a> CheckLoanCtxt<'a> {
253253
self.bccx.mut_to_str(old_loan.mutbl)));
254254
self.bccx.span_note(
255255
old_loan.span,
256-
format!("previous borrow of `{}` occurs here",
256+
format!("second borrow of `{}` occurs here",
257257
self.bccx.loan_path_to_str(new_loan.loan_path)));
258258
return false;
259259
}

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ impl Visitor<Context> for CheckLoopVisitor {
4747
}
4848
ast::ExprBreak(_) => self.require_loop("break", cx, e.span),
4949
ast::ExprAgain(_) => self.require_loop("continue", cx, e.span),
50+
ast::ExprRet(oe) => {
51+
if cx == Closure {
52+
self.tcx.sess.span_err(e.span, "`return` in a closure");
53+
}
54+
visit::walk_expr_opt(self, oe, cx);
55+
}
5056
_ => visit::walk_expr(self, e, cx)
5157
}
5258
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,17 @@ impl Visitor<()> for MarkSymbolVisitor {
158158
visit::walk_expr(self, expr, ())
159159
}
160160

161-
fn visit_path(&mut self, path: &ast::Path, id: ast::NodeId, _: ()) {
161+
fn visit_ty(&mut self, typ: &ast::Ty, _: ()) {
162+
match typ.node {
163+
ast::ty_path(_, _, ref id) => {
164+
self.lookup_and_handle_definition(id);
165+
}
166+
_ => visit::walk_ty(self, typ, ()),
167+
}
168+
}
169+
170+
fn visit_path(&mut self, _: &ast::Path, id: ast::NodeId, _: ()) {
162171
self.lookup_and_handle_definition(&id);
163-
visit::walk_path(self, path, ());
164172
}
165173

166174
fn visit_item(&mut self, _item: @ast::item, _: ()) {

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use driver::session;
1313
use driver::session::Session;
14+
use syntax::abi;
1415
use syntax::ast::{Crate, NodeId, item, item_fn};
1516
use syntax::ast_map;
1617
use syntax::attr;
@@ -45,7 +46,10 @@ impl Visitor<()> for EntryContext {
4546
}
4647

4748
pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map) {
48-
if *session.building_library {
49+
50+
// FIXME #4404 android JNI hacks
51+
if *session.building_library &&
52+
session.targ_cfg.os != abi::OsAndroid {
4953
// No need to find a main function
5054
return;
5155
}
@@ -145,6 +149,10 @@ fn configure_main(this: &mut EntryContext) {
145149
}
146150
}
147151
this.session.abort_if_errors();
152+
} else {
153+
// If we *are* building a library, then we're on android where we still might
154+
// optionally want to translate main $4404
155+
assert_eq!(this.session.targ_cfg.os, abi::OsAndroid);
148156
}
149157
}
150158
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,16 +1258,11 @@ impl Resolver {
12581258
let parent_link =
12591259
self.get_parent_link(new_parent, ident);
12601260
let def_id = local_def(item.id);
1261-
let ns = TypeNS;
1262-
let is_public =
1263-
!name_bindings.defined_in_namespace(ns) ||
1264-
name_bindings.defined_in_public_namespace(ns);
1265-
12661261
name_bindings.define_module(parent_link,
12671262
Some(def_id),
12681263
ImplModuleKind,
12691264
false,
1270-
is_public,
1265+
true,
12711266
sp);
12721267

12731268
ModuleReducedGraphParent(

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

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ use syntax::parse::token::{special_idents};
8484
use syntax::print::pprust::stmt_to_str;
8585
use syntax::{ast, ast_util, codemap, ast_map};
8686
use syntax::attr::AttrMetaMethods;
87-
use syntax::abi::{X86, X86_64, Arm, Mips, Rust, RustIntrinsic, OsWin32};
87+
use syntax::abi::{X86, X86_64, Arm, Mips, Rust, RustIntrinsic, OsWin32, OsAndroid};
8888
use syntax::visit;
8989
use syntax::visit::Visitor;
9090

@@ -130,7 +130,7 @@ pub fn push_ctxt(s: &'static str) -> _InsnCtxt {
130130
_InsnCtxt { _x: () }
131131
}
132132

133-
pub struct StatRecorder<'a> {
133+
struct StatRecorder<'a> {
134134
ccx: @mut CrateContext,
135135
name: &'a str,
136136
start: u64,
@@ -2289,7 +2289,11 @@ fn finish_register_fn(ccx: @mut CrateContext, sp: Span, sym: ~str, node_id: ast:
22892289
lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
22902290
}
22912291

2292-
if is_entry_fn(&ccx.sess, node_id) && !*ccx.sess.building_library {
2292+
// FIXME #4404 android JNI hacks
2293+
let is_entry = is_entry_fn(&ccx.sess, node_id) && (!*ccx.sess.building_library ||
2294+
(*ccx.sess.building_library &&
2295+
ccx.sess.targ_cfg.os == OsAndroid));
2296+
if is_entry {
22932297
create_entry_wrapper(ccx, sp, llfn);
22942298
}
22952299
}
@@ -2357,7 +2361,13 @@ pub fn create_entry_wrapper(ccx: @mut CrateContext,
23572361
let llfty = Type::func([ccx.int_type, Type::i8().ptr_to().ptr_to()],
23582362
&ccx.int_type);
23592363

2360-
let llfn = decl_cdecl_fn(ccx.llmod, "main", llfty);
2364+
// FIXME #4404 android JNI hacks
2365+
let main_name = if *ccx.sess.building_library {
2366+
"amain"
2367+
} else {
2368+
"main"
2369+
};
2370+
let llfn = decl_cdecl_fn(ccx.llmod, main_name, llfty);
23612371
let llbb = "top".with_c_str(|buf| {
23622372
unsafe {
23632373
llvm::LLVMAppendBasicBlockInContext(ccx.llcx, llfn, buf)
@@ -3189,13 +3199,14 @@ pub fn trans_crate(sess: session::Session,
31893199
}).to_owned_vec();
31903200

31913201
// Make sure that some other crucial symbols are not eliminated from the
3192-
// module. This includes the main function, the crate map (used for debug
3193-
// log settings and I/O), and finally the curious rust_stack_exhausted
3194-
// symbol. This symbol is required for use by the libmorestack library that
3195-
// we link in, so we must ensure that this symbol is not internalized (if
3196-
// defined in the crate).
3202+
// module. This includes the main function (main/amain elsewhere), the crate
3203+
// map (used for debug log settings and I/O), and finally the curious
3204+
// rust_stack_exhausted symbol. This symbol is required for use by the
3205+
// libmorestack library that we link in, so we must ensure that this symbol
3206+
// is not internalized (if defined in the crate).
31973207
reachable.push(ccx.crate_map_name.to_owned());
31983208
reachable.push(~"main");
3209+
reachable.push(~"amain");
31993210
reachable.push(~"rust_stack_exhausted");
32003211

32013212
return CrateTranslation {

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ use driver::session;
129129
use lib::llvm::llvm;
130130
use lib::llvm::{ModuleRef, ContextRef, ValueRef};
131131
use lib::llvm::debuginfo::*;
132+
use middle::trans::adt;
133+
use middle::trans::base;
134+
use middle::trans::build;
132135
use middle::trans::common::*;
133136
use middle::trans::machine;
134137
use middle::trans::type_of;
135138
use middle::trans::type_::Type;
136-
use middle::trans::adt;
137139
use middle::trans;
138140
use middle::ty;
139141
use middle::pat_util;
@@ -453,12 +455,29 @@ pub fn create_self_argument_metadata(bcx: @mut Block,
453455

454456
let address_operations = &[unsafe { llvm::LLVMDIBuilderCreateOpDeref(Type::i64().to_ref()) }];
455457

458+
// The self argument comes in one of two forms:
459+
// (1) For `&self`, `~self`, and `@self` it is an alloca containing a pointer to the data. That
460+
// is the `{&~@}self` pointer is contained by value in the alloca, and `type_of_self` will
461+
// be `{&~@}Self`
462+
// (2) For by-value `self`, `llptr` will not be an alloca, but a pointer to the self-value. That
463+
// is by-value `self` is always implicitly passed by reference (sic!). So we have a couple
464+
// of problems here:
465+
// (a) There is no alloca to give to `llvm.dbg.declare` and
466+
// (b) `type_of_self` is `Self`, but `llptr` is of type `*Self`
467+
// In order to solve this problem, the else branch below creates a helper alloca which
468+
// contains a copy of `llptr`. We then describe the `self` parameter by pointing
469+
// `llvm.dbg.declare` to this helper alloca and tell it that the pointer there needs to be
470+
// dereferenced once to get to the actual data (similar to non-immediate by-value args).
456471
let variable_access = if unsafe { llvm::LLVMIsAAllocaInst(llptr) } != ptr::null() {
457472
DirectVariable { alloca: llptr }
458473
} else {
459-
// This is not stable and may break with future LLVM versions. llptr should really always
460-
// be an alloca. Anything else is not supported and just works by chance.
461-
IndirectVariable { alloca: llptr, address_operations: address_operations }
474+
// Create a helper alloca that allows us to track the self-argument properly. The alloca
475+
// contains a pointer to the self-value.
476+
let ptr_type = ty::mk_mut_ptr(bcx.tcx(), type_of_self);
477+
let helper_alloca = base::alloc_ty(bcx, ptr_type, "__self");
478+
build::Store(bcx, llptr, helper_alloca);
479+
480+
IndirectVariable { alloca: helper_alloca, address_operations: address_operations }
462481
};
463482

464483
declare_local(bcx,

0 commit comments

Comments
 (0)