Skip to content

Commit

Permalink
auto merge of #12614 : alexcrichton/rust/rollup, r=alexcrichton
Browse files Browse the repository at this point in the history
Closes #12546 (Add new target 'make dist-osx' to create a .pkg installer for OS X) r=brson
Closes #12575 (rustc: Move local native libs back in link-args) r=brson
Closes #12587 (Provide a more helpful error for tests that fail due to noexec) r=brson
Closes #12589 (rustc: Remove codemap and reachable from metadata encoder) r=alexcrichton
Closes #12591 (Fix syntax::ext::deriving{,::*} docs formatting.) r=huonw
Closes #12592 (Miscellaneous Vim improvements) r=alexcrichton
Closes #12596 (path: Implement windows::make_non_verbatim()) r=alexcrichton
Closes #12598 (Improve the ctags function regular expression) r=alexcrichton
Closes #12599 (Tutorial improvement (new variant of PR #12472).) r=pnkfelix
Closes #12603 (std: Export the select! macro) r=pcwalton
Closes #12605 (Fix typo in doc of Binary trait in std::fmt) r=alexcrichton
Closes #12613 (Fix bytepos_to_file_charpos) r=brson
  • Loading branch information
bors committed Feb 28, 2014
2 parents f203fc7 + a8d57a2 commit 53e90c1
Show file tree
Hide file tree
Showing 23 changed files with 407 additions and 98 deletions.
36 changes: 34 additions & 2 deletions mk/dist.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ PKG_ICO = $(S)src/etc/pkg/rust-logo.ico
PKG_EXE = $(PKG_DIR)-install.exe
endif

ifeq ($(CFG_OSTYPE), apple-darwin)
PKG_OSX = $(PKG_DIR).pkg
endif

PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt

PKG_FILES := \
Expand Down Expand Up @@ -41,10 +45,10 @@ PKG_FILES := \

UNROOTED_PKG_FILES := $(patsubst $(S)%,./%,$(PKG_FILES))

ifdef CFG_ISCC
LICENSE.txt: $(S)COPYRIGHT $(S)LICENSE-APACHE $(S)LICENSE-MIT
cat $^ > $@

ifdef CFG_ISCC
%.iss: $(S)src/etc/pkg/%.iss
cp $< $@

Expand Down Expand Up @@ -103,7 +107,7 @@ distcheck: dist

else

dist: $(PKG_TAR)
dist: $(PKG_TAR) $(PKG_OSX)

distcheck: $(PKG_TAR)
$(Q)rm -Rf dist
Expand All @@ -124,3 +128,31 @@ distcheck: $(PKG_TAR)
@echo -----------------------------------------------

endif

ifeq ($(CFG_OSTYPE), apple-darwin)

dist-prepare-osx: PREPARE_HOST=$(CFG_BUILD)
dist-prepare-osx: PREPARE_TARGETS=$(CFG_BUILD)
dist-prepare-osx: PREPARE_DEST_DIR=tmp/dist/pkgroot
dist-prepare-osx: PREPARE_STAGE=2
dist-prepare-osx: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
dist-prepare-osx: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
dist-prepare-osx: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
dist-prepare-osx: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
dist-prepare-osx: prepare-base

$(PKG_OSX): Distribution.xml LICENSE.txt dist-prepare-osx
@$(call E, making OS X pkg)
$(Q)pkgbuild --identifier org.rust-lang.rust --root tmp/dist/pkgroot rust.pkg
$(Q)productbuild --distribution Distribution.xml --resources . $(PKG_OSX)
$(Q)rm -rf tmp rust.pkg

dist-osx: $(PKG_OSX)

distcheck-osx: $(PKG_OSX)
@echo
@echo -----------------------------------------------
@echo $(PKG_OSX) ready for distribution
@echo -----------------------------------------------

endif
23 changes: 17 additions & 6 deletions src/doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ fn main() {
println!("hello?");
}
~~~~
> ***Note:*** An identifier followed by an exclamation point, like
> `println!`, is a macro invocation. Macros are explained
> [later](#syntax-extensions); for now just remember to include the
> exclamation point.
If the Rust compiler was installed successfully, running `rustc
hello.rs` will produce an executable called `hello` (or `hello.exe` on
Expand Down Expand Up @@ -1059,7 +1063,7 @@ box, while the owner holds onto a pointer to it:
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
+--------------+ +--------------+ +--------------+ +--------------+

> Note: the above diagram shows the logical contents of the enum. The actual
> ***Note:*** the above diagram shows the logical contents of the enum. The actual
> memory layout of the enum may vary. For example, for the `List` enum shown
> above, Rust guarantees that there will be no enum tag field in the actual
> structure. See the language reference for more details.
Expand Down Expand Up @@ -1114,7 +1118,7 @@ let z = x; // no new memory allocated, `x` can no longer be used
~~~~

The `clone` method is provided by the `Clone` trait, and can be derived for
our `List` type. Traits will be explained in detail later.
our `List` type. Traits will be explained in detail [later](#traits).

~~~{.ignore}
#[deriving(Clone)]
Expand Down Expand Up @@ -1207,8 +1211,8 @@ let ys = Cons(5, ~Cons(10, ~Nil));
assert!(eq(&xs, &ys));
~~~

Note that Rust doesn't guarantee [tail-call](http://en.wikipedia.org/wiki/Tail_call) optimization,
but LLVM is able to handle a simple case like this with optimizations enabled.
> ***Note:*** Rust doesn't guarantee [tail-call](http://en.wikipedia.org/wiki/Tail_call) optimization,
> but LLVM is able to handle a simple case like this with optimizations enabled.
## Lists of other types

Expand All @@ -1218,6 +1222,9 @@ element type.

The `u32` in the previous definition can be substituted with a type parameter:

> ***Note:*** The following code introduces generics, which are explained in a
> [dedicated section](#generics).
~~~
enum List<T> {
Cons(T, ~List<T>),
Expand Down Expand Up @@ -1336,10 +1343,14 @@ impl<T: Eq> Eq for List<T> {
let xs = Cons(5, ~Cons(10, ~Nil));
let ys = Cons(5, ~Cons(10, ~Nil));
// The methods below are part of the Eq trait,
// which we implemented on our linked list.
assert!(xs.eq(&ys));
assert!(xs == ys);
assert!(!xs.ne(&ys));
assert!(!(xs != ys));
// The Eq trait also allows us to use the shorthand infix operators.
assert!(xs == ys); // `xs == ys` is short for `xs.eq(&ys)`
assert!(!(xs != ys)); // `xs != ys` is short for `xs.ne(&ys)`
~~~

# More on boxes
Expand Down
2 changes: 1 addition & 1 deletion src/etc/ctags.rust
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--langdef=Rust
--langmap=Rust:.rs
--regex-Rust=/^[ \t]*(pub[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\2/f,functions,function definitions/
--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/
--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/
--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/
--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/
Expand Down
22 changes: 22 additions & 0 deletions src/etc/pkg/Distribution.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<installer-gui-script minSpecVersion="2">
<title>Rust</title>
<license file="LICENSE.txt" mime-type="text/plain"/>
<pkg-ref id="org.rust-lang.rust"/>
<options customize="never" require-scripts="false" hostArchitectures="i386,x86_64"/>
<volume-check>
<allowed-os-versions>
<os-version min="10.7"/>
</allowed-os-versions>
</volume-check>
<choices-outline>
<line choice="default">
<line choice="org.rust-lang.rust"/>
</line>
</choices-outline>
<choice id="default"/>
<choice id="org.rust-lang.rust" visible="false">
<pkg-ref id="org.rust-lang.rust"/>
</choice>
<pkg-ref id="org.rust-lang.rust" version="0" onConclusion="none">rust.pkg</pkg-ref>
</installer-gui-script>
55 changes: 53 additions & 2 deletions src/etc/vim/ftplugin/rust.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" Vim syntax file
" Language: Rust
" Maintainer: Chris Morgan <me@chrismorgan.info>
" Last Change: 2013 Jul 10
" Last Change: 2014 Feb 27

if exists("b:did_ftplugin")
finish
Expand Down Expand Up @@ -42,4 +42,55 @@ if exists("g:loaded_delimitMate")
let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
endif

let b:undo_ftplugin = "setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd< | if exists('b:rust_original_delimitMate_excluded_regions') | let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions | unlet b:rust_original_delimitMate_excluded_regions | elseif exists('b:delimitMate_excluded_regions') | unlet b:delimitMate_excluded_regions | endif"
" Bind motion commands to support hanging indents
nnoremap <silent> <buffer> [[ :call <SID>Rust_Jump('n', 'Back')<CR>
nnoremap <silent> <buffer> ]] :call <SID>Rust_Jump('n', 'Forward')<CR>
xnoremap <silent> <buffer> [[ :call <SID>Rust_Jump('v', 'Back')<CR>
xnoremap <silent> <buffer> ]] :call <SID>Rust_Jump('v', 'Forward')<CR>
onoremap <silent> <buffer> [[ :call <SID>Rust_Jump('o', 'Back')<CR>
onoremap <silent> <buffer> ]] :call <SID>Rust_Jump('o', 'Forward')<CR>
let b:undo_ftplugin = "
\setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
\|if exists('b:rust_original_delimitMate_excluded_regions')
\|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions
\|unlet b:rust_original_delimitMate_excluded_regions
\|elseif exists('b:delimitMate_excluded_regions')
\|unlet b:delimitMate_excluded_regions
\|endif
\|nunmap <buffer> [[
\|nunmap <buffer> ]]
\|xunmap <buffer> [[
\|xunmap <buffer> ]]
\|ounmap <buffer> [[
\|ounmap <buffer> ]]
\"

if exists('*<SID>Rust_Jump') | finish | endif

function! <SID>Rust_Jump(mode, function) range
let cnt = v:count1
normal! m'
if a:mode ==# 'v'
norm! gv
endif
let foldenable = &foldenable
set nofoldenable
while cnt > 0
execute "call <SID>Rust_Jump_" . a:function . "()"
let cnt = cnt - 1
endwhile
let &foldenable = foldenable
endfunction

function! <SID>Rust_Jump_Back()
call search('{', 'b')
keepjumps normal! w99[{
endfunction

function! <SID>Rust_Jump_Forward()
normal! j0
call search('{', 'b')
keepjumps normal! w99[{%
call search('{')
endfunction
39 changes: 15 additions & 24 deletions src/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" Maintainer: Patrick Walton <pcwalton@mozilla.com>
" Maintainer: Ben Blum <bblum@cs.cmu.edu>
" Maintainer: Chris Morgan <me@chrismorgan.info>
" Last Change: 2014 Feb 14
" Last Change: 2014 Feb 27

if version < 600
syntax clear
Expand All @@ -18,8 +18,8 @@ syn keyword rustOperator as

syn match rustAssert "\<assert\(\w\)*!" contained
syn match rustFail "\<fail\(\w\)*!" contained
syn keyword rustKeyword break continue do
syn keyword rustKeyword extern nextgroup=rustExternCrate skipwhite
syn keyword rustKeyword break continue
syn keyword rustKeyword extern nextgroup=rustExternCrate,rustObsoleteExternMod skipwhite
syn keyword rustKeyword for in if impl let
syn keyword rustKeyword loop once priv pub
syn keyword rustKeyword return
Expand All @@ -35,12 +35,13 @@ syn keyword rustObsoleteStorage const
syn keyword rustInvalidBareKeyword crate

syn keyword rustExternCrate crate contained nextgroup=rustIdentifier skipwhite
syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite

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

" Reserved (but not yet used) keywords {{{2
syn keyword rustReservedKeyword alignof be offsetof pure sizeof typeof yield
syn keyword rustReservedKeyword alignof be do offsetof pure sizeof typeof yield

" Built-in types {{{2
syn keyword rustType int uint float char bool u8 u16 u32 u64 f32
Expand All @@ -51,8 +52,7 @@ syn keyword rustType f64 i8 i16 i32 i64 str Self
" to make it easy to update.

" Core operators {{{3
syn keyword rustTrait Sized
syn keyword rustTrait Freeze Send
syn keyword rustTrait Freeze Pod Send Sized
syn keyword rustTrait Add Sub Mul Div Rem Neg Not
syn keyword rustTrait BitAnd BitOr BitXor
syn keyword rustTrait Drop
Expand All @@ -63,32 +63,25 @@ syn keyword rustEnum Result
syn keyword rustEnumVariant Ok Err

" Functions {{{3
"syn keyword rustFunction print println
"syn keyword rustFunction range
"syn keyword rustFunction from_str
"syn keyword rustFunction range
"syn keyword rustFunction drop

" Types and traits {{{3
syn keyword rustTrait Any AnyOwnExt AnyRefExt AnyMutRefExt
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr IntoBytes
syn keyword rustTrait Bool
syn keyword rustTrait ToCStr
syn keyword rustTrait Char
syn keyword rustTrait Clone DeepClone
syn keyword rustTrait Eq Ord TotalEq TotalOrd Ordering Equiv
syn keyword rustEnumVariant Less Equal Greater
syn keyword rustTrait Container Mutable Map MutableMap Set MutableSet
syn keyword rustTrait Default
syn keyword rustTrait Hash
syn keyword rustTrait FromStr
syn keyword rustTrait FromIterator Extendable
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator CloneableIterator
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize

syn keyword rustTrait Algebraic Trigonometric Exponential Hyperbolic
syn keyword rustTrait Bitwise Bounded Fractional
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul CheckedDiv
syn keyword rustTrait Orderable Signed Unsigned Round
syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul
syn keyword rustTrait Signed Unsigned Round
syn keyword rustTrait Primitive Int Float ToPrimitive FromPrimitive
syn keyword rustTrait GenericPath Path PosixPath WindowsPath
syn keyword rustTrait RawPtr
syn keyword rustTrait Buffer Writer Reader Seek
Expand All @@ -98,20 +91,17 @@ syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector ImmutableCloneableVector
syn keyword rustTrait OwnedVector OwnedCloneableVector OwnedEqVector MutableVector
syn keyword rustTrait OwnedVector OwnedCloneableVector OwnedEqVector
syn keyword rustTrait MutableVector MutableTotalOrdVector
syn keyword rustTrait Vector VectorVector CloneableVector ImmutableVector

"syn keyword rustFunction stream
syn keyword rustTrait Port Chan GenericChan GenericSmartChan GenericPort Peekable
syn keyword rustTrait Port Chan
"syn keyword rustFunction spawn

syn keyword rustSelf self
syn keyword rustBoolean true false

syn keyword rustConstant Some None " option
syn keyword rustConstant Ok Err " result
syn keyword rustConstant Less Equal Greater " Ordering

" Other syntax {{{2

" If foo::bar changes to foo.bar, change this ("::" to "\.").
Expand Down Expand Up @@ -247,6 +237,7 @@ hi def link rustObsoleteStorage Error
hi def link rustLifetime Special
hi def link rustInvalidBareKeyword Error
hi def link rustExternCrate rustKeyword
hi def link rustObsoleteExternMod Error

" Other Suggestions:
" hi rustAttribute ctermfg=cyan
Expand Down
35 changes: 34 additions & 1 deletion src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,8 +1132,41 @@ fn link_args(sess: Session,
args.push(~"-Wl,--allow-multiple-definition");
}

add_local_native_libraries(&mut args, sess);
// Take careful note of the ordering of the arguments we pass to the linker
// here. Linkers will assume that things on the left depend on things to the
// right. Things on the right cannot depend on things on the left. This is
// all formally implemented in terms of resolving symbols (libs on the right
// resolve unknown symbols of libs on the left, but not vice versa).
//
// For this reason, we have organized the arguments we pass to the linker as
// such:
//
// 1. The local object that LLVM just generated
// 2. Upstream rust libraries
// 3. Local native libraries
// 4. Upstream native libraries
//
// This is generally fairly natural, but some may expect 2 and 3 to be
// swapped. The reason that all native libraries are put last is that it's
// not recommended for a native library to depend on a symbol from a rust
// crate. If this is the case then a staticlib crate is recommended, solving
// the problem.
//
// Additionally, it is occasionally the case that upstream rust libraries
// depend on a local native library. In the case of libraries such as
// lua/glfw/etc the name of the library isn't the same across all platforms,
// so only the consumer crate of a library knows the actual name. This means
// that downstream crates will provide the #[link] attribute which upstream
// crates will depend on. Hence local native libraries are after out
// upstream rust crates.
//
// In theory this means that a symbol in an upstream native library will be
// shadowed by a local native library when it wouldn't have been before, but
// this kind of behavior is pretty platform specific and generally not
// recommended anyway, so I don't think we're shooting ourself in the foot
// much with that.
add_upstream_rust_crates(&mut args, sess, dylib, tmpdir);
add_local_native_libraries(&mut args, sess);
add_upstream_native_libraries(&mut args, sess);

// # Telling the linker what we're doing
Expand Down
Loading

0 comments on commit 53e90c1

Please sign in to comment.