Skip to content

Commit e95f21f

Browse files
committed
convert SyntaxExtensions's key to a @~str
1 parent de5fdaf commit e95f21f

File tree

2 files changed

+31
-31
lines changed

2 files changed

+31
-31
lines changed

src/libsyntax/ext/base.rs

+26-26
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub enum SyntaxExtension {
7575
ItemTT(SyntaxExpanderTTItem),
7676
}
7777

78-
type SyntaxExtensions = HashMap<~str, SyntaxExtension>;
78+
type SyntaxExtensions = HashMap<@~str, SyntaxExtension>;
7979

8080
// A temporary hard-coded map of methods for expanding syntax extension
8181
// AST nodes into full ASTs
@@ -89,74 +89,74 @@ pub fn syntax_expander_table() -> SyntaxExtensions {
8989
ItemTT(SyntaxExpanderTTItem{expander: f, span: None})
9090
}
9191
let syntax_expanders = HashMap();
92-
syntax_expanders.insert(~"macro_rules",
92+
syntax_expanders.insert(@~"macro_rules",
9393
builtin_item_tt(
9494
ext::tt::macro_rules::add_new_extension));
95-
syntax_expanders.insert(~"fmt",
95+
syntax_expanders.insert(@~"fmt",
9696
builtin_normal_tt(ext::fmt::expand_syntax_ext));
9797
syntax_expanders.insert(
98-
~"auto_encode",
98+
@~"auto_encode",
9999
ItemDecorator(ext::auto_encode::expand_auto_encode));
100100
syntax_expanders.insert(
101-
~"auto_decode",
101+
@~"auto_decode",
102102
ItemDecorator(ext::auto_encode::expand_auto_decode));
103-
syntax_expanders.insert(~"env",
103+
syntax_expanders.insert(@~"env",
104104
builtin_normal_tt(ext::env::expand_syntax_ext));
105-
syntax_expanders.insert(~"concat_idents",
105+
syntax_expanders.insert(@~"concat_idents",
106106
builtin_normal_tt(
107107
ext::concat_idents::expand_syntax_ext));
108-
syntax_expanders.insert(~"log_syntax",
108+
syntax_expanders.insert(@~"log_syntax",
109109
builtin_normal_tt(
110110
ext::log_syntax::expand_syntax_ext));
111-
syntax_expanders.insert(~"deriving_eq",
111+
syntax_expanders.insert(@~"deriving_eq",
112112
ItemDecorator(
113113
ext::deriving::expand_deriving_eq));
114-
syntax_expanders.insert(~"deriving_iter_bytes",
114+
syntax_expanders.insert(@~"deriving_iter_bytes",
115115
ItemDecorator(
116116
ext::deriving::expand_deriving_iter_bytes));
117117

118118
// Quasi-quoting expanders
119-
syntax_expanders.insert(~"quote_tokens",
119+
syntax_expanders.insert(@~"quote_tokens",
120120
builtin_normal_tt(ext::quote::expand_quote_tokens));
121-
syntax_expanders.insert(~"quote_expr",
121+
syntax_expanders.insert(@~"quote_expr",
122122
builtin_normal_tt(ext::quote::expand_quote_expr));
123-
syntax_expanders.insert(~"quote_ty",
123+
syntax_expanders.insert(@~"quote_ty",
124124
builtin_normal_tt(ext::quote::expand_quote_ty));
125-
syntax_expanders.insert(~"quote_item",
125+
syntax_expanders.insert(@~"quote_item",
126126
builtin_normal_tt(ext::quote::expand_quote_item));
127-
syntax_expanders.insert(~"quote_pat",
127+
syntax_expanders.insert(@~"quote_pat",
128128
builtin_normal_tt(ext::quote::expand_quote_pat));
129-
syntax_expanders.insert(~"quote_stmt",
129+
syntax_expanders.insert(@~"quote_stmt",
130130
builtin_normal_tt(ext::quote::expand_quote_stmt));
131131

132-
syntax_expanders.insert(~"line",
132+
syntax_expanders.insert(@~"line",
133133
builtin_normal_tt(
134134
ext::source_util::expand_line));
135-
syntax_expanders.insert(~"col",
135+
syntax_expanders.insert(@~"col",
136136
builtin_normal_tt(
137137
ext::source_util::expand_col));
138-
syntax_expanders.insert(~"file",
138+
syntax_expanders.insert(@~"file",
139139
builtin_normal_tt(
140140
ext::source_util::expand_file));
141-
syntax_expanders.insert(~"stringify",
141+
syntax_expanders.insert(@~"stringify",
142142
builtin_normal_tt(
143143
ext::source_util::expand_stringify));
144-
syntax_expanders.insert(~"include",
144+
syntax_expanders.insert(@~"include",
145145
builtin_normal_tt(
146146
ext::source_util::expand_include));
147-
syntax_expanders.insert(~"include_str",
147+
syntax_expanders.insert(@~"include_str",
148148
builtin_normal_tt(
149149
ext::source_util::expand_include_str));
150-
syntax_expanders.insert(~"include_bin",
150+
syntax_expanders.insert(@~"include_bin",
151151
builtin_normal_tt(
152152
ext::source_util::expand_include_bin));
153-
syntax_expanders.insert(~"module_path",
153+
syntax_expanders.insert(@~"module_path",
154154
builtin_normal_tt(
155155
ext::source_util::expand_mod));
156-
syntax_expanders.insert(~"proto",
156+
syntax_expanders.insert(@~"proto",
157157
builtin_item_tt(ext::pipes::expand_proto));
158158
syntax_expanders.insert(
159-
~"trace_macros",
159+
@~"trace_macros",
160160
builtin_normal_tt(ext::trace_macros::expand_trace_macros));
161161
return syntax_expanders;
162162
}

src/libsyntax/ext/expand.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn expand_expr(exts: SyntaxExtensions, cx: ext_ctxt,
4141
/* using idents and token::special_idents would make the
4242
the macro names be hygienic */
4343
let extname = cx.parse_sess().interner.get(pth.idents[0]);
44-
match exts.find(extname) {
44+
match exts.find(&extname) {
4545
None => {
4646
cx.span_fatal(pth.span,
4747
fmt!("macro undefined: '%s'", *extname))
@@ -102,7 +102,7 @@ pub fn expand_mod_items(exts: SyntaxExtensions, cx: ext_ctxt,
102102
do vec::foldr(item.attrs, ~[*item]) |attr, items| {
103103
let mname = attr::get_attr_name(attr);
104104

105-
match exts.find(&*mname) {
105+
match exts.find(&mname) {
106106
None | Some(NormalTT(_)) | Some(ItemTT(*)) => items,
107107
Some(ItemDecorator(dec_fn)) => {
108108
cx.bt_push(ExpandedFrom({call_site: attr.span,
@@ -159,7 +159,7 @@ pub fn expand_item_mac(exts: SyntaxExtensions,
159159
};
160160

161161
let extname = cx.parse_sess().interner.get(pth.idents[0]);
162-
let expanded = match exts.find(extname) {
162+
let expanded = match exts.find(&extname) {
163163
None => cx.span_fatal(pth.span,
164164
fmt!("macro undefined: '%s!'", *extname)),
165165

@@ -198,7 +198,7 @@ pub fn expand_item_mac(exts: SyntaxExtensions,
198198
MRAny(_, item_maker, _) =>
199199
option::chain(item_maker(), |i| {fld.fold_item(i)}),
200200
MRDef(ref mdef) => {
201-
exts.insert((*mdef).name, (*mdef).ext);
201+
exts.insert(@/*bad*/ copy mdef.name, (*mdef).ext);
202202
None
203203
}
204204
};
@@ -222,7 +222,7 @@ pub fn expand_stmt(exts: SyntaxExtensions, cx: ext_ctxt,
222222
223223
assert(vec::len(pth.idents) == 1u);
224224
let extname = cx.parse_sess().interner.get(pth.idents[0]);
225-
let (fully_expanded, sp) = match exts.find(extname) {
225+
let (fully_expanded, sp) = match exts.find(&extname) {
226226
None =>
227227
cx.span_fatal(pth.span, fmt!("macro undefined: '%s'", *extname)),
228228

0 commit comments

Comments
 (0)