Skip to content

Commit 2976b04

Browse files
committed
---
yaml --- r: 94072 b: refs/heads/try c: ad58e2c h: refs/heads/master v: v3
1 parent 534f282 commit 2976b04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+811
-604
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 0da105a8b7b6b1e0568e8ff20f6ff4b13cc7ecc2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d3e57dca68fde4effdda3e4ae2887aa535fcd6
5-
refs/heads/try: c00837e90ade4baaae6639b4a89b26636ca01227
5+
refs/heads/try: ad58e2c31c7abf88590c321bb939583ee8e4048f
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/Makefile.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ endif
134134
# static copies of libstd and libextra. We also generate dynamic versions of all
135135
# libraries, so in the interest of space, prefer dynamic linking throughout the
136136
# compilation process.
137+
RUSTFLAGS_STAGE0 += -Z prefer-dynamic
137138
RUSTFLAGS_STAGE1 += -Z prefer-dynamic
138139
RUSTFLAGS_STAGE2 += -Z prefer-dynamic
139140
RUSTFLAGS_STAGE3 += -Z prefer-dynamic

branches/try/configure

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,11 +893,11 @@ do
893893
LLVM_CC_64="ccache clang -Qunused-arguments"
894894
;;
895895
("clang")
896-
LLVM_CXX_32="clang++ -m32"
897-
LLVM_CC_32="clang -m32"
896+
LLVM_CXX_32="clang++ -m32 -Qunused-arguments"
897+
LLVM_CC_32="clang -m32 -Qunused-arguments"
898898

899-
LLVM_CXX_64="clang++"
900-
LLVM_CC_64="clang"
899+
LLVM_CXX_64="clang++ -Qunused-arguments"
900+
LLVM_CC_64="clang -Qunused-arguments"
901901
;;
902902
("ccache gcc")
903903
LLVM_CXX_32="ccache g++ -m32"

branches/try/doc/rust.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3225,6 +3225,32 @@ let bo: Binop = add;
32253225
x = bo(5,7);
32263226
~~~~
32273227

3228+
### Closure types
3229+
3230+
The type of a closure mapping an input of type `A` to an output of type `B` is `|A| -> B`. A closure with no arguments or return values has type `||`.
3231+
3232+
3233+
An example of creating and calling a closure:
3234+
3235+
```rust
3236+
let captured_var = 10;
3237+
3238+
let closure_no_args = || println!("captured_var={}", captured_var);
3239+
3240+
let closure_args = |arg: int| -> int {
3241+
println!("captured_var={}, arg={}", captured_var, arg);
3242+
arg // Note lack of semicolon after 'arg'
3243+
};
3244+
3245+
fn call_closure(c1: ||, c2: |int| -> int) {
3246+
c1();
3247+
c2(2);
3248+
}
3249+
3250+
call_closure(closure_no_args, closure_args);
3251+
3252+
```
3253+
32283254
### Object types
32293255

32303256
Every trait item (see [traits](#traits)) defines a type with the same name as the trait.

branches/try/mk/platform.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,15 @@ AR := ar
8888

8989
CFG_INFO := $(info cfg: using $(CFG_C_COMPILER))
9090
ifeq ($(CFG_C_COMPILER),clang)
91+
# The -Qunused-arguments sidesteps spurious warnings from clang
9192
ifeq ($(origin CC),default)
92-
CC=clang
93+
CC=clang -Qunused-arguments
9394
endif
9495
ifeq ($(origin CXX),default)
95-
CXX=clang++
96+
CXX=clang++ -Qunused-arguments
9697
endif
9798
ifeq ($(origin CPP),default)
98-
CPP=clang
99+
CPP=clang -Qunused-arguments
99100
endif
100101
else
101102
ifeq ($(CFG_C_COMPILER),gcc)

branches/try/mk/tests.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,11 +920,11 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),rmake): \
920920

921921
$(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
922922
$(S)src/test/run-make/%/Makefile \
923-
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3))
923+
$$(HSREQ$(1)_H_$(3))
924924
@rm -rf $(3)/test/run-make/$$*
925925
@mkdir -p $(3)/test/run-make/$$*
926926
@echo maketest: $$*
927-
$$(Q)python $(S)src/etc/maketest.py $$(dir $$<) \
927+
$$(Q)$$(CFG_PYTHON) $(S)src/etc/maketest.py $$(dir $$<) \
928928
$$(HBIN$(1)_H_$(3))/rustc$$(X_$(3)) \
929929
$(3)/test/run-make/$$* \
930930
"$$(CC_$(3)) $$(CFG_GCCISH_CFLAGS_$(3))"

branches/try/src/compiletest/procsrv.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ pub fn run(lib_path: &str,
6060
for input in input.iter() {
6161
process.input().write(input.as_bytes());
6262
}
63-
let output = process.finish_with_output();
63+
let run::ProcessOutput { status, output, error } = process.finish_with_output();
6464

6565
Result {
66-
status: output.status,
67-
out: str::from_utf8(output.output),
68-
err: str::from_utf8(output.error)
66+
status: status,
67+
out: str::from_utf8_owned(output),
68+
err: str::from_utf8_owned(error)
6969
}
7070
}
7171

@@ -90,4 +90,3 @@ pub fn run_background(lib_path: &str,
9090

9191
return process;
9292
}
93-

branches/try/src/compiletest/runtest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
298298

299299
let adb_arg = format!("export LD_LIBRARY_PATH={}; gdbserver :5039 {}/{}",
300300
config.adb_test_dir.clone(), config.adb_test_dir.clone(),
301-
str::from_utf8(exe_file.filename().unwrap())).clone();
301+
str::from_utf8(exe_file.filename().unwrap()));
302302

303303
let mut process = procsrv::run_background("", config.adb_path.clone(),
304304
[~"shell",adb_arg.clone()],~[(~"",~"")], Some(~""));
@@ -1151,4 +1151,3 @@ fn run_codegen_test(config: &config, props: &TestProps,
11511151
(base_lines as f64) / (clang_lines as f64),
11521152
0.001);
11531153
}
1154-

branches/try/src/etc/vim/syntax/rust.vim

Lines changed: 42 additions & 36 deletions
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: 2013 Oct 29
6+
" Last Change: 2013 Dec 04
77

88
if version < 600
99
syntax clear
@@ -28,6 +28,7 @@ syn keyword rustKeyword use nextgroup=rustModPath skipwhite
2828
" FIXME: Scoped impl's name is also fallen in this category
2929
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite
3030
syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite
31+
syn keyword rustKeyword proc
3132
syn keyword rustStorage const mut ref static
3233

3334
syn match rustIdentifier contains=rustIdentifierPrime "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
@@ -89,6 +90,7 @@ syn keyword rustTrait Orderable Signed Unsigned Round
8990
syn keyword rustTrait Primitive Int Float ToStrRadix ToPrimitive FromPrimitive
9091
syn keyword rustTrait GenericPath Path PosixPath WindowsPath
9192
syn keyword rustTrait RawPtr
93+
syn keyword rustTrait Buffer Writer Reader Seek
9294
syn keyword rustTrait SendStr SendStrOwned SendStrStatic IntoSendStr
9395
syn keyword rustTrait Str StrVector StrSlice OwnedStr
9496
syn keyword rustTrait IterBytes
@@ -143,38 +145,29 @@ syn match rustOperator display "&&\|||"
143145
syn match rustMacro '\w\(\w\)*!' contains=rustAssert,rustFail
144146
syn match rustMacro '#\w\(\w\)*' contains=rustAssert,rustFail
145147

146-
syn match rustFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlLjzt]\|ll\|hh\)\=\([aAbdiuoxXDOUfFeEgGcCsSpn?]\|\[\^\=.[^]]*\]\)" contained
147-
syn match rustFormat display "%%" contained
148+
syn match rustSpecialError display contained /\\./
148149
syn match rustSpecial display contained /\\\([nrt0\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)/
149150
syn match rustStringContinuation display contained /\\\n\s*/
150-
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustTodo,rustFormat,rustSpecial,rustStringContinuation
151+
syn region rustString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=rustSpecial,rustSpecialError,rustStringContinuation
151152
syn region rustString start='r\z(#*\)"' end='"\z1'
152153

153154
syn region rustAttribute start="#\[" end="\]" contains=rustString,rustDeriving
154155
syn region rustDeriving start="deriving(" end=")" contained contains=rustTrait
155156

156157
" Number literals
157-
syn match rustNumber display "\<[0-9][0-9_]*\>"
158-
syn match rustNumber display "\<[0-9][0-9_]*\(u\|u8\|u16\|u32\|u64\)\>"
159-
syn match rustNumber display "\<[0-9][0-9_]*\(i\|i8\|i16\|i32\|i64\)\>"
160-
161-
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\>"
162-
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\(u\|u8\|u16\|u32\|u64\)\>"
163-
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\(i8\|i16\|i32\|i64\)\>"
164-
syn match rustOctNumber display "\<0o[0-7_]\+\>"
165-
syn match rustOctNumber display "\<0o[0-7_]\+\(u\|u8\|u16\|u32\|u64\)\>"
166-
syn match rustOctNumber display "\<0o[0-7_]\+\(i8\|i16\|i32\|i64\)\>"
167-
syn match rustBinNumber display "\<0b[01_]\+\>"
168-
syn match rustBinNumber display "\<0b[01_]\+\(u\|u8\|u16\|u32\|u64\)\>"
169-
syn match rustBinNumber display "\<0b[01_]\+\(i8\|i16\|i32\|i64\)\>"
170-
171-
syn match rustFloat display "\<[0-9][0-9_]*\(f\|f32\|f64\)\>"
172-
syn match rustFloat display "\<[0-9][0-9_]*\([eE][+-]\=[0-9_]\+\)\>"
173-
syn match rustFloat display "\<[0-9][0-9_]*\([eE][+-]\=[0-9_]\+\)\(f\|f32\|f64\)\>"
174-
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\>"
175-
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\(f\|f32\|f64\)\>"
176-
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\>"
177-
syn match rustFloat display "\<[0-9][0-9_]*\.[0-9_]\+\%([eE][+-]\=[0-9_]\+\)\(f\|f32\|f64\)\>"
158+
syn match rustDecNumber display "\<[0-9][0-9_]*\%([iu]\%(8\|16\|32\|64\)\=\)\="
159+
syn match rustHexNumber display "\<0x[a-fA-F0-9_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\="
160+
syn match rustOctNumber display "\<0o[0-7_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\="
161+
syn match rustBinNumber display "\<0b[01_]\+\%([iu]\%(8\|16\|32\|64\)\=\)\="
162+
163+
" To mark it as a float, it must have at least one of the three things integral values don't have:
164+
" a decimal point and more numbers; an exponent; and a type suffix.
165+
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)\="
166+
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\(f32\|f64\)\="
167+
syn match rustFloat display "\<[0-9][0-9_]*\%(\.[0-9][0-9_]*\)\=\%([eE][+-]\=[0-9_]\+\)\=\(f32\|f64\)"
168+
" Special case for numbers of the form "1." which are float literals, unless followed by
169+
" an identifier, which makes them integer literals with a method call or field access.
170+
syn match rustFloat display "\<[0-9][0-9_]*\.\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\@!"
178171

179172
" For the benefit of delimitMate
180173
syn region rustLifetimeCandidate display start=/&'\%(\([^'\\]\|\\\(['nrt0\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'\)\@!/ end=/[[:cntrl:][:space:][:punct:]]\@=\|$/ contains=rustSigil,rustLifetime
@@ -183,12 +176,24 @@ syn region rustGenericLifetimeCandidate display start=/\%(<\|,\s*\)\@<='/ end=/[
183176

184177
"rustLifetime must appear before rustCharacter, or chars will get the lifetime highlighting
185178
syn match rustLifetime display "\'\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*"
186-
syn match rustCharacter /'\([^'\\]\|\\\([nrt0\\'"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustSpecial
187-
188-
syn region rustCommentML start="/\*" end="\*/" contains=rustTodo
189-
syn region rustComment start="//" end="$" contains=rustTodo keepend
190-
syn region rustCommentMLDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo
191-
syn region rustCommentDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo keepend
179+
syn match rustCharacter /'\([^'\\]\|\\\(.\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'/ contains=rustSpecial,rustSpecialError
180+
181+
syn cluster rustComment contains=rustCommentLine,rustCommentLineDoc,rustCommentBlock,rustCommentBlockDoc
182+
syn region rustCommentLine start="//" end="$" contains=rustTodo
183+
syn region rustCommentLineDoc start="//\%(//\@!\|!\)" end="$" contains=rustTodo
184+
syn region rustCommentBlock matchgroup=rustCommentBlock start="/\*\%(!\|\*[*/]\@!\)\@!" end="\*/" contains=rustTodo,@rustComment keepend extend
185+
syn region rustCommentBlockDoc matchgroup=rustCommentBlockDoc start="/\*\%(!\|\*[*/]\@!\)" end="\*/" contains=rustTodo,@rustComment keepend extend
186+
" FIXME: this is a really ugly and not fully correct implementation. Most
187+
" importantly, a case like ``/* */*`` should have the final ``*`` not being in
188+
" a comment, but in practice at present it leaves comments open two levels
189+
" deep. But as long as you stay away from that particular case, I *believe*
190+
" the highlighting is correct. Due to the way Vim's syntax engine works
191+
" (greedy for start matches, unlike Rust's tokeniser which is searching for
192+
" the earliest-starting match, start or end), I believe this cannot be solved.
193+
" Oh you who would fix it, don't bother with things like duplicating the Block
194+
" rules and putting ``\*\@<!`` at the start of them; it makes it worse, as
195+
" then you must deal with cases like ``/*/**/*/``. And don't try making it
196+
" worse with ``\%(/\@<!\*\)\@<!``, either...
192197

193198
syn keyword rustTodo contained TODO FIXME XXX NB NOTE
194199

@@ -200,15 +205,16 @@ syn region rustFoldBraces start="{" end="}" transparent fold
200205
" It's not enabled by default as it would drive some people mad.
201206

202207
" Default highlighting {{{1
208+
hi def link rustDecNumber rustNumber
203209
hi def link rustHexNumber rustNumber
204210
hi def link rustOctNumber rustNumber
205211
hi def link rustBinNumber rustNumber
206212
hi def link rustIdentifierPrime rustIdentifier
207213
hi def link rustTrait rustType
208214

209215
hi def link rustSigil StorageClass
210-
hi def link rustFormat Special
211216
hi def link rustSpecial Special
217+
hi def link rustSpecialError Error
212218
hi def link rustStringContinuation Special
213219
hi def link rustString String
214220
hi def link rustCharacter Character
@@ -229,10 +235,10 @@ hi def link rustModPathSep Delimiter
229235
hi def link rustFunction Function
230236
hi def link rustFuncName Function
231237
hi def link rustFuncCall Function
232-
hi def link rustCommentMLDoc rustCommentDoc
233-
hi def link rustCommentDoc SpecialComment
234-
hi def link rustCommentML rustComment
235-
hi def link rustComment Comment
238+
hi def link rustCommentLine Comment
239+
hi def link rustCommentLineDoc SpecialComment
240+
hi def link rustCommentBlock rustCommentLine
241+
hi def link rustCommentBlockDoc rustCommentLineDoc
236242
hi def link rustAssert PreCondit
237243
hi def link rustFail PreCondit
238244
hi def link rustMacro Macro

branches/try/src/libextra/base64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ impl<'self> FromBase64 for &'self str {
162162
* Convert any base64 encoded string (literal, `@`, `&`, or `~`)
163163
* to the byte values it encodes.
164164
*
165-
* You can use the `from_utf8` function in `std::str`
165+
* You can use the `from_utf8_owned` function in `std::str`
166166
* to turn a `[u8]` into a string with characters corresponding to those
167167
* values.
168168
*
@@ -180,7 +180,7 @@ impl<'self> FromBase64 for &'self str {
180180
* println!("base64 output: {}", hello_str);
181181
* let res = hello_str.from_base64();
182182
* if res.is_ok() {
183-
* let optBytes = str::from_utf8_opt(res.unwrap());
183+
* let optBytes = str::from_utf8_owned_opt(res.unwrap());
184184
* if optBytes.is_some() {
185185
* println!("decoded from base64: {}", optBytes.unwrap());
186186
* }

0 commit comments

Comments
 (0)