Skip to content

Commit 4207e12

Browse files
committed
---
yaml --- r: 63542 b: refs/heads/snap-stage3 c: f886520 h: refs/heads/master v: v3
1 parent 427aadd commit 4207e12

File tree

22 files changed

+189
-156
lines changed

22 files changed

+189
-156
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 116897fa6cba39ba43180debf0f9136be6a44205
4+
refs/heads/snap-stage3: f886520d2468507cc80ceb40a26594265052603e
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/librustc/back/link.rs

Lines changed: 67 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,12 @@ pub mod jit {
129129

130130
debug!("linking: %s", path);
131131

132-
let _: () = str::as_c_str(
133-
path,
134-
|buf_t| {
135-
if !llvm::LLVMRustLoadCrate(manager, buf_t) {
136-
llvm_err(sess, ~"Could not link");
137-
}
138-
debug!("linked: %s", path);
139-
});
132+
do str::as_c_str(path) |buf_t| {
133+
if !llvm::LLVMRustLoadCrate(manager, buf_t) {
134+
llvm_err(sess, ~"Could not link");
135+
}
136+
debug!("linked: %s", path);
137+
}
140138
}
141139

142140
// We custom-build a JIT execution engine via some rust wrappers
@@ -203,11 +201,10 @@ pub mod write {
203201
use core::str;
204202

205203
pub fn is_object_or_assembly_or_exe(ot: output_type) -> bool {
206-
if ot == output_type_assembly || ot == output_type_object ||
207-
ot == output_type_exe {
208-
return true;
204+
match ot {
205+
output_type_assembly | output_type_object | output_type_exe => true,
206+
_ => false
209207
}
210-
return false;
211208
}
212209

213210
pub fn run_passes(sess: Session,
@@ -290,11 +287,11 @@ pub mod write {
290287
session::Aggressive => LLVMOptAggressive
291288
};
292289

293-
let FileType;
294-
if output_type == output_type_object ||
295-
output_type == output_type_exe {
296-
FileType = lib::llvm::ObjectFile;
297-
} else { FileType = lib::llvm::AssemblyFile; }
290+
let FileType = match output_type {
291+
output_type_object | output_type_exe => lib::llvm::ObjectFile,
292+
_ => lib::llvm::AssemblyFile
293+
};
294+
298295
// Write optimized bitcode if --save-temps was on.
299296

300297
if opts.save_temps {
@@ -384,11 +381,11 @@ pub mod write {
384381
(--android-cross-path)")
385382
}
386383
};
387-
let mut cc_args = ~[];
388-
cc_args.push(~"-c");
389-
cc_args.push(~"-o");
390-
cc_args.push(object.to_str());
391-
cc_args.push(assembly.to_str());
384+
385+
let cc_args = ~[
386+
~"-c",
387+
~"-o", object.to_str(),
388+
assembly.to_str()];
392389

393390
let prog = run::process_output(cc_prog, cc_args);
394391

@@ -474,19 +471,19 @@ pub fn build_link_meta(sess: Session,
474471
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
475472
attr::require_unique_names(sess.diagnostic(), linkage_metas);
476473
for linkage_metas.each |meta| {
477-
if "name" == attr::get_meta_item_name(*meta) {
478-
match attr::get_meta_item_value_str(*meta) {
479-
// Changing attr would avoid the need for the copy
480-
// here
481-
Some(v) => { name = Some(v); }
482-
None => cmh_items.push(*meta)
483-
}
484-
} else if "vers" == attr::get_meta_item_name(*meta) {
485-
match attr::get_meta_item_value_str(*meta) {
486-
Some(v) => { vers = Some(v); }
487-
None => cmh_items.push(*meta)
488-
}
489-
} else { cmh_items.push(*meta); }
474+
match attr::get_meta_item_value_str(*meta) {
475+
Some(value) => {
476+
let item_name : &str = attr::get_meta_item_name(*meta);
477+
match item_name {
478+
// Changing attr would avoid the need for the copy
479+
// here
480+
"name" => name = Some(value),
481+
"vers" => vers = Some(value),
482+
_ => cmh_items.push(*meta)
483+
}
484+
},
485+
None => cmh_items.push(*meta)
486+
}
490487
}
491488

492489
ProvidedMetas {
@@ -548,32 +545,32 @@ pub fn build_link_meta(sess: Session,
548545
}
549546

550547
fn crate_meta_name(sess: Session, output: &Path, opt_name: Option<@str>)
551-
-> @str {
552-
return match opt_name {
553-
Some(v) => v,
554-
None => {
548+
-> @str {
549+
match opt_name {
550+
Some(v) => v,
551+
None => {
555552
// to_managed could go away if there was a version of
556553
// filestem that returned an @str
557554
let name = session::expect(sess,
558-
output.filestem(),
559-
|| fmt!("output file name `%s` doesn't\
560-
appear to have a stem",
561-
output.to_str())).to_managed();
555+
output.filestem(),
556+
|| fmt!("output file name `%s` doesn't\
557+
appear to have a stem",
558+
output.to_str())).to_managed();
562559
warn_missing(sess, "name", name);
563560
name
564-
}
565-
};
561+
}
562+
}
566563
}
567564

568565
fn crate_meta_vers(sess: Session, opt_vers: Option<@str>) -> @str {
569-
return match opt_vers {
570-
Some(v) => v,
571-
None => {
566+
match opt_vers {
567+
Some(v) => v,
568+
None => {
572569
let vers = @"0.0";
573570
warn_missing(sess, "vers", vers);
574571
vers
575-
}
576-
};
572+
}
573+
}
577574
}
578575

579576
let ProvidedMetas {
@@ -699,10 +696,10 @@ pub fn exported_name(sess: Session,
699696
path: path,
700697
hash: &str,
701698
vers: &str) -> ~str {
702-
return mangle(sess,
703-
vec::append_one(
704-
vec::append_one(path, path_name(sess.ident_of(hash))),
705-
path_name(sess.ident_of(vers))));
699+
mangle(sess,
700+
vec::append_one(
701+
vec::append_one(path, path_name(sess.ident_of(hash))),
702+
path_name(sess.ident_of(vers))))
706703
}
707704

708705
pub fn mangle_exported_name(ccx: &mut CrateContext,
@@ -739,16 +736,16 @@ pub fn mangle_internal_name_by_type_and_seq(ccx: &mut CrateContext,
739736
pub fn mangle_internal_name_by_path_and_seq(ccx: &mut CrateContext,
740737
path: path,
741738
flav: &str) -> ~str {
742-
return mangle(ccx.sess,
743-
vec::append_one(path, path_name((ccx.names)(flav))));
739+
mangle(ccx.sess,
740+
vec::append_one(path, path_name((ccx.names)(flav))))
744741
}
745742

746743
pub fn mangle_internal_name_by_path(ccx: &mut CrateContext, path: path) -> ~str {
747-
return mangle(ccx.sess, path);
744+
mangle(ccx.sess, path)
748745
}
749746

750747
pub fn mangle_internal_name_by_seq(ccx: &mut CrateContext, flav: &str) -> ~str {
751-
return fmt!("%s_%u", flav, (ccx.names)(flav).name);
748+
fmt!("%s_%u", flav, (ccx.names)(flav).name)
752749
}
753750

754751

@@ -776,8 +773,8 @@ pub fn link_binary(sess: Session,
776773
// so we add a condition to make it use gcc.
777774
let cc_prog: ~str = match sess.opts.linker {
778775
Some(ref linker) => copy *linker,
779-
None => {
780-
if sess.targ_cfg.os == session::os_android {
776+
None => match sess.targ_cfg.os {
777+
session::os_android =>
781778
match &sess.opts.android_cross_path {
782779
&Some(ref path) => {
783780
fmt!("%s/bin/arm-linux-androideabi-gcc", *path)
@@ -786,12 +783,9 @@ pub fn link_binary(sess: Session,
786783
sess.fatal("need Android NDK path for linking \
787784
(--android-cross-path)")
788785
}
789-
}
790-
} else if sess.targ_cfg.os == session::os_win32 {
791-
~"gcc"
792-
} else {
793-
~"cc"
794-
}
786+
},
787+
session::os_win32 => ~"gcc",
788+
_ => ~"cc"
795789
}
796790
};
797791
// The invocations of cc share some flags across platforms
@@ -866,17 +860,14 @@ pub fn link_args(sess: Session,
866860

867861
let mut args = vec::append(~[stage], sess.targ_cfg.target_strs.cc_args);
868862

869-
args.push(~"-o");
870-
args.push(output.to_str());
871-
args.push(obj_filename.to_str());
863+
args.push_all([
864+
~"-o", output.to_str(),
865+
obj_filename.to_str()]);
872866

873-
let lib_cmd;
874-
let os = sess.targ_cfg.os;
875-
if os == session::os_macos {
876-
lib_cmd = ~"-dynamiclib";
877-
} else {
878-
lib_cmd = ~"-shared";
879-
}
867+
let lib_cmd = match sess.targ_cfg.os {
868+
session::os_macos => ~"-dynamiclib",
869+
_ => ~"-shared"
870+
};
880871

881872
// # Crate linking
882873

branches/snap-stage3/src/librustc/back/rpath.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -21,10 +21,7 @@ use core::util;
2121
use core::vec;
2222

2323
fn not_win32(os: session::os) -> bool {
24-
match os {
25-
session::os_win32 => false,
26-
_ => true
27-
}
24+
os != session::os_win32
2825
}
2926

3027
pub fn get_rpath_flags(sess: session::Session, out_filename: &Path)
@@ -122,7 +119,7 @@ pub fn get_rpath_relative_to_output(os: session::os,
122119

123120
// Mac doesn't appear to support $ORIGIN
124121
let prefix = match os {
125-
session::os_android |session::os_linux | session::os_freebsd
122+
session::os_android | session::os_linux | session::os_freebsd
126123
=> "$ORIGIN",
127124
session::os_macos => "@executable_path",
128125
session::os_win32 => util::unreachable()
@@ -159,10 +156,10 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
159156

160157
path.push_all(vec::slice(split2, start_idx, len2 - 1));
161158

162-
if !path.is_empty() {
163-
return Path("").push_many(path);
159+
return if !path.is_empty() {
160+
Path("").push_many(path)
164161
} else {
165-
return Path(".");
162+
Path(".")
166163
}
167164
}
168165

branches/snap-stage3/src/librustc/metadata/decoder.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,10 @@ enum Family {
100100
Const, // c
101101
Fn, // f
102102
UnsafeFn, // u
103+
PureFn, // p
103104
StaticMethod, // F
104105
UnsafeStaticMethod, // U
106+
PureStaticMethod, // P
105107
ForeignFn, // e
106108
Type, // y
107109
ForeignType, // T
@@ -123,8 +125,10 @@ fn item_family(item: ebml::Doc) -> Family {
123125
'c' => Const,
124126
'f' => Fn,
125127
'u' => UnsafeFn,
128+
'p' => PureFn,
126129
'F' => StaticMethod,
127130
'U' => UnsafeStaticMethod,
131+
'P' => PureStaticMethod,
128132
'e' => ForeignFn,
129133
'y' => Type,
130134
'T' => ForeignType,
@@ -321,6 +325,7 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
321325
Struct => dl_def(ast::def_struct(did)),
322326
UnsafeFn => dl_def(ast::def_fn(did, ast::unsafe_fn)),
323327
Fn => dl_def(ast::def_fn(did, ast::impure_fn)),
328+
PureFn => dl_def(ast::def_fn(did, ast::pure_fn)),
324329
ForeignFn => dl_def(ast::def_fn(did, ast::extern_fn)),
325330
UnsafeStaticMethod => {
326331
let trait_did_opt = translated_parent_item_opt(cnum, item);
@@ -330,6 +335,10 @@ fn item_to_def_like(item: ebml::Doc, did: ast::def_id, cnum: ast::crate_num)
330335
let trait_did_opt = translated_parent_item_opt(cnum, item);
331336
dl_def(ast::def_static_method(did, trait_did_opt, ast::impure_fn))
332337
}
338+
PureStaticMethod => {
339+
let trait_did_opt = translated_parent_item_opt(cnum, item);
340+
dl_def(ast::def_static_method(did, trait_did_opt, ast::pure_fn))
341+
}
333342
Type | ForeignType => dl_def(ast::def_ty(did)),
334343
Mod => dl_def(ast::def_mod(did)),
335344
ForeignMod => dl_def(ast::def_foreign_mod(did)),
@@ -813,11 +822,12 @@ pub fn get_static_methods_if_impl(intr: @ident_interner,
813822
let impl_method_doc = lookup_item(impl_method_id.node, cdata.data);
814823
let family = item_family(impl_method_doc);
815824
match family {
816-
StaticMethod | UnsafeStaticMethod => {
825+
StaticMethod | UnsafeStaticMethod | PureStaticMethod => {
817826
let purity;
818827
match item_family(impl_method_doc) {
819828
StaticMethod => purity = ast::impure_fn,
820829
UnsafeStaticMethod => purity = ast::unsafe_fn,
830+
PureStaticMethod => purity = ast::pure_fn,
821831
_ => fail!()
822832
}
823833

@@ -924,8 +934,10 @@ fn item_family_to_str(fam: Family) -> ~str {
924934
Const => ~"const",
925935
Fn => ~"fn",
926936
UnsafeFn => ~"unsafe fn",
937+
PureFn => ~"pure fn",
927938
StaticMethod => ~"static method",
928939
UnsafeStaticMethod => ~"unsafe static method",
940+
PureStaticMethod => ~"pure static method",
929941
ForeignFn => ~"foreign fn",
930942
Type => ~"type",
931943
ForeignType => ~"foreign type",

branches/snap-stage3/src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ fn encode_info_for_method(ecx: &EncodeContext,
753753
fn purity_fn_family(p: purity) -> char {
754754
match p {
755755
unsafe_fn => 'u',
756+
pure_fn => 'p',
756757
impure_fn => 'f',
757758
extern_fn => 'e'
758759
}
@@ -761,6 +762,7 @@ fn purity_fn_family(p: purity) -> char {
761762
fn purity_static_method_family(p: purity) -> char {
762763
match p {
763764
unsafe_fn => 'U',
765+
pure_fn => 'P',
764766
impure_fn => 'F',
765767
_ => fail!("extern fn can't be static")
766768
}

branches/snap-stage3/src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,10 @@ fn parse_hex(st: &mut PState) -> uint {
439439
fn parse_purity(c: char) -> purity {
440440
match c {
441441
'u' => unsafe_fn,
442+
'p' => pure_fn,
442443
'i' => impure_fn,
443444
'c' => extern_fn,
444-
_ => fail!("parse_purity: bad purity %c", c)
445+
_ => fail!("parse_purity: bad purity")
445446
}
446447
}
447448

branches/snap-stage3/src/librustc/metadata/tyencode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ fn enc_sigil(w: @io::Writer, sigil: Sigil) {
347347

348348
fn enc_purity(w: @io::Writer, p: purity) {
349349
match p {
350+
pure_fn => w.write_char('p'),
350351
impure_fn => w.write_char('i'),
351352
unsafe_fn => w.write_char('u'),
352353
extern_fn => w.write_char('c')

0 commit comments

Comments
 (0)