From 0224eb3d3273519ed82404b711f8cb0bbab05c95 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 30 Mar 2013 17:19:39 -0400 Subject: [PATCH 01/19] vim: assert and pure keywords were removed --- src/etc/vim/syntax/rust.vim | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index f811fbf585542..a5697a91505be 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -10,11 +10,10 @@ elseif exists("b:current_syntax") finish endif -syn match rustAssert "\(); +syn match rustFuncCall "\w\(\w\)*("he=e-1,me=e-1 +syn match rustFuncCall "\w\(\w\)*::<"he=e-3,me=e-3 " foo::(); syn match rustMacro '\w\(\w\)*!' syn match rustMacro '#\w\(\w\)*' @@ -126,7 +125,6 @@ hi def link rustBoolean Boolean hi def link rustConstant Constant hi def link rustSelf Constant hi def link rustFloat Float -hi def link rustAssert Keyword hi def link rustKeyword Keyword hi def link rustIdentifier Identifier hi def link rustModPath Include @@ -140,7 +138,6 @@ hi def link rustStorage StorageClass hi def link rustLifetime Special " Other Suggestions: -" hi rustAssert ctermfg=yellow " hi rustMacro ctermfg=magenta syn sync minlines=200 From 7142cdef1e083c628d787abe5b5eaabe52491197 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 30 Mar 2013 17:27:12 -0400 Subject: [PATCH 02/19] vim: highlight ref + static as storage specifiers lifetimes and globals are now the only two places static is used, and 'static isn't matched by this --- src/etc/vim/syntax/rust.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index a5697a91505be..9de051d7fa4ec 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -14,12 +14,12 @@ syn keyword rustKeyword as break syn keyword rustKeyword copy do drop else extern syn keyword rustKeyword for if impl let log syn keyword rustKeyword loop match mod once priv pub -syn keyword rustKeyword ref return static +syn keyword rustKeyword return syn keyword rustKeyword unsafe use while " FIXME: Scoped impl's name is also fallen in this category syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite -syn keyword rustStorage const mut +syn keyword rustStorage const mut ref static syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained From b0f66c4732e28f2409e8f2fe3afa1e564cde7b30 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 30 Mar 2013 17:31:54 -0400 Subject: [PATCH 03/19] vim: mark Todo as contained and rm unsafe from it It's nice to make unsafe stand out, but this way isn't correct because it highlights it in comments. --- src/etc/vim/syntax/rust.vim | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 9de051d7fa4ec..04f5d1f1234b3 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -109,8 +109,7 @@ syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8 syn region rustComment start="/\*" end="\*/" contains=rustComment,rustTodo syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend - -syn keyword rustTodo TODO FIXME XXX NB unsafe +syn keyword rustTodo contained TODO FIXME XXX NB hi def link rustHexNumber rustNumber hi def link rustBinNumber rustNumber From 6442b1c0e7812cc4a7651dca9ac8df2a70326c79 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 30 Mar 2013 17:39:33 -0400 Subject: [PATCH 04/19] vim: separate the conditional keywords --- src/etc/vim/syntax/rust.vim | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 04f5d1f1234b3..52e8fa69e72ba 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -10,10 +10,13 @@ elseif exists("b:current_syntax") finish endif +syn keyword rustConditional match if else + syn keyword rustKeyword as break -syn keyword rustKeyword copy do drop else extern syn keyword rustKeyword for if impl let log -syn keyword rustKeyword loop match mod once priv pub +syn keyword rustKeyword copy do drop extern +syn keyword rustKeyword for impl let log +syn keyword rustKeyword loop mod once priv pub syn keyword rustKeyword return syn keyword rustKeyword unsafe use while " FIXME: Scoped impl's name is also fallen in this category @@ -125,6 +128,7 @@ hi def link rustConstant Constant hi def link rustSelf Constant hi def link rustFloat Float hi def link rustKeyword Keyword +hi def link rustConditional Conditional hi def link rustIdentifier Identifier hi def link rustModPath Include hi def link rustFuncName Function From 47011e3b710e9ef43a753defc467fefe5dcfd9f3 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 30 Mar 2013 17:51:19 -0400 Subject: [PATCH 05/19] vim: use Operator group for 'as' --- src/etc/vim/syntax/rust.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/etc/vim/syntax/rust.vim b/src/etc/vim/syntax/rust.vim index 52e8fa69e72ba..87f4059716b35 100644 --- a/src/etc/vim/syntax/rust.vim +++ b/src/etc/vim/syntax/rust.vim @@ -11,8 +11,9 @@ elseif exists("b:current_syntax") endif syn keyword rustConditional match if else +syn keyword rustOperator as -syn keyword rustKeyword as break +syn keyword rustKeyword break copy do drop extern syn keyword rustKeyword for if impl let log syn keyword rustKeyword copy do drop extern syn keyword rustKeyword for impl let log @@ -127,6 +128,7 @@ hi def link rustBoolean Boolean hi def link rustConstant Constant hi def link rustSelf Constant hi def link rustFloat Float +hi def link rustOperator Operator hi def link rustKeyword Keyword hi def link rustConditional Conditional hi def link rustIdentifier Identifier From 258a36738e6dcba1b01609e026862aa9750ccdbd Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sat, 30 Mar 2013 16:15:46 -0400 Subject: [PATCH 06/19] move dlist from core -> std Closes #3549 --- src/libcore/core.rc | 1 - src/{libcore => libstd}/dlist.rs | 14 ++++---------- src/libstd/serialize.rs | 2 +- src/libstd/std.rc | 1 + 4 files changed, 6 insertions(+), 12 deletions(-) rename src/{libcore => libstd}/dlist.rs (99%) diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 4d91e8f2993db..443f2538fa934 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -189,7 +189,6 @@ pub mod container; pub mod option; pub mod result; pub mod either; -pub mod dlist; pub mod hashmap; pub mod cell; pub mod trie; diff --git a/src/libcore/dlist.rs b/src/libstd/dlist.rs similarity index 99% rename from src/libcore/dlist.rs rename to src/libstd/dlist.rs index ee7c1651514fe..e7701974097b3 100644 --- a/src/libcore/dlist.rs +++ b/src/libstd/dlist.rs @@ -18,12 +18,8 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate. */ -use iter; -use iter::BaseIter; -use kinds::Copy; -use managed; -use option::{None, Option, Some}; -use vec; +use core::prelude::*; +use core::managed; pub type DListLink = Option<@mut DListNode>; @@ -540,10 +536,8 @@ impl BaseIter for @mut DList { #[cfg(test)] mod tests { - use dlist::{DList, concat, from_vec, new_dlist_node}; - use iter; - use option::{None, Some}; - use vec; + use super::*; + use core::prelude::*; #[test] pub fn test_dlist_concat() { diff --git a/src/libstd/serialize.rs b/src/libstd/serialize.rs index 72c81d6d6b40c..ddc84e07a3584 100644 --- a/src/libstd/serialize.rs +++ b/src/libstd/serialize.rs @@ -17,10 +17,10 @@ Core encoding and decoding interfaces. #[forbid(non_camel_case_types)]; use core::prelude::*; -use core::dlist::DList; use core::hashmap::linear::{LinearMap, LinearSet}; use core::trie::{TrieMap, TrieSet}; use deque::Deque; +use dlist::DList; use treemap::{TreeMap, TreeSet}; pub trait Encoder { diff --git a/src/libstd/std.rc b/src/libstd/std.rc index b28e2f0ab6df1..89bdc750c2277 100644 --- a/src/libstd/std.rc +++ b/src/libstd/std.rc @@ -75,6 +75,7 @@ pub mod priority_queue; pub mod rope; pub mod smallintmap; pub mod sort; +pub mod dlist; pub mod treemap; // And ... other stuff From 02700e0e8d77ce7cd0e606088cdc17b293a00fd6 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sat, 30 Mar 2013 19:28:50 -0700 Subject: [PATCH 07/19] libsyntax: Update abi constants. Fixes #5423. --- src/libsyntax/abi.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libsyntax/abi.rs b/src/libsyntax/abi.rs index 076c09e446d44..37fed113382a2 100644 --- a/src/libsyntax/abi.rs +++ b/src/libsyntax/abi.rs @@ -40,11 +40,8 @@ pub enum Architecture { Mips } -// FIXME(#5423) After a snapshot, we can change these constants: -// const IntelBits: u32 = (1 << (X86 as uint)) | (1 << X86_64 as uint)); -// const ArmBits: u32 = (1 << (Arm as uint)); -static IntelBits: u32 = 1 | 2; -static ArmBits: u32 = 4; +static IntelBits: u32 = (1 << (X86 as uint)) | (1 << (X86_64 as uint)); +static ArmBits: u32 = (1 << (Arm as uint)); struct AbiData { abi: Abi, From eadd358b2a35a64ed91565ce436469089aa9e718 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sat, 30 Mar 2013 19:59:21 -0700 Subject: [PATCH 08/19] Correct type signature for start lang item. --- src/libcore/rt/mod.rs | 20 ++++++++++++++++++++ src/libcore/unstable/lang.rs | 26 ++++++++++++++++++++++++++ src/librustc/middle/trans/base.rs | 2 +- 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/libcore/rt/mod.rs b/src/libcore/rt/mod.rs index a7b3fb1355c70..0f2a6cd7ef9ef 100644 --- a/src/libcore/rt/mod.rs +++ b/src/libcore/rt/mod.rs @@ -48,6 +48,7 @@ mod context; mod thread; pub mod env; +#[cfg(stage0)] pub fn start(main: *u8, _argc: int, _argv: *c_char, _crate_map: *u8) -> int { use self::sched::{Scheduler, Task}; use self::uvio::UvEventLoop; @@ -67,3 +68,22 @@ pub fn start(main: *u8, _argc: int, _argv: *c_char, _crate_map: *u8) -> int { } } +#[cfg(not(stage0))] +pub fn start(main: *u8, _argc: int, _argv: **c_char, _crate_map: *u8) -> int { + use self::sched::{Scheduler, Task}; + use self::uvio::UvEventLoop; + + let loop_ = ~UvEventLoop::new(); + let mut sched = ~Scheduler::new(loop_); + let main_task = ~do Task::new(&mut sched.stack_pool) { + // XXX: Can't call a C function pointer from Rust yet + unsafe { rust_call_nullary_fn(main) }; + }; + sched.task_queue.push_back(main_task); + sched.run(); + return 0; + + extern { + fn rust_call_nullary_fn(f: *u8); + } +} diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index ff96029bc0e31..3bb723abae6f7 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -127,6 +127,7 @@ pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str { } #[lang="start"] +#[cfg(stage0)] pub fn start(main: *u8, argc: int, argv: *c_char, crate_map: *u8) -> int { use libc::getenv; @@ -150,6 +151,31 @@ pub fn start(main: *u8, argc: int, argv: *c_char, } } +#[lang="start"] +#[cfg(not(stage0))] +pub fn start(main: *u8, argc: int, argv: **c_char, + crate_map: *u8) -> int { + use libc::getenv; + use rt::start; + + unsafe { + let use_new_rt = do str::as_c_str("RUST_NEWRT") |s| { + getenv(s).is_null() + }; + if use_new_rt { + return rust_start(main as *c_void, argc as c_int, argv, + crate_map as *c_void) as int; + } else { + return start(main, argc, argv, crate_map); + } + } + + extern { + fn rust_start(main: *c_void, argc: c_int, argv: **c_char, + crate_map: *c_void) -> c_int; + } +} + // Local Variables: // mode: rust; // fill-column: 78; diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index 0947dfa93fee2..15238f168944d 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -2247,7 +2247,7 @@ pub fn create_main_wrapper(ccx: @CrateContext, fn main_name() -> ~str { return ~"WinMain@16"; } #[cfg(unix)] fn main_name() -> ~str { return ~"main"; } - let llfty = T_fn(~[ccx.int_type, T_ptr(T_i8())], ccx.int_type); + let llfty = T_fn(~[ccx.int_type, T_ptr(T_ptr(T_i8()))], ccx.int_type); // FIXME #4404 android JNI hacks let llfn = if *ccx.sess.building_library { From 74d20b46c5aac5c7f058ae33aa5c59fd03dfa88b Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sat, 30 Mar 2013 20:00:19 -0700 Subject: [PATCH 09/19] Rename confusing var, use_new_rt -> use_old_rt. --- src/libcore/unstable/lang.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/unstable/lang.rs b/src/libcore/unstable/lang.rs index 3bb723abae6f7..dad990c0f97cf 100644 --- a/src/libcore/unstable/lang.rs +++ b/src/libcore/unstable/lang.rs @@ -134,10 +134,10 @@ pub fn start(main: *u8, argc: int, argv: *c_char, use rt::start; unsafe { - let use_new_rt = do str::as_c_str("RUST_NEWRT") |s| { + let use_old_rt = do str::as_c_str("RUST_NEWRT") |s| { getenv(s).is_null() }; - if use_new_rt { + if use_old_rt { return rust_start(main as *c_void, argc as c_int, argv, crate_map as *c_void) as int; } else { @@ -159,10 +159,10 @@ pub fn start(main: *u8, argc: int, argv: **c_char, use rt::start; unsafe { - let use_new_rt = do str::as_c_str("RUST_NEWRT") |s| { + let use_old_rt = do str::as_c_str("RUST_NEWRT") |s| { getenv(s).is_null() }; - if use_new_rt { + if use_old_rt { return rust_start(main as *c_void, argc as c_int, argv, crate_map as *c_void) as int; } else { From df66e8d4a197443c214e918a858208ecc38e9f1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20L=C3=B6bel?= Date: Fri, 29 Mar 2013 00:37:12 +0100 Subject: [PATCH 10/19] Fix underflow in char_range_at_reverse Added char_range_at_reverse underflow test --- src/libcore/str.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/libcore/str.rs b/src/libcore/str.rs index c54a1048c4603..67fd37996cda0 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1865,8 +1865,10 @@ pub struct CharRange { * Given a byte position and a str, return the previous char and its position * * This function can be used to iterate over a unicode string in reverse. + * + * returns 0 for next index if called on start index 0 */ -fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { +pub fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { let mut prev = start; // while there is a previous byte == 10...... @@ -1875,7 +1877,12 @@ fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { } // now refer to the initial byte of previous char - prev -= 1u; + if prev > 0u { + prev -= 1u; + } else { + prev = 0u; + } + let ch = char_at(ss, prev); return CharRange {ch:ch, next:prev}; @@ -3761,4 +3768,10 @@ mod tests { "12345555".cmp(& &"123456") == Less; "22".cmp(& &"1234") == Greater; } + + #[test] + fn test_char_range_at_reverse_underflow() { + assert!(char_range_at_reverse("abc", 0).next == 0); + } + } From 4c58903454f5409c4b0cb2060ce869021dbf46c2 Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sun, 31 Mar 2013 14:37:04 -0700 Subject: [PATCH 11/19] Update RELEASES.txt Fix typo and add fixed length vec changes. --- RELEASES.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/RELEASES.txt b/RELEASES.txt index bbe53e8d13fc0..19ba7d3466dc2 100644 --- a/RELEASES.txt +++ b/RELEASES.txt @@ -30,7 +30,7 @@ Version 0.6 (April 2013) `@mut T`, `core::mut` or `core::cell` * `extern mod { ... }` is no longer valid syntax for foreign function modules. Use extern blocks: `extern { ... }` - * Newtype enums removed. Used tuple-structs. + * Newtype enums removed. Use tuple-structs. * Trait implementations no longer support visibility modifiers * Pattern matching over vectors improved and expanded * `const` renamed to `static` to correspond to lifetime name, @@ -40,6 +40,10 @@ Version 0.6 (April 2013) `#[deriving(Clone)]` * Casts to traits must use a pointer sigil, e.g. `@foo as @Bar` instead of `foo as Bar`. + * Fixed length vector types are now written as `[int, .. 3]` + instead of `[int * 3]`. + * Fixed length vector types can express the length as a constant + expression. (ex: `[int, .. GL_BUFFER_SIZE - 2]`) * Semantic changes * Types with owned pointers or custom destructors move by default, From c0be7df5de2d5b5137f66743a428d1843b98ba9b Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 31 Mar 2013 16:22:05 -0400 Subject: [PATCH 12/19] mark the assembly object stacks as non-executable Closes #5643 This also removes the need to pass noexecstack to gcc, but that wasn't actually working anymore. --- mk/platform.mk | 8 +++----- src/rt/arch/arm/_context.S | 13 +++++++++---- src/rt/arch/arm/ccall.S | 6 +++++- src/rt/arch/arm/morestack.S | 5 +++++ src/rt/arch/arm/record_sp.S | 11 ++++++++--- src/rt/arch/i386/_context.S | 5 +++++ src/rt/arch/i386/ccall.S | 5 +++++ src/rt/arch/i386/morestack.S | 11 ++++++++--- src/rt/arch/i386/record_sp.S | 4 ++++ src/rt/arch/mips/_context.S | 5 +++++ src/rt/arch/mips/ccall.S | 5 +++++ src/rt/arch/mips/record_sp.S | 5 +++++ src/rt/arch/x86_64/_context.S | 15 ++++++++++----- src/rt/arch/x86_64/ccall.S | 7 ++++++- src/rt/arch/x86_64/morestack.S | 9 +++++++-- src/rt/arch/x86_64/record_sp.S | 4 ++++ 16 files changed, 94 insertions(+), 24 deletions(-) diff --git a/mk/platform.mk b/mk/platform.mk index 33dfac4007ae1..16b5ba452f4c9 100644 --- a/mk/platform.mk +++ b/mk/platform.mk @@ -61,8 +61,6 @@ ifdef CFG_VALGRIND endif ifneq ($(findstring linux,$(CFG_OSTYPE)),) - # -znoexecstack is here because librt is for some reason being created - # with executable stack and Fedora (or SELinux) doesn't like that (#798) ifdef CFG_PERF ifneq ($(CFG_PERF_WITH_LOGFD),) CFG_PERF_TOOL := $(CFG_PERF) stat -r 3 --log-fd 2 @@ -126,7 +124,7 @@ CFG_GCCISH_CXXFLAGS_x86_64-unknown-linux-gnu := -fno-rtti CFG_GCCISH_LINK_FLAGS_x86_64-unknown-linux-gnu := -shared -fPIC -ldl -lpthread -lrt -g -m64 CFG_GCCISH_DEF_FLAG_x86_64-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= CFG_GCCISH_PRE_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-no-whole-archive -Wl,-znoexecstack +CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-no-whole-archive CFG_DEF_SUFFIX_x86_64-unknown-linux-gnu := .linux.def CFG_INSTALL_NAME_x86_64-unknown-linux-gnu = CFG_LIBUV_LINK_FLAGS_x86_64-unknown-linux-gnu = @@ -152,7 +150,7 @@ CFG_GCCISH_CXXFLAGS_i686-unknown-linux-gnu := -fno-rtti CFG_GCCISH_LINK_FLAGS_i686-unknown-linux-gnu := -shared -fPIC -ldl -lpthread -lrt -g -m32 CFG_GCCISH_DEF_FLAG_i686-unknown-linux-gnu := -Wl,--export-dynamic,--dynamic-list= CFG_GCCISH_PRE_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-no-whole-archive -Wl,-znoexecstack +CFG_GCCISH_POST_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-no-whole-archive CFG_DEF_SUFFIX_i686-unknown-linux-gnu := .linux.def CFG_INSTALL_NAME_i686-unknown-linux-gnu = CFG_LIBUV_LINK_FLAGS_i686-unknown-linux-gnu = @@ -228,7 +226,7 @@ CFG_GCCISH_CXXFLAGS_arm-linux-androideabi := -fno-rtti CFG_GCCISH_LINK_FLAGS_arm-linux-androideabi := -shared -fPIC -ldl -g -lm -lsupc++ -lgnustl_shared CFG_GCCISH_DEF_FLAG_arm-linux-androideabi := -Wl,--export-dynamic,--dynamic-list= CFG_GCCISH_PRE_LIB_FLAGS_arm-linux-androideabi := -Wl,-whole-archive -CFG_GCCISH_POST_LIB_FLAGS_arm-linux-androideabi := -Wl,-no-whole-archive -Wl,-znoexecstack +CFG_GCCISH_POST_LIB_FLAGS_arm-linux-androideabi := -Wl,-no-whole-archive CFG_DEF_SUFFIX_arm-linux-androideabi := .android.def CFG_INSTALL_NAME_arm-linux-androideabi = CFG_LIBUV_LINK_FLAGS_arm-linux-androideabi = diff --git a/src/rt/arch/arm/_context.S b/src/rt/arch/arm/_context.S index 8d370c2d64e4c..b29575aada9f7 100644 --- a/src/rt/arch/arm/_context.S +++ b/src/rt/arch/arm/_context.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + .text .code 32 .arm @@ -17,12 +22,12 @@ swap_registers: str r10, [r0, #40] str r11, [r0, #44] str r12, [r0, #48] - str sp, [r0, #52] + str sp, [r0, #52] str lr, [r0, #56] mrs r2, cpsr str r2, [r0, #64] - + ldr r0, [r1, #0] ldr r3, [r1, #12] @@ -35,10 +40,10 @@ swap_registers: ldr r10, [r1, #40] ldr r11, [r1, #44] ldr r12, [r1, #48] - + ldr sp, [r1, #52] ldr lr, [r1, #56] - + ldr r2, [r1, #64] msr cpsr_cxsf, r2 diff --git a/src/rt/arch/arm/ccall.S b/src/rt/arch/arm/ccall.S index 345e6462d07b0..52806d67837bc 100644 --- a/src/rt/arch/arm/ccall.S +++ b/src/rt/arch/arm/ccall.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + .text .code 32 .arm @@ -19,4 +24,3 @@ __morestack: pop {r4, fp, lr} mov pc, lr .fnend - diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S index bc1c0c2302533..ccb23037f79f1 100644 --- a/src/rt/arch/arm/morestack.S +++ b/src/rt/arch/arm/morestack.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + .text .code 32 .arm diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S index 193104d53b11b..528359420e628 100644 --- a/src/rt/arch/arm/record_sp.S +++ b/src/rt/arch/arm/record_sp.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + .text .code 32 .arm @@ -45,11 +50,12 @@ get_sp_limit: get_sp: mov r0, sp mov pc, lr - + .data my_cpu: .long 0 .global my_array -my_array: +my_array: + .long 0 .long 0 .long 0 .long 0 @@ -57,5 +63,4 @@ my_array: .long 0 .long 0 .long 0 - .long 0 .end diff --git a/src/rt/arch/i386/_context.S b/src/rt/arch/i386/_context.S index d8b7281e72b75..d2643d07c3df6 100644 --- a/src/rt/arch/i386/_context.S +++ b/src/rt/arch/i386/_context.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + .text /* diff --git a/src/rt/arch/i386/ccall.S b/src/rt/arch/i386/ccall.S index c04c3e01c7ea4..e47d51bbdb721 100644 --- a/src/rt/arch/i386/ccall.S +++ b/src/rt/arch/i386/ccall.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + /* The function for switching to the C stack. It is called __morestack because gdb allows any frame with that name to diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S index 7f2205b573a8c..e8a9c1312ed2c 100644 --- a/src/rt/arch/i386/morestack.S +++ b/src/rt/arch/i386/morestack.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + /* __morestack @@ -218,11 +223,11 @@ MORESTACK: .L$bail: movl 32(%esp),%eax inc %eax - + addl $44, %esp popl %ebp addl $4+8,%esp - + jmpl *%eax #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) @@ -241,7 +246,7 @@ L_rust_get_task$stub: L_upcall_new_stack$stub: .indirect_symbol _upcall_new_stack .ascii "\364\364\364\364\364" - + L_upcall_del_stack$stub: .indirect_symbol _upcall_del_stack .ascii "\364\364\364\364\364" diff --git a/src/rt/arch/i386/record_sp.S b/src/rt/arch/i386/record_sp.S index e69de29bb2d1d..12d9a2b6456ca 100644 --- a/src/rt/arch/i386/record_sp.S +++ b/src/rt/arch/i386/record_sp.S @@ -0,0 +1,4 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif diff --git a/src/rt/arch/mips/_context.S b/src/rt/arch/mips/_context.S index 614cf68681708..c926a03798d2d 100644 --- a/src/rt/arch/mips/_context.S +++ b/src/rt/arch/mips/_context.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + .text .globl swap_registers .align 2 diff --git a/src/rt/arch/mips/ccall.S b/src/rt/arch/mips/ccall.S index 522714a8807b4..f41d8e721f66f 100644 --- a/src/rt/arch/mips/ccall.S +++ b/src/rt/arch/mips/ccall.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + .text .globl __morestack diff --git a/src/rt/arch/mips/record_sp.S b/src/rt/arch/mips/record_sp.S index 6b782fc4629ec..dd4d2f393754d 100644 --- a/src/rt/arch/mips/record_sp.S +++ b/src/rt/arch/mips/record_sp.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + .text .globl record_sp_limit diff --git a/src/rt/arch/x86_64/_context.S b/src/rt/arch/x86_64/_context.S index 1f9ae1c83c565..bedd685546756 100644 --- a/src/rt/arch/x86_64/_context.S +++ b/src/rt/arch/x86_64/_context.S @@ -1,7 +1,12 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + #include "regs.h" #define ARG0 RUSTRT_ARG0_S #define ARG1 RUSTRT_ARG1_S - + .text /* @@ -11,7 +16,7 @@ and Microsoft discussion at http://msdn.microsoft.com/en-US/library/9z1stfyw%28v=VS.80%29.aspx. BOTH CALLING CONVENTIONS - + Callee save registers: R12--R15, RDI, RSI, RBX, RBP, RSP XMM0--XMM5 @@ -30,7 +35,7 @@ User flags have no specified role and are not preserved across calls, with the exception of DF in %rFLAGS, which must be clear (set to "forward" direction) on function entry and return. - + MICROSOFT CALLING CONVENTIONS Return value: RAX @@ -39,7 +44,7 @@ First four arguments: RCX, RDX, R8, R9 XMM0, XMM1, XMM2, XMM3 */ - + /* Stores current registers into arg0/RCX and restores registers found in arg1/RDX. This is used by our @@ -47,7 +52,7 @@ First four arguments: registers and the register used for the first argument. Volatile registers in general ought to be saved by the caller anyhow. -*/ +*/ #if defined(__APPLE__) || defined(_WIN32) #define SWAP_REGISTERS _swap_registers diff --git a/src/rt/arch/x86_64/ccall.S b/src/rt/arch/x86_64/ccall.S index 42415e84a52f0..d4bc37fee957d 100644 --- a/src/rt/arch/x86_64/ccall.S +++ b/src/rt/arch/x86_64/ccall.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + /* The function for switching to the C stack. It is called __morestack because gdb allows any frame with that name to @@ -10,7 +15,7 @@ #define ARG0 RUSTRT_ARG0_S #define ARG1 RUSTRT_ARG1_S #define ARG2 RUSTRT_ARG2_S - + .text #if defined(__APPLE__) || defined(_WIN32) diff --git a/src/rt/arch/x86_64/morestack.S b/src/rt/arch/x86_64/morestack.S index 4acb50497d92e..e4dfc033bf433 100644 --- a/src/rt/arch/x86_64/morestack.S +++ b/src/rt/arch/x86_64/morestack.S @@ -1,3 +1,8 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif + /* __morestack @@ -78,7 +83,7 @@ MORESTACK: movq %r11, %rdx // Size of stack arguments movq %rax, %rsi // Address of stack arguments movq %r10, %rdi // The amount of stack needed - + #ifdef __APPLE__ call UPCALL_NEW_STACK #endif @@ -132,7 +137,7 @@ MORESTACK: popq %rax // Restore the return value popq %rbp ret - + .cfi_endproc #else diff --git a/src/rt/arch/x86_64/record_sp.S b/src/rt/arch/x86_64/record_sp.S index e69de29bb2d1d..12d9a2b6456ca 100644 --- a/src/rt/arch/x86_64/record_sp.S +++ b/src/rt/arch/x86_64/record_sp.S @@ -0,0 +1,4 @@ +// Mark stack as non-executable +#if defined(__linux__) && defined(__ELF__) +.section .note.GNU-stack, "", @progbits +#endif From 431380f011d122b9d893addf4817f632d8c94ba8 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Sun, 31 Mar 2013 19:14:02 -0400 Subject: [PATCH 13/19] install.mk: use INSTALL_LIB for all libraries There's no reason to make them executable, and this throws a warning with the Arch Linux package lint tool (namcap) for .a files. --- mk/install.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mk/install.mk b/mk/install.mk index 90679f0a116bf..fd7f44ddae57c 100644 --- a/mk/install.mk +++ b/mk/install.mk @@ -51,19 +51,19 @@ $(foreach target,$(CFG_TARGET_TRIPLES), \ define INSTALL_TARGET_N install-target-$(1)-host-$(2): $$(TSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(SREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(Q)mkdir -p $$(PTL$(1)$(2)) - $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_RUNTIME_$(1))) + $$(Q)$$(call INSTALL_LIB,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_RUNTIME_$(1))) $$(Q)$$(call INSTALL_LIB, \ $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CORELIB_GLOB_$(1))) $$(Q)$$(call INSTALL_LIB, \ $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(STDLIB_GLOB_$(1))) - $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a) + $$(Q)$$(call INSTALL_LIB,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a) endef define INSTALL_HOST_N install-target-$(1)-host-$(2): $$(CSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(Q)mkdir -p $$(PTL$(1)$(2)) - $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_RUNTIME_$(1))) + $$(Q)$$(call INSTALL_LIB,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CFG_RUNTIME_$(1))) $$(Q)$$(call INSTALL_LIB, \ $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(CORELIB_GLOB_$(1))) $$(Q)$$(call INSTALL_LIB, \ @@ -80,7 +80,7 @@ install-target-$(1)-host-$(2): $$(CSREQ$$(ISTAGE)_T_$(1)_H_$(2)) $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(LIBRUSTI_GLOB_$(1))) $$(Q)$$(call INSTALL_LIB, \ $$(TL$(1)$(2)),$$(PTL$(1)$(2)),$$(LIBRUST_GLOB_$(1))) - $$(Q)$$(call INSTALL,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a) + $$(Q)$$(call INSTALL_LIB,$$(TL$(1)$(2)),$$(PTL$(1)$(2)),libmorestack.a) endef From d617030d635c0d93fb969d76a622774133f61f7a Mon Sep 17 00:00:00 2001 From: Luqman Aden Date: Sun, 31 Mar 2013 18:34:51 -0700 Subject: [PATCH 14/19] Update tutorial.md Change fn() -> &fn(). --- doc/tutorial.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 9344c43ba10ad..874383097db5a 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -1539,9 +1539,9 @@ for spawning [tasks][tasks]. Rust closures have a convenient subtyping property: you can pass any kind of closure (as long as the arguments and return types match) to functions -that expect a `fn()`. Thus, when writing a higher-order function that +that expect a `&fn()`. Thus, when writing a higher-order function that only calls its function argument, and does nothing else with it, you -should almost always declare the type of that argument as `fn()`. That way, +should almost always declare the type of that argument as `&fn()`. That way, callers may pass any kind of closure. ~~~~ From e3327d3833e6b1ea4b23ecd3332b869ce82f1999 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Sun, 31 Mar 2013 19:27:51 -0700 Subject: [PATCH 15/19] Fix warnings --- src/librustc/metadata/creader.rs | 1 - src/librustc/middle/lint.rs | 1 - src/librustc/middle/moves.rs | 4 ++-- src/librustc/middle/resolve.rs | 2 +- src/librustc/middle/trans/consts.rs | 2 +- src/librustc/middle/trans/foreign.rs | 1 - src/librustc/middle/typeck/check/mod.rs | 7 +++---- src/librustc/middle/typeck/collect.rs | 4 ++-- src/librustc/middle/typeck/infer/coercion.rs | 11 +++++------ src/librustc/middle/typeck/infer/glb.rs | 2 +- src/libstd/net_tcp.rs | 3 +-- src/libsyntax/ast.rs | 2 +- src/libsyntax/ast_map.rs | 1 - src/libsyntax/attr.rs | 1 - src/libsyntax/ext/deriving/mod.rs | 2 +- src/libsyntax/ext/pipes/ast_builder.rs | 2 +- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/print/pprust.rs | 3 +-- 18 files changed, 21 insertions(+), 30 deletions(-) diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index 5e2ba4156bd8d..086c6a33b3ec8 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -18,7 +18,6 @@ use metadata::decoder; use metadata::filesearch::FileSearch; use metadata::loader; -use core::either; use core::hashmap::linear::LinearMap; use core::vec; use syntax::attr; diff --git a/src/librustc/middle/lint.rs b/src/librustc/middle/lint.rs index 64c6c3391797a..ba232f55f74f6 100644 --- a/src/librustc/middle/lint.rs +++ b/src/librustc/middle/lint.rs @@ -18,7 +18,6 @@ use util::ppaux::{ty_to_str}; use core::hashmap::linear::LinearMap; use core::char; use core::cmp; -use core::either; use core::i8; use core::i16; use core::i32; diff --git a/src/librustc/middle/moves.rs b/src/librustc/middle/moves.rs index 980fb5319f8c8..a93618b66246f 100644 --- a/src/librustc/middle/moves.rs +++ b/src/librustc/middle/moves.rs @@ -718,8 +718,8 @@ pub impl VisitContext { } fn use_receiver(&self, - expr_id: node_id, - span: span, + _expr_id: node_id, + _span: span, receiver_expr: @expr, visitor: vt) { diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 5bad8d1d6ca09..70d9dfacb6940 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1358,7 +1358,7 @@ pub impl Resolver { item_id: def_id, +parent_privacy: Privacy, parent: ReducedGraphParent, - &&visitor: vt) { + &&_visitor: vt) { let ident = variant.node.name; let (child, _) = self.add_child(ident, parent, ForbidDuplicateValues, variant.span); diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index 2443c9998f135..55e6b30439ba4 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -11,7 +11,7 @@ use core::prelude::*; use back::abi; -use lib::llvm::{llvm, SetLinkage, InternalLinkage, PrivateLinkage, +use lib::llvm::{llvm, SetLinkage, PrivateLinkage, ValueRef, TypeRef, Bool, True, False}; use metadata::csearch; use middle::const_eval; diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index 6a040e81186ff..7dc2e385e2cf6 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -11,7 +11,6 @@ use core::prelude::*; use back::{link, abi}; -use driver::session; use lib::llvm::{SequentiallyConsistent, Acquire, Release, Xchg}; use lib::llvm::{TypeRef, ValueRef}; use lib; diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index 41877017685d6..056ccf185995b 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -110,7 +110,6 @@ use util::common::{block_query, indenter, loop_query}; use util::ppaux::{bound_region_to_str, expr_repr, pat_repr}; use util::ppaux; -use core::either; use core::hashmap::linear::LinearMap; use core::ptr; use core::result::{Result, Ok, Err}; @@ -119,7 +118,7 @@ use core::str; use core::vec; use std::list::Nil; use syntax::abi::AbiSet; -use syntax::ast::{provided, required, ty_i}; +use syntax::ast::{provided, required}; use syntax::ast; use syntax::ast_map; use syntax::ast_util::local_def; @@ -3021,7 +3020,7 @@ pub fn check_enum_variants(ccx: @mut CrateCtxt, vs: &[ast::variant], id: ast::node_id) { fn do_check(ccx: @mut CrateCtxt, - sp: span, + _sp: span, vs: &[ast::variant], id: ast::node_id, disr_vals: &mut ~[int], @@ -3303,7 +3302,7 @@ pub fn type_is_c_like_enum(fcx: @mut FnCtxt, sp: span, typ: ty::t) -> bool { pub fn ast_expr_vstore_to_vstore(fcx: @mut FnCtxt, e: @ast::expr, - n: uint, + _n: uint, v: ast::expr_vstore) -> ty::vstore { match v { diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 0ef65d5932cbe..f1d743e79e58a 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -33,7 +33,7 @@ are represented as `ty_param()` instances. use core::prelude::*; use metadata::csearch; -use middle::ty::{InstantiatedTraitRef, arg}; +use middle::ty::InstantiatedTraitRef; use middle::ty::{substs, ty_param_bounds_and_ty, ty_param_substs_and_ty}; use middle::ty; use middle::typeck::astconv::{AstConv, ty_of_arg}; @@ -860,7 +860,7 @@ pub fn ty_of_item(ccx: &CrateCtxt, it: @ast::item) tcx.tcache.insert(local_def(it.id), tpt); return tpt; } - ast::item_fn(ref decl, purity, abi, ref generics, _) => { + ast::item_fn(ref decl, purity, _, ref generics, _) => { let bounds = ty_param_bounds(ccx, generics); let tofd = astconv::ty_of_bare_fn(ccx, &empty_rscope, diff --git a/src/librustc/middle/typeck/infer/coercion.rs b/src/librustc/middle/typeck/infer/coercion.rs index 95ff552eb51b7..43731c6a676ca 100644 --- a/src/librustc/middle/typeck/infer/coercion.rs +++ b/src/librustc/middle/typeck/infer/coercion.rs @@ -66,9 +66,9 @@ we may want to adjust precisely when coercions occur. use core::prelude::*; -use middle::ty::{TyVar, AutoPtr, AutoBorrowVec, AutoBorrowFn}; -use middle::ty::{AutoAdjustment, AutoDerefRef, AutoRef}; -use middle::ty::{vstore_slice, vstore_box, vstore_uniq, vstore_fixed}; +use middle::ty::{AutoPtr, AutoBorrowVec, AutoBorrowFn}; +use middle::ty::{AutoDerefRef, AutoRef}; +use middle::ty::{vstore_slice, vstore_box, vstore_uniq}; use middle::ty::{mt}; use middle::ty; use middle::typeck::infer::{CoerceResult, resolve_type}; @@ -76,10 +76,9 @@ use middle::typeck::infer::combine::CombineFields; use middle::typeck::infer::sub::Sub; use middle::typeck::infer::to_str::InferStr; use middle::typeck::infer::resolve::try_resolve_tvar_shallow; -use util::common::{indent, indenter}; +use util::common::indenter; -use syntax::abi::AbiSet; -use syntax::ast::{m_const, m_imm, m_mutbl}; +use syntax::ast::m_imm; use syntax::ast; // Note: Coerce is not actually a combiner, in that it does not diff --git a/src/librustc/middle/typeck/infer/glb.rs b/src/librustc/middle/typeck/infer/glb.rs index d521d005aba4a..9c8c8997ae087 100644 --- a/src/librustc/middle/typeck/infer/glb.rs +++ b/src/librustc/middle/typeck/infer/glb.rs @@ -21,7 +21,7 @@ use middle::typeck::infer::{cres, InferCtxt}; use middle::typeck::isr_alist; use syntax::ast; use syntax::ast::{Many, Once, extern_fn, impure_fn, m_const, m_imm, m_mutbl}; -use syntax::ast::{noreturn, pure_fn, ret_style, return_val, unsafe_fn}; +use syntax::ast::{pure_fn, unsafe_fn}; use syntax::ast::{Onceness, purity}; use syntax::abi::AbiSet; use syntax::codemap::span; diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 8a51af8573f06..9630351b5c9be 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -20,7 +20,6 @@ use uv; use uv::iotask; use uv::iotask::IoTask; -use core::io::{Reader, ReaderUtil, Writer}; use core::io; use core::libc::size_t; use core::libc; @@ -1439,7 +1438,7 @@ struct TcpBufferedSocketData { mut buf_off: uint } -//#[cfg(test)] +#[cfg(test)] pub mod test { use net::ip; use net::tcp::{GenericListenErr, TcpConnectErrData, TcpListenErrData}; diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 16399674b5599..2e7ae4c537a8c 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -10,7 +10,7 @@ // The Rust abstract syntax tree. -use codemap::{span, FileName, spanned}; +use codemap::{span, spanned}; use abi::AbiSet; use opt_vec::OptVec; diff --git a/src/libsyntax/ast_map.rs b/src/libsyntax/ast_map.rs index ff5cbbe9f2350..f22b466efebda 100644 --- a/src/libsyntax/ast_map.rs +++ b/src/libsyntax/ast_map.rs @@ -15,7 +15,6 @@ use ast::*; use ast; use ast_util::{inlined_item_utils, stmt_id}; use ast_util; -use attr; use codemap; use codemap::spanned; use diagnostic::span_handler; diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 72355d0445620..9f8dbef9b967b 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -19,7 +19,6 @@ use codemap::BytePos; use diagnostic::span_handler; use parse::comments::{doc_comment_style, strip_doc_comment_decoration}; -use core::either::Either; use core::vec; use core::hashmap::linear::LinearSet; use std; diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs index e2c52fad1102a..18ebceaeb4396 100644 --- a/src/libsyntax/ext/deriving/mod.rs +++ b/src/libsyntax/ext/deriving/mod.rs @@ -286,7 +286,7 @@ pub fn create_enum_variant_pattern(cx: @ext_ctxt, } } -pub fn variant_arg_count(cx: @ext_ctxt, span: span, variant: &variant) -> uint { +pub fn variant_arg_count(_cx: @ext_ctxt, _span: span, variant: &variant) -> uint { match variant.node.kind { tuple_variant_kind(ref args) => args.len(), struct_variant_kind(ref struct_def) => struct_def.fields.len(), diff --git a/src/libsyntax/ext/pipes/ast_builder.rs b/src/libsyntax/ext/pipes/ast_builder.rs index 72e6c22dbc882..1d1a101d61f1d 100644 --- a/src/libsyntax/ext/pipes/ast_builder.rs +++ b/src/libsyntax/ext/pipes/ast_builder.rs @@ -16,7 +16,7 @@ use core::prelude::*; use abi::AbiSet; -use ast::{ident, node_id}; +use ast::ident; use ast; use ast_util; use codemap::{span, respan, dummy_sp, spanned}; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 353e3014cf7ba..ceafecde3a0b1 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3777,7 +3777,7 @@ pub impl Parser { }; } - fn parse_enum_def(&self, generics: &ast::Generics) -> enum_def { + fn parse_enum_def(&self, _generics: &ast::Generics) -> enum_def { let mut variants = ~[]; let mut all_nullary = true, have_disr = false; while *self.token != token::RBRACE { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 0ec7bdba3d13e..0c79cbca039a6 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -11,7 +11,6 @@ use core::prelude::*; use abi::AbiSet; -use abi; use ast::{RegionTyParamBound, TraitTyParamBound, required, provided}; use ast; use ast_util; @@ -2180,7 +2179,7 @@ pub fn print_opt_sigil(s: @ps, opt_sigil: Option) { } pub fn print_fn_header_info(s: @ps, - opt_sty: Option, + _opt_sty: Option, opt_purity: Option, abis: AbiSet, onceness: ast::Onceness, From 26fc76acb6bd86375cc1fef218b3f91708a8f699 Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Mon, 1 Apr 2013 00:31:22 -0400 Subject: [PATCH 16/19] rt/arch/arm: fix syntax used for noexec stack --- src/rt/arch/arm/_context.S | 2 +- src/rt/arch/arm/ccall.S | 2 +- src/rt/arch/arm/morestack.S | 2 +- src/rt/arch/arm/record_sp.S | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/rt/arch/arm/_context.S b/src/rt/arch/arm/_context.S index b29575aada9f7..9097ebfc07004 100644 --- a/src/rt/arch/arm/_context.S +++ b/src/rt/arch/arm/_context.S @@ -1,6 +1,6 @@ // Mark stack as non-executable #if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack, "", @progbits +.section .note.GNU-stack, "", %progbits #endif .text diff --git a/src/rt/arch/arm/ccall.S b/src/rt/arch/arm/ccall.S index 52806d67837bc..3350a040f5303 100644 --- a/src/rt/arch/arm/ccall.S +++ b/src/rt/arch/arm/ccall.S @@ -1,6 +1,6 @@ // Mark stack as non-executable #if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack, "", @progbits +.section .note.GNU-stack, "", %progbits #endif .text diff --git a/src/rt/arch/arm/morestack.S b/src/rt/arch/arm/morestack.S index ccb23037f79f1..1afce5bd848b7 100644 --- a/src/rt/arch/arm/morestack.S +++ b/src/rt/arch/arm/morestack.S @@ -1,6 +1,6 @@ // Mark stack as non-executable #if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack, "", @progbits +.section .note.GNU-stack, "", %progbits #endif .text diff --git a/src/rt/arch/arm/record_sp.S b/src/rt/arch/arm/record_sp.S index 528359420e628..abd8fbb6a5b05 100644 --- a/src/rt/arch/arm/record_sp.S +++ b/src/rt/arch/arm/record_sp.S @@ -1,6 +1,6 @@ // Mark stack as non-executable #if defined(__linux__) && defined(__ELF__) -.section .note.GNU-stack, "", @progbits +.section .note.GNU-stack, "", %progbits #endif .text From 37634f3363fa871b72d181920caa2ec23eb63135 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 1 Apr 2013 12:10:51 -0700 Subject: [PATCH 17/19] core: Update libc docs to clarify usage --- src/libcore/libc.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libcore/libc.rs b/src/libcore/libc.rs index 79bb375d360c0..fdb82a7303bea 100644 --- a/src/libcore/libc.rs +++ b/src/libcore/libc.rs @@ -9,7 +9,19 @@ // except according to those terms. /*! -* Bindings for libc. +* Bindings for the C standard library and other platform libraries +* +* This module contains bindings to the C standard library, +* organized into modules by their defining standard. +* Additionally, it contains some assorted platform-specific definitions. +* For convenience, most functions and types are reexported from `core::libc`, +* so `pub use core::libc::*` will import the available +* C bindings as appropriate for the target platform. The exact +* set of functions available are platform specific. +* +* *Note* Rustdoc does not indicate reexports currently. Also, because these +* definitions are platform-specific, some may not +* appear in the generated documentation. * * We consider the following specs reasonably normative with respect * to interoperating with the C standard library (libc/msvcrt): From 243e601e51fa899dd57c98f0624659364ea77f22 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 1 Apr 2013 12:11:07 -0700 Subject: [PATCH 18/19] doc: Update tutorial description of core --- doc/tutorial.md | 82 ++++++++++++++++++++++++++++++++------------- src/libcore/core.rc | 2 +- 2 files changed, 60 insertions(+), 24 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 874383097db5a..3ae320adffc07 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -2554,26 +2554,65 @@ a hash representing the crate metadata. ## The core library -The Rust [core] library is the language runtime and contains -required memory management and task scheduling code as well as a -number of modules necessary for effective usage of the primitive -types. Methods on [vectors] and [strings], implementations of most -comparison and math operators, and pervasive types like [`Option`] -and [`Result`] live in core. - -All Rust programs link to the core library and import its contents, -as if the following were written at the top of the crate. - -~~~ {.xfail-test} -extern mod core; -use core::*; -~~~ - -[core]: core/index.html -[vectors]: core/vec.html +The Rust core library provides runtime features required by the language, +including the task scheduler and memory allocators, as well as library +support for Rust built-in types, platform abstractions, and other commonly +used features. + +[`core`] includes modules corresponding to each of the integer types, each of +the floating point types, the [`bool`] type, [tuples], [characters], [strings], +[vectors], [managed boxes], [owned boxes], +and unsafe and borrowed [pointers]. Additionally, `core` provides +some pervasive types ([`option`] and [`result`]), +[task] creation and [communication] primitives, +platform abstractions ([`os`] and [`path`]), basic +I/O abstractions ([`io`]), [containers] like [`hashmap`], +common traits ([`kinds`], [`ops`], [`cmp`], [`num`], +[`to_str`], [`clone`]), and complete bindings to the C standard library ([`libc`]). + +### Core injection and the Rust prelude + +`core` is imported at the topmost level of every crate by default, as +if the first line of each crate was + + extern mod core; + +This means that the contents of core can be accessed from from any context +with the `core::` path prefix, as in `use core::vec`, `use core::task::spawn`, +etc. + +Additionally, `core` contains a `prelude` module that reexports many of the +most common core modules, types and traits. The contents of the prelude are +imported into every *module* by default. Implicitly, all modules behave as if +they contained the following prologue: + + use core::prelude::*; + +[`core`]: core/index.html +[`bool`]: core/bool.html +[tuples]: core/tuple.html +[characters]: core/char.html [strings]: core/str.html -[`Option`]: core/option.html -[`Result`]: core/result.html +[vectors]: core/vec.html +[managed boxes]: core/managed.html +[owned boxes]: core/owned.html +[pointers]: core/ptr.html +[`option`]: core/option.html +[`result`]: core/result.html +[task]: core/task.html +[communication]: core/comm.html +[`os`]: core/os.html +[`path`]: core/path.html +[`io`]: core/io.html +[containers]: core/container.html +[`hashmap`]: core/hashmap.html +[`kinds`]: core/kinds.html +[`ops`]: core/ops.html +[`cmp`]: core/cmp.html +[`num`]: core/num.html +[`to_str`]: core/to_str.html +[`clone`]: core/clone.html +[`libc`]: core/libc.html # What next? @@ -2585,10 +2624,7 @@ tutorials on individual topics. * [Macros][macros] * [The foreign function interface][ffi] -There is further documentation on the [wiki], including articles about -[unit testing] in Rust, [documenting][rustdoc] and [packaging][cargo] -Rust code, and a discussion of the [attributes] used to apply metadata -to code. +There is further documentation on the [wiki]. [borrow]: tutorial-borrowed-ptr.html [tasks]: tutorial-tasks.html diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 443f2538fa934..292dd1d92cfa3 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -39,7 +39,7 @@ etc. Additionally, `core` contains a `prelude` module that reexports many of the most common core modules, types and traits. The contents of the prelude are -imported inte every *module* by default. Implicitly, all modules behave as if +imported into every *module* by default. Implicitly, all modules behave as if they contained the following prologue: use core::prelude::*; From a20d1ad0cbcca13ee386fd819f33563b465f1185 Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Mon, 1 Apr 2013 16:37:40 -0700 Subject: [PATCH 19/19] Improve documentation for core::io. --- src/libcore/io.rs | 76 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 68 insertions(+), 8 deletions(-) diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 60a0ee4fa9713..be3e100631488 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -49,29 +49,89 @@ pub mod rustrt { // FIXME (#2004): This is all buffered. We might need an unbuffered variant // as well +/** +* The SeekStyle enum describes the relationship between the position +* we'd like to seek to from our current position. It's used as an argument +* to the `seek` method defined on the `Reader` trait. +* +* There are three seek styles: +* +* 1. `SeekSet` means that the new position should become our position. +* 2. `SeekCur` means that we should seek from the current position. +* 3. `SeekEnd` means that we should seek from the end. +* +* # Examples +* +* None right now. +*/ pub enum SeekStyle { SeekSet, SeekEnd, SeekCur, } -/// The raw underlying reader trait. All readers must implement this. +/** +* The core Reader trait. All readers must implement this trait. +* +* # Examples +* +* None right now. +*/ pub trait Reader { // FIXME (#2004): Seekable really should be orthogonal. - /// Read up to len bytes (or EOF) and put them into bytes (which - /// must be at least len bytes long). Return number of bytes read. // FIXME (#2982): This should probably return an error. + /** + * Reads bytes and puts them into `bytes`. Returns the number of + * bytes read. + * + * The number of bytes to be read is `len` or the end of the file, + * whichever comes first. + * + * The buffer must be at least `len` bytes long. + * + * # Examples + * + * None right now. + */ fn read(&self, bytes: &mut [u8], len: uint) -> uint; - /// Read a single byte, returning a negative value for EOF or read error. + /** + * Reads a single byte. + * + * In the case of an EOF or an error, returns a negative value. + * + * # Examples + * + * None right now. + */ fn read_byte(&self) -> int; - /// Return whether the stream is currently at EOF position. + /** + * Returns a boolean value: are we currently at EOF? + * + * # Examples + * + * None right now. + */ fn eof(&self) -> bool; - /// Move the current position within the stream. The second parameter - /// determines the position that the first parameter is relative to. + /** + * Seek to a given `position` in the stream. + * + * Takes an optional SeekStyle, which affects how we seek from the + * position. See `SeekStyle` docs for more details. + * + * # Examples + * + * None right now. + */ fn seek(&self, position: int, style: SeekStyle); - /// Return the current position within the stream. + /** + * Returns the current position within the stream. + * + * # Examples + * + * None right now. + */ fn tell(&self) -> uint; }