Skip to content

Commit ccfb3eb

Browse files
committed
rusti: Remove #[allow(vecs_implicitly_copyable)]
1 parent 92d39fe commit ccfb3eb

File tree

4 files changed

+43
-43
lines changed

4 files changed

+43
-43
lines changed

src/librustdoc/tystr_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn fold_enum(
125125
}.get();
126126

127127
pprust::variant_to_str(
128-
ast_variant, extract::interner())
128+
&ast_variant, extract::interner())
129129
}
130130
_ => fail!("enum variant not bound to an enum item")
131131
}

src/librusti/rusti.rc

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
#[license = "MIT/ASL2"];
1919
#[crate_type = "lib"];
2020

21-
#[allow(vecs_implicitly_copyable,
22-
non_implicitly_copyable_typarams)];
23-
2421
extern mod std(vers = "0.7-pre");
2522
extern mod rustc(vers = "0.7-pre");
2623
extern mod syntax(vers = "0.7-pre");
2724

2825
use core::*;
26+
use core::cell::Cell;
2927
use rustc::driver::{driver, session};
3028
use syntax::{ast, diagnostic};
3129
use syntax::ast_util::*;
@@ -71,8 +69,8 @@ fn with_pp(intr: @token::ident_interner,
7169
* because it has to parse the statements and view_items on each
7270
* input.
7371
*/
74-
fn record(repl: Repl, blk: @ast::blk, intr: @token::ident_interner) -> Repl {
75-
let view_items = if blk.node.view_items.len() > 0 {
72+
fn record(mut repl: Repl, blk: &ast::blk, intr: @token::ident_interner) -> Repl {
73+
if blk.node.view_items.len() > 0 {
7674
let new_view_items = do with_pp(intr) |pp, writer| {
7775
for blk.node.view_items.each |view_item| {
7876
pprust::print_view_item(pp, *view_item);
@@ -82,9 +80,9 @@ fn record(repl: Repl, blk: @ast::blk, intr: @token::ident_interner) -> Repl {
8280

8381
debug!("new view items %s", new_view_items);
8482

85-
repl.view_items + "\n" + new_view_items
86-
} else { repl.view_items };
87-
let stmts = if blk.node.stmts.len() > 0 {
83+
repl.view_items = repl.view_items + "\n" + new_view_items
84+
}
85+
if blk.node.stmts.len() > 0 {
8886
let new_stmts = do with_pp(intr) |pp, writer| {
8987
for blk.node.stmts.each |stmt| {
9088
match stmt.node {
@@ -105,24 +103,21 @@ fn record(repl: Repl, blk: @ast::blk, intr: @token::ident_interner) -> Repl {
105103

106104
debug!("new stmts %s", new_stmts);
107105

108-
repl.stmts + "\n" + new_stmts
109-
} else { repl.stmts };
110-
111-
Repl{
112-
view_items: view_items,
113-
stmts: stmts,
114-
.. repl
106+
repl.stmts = repl.stmts + "\n" + new_stmts
115107
}
108+
109+
return repl;
116110
}
117111

118112
/// Run an input string in a Repl, returning the new Repl.
119113
fn run(repl: Repl, input: ~str) -> Repl {
114+
let binary = @copy repl.binary;
120115
let options = @session::options {
121116
crate_type: session::unknown_crate,
122-
binary: @repl.binary,
117+
binary: binary,
123118
addl_lib_search_paths: repl.lib_search_paths.map(|p| Path(*p)),
124119
jit: true,
125-
.. *session::basic_options()
120+
.. copy *session::basic_options()
126121
};
127122

128123
debug!("building driver input");
@@ -138,7 +133,7 @@ fn run(repl: Repl, input: ~str) -> Repl {
138133

139134
debug!("building driver configuration");
140135
let cfg = driver::build_configuration(sess,
141-
@repl.binary,
136+
binary,
142137
&wrapped);
143138

144139
let outputs = driver::build_output_filenames(&wrapped, &None, &None, sess);
@@ -151,7 +146,7 @@ fn run(repl: Repl, input: ~str) -> Repl {
151146

152147
for crate.node.module.items.each |item| {
153148
match item.node {
154-
ast::item_fn(_, _, _, _, blk) => {
149+
ast::item_fn(_, _, _, _, ref blk) => {
155150
if item.ident == sess.ident_of("main") {
156151
opt = blk.node.expr;
157152
}
@@ -160,10 +155,11 @@ fn run(repl: Repl, input: ~str) -> Repl {
160155
}
161156
}
162157

163-
let blk = match opt.get().node {
164-
ast::expr_call(_, exprs, _) => {
158+
let e = opt.unwrap();
159+
let blk = match e.node {
160+
ast::expr_call(_, ref exprs, _) => {
165161
match exprs[0].node {
166-
ast::expr_block(blk) => @blk,
162+
ast::expr_block(ref blk) => blk,
167163
_ => fail!()
168164
}
169165
}
@@ -182,15 +178,16 @@ fn run(repl: Repl, input: ~str) -> Repl {
182178
fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
183179
match do task::try {
184180
let src_path = Path(src_filename);
181+
let binary = @copy binary;
185182
let options = @session::options {
186-
binary: @binary,
183+
binary: binary,
187184
addl_lib_search_paths: ~[os::getcwd()],
188-
.. *session::basic_options()
185+
.. copy *session::basic_options()
189186
};
190-
let input = driver::file_input(src_path);
187+
let input = driver::file_input(copy src_path);
191188
let sess = driver::build_session(options, diagnostic::emit);
192189
*sess.building_library = true;
193-
let cfg = driver::build_configuration(sess, @binary, &input);
190+
let cfg = driver::build_configuration(sess, binary, &input);
194191
let outputs = driver::build_output_filenames(
195192
&input, &None, &None, sess);
196193
// If the library already exists and is newer than the source
@@ -233,7 +230,7 @@ fn compile_crate(src_filename: ~str, binary: ~str) -> Option<bool> {
233230

234231
/// Tries to get a line from rl after outputting a prompt. Returns
235232
/// None if no input was read (e.g. EOF was reached).
236-
fn get_line(use_rl: bool, prompt: ~str) -> Option<~str> {
233+
fn get_line(use_rl: bool, prompt: &str) -> Option<~str> {
237234
if use_rl {
238235
let result = unsafe { rl::read(prompt) };
239236

@@ -280,11 +277,11 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
280277
for args.each |arg| {
281278
let (crate, filename) =
282279
if arg.ends_with(".rs") || arg.ends_with(".rc") {
283-
(arg.substr(0, arg.len() - 3).to_owned(), *arg)
280+
(arg.substr(0, arg.len() - 3).to_owned(), copy *arg)
284281
} else {
285-
(*arg, arg + ~".rs")
282+
(copy *arg, arg + ".rs")
286283
};
287-
match compile_crate(filename, repl.binary) {
284+
match compile_crate(filename, copy repl.binary) {
288285
Some(_) => loaded_crates.push(crate),
289286
None => { }
290287
}
@@ -311,7 +308,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
311308
let mut multiline_cmd = ~"";
312309
let mut end_multiline = false;
313310
while (!end_multiline) {
314-
match get_line(use_rl, ~"rusti| ") {
311+
match get_line(use_rl, "rusti| ") {
315312
None => fail!("unterminated multiline command :{ .. :}"),
316313
Some(line) => {
317314
if str::trim(line) == ~":}" {
@@ -334,14 +331,14 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
334331
fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
335332
use_rl: bool)
336333
-> Option<Repl> {
337-
if line.starts_with(~":") {
334+
if line.starts_with(":") {
338335
let full = line.substr(1, line.len() - 1);
339336
let mut split = ~[];
340337
for str::each_word(full) |word| { split.push(word.to_owned()) }
341338
let len = split.len();
342339

343340
if len > 0 {
344-
let cmd = split[0];
341+
let cmd = copy split[0];
345342

346343
if !cmd.is_empty() {
347344
let args = if len > 1 {
@@ -361,9 +358,10 @@ fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
361358
}
362359
}
363360

364-
let r = *repl;
361+
let line = Cell(line);
362+
let r = Cell(copy *repl);
365363
let result = do task::try {
366-
run(r, line)
364+
run(r.take(), line.take())
367365
};
368366

369367
if result.is_ok() {
@@ -378,7 +376,7 @@ pub fn main() {
378376
let out = io::stdout();
379377
let mut repl = Repl {
380378
prompt: ~"rusti> ",
381-
binary: args[0],
379+
binary: copy args[0],
382380
running: true,
383381
view_items: ~"",
384382
lib_search_paths: ~[],

src/librusti/wrapper.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313
#[allow(implicit_copies)];
1414
#[allow(managed_heap_memory)];
1515
#[allow(non_camel_case_types)];
16-
#[allow(non_implicitly_copyable_typarams)];
1716
#[allow(owned_heap_memory)];
1817
#[allow(path_statement)];
1918
#[allow(unrecognized_lint)];
2019
#[allow(unused_imports)];
21-
#[allow(vecs_implicitly_copyable)];
2220
#[allow(while_true)];
21+
#[allow(dead_assignment)];
22+
#[allow(unused_variable)];
23+
#[allow(unused_unsafe)];
24+
#[allow(unused_mut)];
2325

2426
extern mod std;
2527

src/libstd/rl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub mod rustrt {
2828
}
2929

3030
/// Add a line to history
31-
pub unsafe fn add_history(line: ~str) -> bool {
31+
pub unsafe fn add_history(line: &str) -> bool {
3232
do str::as_c_str(line) |buf| {
3333
rustrt::linenoiseHistoryAdd(buf) == 1 as c_int
3434
}
@@ -40,21 +40,21 @@ pub unsafe fn set_history_max_len(len: int) -> bool {
4040
}
4141

4242
/// Save line history to a file
43-
pub unsafe fn save_history(file: ~str) -> bool {
43+
pub unsafe fn save_history(file: &str) -> bool {
4444
do str::as_c_str(file) |buf| {
4545
rustrt::linenoiseHistorySave(buf) == 1 as c_int
4646
}
4747
}
4848

4949
/// Load line history from a file
50-
pub unsafe fn load_history(file: ~str) -> bool {
50+
pub unsafe fn load_history(file: &str) -> bool {
5151
do str::as_c_str(file) |buf| {
5252
rustrt::linenoiseHistoryLoad(buf) == 1 as c_int
5353
}
5454
}
5555

5656
/// Print out a prompt and then wait for input and return it
57-
pub unsafe fn read(prompt: ~str) -> Option<~str> {
57+
pub unsafe fn read(prompt: &str) -> Option<~str> {
5858
do str::as_c_str(prompt) |buf| {
5959
let line = rustrt::linenoise(buf);
6060

0 commit comments

Comments
 (0)