Skip to content

Commit f924432

Browse files
committed
---
yaml --- r: 15724 b: refs/heads/try c: d0d7183 h: refs/heads/master v: v3
1 parent c133645 commit f924432

File tree

10 files changed

+91
-52
lines changed

10 files changed

+91
-52
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: 1e44e04a9dc0f801492ea1630d6a42e9df07af99
5+
refs/heads/try: d0d71838cdf1bdcb7c61c8dc62c3409545b850ae
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

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

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,11 @@ if !exists("main_syntax")
1515
endif
1616

1717
syn keyword rustKeyword alt as assert be bind break
18-
syn keyword rustKeyword check claim cont const copy do else export fail
19-
syn keyword rustKeyword for if impl import in inline lambda let log
18+
syn keyword rustKeyword check claim cont const copy do else enum export fail
19+
syn keyword rustKeyword fn for if iface impl import in inline lambda let log
2020
syn keyword rustKeyword loop mod mut mutable native note of prove pure
21-
syn keyword rustKeyword ret self syntax to unchecked
21+
syn keyword rustKeyword resource ret self syntax to type unchecked
2222
syn keyword rustKeyword unsafe use while with
23-
" FIXME: Scoped impl's name is also fallen in this category
24-
syn keyword rustKeyword mod iface resource class enum type nextgroup=rustIdentifier skipwhite
25-
syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite
26-
27-
syn match rustIdentifier "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
28-
syn match rustFuncName "\%([^[:cntrl:][:space:][:punct:][:digit:]]\|_\)\%([^[:cntrl:][:punct:][:space:]]\|_\)*" display contained
2923

3024
" Reserved words
3125
syn keyword rustKeyword m32 m64 m128 f80 f16 f128 class trait
@@ -39,45 +33,32 @@ syn match rustItemPath "\(\w\|::\)\+"
3933

4034
syn region rustString start=+L\="+ skip=+\\\\\|\\"+ end=+"+
4135

42-
" Number/Float literals
43-
syn match rustNumber display "\<\d\>"
44-
syn match rustNumber display "\<[1-9]\d\+\>"
45-
syn match rustNumber display "\<\d\+\(u\|u8\|u16\|u32\|u64\)\>"
46-
syn match rustNumber display "\<\d\+\(i8\|i16\|i32\|i64\)\>"
47-
48-
syn match rustHexNumber display "\<0[xX]\x\+\>"
49-
syn match rustHexNumber display "\<0[xX]\x\+_\(u\|u8\|u16\|u32\|u64\)\>"
50-
syn match rustHexNumber display "\<0[xX]\x\+_\(i8\|i16\|i32\|i64\)\>"
51-
syn match rustOctNumber display "\<0\o\+\>"
52-
syn match rustOctNumber display "\<0\o\+_\(u\|u8\|u16\|u32\|u64\)\>"
53-
syn match rustOctNumber display "\<0\o\+_\(i8\|i16\|i32\|i64\)\>"
54-
syn match rustBinNumber display "\<0[bB][01]\+\>"
55-
syn match rustBinNumber display "\<0[bB][01]\+_\(u\|u8\|u16\|u32\|u64\)\>"
56-
syn match rustBinNumber display "\<0[bB][01]\+_\(i8\|i16\|i32\|i64\)\>"
57-
58-
syn match rustFloat display "\.\d\+\%([eE][+-]\=\d\+\)\=\>"
59-
syn match rustFloat display "\<\d\+[eE][+-]\=\d\+\>"
60-
syn match rustFloat display "\<\d\+\.\d*\%([eE][+-]\=\d\+\)\="
36+
"integer number, or floating point number without a dot and with "f".
37+
syn case ignore
38+
syn match rustNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
39+
"hex number
40+
syn match rustNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
41+
syn match rustFloat display contained "\d\+f"
42+
"floating point number, with dot, optional exponent
43+
syn match rustFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
44+
"floating point number, starting with a dot, optional exponent
45+
syn match rustFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
46+
"floating point number, without dot, with exponent
47+
syn match rustFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
48+
49+
syn case match
6150

6251
syn match rustCharacter "'\([^'\\]\|\\\(['nrt\\\"]\|x\x\{2}\|u\x\{4}\|U\x\{8}\)\)'"
6352

64-
syn region rustComment start="/\*" end="\*/" contains=rustComment,rustTodo
65-
syn region rustComment start="//" skip="\\$" end="$" contains=rustTodo keepend
66-
67-
syn keyword rustTodo TODO FIXME XXX NB
68-
69-
hi def link rustHexNumber rustNumber
70-
hi def link rustOctNumber rustNumber
71-
hi def link rustBinNumber rustNumber
53+
syn region rustComment start="/\*" end="\*/" contains=rustComment
54+
syn region rustComment start="//" skip="\\$" end="$" keepend
7255

7356
hi def link rustString String
7457
hi def link rustCharacter Character
7558
hi def link rustNumber Number
7659
hi def link rustBoolean Boolean
7760
hi def link rustFloat Float
7861
hi def link rustKeyword Keyword
79-
hi def link rustIdentifier Identifier
80-
hi def link rustFuncName Function
8162
hi def link rustComment Comment
8263
hi def link rustMacro Macro
8364
hi def link rustType Type

branches/try/src/libcore/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ unsafe fn memmove<T>(dst: *T, src: *T, count: uint) {
104104
#[doc = "Extension methods for pointers"]
105105
impl extensions<T> for *T {
106106
#[doc = "Returns true if the pointer is equal to the null pointer."]
107-
pure fn is_null<T>() -> bool { is_null(self) }
107+
pure fn is_null() -> bool { is_null(self) }
108108

109109
#[doc = "Returns true if the pointer is not equal to the null pointer."]
110-
pure fn is_not_null<T>() -> bool { is_not_null(self) }
110+
pure fn is_not_null() -> bool { is_not_null(self) }
111111
}
112112

113113
#[test]

branches/try/src/rustc/middle/check_alt.rs

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: [@pat]) -> useful {
122122

123123
alt pat_ctor_id(tcx, v[0]) {
124124
none {
125-
if is_complete(tcx, m, left_ty) {
125+
alt missing_ctor(tcx, m, left_ty) {
126+
none {
126127
alt ty::get(left_ty).struct {
127128
ty::ty_bool {
128129
alt is_useful_specialized(tcx, m, v, val(const_int(1i64)),
@@ -149,9 +150,14 @@ fn is_useful(tcx: ty::ctxt, m: matrix, v: [@pat]) -> useful {
149150
is_useful_specialized(tcx, m, v, single, arity, left_ty)
150151
}
151152
}
152-
} else {
153-
is_useful(tcx, vec::filter_map(m, {|r| default(tcx, r)}),
154-
vec::tail(v))
153+
}
154+
some(ctor) {
155+
alt is_useful(tcx, vec::filter_map(m, {|r| default(tcx, r)}),
156+
vec::tail(v)) {
157+
useful_ { useful(left_ty, ctor) }
158+
u { u }
159+
}
160+
}
155161
}
156162
}
157163
some(v0_ctor) {
@@ -202,13 +208,13 @@ fn is_wild(tcx: ty::ctxt, p: @pat) -> bool {
202208
}
203209
}
204210

205-
fn is_complete(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> bool {
211+
fn missing_ctor(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> option<ctor> {
206212
alt ty::get(left_ty).struct {
207213
ty::ty_box(_) | ty::ty_uniq(_) | ty::ty_tup(_) | ty::ty_rec(_) {
208214
for m.each {|r|
209-
if !is_wild(tcx, r[0]) { ret true; }
215+
if !is_wild(tcx, r[0]) { ret none; }
210216
}
211-
ret false;
217+
ret some(single);
212218
}
213219
ty::ty_enum(eid, _) {
214220
let mut found = [];
@@ -217,9 +223,17 @@ fn is_complete(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> bool {
217223
if !vec::contains(found, id) { found += [id]; }
218224
}
219225
}
220-
found.len() == (*ty::enum_variants(tcx, eid)).len()
226+
let variants = ty::enum_variants(tcx, eid);
227+
if found.len() != (*variants).len() {
228+
for vec::each(*variants) {|v|
229+
if !found.contains(variant(v.id)) {
230+
ret some(variant(v.id));
231+
}
232+
}
233+
fail;
234+
} else { none }
221235
}
222-
ty::ty_nil { true }
236+
ty::ty_nil { none }
223237
ty::ty_bool {
224238
let mut true_found = false, false_found = false;
225239
for m.each {|r|
@@ -229,9 +243,11 @@ fn is_complete(tcx: ty::ctxt, m: matrix, left_ty: ty::t) -> bool {
229243
some(val(const_int(0i64))) { false_found = true; }
230244
}
231245
}
232-
true_found && false_found
246+
if true_found && false_found { none }
247+
else if true_found { some(val(const_int(0i64))) }
248+
else { some(val(const_int(1i64))) }
233249
}
234-
_ { false }
250+
_ { some(single) }
235251
}
236252
}
237253

branches/try/src/rustc/middle/typeck.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2738,6 +2738,25 @@ impl methods for lookup {
27382738
self.tcx().sess.span_err(
27392739
self.expr.span,
27402740
"multiple applicable methods in scope");
2741+
2742+
// I would like to print out how each impl was imported,
2743+
// but I cannot for the life of me figure out how to
2744+
// annotate resolve to preserve this information.
2745+
for results.eachi { |i, result|
2746+
let (_, _, did) = result;
2747+
let span = if did.crate == ast::local_crate {
2748+
alt check self.tcx().items.get(did.node) {
2749+
ast_map::node_method(m, _, _) { m.span }
2750+
}
2751+
} else {
2752+
self.expr.span
2753+
};
2754+
self.tcx().sess.span_note(
2755+
span,
2756+
#fmt["candidate #%u is %s",
2757+
(i+1u),
2758+
ty::item_path_str(self.tcx(), did)]);
2759+
}
27412760
}
27422761

27432762
let (self_substs, n_tps, did) = results[0];
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
impl methods1 for uint { fn me() -> uint { self } }
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
impl methods1 for uint { fn me() -> uint { self } } //! NOTE candidate #1 is methods1::me
2+
impl methods2 for uint { fn me() -> uint { self } } //! NOTE candidate #2 is methods2::me
3+
fn main() { 1u.me(); } //! ERROR multiple applicable methods in scope
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// xfail-fast aux-build
2+
// aux-build:ambig_impl_2_lib.rs
3+
use ambig_impl_2_lib;
4+
import ambig_impl_2_lib::methods1;
5+
impl methods2 for uint { fn me() -> uint { self } } //! NOTE candidate #2 is methods2::me
6+
fn main() { 1u.me(); } //! ERROR multiple applicable methods in scope
7+
//!^ NOTE candidate #1 is ambig_impl_2_lib::methods1::me

branches/try/src/test/compile-fail/non-exhaustive-match.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ fn main() {
1616
(a, b) {}
1717
(b, a) {}
1818
}
19+
alt a { //! ERROR b not covered
20+
a {}
21+
}
1922
// This is exhaustive, though the algorithm got it wrong at one point
2023
alt (a, b) {
2124
(a, _) {}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fn main() {
2+
let p: *int = ptr::null();
3+
assert p.is_null();
4+
assert !p.is_not_null();
5+
6+
let q = ptr::offset(p, 1u);
7+
assert !q.is_null();
8+
assert q.is_not_null();
9+
}

0 commit comments

Comments
 (0)