Skip to content

Commit 53e90c1

Browse files
committed
auto merge of #12614 : alexcrichton/rust/rollup, r=alexcrichton
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
2 parents f203fc7 + a8d57a2 commit 53e90c1

File tree

23 files changed

+407
-98
lines changed

23 files changed

+407
-98
lines changed

mk/dist.mk

+34-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ PKG_ICO = $(S)src/etc/pkg/rust-logo.ico
1212
PKG_EXE = $(PKG_DIR)-install.exe
1313
endif
1414

15+
ifeq ($(CFG_OSTYPE), apple-darwin)
16+
PKG_OSX = $(PKG_DIR).pkg
17+
endif
18+
1519
PKG_GITMODULES := $(S)src/libuv $(S)src/llvm $(S)src/gyp $(S)src/compiler-rt
1620

1721
PKG_FILES := \
@@ -41,10 +45,10 @@ PKG_FILES := \
4145

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

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

51+
ifdef CFG_ISCC
4852
%.iss: $(S)src/etc/pkg/%.iss
4953
cp $< $@
5054

@@ -103,7 +107,7 @@ distcheck: dist
103107

104108
else
105109

106-
dist: $(PKG_TAR)
110+
dist: $(PKG_TAR) $(PKG_OSX)
107111

108112
distcheck: $(PKG_TAR)
109113
$(Q)rm -Rf dist
@@ -124,3 +128,31 @@ distcheck: $(PKG_TAR)
124128
@echo -----------------------------------------------
125129

126130
endif
131+
132+
ifeq ($(CFG_OSTYPE), apple-darwin)
133+
134+
dist-prepare-osx: PREPARE_HOST=$(CFG_BUILD)
135+
dist-prepare-osx: PREPARE_TARGETS=$(CFG_BUILD)
136+
dist-prepare-osx: PREPARE_DEST_DIR=tmp/dist/pkgroot
137+
dist-prepare-osx: PREPARE_STAGE=2
138+
dist-prepare-osx: PREPARE_DIR_CMD=$(DEFAULT_PREPARE_DIR_CMD)
139+
dist-prepare-osx: PREPARE_BIN_CMD=$(DEFAULT_PREPARE_BIN_CMD)
140+
dist-prepare-osx: PREPARE_LIB_CMD=$(DEFAULT_PREPARE_LIB_CMD)
141+
dist-prepare-osx: PREPARE_MAN_CMD=$(DEFAULT_PREPARE_MAN_CMD)
142+
dist-prepare-osx: prepare-base
143+
144+
$(PKG_OSX): Distribution.xml LICENSE.txt dist-prepare-osx
145+
@$(call E, making OS X pkg)
146+
$(Q)pkgbuild --identifier org.rust-lang.rust --root tmp/dist/pkgroot rust.pkg
147+
$(Q)productbuild --distribution Distribution.xml --resources . $(PKG_OSX)
148+
$(Q)rm -rf tmp rust.pkg
149+
150+
dist-osx: $(PKG_OSX)
151+
152+
distcheck-osx: $(PKG_OSX)
153+
@echo
154+
@echo -----------------------------------------------
155+
@echo $(PKG_OSX) ready for distribution
156+
@echo -----------------------------------------------
157+
158+
endif

src/doc/tutorial.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ fn main() {
133133
println!("hello?");
134134
}
135135
~~~~
136+
> ***Note:*** An identifier followed by an exclamation point, like
137+
> `println!`, is a macro invocation. Macros are explained
138+
> [later](#syntax-extensions); for now just remember to include the
139+
> exclamation point.
136140
137141
If the Rust compiler was installed successfully, running `rustc
138142
hello.rs` will produce an executable called `hello` (or `hello.exe` on
@@ -1059,7 +1063,7 @@ box, while the owner holds onto a pointer to it:
10591063
list -> | Cons | 1 | ~ | -> | Cons | 2 | ~ | -> | Cons | 3 | ~ | -> | Nil |
10601064
+--------------+ +--------------+ +--------------+ +--------------+
10611065

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

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

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

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

@@ -1218,6 +1222,9 @@ element type.
12181222

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

1225+
> ***Note:*** The following code introduces generics, which are explained in a
1226+
> [dedicated section](#generics).
1227+
12211228
~~~
12221229
enum List<T> {
12231230
Cons(T, ~List<T>),
@@ -1336,10 +1343,14 @@ impl<T: Eq> Eq for List<T> {
13361343
13371344
let xs = Cons(5, ~Cons(10, ~Nil));
13381345
let ys = Cons(5, ~Cons(10, ~Nil));
1346+
// The methods below are part of the Eq trait,
1347+
// which we implemented on our linked list.
13391348
assert!(xs.eq(&ys));
1340-
assert!(xs == ys);
13411349
assert!(!xs.ne(&ys));
1342-
assert!(!(xs != ys));
1350+
1351+
// The Eq trait also allows us to use the shorthand infix operators.
1352+
assert!(xs == ys); // `xs == ys` is short for `xs.eq(&ys)`
1353+
assert!(!(xs != ys)); // `xs != ys` is short for `xs.ne(&ys)`
13431354
~~~
13441355

13451356
# More on boxes

src/etc/ctags.rust

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--langdef=Rust
22
--langmap=Rust:.rs
3-
--regex-Rust=/^[ \t]*(pub[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\2/f,functions,function definitions/
3+
--regex-Rust=/^[ \t]*(#\[[^\]]\][ \t]*)*(pub[ \t]+)?(extern[ \t]+)?("[^"]+"[ \t]+)?(unsafe[ \t]+)?fn[ \t]+([a-zA-Z0-9_]+)/\6/f,functions,function definitions/
44
--regex-Rust=/^[ \t]*(pub[ \t]+)?type[ \t]+([a-zA-Z0-9_]+)/\2/T,types,type definitions/
55
--regex-Rust=/^[ \t]*(pub[ \t]+)?enum[ \t]+([a-zA-Z0-9_]+)/\2/g,enum,enumeration names/
66
--regex-Rust=/^[ \t]*(pub[ \t]+)?struct[ \t]+([a-zA-Z0-9_]+)/\2/s,structure names/

src/etc/pkg/Distribution.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="no"?>
2+
<installer-gui-script minSpecVersion="2">
3+
<title>Rust</title>
4+
<license file="LICENSE.txt" mime-type="text/plain"/>
5+
<pkg-ref id="org.rust-lang.rust"/>
6+
<options customize="never" require-scripts="false" hostArchitectures="i386,x86_64"/>
7+
<volume-check>
8+
<allowed-os-versions>
9+
<os-version min="10.7"/>
10+
</allowed-os-versions>
11+
</volume-check>
12+
<choices-outline>
13+
<line choice="default">
14+
<line choice="org.rust-lang.rust"/>
15+
</line>
16+
</choices-outline>
17+
<choice id="default"/>
18+
<choice id="org.rust-lang.rust" visible="false">
19+
<pkg-ref id="org.rust-lang.rust"/>
20+
</choice>
21+
<pkg-ref id="org.rust-lang.rust" version="0" onConclusion="none">rust.pkg</pkg-ref>
22+
</installer-gui-script>

src/etc/vim/ftplugin/rust.vim

+53-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" Vim syntax file
22
" Language: Rust
33
" Maintainer: Chris Morgan <[email protected]>
4-
" Last Change: 2013 Jul 10
4+
" Last Change: 2014 Feb 27
55

66
if exists("b:did_ftplugin")
77
finish
@@ -42,4 +42,55 @@ if exists("g:loaded_delimitMate")
4242
let b:delimitMate_excluded_regions = delimitMate#Get("excluded_regions") . ',rustLifetimeCandidate,rustGenericLifetimeCandidate'
4343
endif
4444

45-
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"
45+
" Bind motion commands to support hanging indents
46+
nnoremap <silent> <buffer> [[ :call <SID>Rust_Jump('n', 'Back')<CR>
47+
nnoremap <silent> <buffer> ]] :call <SID>Rust_Jump('n', 'Forward')<CR>
48+
xnoremap <silent> <buffer> [[ :call <SID>Rust_Jump('v', 'Back')<CR>
49+
xnoremap <silent> <buffer> ]] :call <SID>Rust_Jump('v', 'Forward')<CR>
50+
onoremap <silent> <buffer> [[ :call <SID>Rust_Jump('o', 'Back')<CR>
51+
onoremap <silent> <buffer> ]] :call <SID>Rust_Jump('o', 'Forward')<CR>
52+
53+
let b:undo_ftplugin = "
54+
\setlocal formatoptions< comments< commentstring< includeexpr< suffixesadd<
55+
\|if exists('b:rust_original_delimitMate_excluded_regions')
56+
\|let b:delimitMate_excluded_regions = b:rust_original_delimitMate_excluded_regions
57+
\|unlet b:rust_original_delimitMate_excluded_regions
58+
\|elseif exists('b:delimitMate_excluded_regions')
59+
\|unlet b:delimitMate_excluded_regions
60+
\|endif
61+
\|nunmap <buffer> [[
62+
\|nunmap <buffer> ]]
63+
\|xunmap <buffer> [[
64+
\|xunmap <buffer> ]]
65+
\|ounmap <buffer> [[
66+
\|ounmap <buffer> ]]
67+
\"
68+
69+
if exists('*<SID>Rust_Jump') | finish | endif
70+
71+
function! <SID>Rust_Jump(mode, function) range
72+
let cnt = v:count1
73+
normal! m'
74+
if a:mode ==# 'v'
75+
norm! gv
76+
endif
77+
let foldenable = &foldenable
78+
set nofoldenable
79+
while cnt > 0
80+
execute "call <SID>Rust_Jump_" . a:function . "()"
81+
let cnt = cnt - 1
82+
endwhile
83+
let &foldenable = foldenable
84+
endfunction
85+
86+
function! <SID>Rust_Jump_Back()
87+
call search('{', 'b')
88+
keepjumps normal! w99[{
89+
endfunction
90+
91+
function! <SID>Rust_Jump_Forward()
92+
normal! j0
93+
call search('{', 'b')
94+
keepjumps normal! w99[{%
95+
call search('{')
96+
endfunction

src/etc/vim/syntax/rust.vim

+15-24
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
" Maintainer: Patrick Walton <[email protected]>
44
" Maintainer: Ben Blum <[email protected]>
55
" Maintainer: Chris Morgan <[email protected]>
6-
" Last Change: 2014 Feb 14
6+
" Last Change: 2014 Feb 27
77

88
if version < 600
99
syntax clear
@@ -18,8 +18,8 @@ syn keyword rustOperator as
1818

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

3737
syn keyword rustExternCrate crate contained nextgroup=rustIdentifier skipwhite
38+
syn keyword rustObsoleteExternMod mod contained nextgroup=rustIdentifier skipwhite
3839

3940
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
4041
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
4142

4243
" Reserved (but not yet used) keywords {{{2
43-
syn keyword rustReservedKeyword alignof be offsetof pure sizeof typeof yield
44+
syn keyword rustReservedKeyword alignof be do offsetof pure sizeof typeof yield
4445

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

5354
" Core operators {{{3
54-
syn keyword rustTrait Sized
55-
syn keyword rustTrait Freeze Send
55+
syn keyword rustTrait Freeze Pod Send Sized
5656
syn keyword rustTrait Add Sub Mul Div Rem Neg Not
5757
syn keyword rustTrait BitAnd BitOr BitXor
5858
syn keyword rustTrait Drop
@@ -63,32 +63,25 @@ syn keyword rustEnum Result
6363
syn keyword rustEnumVariant Ok Err
6464

6565
" Functions {{{3
66-
"syn keyword rustFunction print println
67-
"syn keyword rustFunction range
6866
"syn keyword rustFunction from_str
67+
"syn keyword rustFunction range
68+
"syn keyword rustFunction drop
6969

7070
" Types and traits {{{3
7171
syn keyword rustTrait Any AnyOwnExt AnyRefExt AnyMutRefExt
7272
syn keyword rustTrait Ascii AsciiCast OwnedAsciiCast AsciiStr IntoBytes
73-
syn keyword rustTrait Bool
7473
syn keyword rustTrait ToCStr
7574
syn keyword rustTrait Char
7675
syn keyword rustTrait Clone DeepClone
7776
syn keyword rustTrait Eq Ord TotalEq TotalOrd Ordering Equiv
7877
syn keyword rustEnumVariant Less Equal Greater
7978
syn keyword rustTrait Container Mutable Map MutableMap Set MutableSet
80-
syn keyword rustTrait Default
81-
syn keyword rustTrait Hash
82-
syn keyword rustTrait FromStr
8379
syn keyword rustTrait FromIterator Extendable
8480
syn keyword rustTrait Iterator DoubleEndedIterator RandomAccessIterator CloneableIterator
8581
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator ExactSize
86-
87-
syn keyword rustTrait Algebraic Trigonometric Exponential Hyperbolic
88-
syn keyword rustTrait Bitwise Bounded Fractional
89-
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul CheckedDiv
90-
syn keyword rustTrait Orderable Signed Unsigned Round
91-
syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive
82+
syn keyword rustTrait Num NumCast CheckedAdd CheckedSub CheckedMul
83+
syn keyword rustTrait Signed Unsigned Round
84+
syn keyword rustTrait Primitive Int Float ToPrimitive FromPrimitive
9285
syn keyword rustTrait GenericPath Path PosixPath WindowsPath
9386
syn keyword rustTrait RawPtr
9487
syn keyword rustTrait Buffer Writer Reader Seek
@@ -98,20 +91,17 @@ syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
9891
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
9992
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
10093
syn keyword rustTrait ImmutableEqVector ImmutableTotalOrdVector ImmutableCloneableVector
101-
syn keyword rustTrait OwnedVector OwnedCloneableVector OwnedEqVector MutableVector
94+
syn keyword rustTrait OwnedVector OwnedCloneableVector OwnedEqVector
95+
syn keyword rustTrait MutableVector MutableTotalOrdVector
10296
syn keyword rustTrait Vector VectorVector CloneableVector ImmutableVector
10397

10498
"syn keyword rustFunction stream
105-
syn keyword rustTrait Port Chan GenericChan GenericSmartChan GenericPort Peekable
99+
syn keyword rustTrait Port Chan
106100
"syn keyword rustFunction spawn
107101

108102
syn keyword rustSelf self
109103
syn keyword rustBoolean true false
110104

111-
syn keyword rustConstant Some None " option
112-
syn keyword rustConstant Ok Err " result
113-
syn keyword rustConstant Less Equal Greater " Ordering
114-
115105
" Other syntax {{{2
116106

117107
" If foo::bar changes to foo.bar, change this ("::" to "\.").
@@ -247,6 +237,7 @@ hi def link rustObsoleteStorage Error
247237
hi def link rustLifetime Special
248238
hi def link rustInvalidBareKeyword Error
249239
hi def link rustExternCrate rustKeyword
240+
hi def link rustObsoleteExternMod Error
250241

251242
" Other Suggestions:
252243
" hi rustAttribute ctermfg=cyan

src/librustc/back/link.rs

+34-1
Original file line numberDiff line numberDiff line change
@@ -1132,8 +1132,41 @@ fn link_args(sess: Session,
11321132
args.push(~"-Wl,--allow-multiple-definition");
11331133
}
11341134

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

11391172
// # Telling the linker what we're doing

0 commit comments

Comments
 (0)