Skip to content

Commit a901bfc

Browse files
committed
---
yaml --- r: 58219 b: refs/heads/auto c: 5a65f51 h: refs/heads/master i: 58217: 0d34bc3 58215: 6a1c4b7 v: v3
1 parent 9058214 commit a901bfc

26 files changed

+380
-134
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 044abef0e56f02c36cf93fd9572813c2b27f98af
17+
refs/heads/auto: 5a65f51d666855d7685850808cc06e49c3d21c72
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ endif
101101

102102
ifdef CFG_ENABLE_DEBUG
103103
$(info cfg: enabling more debugging (CFG_ENABLE_DEBUG))
104-
CFG_RUSTC_FLAGS +=
104+
CFG_RUSTC_FLAGS += --cfg debug
105105
CFG_GCCISH_CFLAGS += -DRUST_DEBUG
106106
else
107107
CFG_GCCISH_CFLAGS += -DRUST_NDEBUG

branches/auto/doc/tutorial-ffi.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub struct Unique<T> {
157157
priv ptr: *mut T
158158
}
159159
160-
pub impl<T: Owned> Unique<T> {
160+
pub impl<'self, T: Owned> Unique<T> {
161161
fn new(value: T) -> Unique<T> {
162162
unsafe {
163163
let ptr = malloc(core::sys::size_of::<T>() as size_t) as *mut T;
@@ -168,14 +168,14 @@ pub impl<T: Owned> Unique<T> {
168168
}
169169
}
170170
171-
// the 'r lifetime results in the same semantics as `&*x` with ~T
172-
fn borrow<'r>(&'r self) -> &'r T {
173-
unsafe { cast::copy_lifetime(self, &*self.ptr) }
171+
// the 'self lifetime results in the same semantics as `&*x` with ~T
172+
fn borrow(&self) -> &'self T {
173+
unsafe { cast::transmute(self.ptr) }
174174
}
175175
176-
// the 'r lifetime results in the same semantics as `&mut *x` with ~T
177-
fn borrow_mut<'r>(&'r mut self) -> &'r mut T {
178-
unsafe { cast::copy_mut_lifetime(self, &mut *self.ptr) }
176+
// the 'self lifetime results in the same semantics as `&mut *x` with ~T
177+
fn borrow_mut(&mut self) -> &'self mut T {
178+
unsafe { cast::transmute(self.ptr) }
179179
}
180180
}
181181

branches/auto/src/libcore/cast.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,6 @@ pub unsafe fn copy_lifetime<'a,S,T>(_ptr: &'a S, ptr: &T) -> &'a T {
108108
transmute_region(ptr)
109109
}
110110

111-
/// Transforms lifetime of the second pointer to match the first.
112-
#[inline(always)]
113-
pub unsafe fn copy_mut_lifetime<'a,S,T>(_ptr: &'a mut S, ptr: &mut T) -> &'a mut T {
114-
transmute_mut_region(ptr)
115-
}
116-
117111
/// Transforms lifetime of the second pointer to match the first.
118112
#[inline(always)]
119113
pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {

branches/auto/src/libcore/unstable.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ pub mod weak_task;
3030
pub mod exchange_alloc;
3131
#[path = "unstable/intrinsics.rs"]
3232
pub mod intrinsics;
33+
#[path = "unstable/simd.rs"]
34+
pub mod simd;
3335
#[path = "unstable/extfmt.rs"]
3436
pub mod extfmt;
3537
#[path = "unstable/lang.rs"]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
//! SIMD vectors
12+
13+
#[allow(non_camel_case_types)];
14+
15+
#[simd]
16+
pub struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8);
17+
18+
#[simd]
19+
pub struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
20+
21+
#[simd]
22+
pub struct i32x4(i32, i32, i32, i32);
23+
24+
#[simd]
25+
pub struct i64x2(i64, i64);
26+
27+
#[simd]
28+
pub struct u8x16(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8);
29+
30+
#[simd]
31+
pub struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16);
32+
33+
#[simd]
34+
pub struct u32x4(u32, u32, u32, u32);
35+
36+
#[simd]
37+
pub struct u64x2(u64, u64);
38+
39+
#[simd]
40+
pub struct f32x4(f32, f32, f32, f32);
41+
42+
#[simd]
43+
pub struct f64x2(f64, f64);

branches/auto/src/librustc/driver/driver.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ pub fn compile_rest(sess: Session,
225225
time(time_passes, ~"resolution", ||
226226
middle::resolve::resolve_crate(sess, lang_items, crate));
227227

228+
time(time_passes, ~"looking for entry point",
229+
|| middle::entry::find_entry_point(sess, crate, ast_map));
230+
228231
let freevars = time(time_passes, ~"freevar finding", ||
229232
freevars::annotate_freevars(def_map, crate));
230233

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
// Copyright 2012 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+
use driver::session;
12+
use driver::session::Session;
13+
use syntax::parse::token::special_idents;
14+
use syntax::ast::{crate, node_id, item, item_fn};
15+
use syntax::codemap::span;
16+
use syntax::visit::{default_visitor, mk_vt, vt, Visitor, visit_crate, visit_item};
17+
use syntax::attr::{attrs_contains_name};
18+
use syntax::ast_map;
19+
use core::util;
20+
21+
struct EntryContext {
22+
session: Session,
23+
24+
ast_map: ast_map::map,
25+
26+
// The top-level function called 'main'
27+
main_fn: Option<(node_id, span)>,
28+
29+
// The function that has attribute named 'main'
30+
attr_main_fn: Option<(node_id, span)>,
31+
32+
// The function that has the attribute 'start' on it
33+
start_fn: Option<(node_id, span)>,
34+
35+
// The functions that one might think are 'main' but aren't, e.g.
36+
// main functions not defined at the top level. For diagnostics.
37+
non_main_fns: ~[(node_id, span)],
38+
}
39+
40+
type EntryVisitor = vt<@mut EntryContext>;
41+
42+
pub fn find_entry_point(session: Session, crate: @crate, ast_map: ast_map::map) {
43+
44+
// FIXME #4404 android JNI hacks
45+
if *session.building_library &&
46+
session.targ_cfg.os != session::os_android {
47+
// No need to find a main function
48+
return;
49+
}
50+
51+
let ctxt = @mut EntryContext {
52+
session: session,
53+
ast_map: ast_map,
54+
main_fn: None,
55+
attr_main_fn: None,
56+
start_fn: None,
57+
non_main_fns: ~[],
58+
};
59+
60+
visit_crate(crate, ctxt, mk_vt(@Visitor {
61+
visit_item: |item, ctxt, visitor| find_item(item, ctxt, visitor),
62+
.. *default_visitor()
63+
}));
64+
65+
configure_main(ctxt);
66+
}
67+
68+
fn find_item(item: @item, ctxt: @mut EntryContext, visitor: EntryVisitor) {
69+
match item.node {
70+
item_fn(*) => {
71+
if item.ident == special_idents::main {
72+
match ctxt.ast_map.find(&item.id) {
73+
Some(&ast_map::node_item(_, path)) => {
74+
if path.len() == 0 {
75+
// This is a top-level function so can be 'main'
76+
if ctxt.main_fn.is_none() {
77+
ctxt.main_fn = Some((item.id, item.span));
78+
} else {
79+
ctxt.session.span_err(
80+
item.span,
81+
~"multiple 'main' functions");
82+
}
83+
} else {
84+
// This isn't main
85+
ctxt.non_main_fns.push((item.id, item.span));
86+
}
87+
}
88+
_ => util::unreachable()
89+
}
90+
}
91+
92+
if attrs_contains_name(item.attrs, ~"main") {
93+
if ctxt.attr_main_fn.is_none() {
94+
ctxt.attr_main_fn = Some((item.id, item.span));
95+
} else {
96+
ctxt.session.span_err(
97+
item.span,
98+
~"multiple 'main' functions");
99+
}
100+
}
101+
102+
if attrs_contains_name(item.attrs, ~"start") {
103+
if ctxt.start_fn.is_none() {
104+
ctxt.start_fn = Some((item.id, item.span));
105+
} else {
106+
ctxt.session.span_err(
107+
item.span,
108+
~"multiple 'start' functions");
109+
}
110+
}
111+
}
112+
_ => ()
113+
}
114+
115+
visit_item(item, ctxt, visitor);
116+
}
117+
118+
fn configure_main(ctxt: @mut EntryContext) {
119+
let this = &mut *ctxt;
120+
if this.start_fn.is_some() {
121+
*this.session.entry_fn = this.start_fn;
122+
*this.session.entry_type = Some(session::EntryStart);
123+
} else if this.attr_main_fn.is_some() {
124+
*this.session.entry_fn = this.attr_main_fn;
125+
*this.session.entry_type = Some(session::EntryMain);
126+
} else if this.main_fn.is_some() {
127+
*this.session.entry_fn = this.main_fn;
128+
*this.session.entry_type = Some(session::EntryMain);
129+
} else {
130+
if !*this.session.building_library {
131+
// No main function
132+
this.session.err(~"main function not found");
133+
if !this.non_main_fns.is_empty() {
134+
// There were some functions named 'main' though. Try to give the user a hint.
135+
this.session.note(~"the main function must be defined at the crate level \
136+
but you have one or more functions named 'main' that are not \
137+
defined at the crate level. Either move the definition or \
138+
attach the `#[main]` attribute to override this behavior.");
139+
for this.non_main_fns.each |&(_, span)| {
140+
this.session.span_note(span, ~"here is a function named 'main'");
141+
}
142+
}
143+
this.session.abort_if_errors();
144+
} else {
145+
// If we *are* building a library, then we're on android where we still might
146+
// optionally want to translate main $4404
147+
assert!(this.session.targ_cfg.os == session::os_android);
148+
}
149+
}
150+
}

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

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use driver::session;
1211
use driver::session::Session;
1312
use metadata::csearch::{each_path, get_trait_method_def_ids};
1413
use metadata::csearch::get_method_name_and_self_ty;
@@ -794,11 +793,6 @@ pub fn Resolver(session: Session,
794793
795794
namespaces: ~[ TypeNS, ValueNS ],
796795
797-
attr_main_fn: None,
798-
main_fns: ~[],
799-
800-
start_fn: None,
801-
802796
def_map: @mut HashMap::new(),
803797
export_map2: @mut HashMap::new(),
804798
trait_map: HashMap::new(),
@@ -856,15 +850,6 @@ pub struct Resolver {
856850
// The four namespaces.
857851
namespaces: ~[Namespace],
858852
859-
// The function that has attribute named 'main'
860-
attr_main_fn: Option<(node_id, span)>,
861-
862-
// The functions that could be main functions
863-
main_fns: ~[Option<(node_id, span)>],
864-
865-
// The function that has the attribute 'start' on it
866-
start_fn: Option<(node_id, span)>,
867-
868853
def_map: DefMap,
869854
export_map2: ExportMap2,
870855
trait_map: TraitMap,
@@ -885,7 +870,6 @@ pub impl Resolver {
885870
self.resolve_crate();
886871
self.session.abort_if_errors();
887872
888-
self.check_duplicate_main();
889873
self.check_for_unused_imports_if_necessary();
890874
}
891875
@@ -3544,40 +3528,6 @@ pub impl Resolver {
35443528
}
35453529

35463530
item_fn(ref fn_decl, _, _, ref generics, ref block) => {
3547-
// If this is the main function, we must record it in the
3548-
// session.
3549-
3550-
// FIXME #4404 android JNI hacks
3551-
if !*self.session.building_library ||
3552-
self.session.targ_cfg.os == session::os_android {
3553-
3554-
if self.attr_main_fn.is_none() &&
3555-
item.ident == special_idents::main {
3556-
3557-
self.main_fns.push(Some((item.id, item.span)));
3558-
}
3559-
3560-
if attrs_contains_name(item.attrs, ~"main") {
3561-
if self.attr_main_fn.is_none() {
3562-
self.attr_main_fn = Some((item.id, item.span));
3563-
} else {
3564-
self.session.span_err(
3565-
item.span,
3566-
~"multiple 'main' functions");
3567-
}
3568-
}
3569-
3570-
if attrs_contains_name(item.attrs, ~"start") {
3571-
if self.start_fn.is_none() {
3572-
self.start_fn = Some((item.id, item.span));
3573-
} else {
3574-
self.session.span_err(
3575-
item.span,
3576-
~"multiple 'start' functions");
3577-
}
3578-
}
3579-
}
3580-
35813531
self.resolve_function(OpaqueFunctionRibKind,
35823532
Some(fn_decl),
35833533
HasTypeParameters
@@ -5089,35 +5039,6 @@ pub impl Resolver {
50895039
}
50905040
}
50915041

5092-
//
5093-
// main function checking
5094-
//
5095-
// be sure that there is only one main function
5096-
//
5097-
fn check_duplicate_main(@mut self) {
5098-
let this = &mut *self;
5099-
if this.attr_main_fn.is_none() && this.start_fn.is_none() {
5100-
if this.main_fns.len() >= 1u {
5101-
let mut i = 1u;
5102-
while i < this.main_fns.len() {
5103-
let (_, dup_main_span) = this.main_fns[i].unwrap();
5104-
this.session.span_err(
5105-
dup_main_span,
5106-
~"multiple 'main' functions");
5107-
i += 1;
5108-
}
5109-
*this.session.entry_fn = this.main_fns[0];
5110-
*this.session.entry_type = Some(session::EntryMain);
5111-
}
5112-
} else if !this.start_fn.is_none() {
5113-
*this.session.entry_fn = this.start_fn;
5114-
*this.session.entry_type = Some(session::EntryStart);
5115-
} else {
5116-
*this.session.entry_fn = this.attr_main_fn;
5117-
*this.session.entry_type = Some(session::EntryMain);
5118-
}
5119-
}
5120-
51215042
//
51225043
// Unused import checking
51235044
//

0 commit comments

Comments
 (0)