Skip to content

Commit 38a02ee

Browse files
committed
---
yaml --- r: 47039 b: refs/heads/try c: fe9f1d1 h: refs/heads/master i: 47037: e30f481 47035: 2086dfe 47031: 58dfff7 47023: 3e87146 47007: 2737d6b 46975: a0ffc72 v: v3
1 parent 58ce53a commit 38a02ee

File tree

12 files changed

+100
-219
lines changed

12 files changed

+100
-219
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: 3bbcac322669cff3abde5be937cc4ec3860f3985
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
5-
refs/heads/try: d3f3d0731cb1c6050b540bc5542b575dd19844fa
5+
refs/heads/try: fe9f1d155ab674e402cdb1b530df8ecb66bb7dd4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/etc/emacs/rust-mode.el

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
(require 'cm-mode)
99
(require 'cc-mode)
10+
(eval-when-compile (require 'cl))
1011

1112
(defun rust-electric-brace (arg)
1213
(interactive "*P")
@@ -16,12 +17,6 @@
1617
'(font-lock-comment-face font-lock-string-face))))
1718
(cm-indent)))
1819

19-
(defcustom rust-capitalized-idents-are-types t
20-
"If non-nil, capitalized identifiers will be treated as types for the purposes of font-lock mode"
21-
:type 'boolean
22-
:require 'rust-mode
23-
:group 'rust-mode)
24-
2520
(defvar rust-indent-unit 4)
2621
(defvar rust-syntax-table (let ((table (make-syntax-table)))
2722
(c-populate-syntax-table table)
@@ -106,7 +101,14 @@
106101
(rust-push-context st 'string (current-column) t)
107102
(setf (rust-state-tokenize st) 'rust-token-string)
108103
(rust-token-string st))
109-
(def ?\' (rust-single-quote))
104+
(def ?\' (forward-char)
105+
(setf rust-tcat 'atom)
106+
(let ((is-escape (eq (char-after) ?\\))
107+
(start (point)))
108+
(if (not (rust-eat-until-unescaped ?\'))
109+
'font-lock-warning-face
110+
(if (or is-escape (= (point) (+ start 2)))
111+
'font-lock-string-face 'font-lock-warning-face))))
110112
(def ?/ (forward-char)
111113
(case (char-after)
112114
(?/ (end-of-line) 'font-lock-comment-face)
@@ -120,7 +122,12 @@
120122
((rust-eat-re "[a-z_]+") (setf rust-tcat 'macro)))
121123
'font-lock-preprocessor-face)
122124
(def ((?a . ?z) (?A . ?Z) ?_)
123-
(rust-token-identifier))
125+
(rust-eat-re "[a-zA-Z_][a-zA-Z0-9_]*")
126+
(setf rust-tcat 'ident)
127+
(if (and (eq (char-after) ?:) (eq (char-after (+ (point) 1)) ?:)
128+
(not (eq (char-after (+ (point) 2)) ?:)))
129+
(progn (forward-char 2) 'font-lock-builtin-face)
130+
(match-string 0)))
124131
(def ((?0 . ?9))
125132
(rust-eat-re "0x[0-9a-fA-F_]+\\|0b[01_]+\\|[0-9_]+\\(\\.[0-9_]+\\)?\\(e[+\\-]?[0-9_]+\\)?")
126133
(setf rust-tcat 'atom)
@@ -143,31 +150,6 @@
143150
(setf rust-tcat 'op) nil)
144151
table)))
145152

146-
(defun rust-token-identifier ()
147-
(rust-eat-re "[a-zA-Z_][a-zA-Z0-9_]*")
148-
(setf rust-tcat 'ident)
149-
(if (and (eq (char-after) ?:) (eq (char-after (+ (point) 1)) ?:)
150-
(not (eq (char-after (+ (point) 2)) ?:)))
151-
(progn (forward-char 2) 'font-lock-builtin-face)
152-
(match-string 0)))
153-
154-
(defun rust-single-quote ()
155-
(forward-char)
156-
(setf rust-tcat 'atom)
157-
; Is this a lifetime?
158-
(if (or (looking-at "[a-zA-Z_]$")
159-
(looking-at "[a-zA-Z_][^']"))
160-
; If what we see is 'abc, use font-lock-builtin-face:
161-
(progn (rust-eat-re "[a-zA-Z_][a-zA-Z_0-9]*")
162-
'font-lock-builtin-face)
163-
; Otherwise, handle as a character constant:
164-
(let ((is-escape (eq (char-after) ?\\))
165-
(start (point)))
166-
(if (not (rust-eat-until-unescaped ?\'))
167-
'font-lock-warning-face
168-
(if (or is-escape (= (point) (+ start 2)))
169-
'font-lock-string-face 'font-lock-warning-face)))))
170-
171153
(defun rust-token-base (st)
172154
(funcall (char-table-range rust-char-table (char-after)) st))
173155

@@ -208,10 +190,6 @@
208190
(dolist (cx (rust-state-context st))
209191
(when (eq (rust-context-type cx) ?\}) (return (rust-context-info cx)))))
210192

211-
(defun rust-is-capitalized (string)
212-
(let ((case-fold-search nil))
213-
(string-match-p "[A-Z]" string)))
214-
215193
(defun rust-token (st)
216194
(let ((cx (car (rust-state-context st))))
217195
(when (bolp)
@@ -228,8 +206,6 @@
228206
(setf tok (cond ((eq tok-id 'atom) 'font-lock-constant-face)
229207
(tok-id 'font-lock-keyword-face)
230208
((equal (rust-state-last-token st) 'def) 'font-lock-function-name-face)
231-
((and rust-capitalized-idents-are-types
232-
(rust-is-capitalized tok)) 'font-lock-type-face)
233209
(t nil))))
234210
(when rust-tcat
235211
(when (eq (rust-context-align cx) 'unset)

branches/try/src/librustc/back/link.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,7 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
497497

498498
let cmh_items = attr::sort_meta_items(cmh_items);
499499

500-
symbol_hasher.reset();
501-
for cmh_items.each |m| {
500+
fn hash(symbol_hasher: &hash::State, m: &@ast::meta_item) {
502501
match m.node {
503502
ast::meta_name_value(ref key, value) => {
504503
symbol_hasher.write_str(len_and_str((*key)));
@@ -507,13 +506,20 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
507506
ast::meta_word(ref name) => {
508507
symbol_hasher.write_str(len_and_str((*name)));
509508
}
510-
ast::meta_list(_, _) => {
511-
// FIXME (#607): Implement this
512-
fail!(~"unimplemented meta_item variant");
509+
ast::meta_list(ref name, ref mis) => {
510+
symbol_hasher.write_str(len_and_str((*name)));
511+
for mis.each |m_| {
512+
hash(symbol_hasher, m_);
513+
}
513514
}
514515
}
515516
}
516517

518+
symbol_hasher.reset();
519+
for cmh_items.each |m| {
520+
hash(symbol_hasher, m);
521+
}
522+
517523
for dep_hashes.each |dh| {
518524
symbol_hasher.write_str(len_and_str(*dh));
519525
}

branches/try/src/libsyntax/ast.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ pub impl to_bytes::IterBytes for ident {
6767
// Functions may or may not have names.
6868
pub type fn_ident = Option<ident>;
6969
70-
pub struct Lifetime {
71-
id: node_id,
72-
span: span,
73-
ident: ident
74-
}
75-
7670
#[auto_encode]
7771
#[auto_decode]
7872
#[deriving_eq]

branches/try/src/libsyntax/attr.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,13 +192,15 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
192192
}
193193
_ => false
194194
},
195-
ast::meta_list(*) => {
196-
197-
// ~[Fixme-sorting]
198-
// FIXME (#607): Needs implementing
199-
// This involves probably sorting the list by name and
200-
// meta_item variant
201-
fail!(~"unimplemented meta_item variant")
195+
ast::meta_list(ref na, misa) => match b.node {
196+
ast::meta_list(ref nb, misb) => {
197+
if na != nb { return false; }
198+
for misa.each |&mi| {
199+
if !contains(misb, mi) { return false; }
200+
}
201+
true
202+
}
203+
_ => false
202204
}
203205
}
204206
}
@@ -253,8 +255,6 @@ pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: ~str)
253255

254256
/* Higher-level applications */
255257

256-
// FIXME (#607): This needs to sort by meta_item variant in addition to
257-
// the item name (See [Fixme-sorting])
258258
pub fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] {
259259
pure fn lteq(ma: &@ast::meta_item, mb: &@ast::meta_item) -> bool {
260260
pure fn key(m: &ast::meta_item) -> ~str {
@@ -270,7 +270,17 @@ pub fn sort_meta_items(+items: ~[@ast::meta_item]) -> ~[@ast::meta_item] {
270270
// This is sort of stupid here, converting to a vec of mutables and back
271271
let mut v: ~[@ast::meta_item] = items;
272272
std::sort::quick_sort(v, lteq);
273-
v
273+
274+
// There doesn't seem to be a more optimal way to do this
275+
do v.map |&m| {
276+
match m.node {
277+
ast::meta_list(n, mis) => @spanned {
278+
node: ast::meta_list(n, sort_meta_items(mis)),
279+
.. *m
280+
},
281+
_ => m
282+
}
283+
}
274284
}
275285

276286
pub fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: ~str) ->

0 commit comments

Comments
 (0)