Skip to content

Commit bf80976

Browse files
committedAug 10, 2013
auto merge of #8444 : erickt/rust/rollup, r=cmr
This merges these PR together: #8430: r=thestinger #8370: r=thestinger #8386: r=bstrie #8388: r=thestinger #8390: r=graydon #8394: r=graydon #8402: r=thestinger #8403: r=catamorphism
2 parents 8b9e1ce + 20953bb commit bf80976

28 files changed

+594
-171
lines changed
 

‎doc/tutorial.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ match crayons[0] {
13051305
A vector can be destructured using pattern matching:
13061306
13071307
~~~~
1308-
let numbers: [int, ..3] = [1, 2, 3];
1308+
let numbers: &[int] = &[1, 2, 3];
13091309
let score = match numbers {
13101310
[] => 0,
13111311
[a] => a * 10,
@@ -2195,7 +2195,7 @@ use std::float::consts::pi;
21952195
# impl Shape for CircleStruct { fn area(&self) -> float { pi * square(self.radius) } }
21962196
21972197
let concrete = @CircleStruct{center:Point{x:3f,y:4f},radius:5f};
2198-
let mycircle: Circle = concrete as @Circle;
2198+
let mycircle: @Circle = concrete as @Circle;
21992199
let nonsense = mycircle.radius() * mycircle.area();
22002200
~~~
22012201

‎src/etc/emacs/rust-mode.el

+11-6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929

3030
table))
3131

32+
(defcustom rust-indent-offset default-tab-width
33+
"*Indent Rust code by this number of spaces.
34+
35+
The initializer is `DEFAULT-TAB-WIDTH'.")
36+
3237
(defun rust-paren-level () (nth 0 (syntax-ppss)))
3338
(defun rust-in-str-or-cmnt () (nth 8 (syntax-ppss)))
3439
(defun rust-rewind-past-str-cmnt () (goto-char (nth 8 (syntax-ppss))))
@@ -49,10 +54,10 @@
4954
(let ((level (rust-paren-level)))
5055
(cond
5156
;; A function return type is 1 level indented
52-
((looking-at "->") (* default-tab-width (+ level 1)))
57+
((looking-at "->") (* rust-indent-offset (+ level 1)))
5358

5459
;; A closing brace is 1 level unindended
55-
((looking-at "}") (* default-tab-width (- level 1)))
60+
((looking-at "}") (* rust-indent-offset (- level 1)))
5661

5762
;; If we're in any other token-tree / sexp, then:
5863
;; - [ or ( means line up with the opening token
@@ -70,18 +75,18 @@
7075
(goto-char pt)
7176
(back-to-indentation)
7277
(if (looking-at "\\<else\\>")
73-
(* default-tab-width (+ 1 level))
78+
(* rust-indent-offset (+ 1 level))
7479
(progn
7580
(goto-char pt)
7681
(beginning-of-line)
7782
(rust-rewind-irrelevant)
7883
(end-of-line)
7984
(if (looking-back "[{};,]")
80-
(* default-tab-width level)
85+
(* rust-indent-offset level)
8186
(back-to-indentation)
8287
(if (looking-at "#")
83-
(* default-tab-width level)
84-
(* default-tab-width (+ 1 level))))))))))
88+
(* rust-indent-offset level)
89+
(* rust-indent-offset (+ 1 level))))))))))
8590

8691
;; Otherwise we're in a column-zero definition
8792
(t 0))))))

‎src/librustc/middle/check_match.rs

+26
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
255255
}
256256
not_useful
257257
}
258+
ty::ty_evec(_, ty::vstore_fixed(n)) => {
259+
is_useful_specialized(cx, m, v, vec(n), n, left_ty)
260+
}
258261
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
259262
let max_len = do m.rev_iter().fold(0) |max_len, r| {
260263
match r[0].node {
@@ -409,6 +412,29 @@ pub fn missing_ctor(cx: &MatchCheckCtxt,
409412
else if true_found { Some(val(const_bool(false))) }
410413
else { Some(val(const_bool(true))) }
411414
}
415+
ty::ty_evec(_, ty::vstore_fixed(n)) => {
416+
let mut missing = true;
417+
let mut wrong = false;
418+
for r in m.iter() {
419+
match r[0].node {
420+
pat_vec(ref before, ref slice, ref after) => {
421+
let count = before.len() + after.len();
422+
if (count < n && slice.is_none()) || count > n {
423+
wrong = true;
424+
}
425+
if count == n || (count < n && slice.is_some()) {
426+
missing = false;
427+
}
428+
}
429+
_ => {}
430+
}
431+
}
432+
match (wrong, missing) {
433+
(true, _) => Some(vec(n)), // should be compile-time error
434+
(_, true) => Some(vec(n)),
435+
_ => None
436+
}
437+
}
412438
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
413439

414440
// Find the lengths and slices of all vector patterns.

‎src/librustc/middle/privacy.rs

+1
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
403403
// Ditto
404404
match ty::get(ty::type_autoderef(tcx, ty::expr_ty(tcx,
405405
base))).sty {
406+
ty_enum(id, _) |
406407
ty_struct(id, _)
407408
if id.crate != LOCAL_CRATE ||
408409
!privileged_items.iter().any(|x| x == &(id.node)) => {

0 commit comments

Comments
 (0)
Please sign in to comment.