Skip to content

Commit 9058214

Browse files
committed
---
yaml --- r: 58218 b: refs/heads/auto c: 044abef h: refs/heads/master v: v3
1 parent 0d34bc3 commit 9058214

File tree

17 files changed

+110
-187
lines changed

17 files changed

+110
-187
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: 65ded84d204339eb9ac69b53c5e32a0128805f5f
17+
refs/heads/auto: 044abef0e56f02c36cf93fd9572813c2b27f98af
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 += --cfg debug
104+
CFG_RUSTC_FLAGS +=
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<'self, T: Owned> Unique<T> {
160+
pub impl<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<'self, T: Owned> Unique<T> {
168168
}
169169
}
170170
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) }
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) }
174174
}
175175
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) }
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) }
179179
}
180180
}
181181

branches/auto/src/libcore/cast.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ 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+
111117
/// Transforms lifetime of the second pointer to match the first.
112118
#[inline(always)]
113119
pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ 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-
231228
let freevars = time(time_passes, ~"freevar finding", ||
232229
freevars::annotate_freevars(def_map, crate));
233230

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

Lines changed: 0 additions & 150 deletions
This file was deleted.

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

Lines changed: 79 additions & 0 deletions
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 driver::session;
1112
use driver::session::Session;
1213
use metadata::csearch::{each_path, get_trait_method_def_ids};
1314
use metadata::csearch::get_method_name_and_self_ty;
@@ -793,6 +794,11 @@ pub fn Resolver(session: Session,
793794
794795
namespaces: ~[ TypeNS, ValueNS ],
795796
797+
attr_main_fn: None,
798+
main_fns: ~[],
799+
800+
start_fn: None,
801+
796802
def_map: @mut HashMap::new(),
797803
export_map2: @mut HashMap::new(),
798804
trait_map: HashMap::new(),
@@ -850,6 +856,15 @@ pub struct Resolver {
850856
// The four namespaces.
851857
namespaces: ~[Namespace],
852858
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+
853868
def_map: DefMap,
854869
export_map2: ExportMap2,
855870
trait_map: TraitMap,
@@ -870,6 +885,7 @@ pub impl Resolver {
870885
self.resolve_crate();
871886
self.session.abort_if_errors();
872887
888+
self.check_duplicate_main();
873889
self.check_for_unused_imports_if_necessary();
874890
}
875891
@@ -3528,6 +3544,40 @@ pub impl Resolver {
35283544
}
35293545

35303546
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+
35313581
self.resolve_function(OpaqueFunctionRibKind,
35323582
Some(fn_decl),
35333583
HasTypeParameters
@@ -5039,6 +5089,35 @@ pub impl Resolver {
50395089
}
50405090
}
50415091

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+
50425121
//
50435122
// Unused import checking
50445123
//

branches/auto/src/librustc/middle/typeck/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ fn check_for_entry_fn(ccx: @mut CrateCtxt) {
393393
Some(session::EntryStart) => check_start_fn_ty(ccx, id, sp),
394394
None => tcx.sess.bug(~"entry function without a type")
395395
},
396-
None => tcx.sess.bug(~"type checking without entry function")
396+
None => tcx.sess.err(~"entry function not found")
397397
}
398398
}
399399
}

branches/auto/src/librustc/rustc.rc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ pub mod middle {
100100
pub mod lang_items;
101101
pub mod privacy;
102102
pub mod moves;
103-
pub mod entry;
104103
}
105104

106105
pub mod front {

0 commit comments

Comments
 (0)