提交 dabd4762 编写于 作者: D Daniel Micay

make `in` and `foreach` get treated as keywords

上级 c47be692
......@@ -65,7 +65,7 @@ pub trait DigestUtil {
*
* * in The string to feed into the digest
*/
fn input_str(&mut self, in: &str);
fn input_str(&mut self, input: &str);
/**
* Convenience functon that retrieves the result of a digest as a
......@@ -75,8 +75,8 @@ pub trait DigestUtil {
}
impl<D: Digest> DigestUtil for D {
fn input_str(&mut self, in: &str) {
self.input(in.as_bytes());
fn input_str(&mut self, input: &str) {
self.input(input.as_bytes());
}
fn result_str(&mut self) -> ~str {
......
......@@ -66,34 +66,34 @@ struct Engine512 {
}
// Convert a [u8] to a u64 in big-endian format
fn to_u64(in: &[u8]) -> u64 {
(in[0] as u64) << 56 |
(in[1] as u64) << 48 |
(in[2] as u64) << 40 |
(in[3] as u64) << 32 |
(in[4] as u64) << 24 |
(in[5] as u64) << 16 |
(in[6] as u64) << 8 |
(in[7] as u64)
fn to_u64(input: &[u8]) -> u64 {
(input[0] as u64) << 56 |
(input[1] as u64) << 48 |
(input[2] as u64) << 40 |
(input[3] as u64) << 32 |
(input[4] as u64) << 24 |
(input[5] as u64) << 16 |
(input[6] as u64) << 8 |
(input[7] as u64)
}
// Convert a u64 to a [u8] in big endian format
fn from_u64(in: u64, out: &mut [u8]) {
out[0] = (in >> 56) as u8;
out[1] = (in >> 48) as u8;
out[2] = (in >> 40) as u8;
out[3] = (in >> 32) as u8;
out[4] = (in >> 24) as u8;
out[5] = (in >> 16) as u8;
out[6] = (in >> 8) as u8;
out[7] = in as u8;
fn from_u64(input: u64, out: &mut [u8]) {
out[0] = (input >> 56) as u8;
out[1] = (input >> 48) as u8;
out[2] = (input >> 40) as u8;
out[3] = (input >> 32) as u8;
out[4] = (input >> 24) as u8;
out[5] = (input >> 16) as u8;
out[6] = (input >> 8) as u8;
out[7] = input as u8;
}
impl Engine512 {
fn input_byte(&mut self, in: u8) {
fn input_byte(&mut self, input: u8) {
assert!(!self.finished)
self.input_buffer[self.input_buffer_idx] = in;
self.input_buffer[self.input_buffer_idx] = input;
self.input_buffer_idx += 1;
if (self.input_buffer_idx == 8) {
......@@ -105,25 +105,25 @@ fn input_byte(&mut self, in: u8) {
self.bit_counter.add_bytes(1);
}
fn input_vec(&mut self, in: &[u8]) {
fn input_vec(&mut self, input: &[u8]) {
assert!(!self.finished)
let mut i = 0;
while i < in.len() && self.input_buffer_idx != 0 {
self.input_byte(in[i]);
while i < input.len() && self.input_buffer_idx != 0 {
self.input_byte(input[i]);
i += 1;
}
while in.len() - i >= 8 {
let w = to_u64(in.slice(i, i + 8));
while input.len() - i >= 8 {
let w = to_u64(input.slice(i, i + 8));
self.process_word(w);
self.bit_counter.add_bytes(8);
i += 8;
}
while i < in.len() {
self.input_byte(in[i]);
while i < input.len() {
self.input_byte(input[i]);
i += 1;
}
}
......@@ -135,8 +135,8 @@ fn reset(&mut self) {
self.W_idx = 0;
}
fn process_word(&mut self, in: u64) {
self.W[self.W_idx] = in;
fn process_word(&mut self, input: u64) {
self.W[self.W_idx] = input;
self.W_idx += 1;
if (self.W_idx == 16) {
self.W_idx = 0;
......@@ -356,26 +356,26 @@ struct Engine256 {
}
// Convert a [u8] to a u32 in big endian format
fn to_u32(in: &[u8]) -> u32 {
(in[0] as u32) << 24 |
(in[1] as u32) << 16 |
(in[2] as u32) << 8 |
(in[3] as u32)
fn to_u32(input: &[u8]) -> u32 {
(input[0] as u32) << 24 |
(input[1] as u32) << 16 |
(input[2] as u32) << 8 |
(input[3] as u32)
}
// Convert a u32 to a [u8] in big endian format
fn from_u32(in: u32, out: &mut [u8]) {
out[0] = (in >> 24) as u8;
out[1] = (in >> 16) as u8;
out[2] = (in >> 8) as u8;
out[3] = in as u8;
fn from_u32(input: u32, out: &mut [u8]) {
out[0] = (input >> 24) as u8;
out[1] = (input >> 16) as u8;
out[2] = (input >> 8) as u8;
out[3] = input as u8;
}
impl Engine256 {
fn input_byte(&mut self, in: u8) {
fn input_byte(&mut self, input: u8) {
assert!(!self.finished)
self.input_buffer[self.input_buffer_idx] = in;
self.input_buffer[self.input_buffer_idx] = input;
self.input_buffer_idx += 1;
if (self.input_buffer_idx == 4) {
......@@ -387,25 +387,25 @@ fn input_byte(&mut self, in: u8) {
self.length_bytes += 1;
}
fn input_vec(&mut self, in: &[u8]) {
fn input_vec(&mut self, input: &[u8]) {
assert!(!self.finished)
let mut i = 0;
while i < in.len() && self.input_buffer_idx != 0 {
self.input_byte(in[i]);
while i < input.len() && self.input_buffer_idx != 0 {
self.input_byte(input[i]);
i += 1;
}
while in.len() - i >= 4 {
let w = to_u32(in.slice(i, i + 4));
while input.len() - i >= 4 {
let w = to_u32(input.slice(i, i + 4));
self.process_word(w);
self.length_bytes += 4;
i += 4;
}
while i < in.len() {
self.input_byte(in[i]);
while i < input.len() {
self.input_byte(input[i]);
i += 1;
}
......@@ -418,8 +418,8 @@ fn reset(&mut self) {
self.W_idx = 0;
}
fn process_word(&mut self, in: u32) {
self.W[self.W_idx] = in;
fn process_word(&mut self, input: u32) {
self.W[self.W_idx] = input;
self.W_idx += 1;
if (self.W_idx == 16) {
self.W_idx = 0;
......
......@@ -72,10 +72,10 @@
(where the numbers are from the start of each file, rather than the
total line count).
let in = FileInput::from_vec(pathify([~"a.txt", ~"b.txt", ~"c.txt"],
let input = FileInput::from_vec(pathify([~"a.txt", ~"b.txt", ~"c.txt"],
true));
for in.each_line |line| {
for input.each_line |line| {
if line.is_empty() {
break
}
......@@ -85,9 +85,9 @@
io::println("Continue?");
if io::stdin().read_line() == ~"yes" {
in.next_file(); // skip!
input.next_file(); // skip!
for in.each_line_state |line, state| {
for input.each_line_state |line, state| {
io::println(fmt!("%u: %s", state.line_num_file,
line))
}
......@@ -589,29 +589,29 @@ fn test_next_file() {
make_file(filename.get_ref(), contents);
}
let in = FileInput::from_vec(filenames);
let input = FileInput::from_vec(filenames);
// read once from 0
assert_eq!(in.read_line(), ~"0 1");
in.next_file(); // skip the rest of 1
assert_eq!(input.read_line(), ~"0 1");
input.next_file(); // skip the rest of 1
// read all lines from 1 (but don't read any from 2),
for uint::range(1, 4) |i| {
assert_eq!(in.read_line(), fmt!("1 %u", i));
assert_eq!(input.read_line(), fmt!("1 %u", i));
}
// 1 is finished, but 2 hasn't been started yet, so this will
// just "skip" to the beginning of 2 (Python's fileinput does
// the same)
in.next_file();
input.next_file();
assert_eq!(in.read_line(), ~"2 1");
assert_eq!(input.read_line(), ~"2 1");
}
#[test]
#[should_fail]
fn test_input_vec_missing_file() {
for input_vec(pathify([~"this/file/doesnt/exist"], true)) |line| {
io::println(line);
println(line);
}
}
}
......@@ -95,18 +95,18 @@ fn test_flate_round_trip() {
words.push(r.gen_bytes(range));
}
for 20.times {
let mut in = ~[];
let mut input = ~[];
for 2000.times {
in.push_all(r.choose(words));
input.push_all(r.choose(words));
}
debug!("de/inflate of %u bytes of random word-sequences",
in.len());
let cmp = deflate_bytes(in);
input.len());
let cmp = deflate_bytes(input);
let out = inflate_bytes(cmp);
debug!("%u bytes deflated to %u (%.1f%% size)",
in.len(), cmp.len(),
100.0 * ((cmp.len() as float) / (in.len() as float)));
assert_eq!(in, out);
input.len(), cmp.len(),
100.0 * ((cmp.len() as float) / (input.len() as float)));
assert_eq!(input, out);
}
}
}
......@@ -221,7 +221,7 @@ pub fn parse(s: &str) -> Option<Version> {
}
let s = s.trim();
let mut bad = false;
do bad_parse::cond.trap(|_| { debug!("bad"); bad = true }).in {
do bad_parse::cond.trap(|_| { debug!("bad"); bad = true }).inside {
do io::with_str_reader(s) |rdr| {
let v = parse_reader(rdr);
if bad || v.to_str() != s.to_owned() {
......
......@@ -407,7 +407,7 @@ enum State {
let len = rawurl.len();
let mut st = Start;
let mut in = Digit; // most restricted, start here.
let mut input = Digit; // most restricted, start here.
let mut userinfo = None;
let mut host = ~"";
......@@ -425,13 +425,13 @@ enum State {
match c {
'0' .. '9' => (),
'A' .. 'F' | 'a' .. 'f' => {
if in == Digit {
in = Hex;
if input == Digit {
input = Hex;
}
}
'G' .. 'Z' | 'g' .. 'z' | '-' | '.' | '_' | '~' | '%' |
'&' |'\'' | '(' | ')' | '+' | '!' | '*' | ',' | ';' | '=' => {
in = Unreserved;
input = Unreserved;
}
':' | '@' | '?' | '#' | '/' => {
// separators, don't change anything
......@@ -452,7 +452,7 @@ enum State {
}
PassHostPort => {
// multiple colons means ipv6 address.
if in == Unreserved {
if input == Unreserved {
return Err(
~"Illegal characters in IPv6 address.");
}
......@@ -461,13 +461,13 @@ enum State {
InHost => {
pos = i;
// can't be sure whether this is an ipv6 address or a port
if in == Unreserved {
if input == Unreserved {
return Err(~"Illegal characters in authority.");
}
st = Ip6Port;
}
Ip6Port => {
if in == Unreserved {
if input == Unreserved {
return Err(~"Illegal characters in authority.");
}
st = Ip6Host;
......@@ -483,11 +483,11 @@ enum State {
return Err(~"Invalid ':' in authority.");
}
}
in = Digit; // reset input class
input = Digit; // reset input class
}
'@' => {
in = Digit; // reset input class
input = Digit; // reset input class
colon_count = 0; // reset count
match st {
Start => {
......@@ -535,7 +535,7 @@ enum State {
}
}
PassHostPort | Ip6Port => {
if in != Digit {
if input != Digit {
return Err(~"Non-digit characters in port.");
}
host = rawurl.slice(begin, pos).to_owned();
......@@ -545,7 +545,7 @@ enum State {
host = rawurl.slice(begin, end).to_owned();
}
InPort => {
if in != Digit {
if input != Digit {
return Err(~"Non-digit characters in port.");
}
port = Some(rawurl.slice(pos+1, end).to_owned());
......
......@@ -706,8 +706,8 @@ fn check_ty(cx: &Context, ty: &ast::Ty) {
}
fn check_foreign_fn(cx: &Context, decl: &ast::fn_decl) {
for decl.inputs.iter().advance |in| {
check_ty(cx, &in.ty);
for decl.inputs.iter().advance |input| {
check_ty(cx, &input.ty);
}
check_ty(cx, &decl.output)
}
......
......@@ -1461,8 +1461,8 @@ fn check_expr(expr: @expr, (this, vt): (@Liveness, vt<@Liveness>)) {
}
expr_inline_asm(ref ia) => {
for ia.inputs.iter().advance |&(_, in)| {
(vt.visit_expr)(in, (this, vt));
for ia.inputs.iter().advance |&(_, input)| {
(vt.visit_expr)(input, (this, vt));
}
// Output operands must be lvalues
......
......@@ -68,14 +68,14 @@ pub fn trans_inline_asm(bcx: @mut Block, ia: &ast::inline_asm) -> @mut Block {
cleanups.clear();
// Now the input operands
let inputs = do ia.inputs.map |&(c, in)| {
let inputs = do ia.inputs.map |&(c, input)| {
constraints.push(c);
unpack_result!(bcx, {
callee::trans_arg_expr(bcx,
expr_ty(bcx, in),
expr_ty(bcx, input),
ty::ByCopy,
in,
input,
&mut cleanups,
None,
callee::DontAutorefArg)
......
......@@ -388,8 +388,8 @@ pub fn mark_for_expr(cx: &Context, e: &expr) {
}
expr_inline_asm(ref ia) => {
for ia.inputs.iter().advance |&(_, in)| {
node_type_needs(cx, use_repr, in.id);
for ia.inputs.iter().advance |&(_, input)| {
node_type_needs(cx, use_repr, input.id);
}
for ia.outputs.iter().advance |&(_, out)| {
node_type_needs(cx, use_repr, out.id);
......
......@@ -2478,8 +2478,8 @@ fn check_loop_body(fcx: @mut FnCtxt,
fcx.write_ty(id, ty_param_bounds_and_ty.ty);
}
ast::expr_inline_asm(ref ia) => {
for ia.inputs.iter().advance |&(_, in)| {
check_expr(fcx, in);
for ia.inputs.iter().advance |&(_, input)| {
check_expr(fcx, input);
}
for ia.outputs.iter().advance |&(_, out)| {
check_expr(fcx, out);
......
......@@ -447,7 +447,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
/// Executes a line of input, which may either be rust code or a
/// :command. Returns a new Repl if it has changed.
pub fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
pub fn run_line(repl: &mut Repl, input: @io::Reader, out: @io::Writer, line: ~str,
use_rl: bool) -> bool
{
if line.starts_with(":") {
......@@ -464,11 +464,11 @@ pub fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
split.slice(1, len).to_owned()
} else { ~[] };
match run_cmd(repl, in, out, cmd, args, use_rl) {
match run_cmd(repl, input, out, cmd, args, use_rl) {
action_none => { }
action_run_line(multiline_cmd) => {
if !multiline_cmd.is_empty() {
return run_line(repl, in, out, multiline_cmd, use_rl);
return run_line(repl, input, out, multiline_cmd, use_rl);
}
}
}
......@@ -500,7 +500,7 @@ pub fn run_line(repl: &mut Repl, in: @io::Reader, out: @io::Writer, line: ~str,
pub fn main() {
let args = os::args();
let in = io::stdin();
let input = io::stdin();
let out = io::stdout();
let mut repl = Repl {
prompt: ~"rusti> ",
......@@ -542,7 +542,7 @@ pub fn main() {
}
loop;
}
run_line(&mut repl, in, out, line, istty);
run_line(&mut repl, input, out, line, istty);
}
}
}
......
......@@ -485,11 +485,11 @@ fn test_install_invalid() {
let mut error1_occurred = false;
do cond1.trap(|_| {
error1_occurred = true;
}).in {
}).inside {
do cond.trap(|_| {
error_occurred = true;
temp_workspace.clone()
}).in {
}).inside {
ctxt.install(&temp_workspace, &pkgid);
}
}
......@@ -573,7 +573,7 @@ fn test_package_ids_must_be_relative_path_like() {
assert!("" == p.to_str());
assert!("0-length pkgid" == e);
whatever.clone()
}).in {
}).inside {
let x = PkgId::new("", &os::getcwd());
assert_eq!(~"foo-0.1", x.to_str());
}
......@@ -582,7 +582,7 @@ fn test_package_ids_must_be_relative_path_like() {
assert_eq!(p.to_str(), os::make_absolute(&Path("foo/bar/quux")).to_str());
assert!("absolute pkgid" == e);
whatever.clone()
}).in {
}).inside {
let z = PkgId::new(os::make_absolute(&Path("foo/bar/quux")).to_str(),
&os::getcwd());
assert_eq!(~"foo-0.1", z.to_str());
......
......@@ -73,7 +73,7 @@ struct Trap<'self, T, U> {
}
impl<'self, T, U> Trap<'self, T, U> {
pub fn in<V>(&self, inner: &'self fn() -> V) -> V {
pub fn inside<V>(&self, inner: &'self fn() -> V) -> V {
let _g = Guard { cond: self.cond };
debug!("Trap: pushing handler to TLS");
local_data::set(self.cond.key, self.handler);
......@@ -119,7 +119,7 @@ fn nested_trap_test_inner() {
debug!("nested_trap_test_inner: in handler");
inner_trapped = true;
0
}).in {
}).inside {
debug!("nested_trap_test_inner: in protected block");
trouble(1);
}
......@@ -134,7 +134,7 @@ fn nested_trap_test_outer() {
do sadness::cond.trap(|_j| {
debug!("nested_trap_test_outer: in handler");
outer_trapped = true; 0
}).in {
}).inside {
debug!("nested_guard_test_outer: in protected block");
nested_trap_test_inner();
trouble(1);
......@@ -152,7 +152,7 @@ fn nested_reraise_trap_test_inner() {
let i = 10;
debug!("nested_reraise_trap_test_inner: handler re-raising");
sadness::cond.raise(i)
}).in {
}).inside {
debug!("nested_reraise_trap_test_inner: in protected block");
trouble(1);
}
......@@ -167,7 +167,7 @@ fn nested_reraise_trap_test_outer() {
do sadness::cond.trap(|_j| {
debug!("nested_reraise_trap_test_outer: in handler");
outer_trapped = true; 0
}).in {
}).inside {
debug!("nested_reraise_trap_test_outer: in protected block");
nested_reraise_trap_test_inner();
}
......@@ -182,7 +182,7 @@ fn test_default() {
do sadness::cond.trap(|j| {
debug!("test_default: in handler");
sadness::cond.raise_default(j, || { trapped=true; 5 })
}).in {
}).inside {
debug!("test_default: in protected block");
trouble(1);
}
......@@ -205,7 +205,7 @@ fn test_conditions_are_public() {
do sadness::cond.trap(|_| {
trapped = true;
0
}).in {
}).inside {
sadness::cond.raise(0);
}
assert!(trapped);
......
......@@ -389,17 +389,17 @@ pub fn fsync_fd(fd: c_int, _l: io::fsync::Level) -> c_int {
}
pub struct Pipe {
in: c_int,
input: c_int,
out: c_int
}
#[cfg(unix)]
pub fn pipe() -> Pipe {
unsafe {
let mut fds = Pipe {in: 0 as c_int,
let mut fds = Pipe {input: 0 as c_int,
out: 0 as c_int };
assert_eq!(libc::pipe(&mut fds.in), (0 as c_int));
return Pipe {in: fds.in, out: fds.out};
assert_eq!(libc::pipe(&mut fds.input), (0 as c_int));
return Pipe {input: fds.input, out: fds.out};
}
}
......@@ -413,14 +413,14 @@ pub fn pipe() -> Pipe {
// fully understand. Here we explicitly make the pipe non-inheritable,
// which means to pass it to a subprocess they need to be duplicated
// first, as in core::run.
let mut fds = Pipe {in: 0 as c_int,
let mut fds = Pipe {input: 0 as c_int,
out: 0 as c_int };
let res = libc::pipe(&mut fds.in, 1024 as ::libc::c_uint,
let res = libc::pipe(&mut fds.input, 1024 as ::libc::c_uint,
(libc::O_BINARY | libc::O_NOINHERIT) as c_int);
assert_eq!(res, 0 as c_int);
assert!((fds.in != -1 as c_int && fds.in != 0 as c_int));
assert!((fds.out != -1 as c_int && fds.in != 0 as c_int));
return Pipe {in: fds.in, out: fds.out};
assert!((fds.input != -1 as c_int && fds.input != 0 as c_int));
assert!((fds.out != -1 as c_int && fds.input != 0 as c_int));
return Pipe {input: fds.input, out: fds.out};
}
}
......@@ -1931,11 +1931,11 @@ fn copy_file_ok() {
let tempdir = getcwd(); // would like to use $TMPDIR,
// doesn't seem to work on Linux
assert!((tempdir.to_str().len() > 0u));
let in = tempdir.push("in.txt");
let input = tempdir.push("in.txt");
let out = tempdir.push("out.txt");
/* Write the temp input file */
let ostream = do in.to_str().as_c_str |fromp| {
let ostream = do input.to_str().as_c_str |fromp| {
do "w+b".as_c_str |modebuf| {
libc::fopen(fromp, modebuf)
}
......@@ -1950,16 +1950,16 @@ fn copy_file_ok() {
len as size_t)
}
assert_eq!(libc::fclose(ostream), (0u as c_int));
let in_mode = in.get_mode();
let rs = os::copy_file(&in, &out);
if (!os::path_exists(&in)) {
fail!("%s doesn't exist", in.to_str());
let in_mode = input.get_mode();
let rs = os::copy_file(&input, &out);
if (!os::path_exists(&input)) {
fail!("%s doesn't exist", input.to_str());
}
assert!((rs));
let rslt = run::process_status("diff", [in.to_str(), out.to_str()]);
let rslt = run::process_status("diff", [input.to_str(), out.to_str()]);
assert_eq!(rslt, 0);
assert_eq!(out.get_mode(), in_mode);
assert!((remove_file(&in)));
assert!((remove_file(&input)));
assert!((remove_file(&out)));
}
}
......
......@@ -330,7 +330,7 @@ fn read_to_end(&mut self) -> ~[u8] {
} else {
read_error::cond.raise(e)
}
}).in {
}).inside {
while keep_reading {
self.push_bytes(&mut buf, DEFAULT_BUF_SIZE)
}
......@@ -640,7 +640,7 @@ fn read_byte_error() {
None
};
do read_error::cond.trap(|_| {
}).in {
}).inside {
let byte = reader.read_byte();
assert!(byte == None);
}
......@@ -679,7 +679,7 @@ fn read_bytes_partial() {
fn read_bytes_eof() {
let mut reader = MemReader::new(~[10, 11]);
do read_error::cond.trap(|_| {
}).in {
}).inside {
assert!(reader.read_bytes(4) == ~[10, 11]);
}
}
......@@ -720,7 +720,7 @@ fn push_bytes_eof() {
let mut reader = MemReader::new(~[10, 11]);
let mut buf = ~[8, 9];
do read_error::cond.trap(|_| {
}).in {
}).inside {
reader.push_bytes(&mut buf, 4);
assert!(buf == ~[8, 9, 10, 11]);
}
......@@ -743,7 +743,7 @@ fn push_bytes_error() {
}
};
let mut buf = ~[8, 9];
do read_error::cond.trap(|_| { } ).in {
do read_error::cond.trap(|_| { } ).inside {
reader.push_bytes(&mut buf, 4);
}
assert!(buf == ~[8, 9, 10]);
......
......@@ -156,7 +156,7 @@ fn bind_error() {
do io_error::cond.trap(|e| {
assert!(e.kind == PermissionDenied);
called = true;
}).in {
}).inside {
let addr = Ipv4(0, 0, 0, 0, 1);
let listener = TcpListener::bind(addr);
assert!(listener.is_none());
......@@ -172,7 +172,7 @@ fn connect_error() {
do io_error::cond.trap(|e| {
assert!(e.kind == ConnectionRefused);
called = true;
}).in {
}).inside {
let addr = Ipv4(0, 0, 0, 0, 1);
let stream = TcpStream::connect(addr);
assert!(stream.is_none());
......@@ -320,7 +320,7 @@ fn write_close_ip4() {
// NB: ECONNRESET on linux, EPIPE on mac
assert!(e.kind == ConnectionReset || e.kind == BrokenPipe);
stop = true;
}).in {
}).inside {
stream.write(buf);
}
if stop { break }
......@@ -349,7 +349,7 @@ fn write_close_ip6() {
// NB: ECONNRESET on linux, EPIPE on mac
assert!(e.kind == ConnectionReset || e.kind == BrokenPipe);
stop = true;
}).in {
}).inside {
stream.write(buf);
}
if stop { break }
......
......@@ -117,7 +117,7 @@ fn bind_error() {
do io_error::cond.trap(|e| {
assert!(e.kind == PermissionDenied);
called = true;
}).in {
}).inside {
let addr = Ipv4(0, 0, 0, 0, 1);
let socket = UdpSocket::bind(addr);
assert!(socket.is_none());
......
......@@ -100,7 +100,7 @@ fn test_option_writer_error() {
do io_error::cond.trap(|err| {
assert_eq!(err.kind, PreviousIoError);
called = true;
}).in {
}).inside {
writer.write([0, 0, 0]);
}
assert!(called);
......@@ -109,7 +109,7 @@ fn test_option_writer_error() {
do io_error::cond.trap(|err| {
assert_eq!(err.kind, PreviousIoError);
called = true;
}).in {
}).inside {
writer.flush();
}
assert!(called);
......@@ -136,7 +136,7 @@ fn test_option_reader_error() {
do read_error::cond.trap(|err| {
assert_eq!(err.kind, PreviousIoError);
called = true;
}).in {
}).inside {
reader.read(buf);
}
assert!(called);
......@@ -145,7 +145,7 @@ fn test_option_reader_error() {
do io_error::cond.trap(|err| {
assert_eq!(err.kind, PreviousIoError);
called = true;
}).in {
}).inside {
assert!(reader.eof());
}
assert!(called);
......
......@@ -152,7 +152,7 @@ pub fn new(prog: &str, args: &[~str], options: ProcessOptions)
let (in_pipe, in_fd) = match options.in_fd {
None => {
let pipe = os::pipe();
(Some(pipe), pipe.in)
(Some(pipe), pipe.input)
},
Some(fd) => (None, fd)
};
......@@ -175,7 +175,7 @@ pub fn new(prog: &str, args: &[~str], options: ProcessOptions)
in_fd, out_fd, err_fd);
unsafe {
for in_pipe.iter().advance |pipe| { libc::close(pipe.in); }
for in_pipe.iter().advance |pipe| { libc::close(pipe.input); }
for out_pipe.iter().advance |pipe| { libc::close(pipe.out); }
for err_pipe.iter().advance |pipe| { libc::close(pipe.out); }
}
......@@ -184,8 +184,8 @@ pub fn new(prog: &str, args: &[~str], options: ProcessOptions)
pid: res.pid,
handle: res.handle,
input: in_pipe.map(|pipe| pipe.out),
output: out_pipe.map(|pipe| os::fdopen(pipe.in)),
error: err_pipe.map(|pipe| os::fdopen(pipe.in)),
output: out_pipe.map(|pipe| os::fdopen(pipe.input)),
error: err_pipe.map(|pipe| os::fdopen(pipe.input)),
exit_code: None,
}
}
......@@ -1025,7 +1025,7 @@ fn test_pipes() {
let mut proc = run::Process::new("cat", [], run::ProcessOptions {
dir: None,
env: None,
in_fd: Some(pipe_in.in),
in_fd: Some(pipe_in.input),
out_fd: Some(pipe_out.out),
err_fd: Some(pipe_err.out)
});
......@@ -1034,14 +1034,14 @@ fn test_pipes() {
assert!(proc.output_redirected());
assert!(proc.error_redirected());
os::close(pipe_in.in);
os::close(pipe_in.input);
os::close(pipe_out.out);
os::close(pipe_err.out);
let expected = ~"test";
writeclose(pipe_in.out, expected);
let actual = readclose(pipe_out.in);
readclose(pipe_err.in);
let actual = readclose(pipe_out.input);
readclose(pipe_err.input);
proc.finish();
assert_eq!(expected, actual);
......
......@@ -2863,7 +2863,7 @@ fn test_from_bytes_fail() {
assert_eq!(err, ~"from_bytes: input is not UTF-8; first bad byte is 255");
error_happened = true;
~""
}).in {
}).inside {
from_bytes(bb)
};
assert!(error_happened);
......
......@@ -95,10 +95,10 @@ pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
let constraint = p.parse_str();
p.expect(&token::LPAREN);
let in = p.parse_expr();
let input = p.parse_expr();
p.expect(&token::RPAREN);
inputs.push((constraint, in));
inputs.push((constraint, input));
}
}
Clobbers => {
......
......@@ -750,16 +750,16 @@ mod debug_macro {
macro_rules! condition (
{ pub $c:ident: $in:ty -> $out:ty; } => {
{ pub $c:ident: $input:ty -> $out:ty; } => {
pub mod $c {
#[allow(non_uppercase_statics)];
static key: ::std::local_data::Key<
@::std::condition::Handler<$in, $out>> =
@::std::condition::Handler<$input, $out>> =
&::std::local_data::Key;
pub static cond :
::std::condition::Condition<$in,$out> =
::std::condition::Condition<$input,$out> =
::std::condition::Condition {
name: stringify!($c),
key: key
......@@ -767,17 +767,17 @@ pub mod $c {
}
};
{ $c:ident: $in:ty -> $out:ty; } => {
{ $c:ident: $input:ty -> $out:ty; } => {
// FIXME (#6009): remove mod's `pub` below once variant above lands.
pub mod $c {
#[allow(non_uppercase_statics)];
static key: ::std::local_data::Key<
@::std::condition::Handler<$in, $out>> =
@::std::condition::Handler<$input, $out>> =
&::std::local_data::Key;
pub static cond :
::std::condition::Condition<$in,$out> =
::std::condition::Condition<$input,$out> =
::std::condition::Condition {
name: stringify!($c),
key: key
......
......@@ -626,7 +626,7 @@ fn fold_field_(field: Field, fld: @ast_fold) -> Field {
}
expr_inline_asm(ref a) => {
expr_inline_asm(inline_asm {
inputs: a.inputs.map(|&(c, in)| (c, fld.fold_expr(in))),
inputs: a.inputs.map(|&(c, input)| (c, fld.fold_expr(input))),
outputs: a.outputs.map(|&(c, out)| (c, fld.fold_expr(out))),
.. (*a).clone()
})
......
......@@ -125,7 +125,7 @@ pub fn binop_to_str(o: binop) -> ~str {
}
}
pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
pub fn to_str(input: @ident_interner, t: &Token) -> ~str {
match *t {
EQ => ~"=",
LT => ~"<",
......@@ -195,8 +195,8 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
LIT_STR(ref s) => { fmt!("\"%s\"", ident_to_str(s).escape_default()) }
/* Name components */
IDENT(s, _) => in.get(s.name).to_owned(),
LIFETIME(s) => fmt!("'%s", in.get(s.name)),
IDENT(s, _) => input.get(s.name).to_owned(),
LIFETIME(s) => fmt!("'%s", input.get(s.name)),
UNDERSCORE => ~"_",
/* Other */
......@@ -204,7 +204,7 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
EOF => ~"<eof>",
INTERPOLATED(ref nt) => {
match nt {
&nt_expr(e) => ::print::pprust::expr_to_str(e, in),
&nt_expr(e) => ::print::pprust::expr_to_str(e, input),
_ => {
~"an interpolated " +
match (*nt) {
......@@ -471,10 +471,10 @@ fn mk_fresh_ident_interner() -> @ident_interner {
"unsafe", // 61
"use", // 62
"while", // 63
"in", // 64
"foreach", // 65
"be", // 64
"in", // 65
"foreach", // 66
"be", // 66
];
@ident_interner {
......@@ -615,10 +615,10 @@ pub fn to_ident(&self) -> ident {
False => ident { name: 39, ctxt: 0 },
Fn => ident { name: 40, ctxt: 0 },
For => ident { name: 41, ctxt: 0 },
ForEach => ident { name: 66, ctxt: 0 },
ForEach => ident { name: 65, ctxt: 0 },
If => ident { name: 42, ctxt: 0 },
Impl => ident { name: 43, ctxt: 0 },
In => ident { name: 65, ctxt: 0 },
In => ident { name: 64, ctxt: 0 },
Let => ident { name: 44, ctxt: 0 },
__Log => ident { name: 45, ctxt: 0 },
Loop => ident { name: 46, ctxt: 0 },
......@@ -641,7 +641,7 @@ pub fn to_ident(&self) -> ident {
Unsafe => ident { name: 61, ctxt: 0 },
Use => ident { name: 62, ctxt: 0 },
While => ident { name: 63, ctxt: 0 },
Be => ident { name: 64, ctxt: 0 },
Be => ident { name: 66, ctxt: 0 },
}
}
}
......@@ -657,7 +657,7 @@ pub fn is_keyword(kw: keywords::Keyword, tok: &Token) -> bool {
pub fn is_any_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
8 | 27 | 32 .. 64 => true,
8 | 27 | 32 .. 66 => true,
_ => false,
},
_ => false
......@@ -667,7 +667,7 @@ pub fn is_any_keyword(tok: &Token) -> bool {
pub fn is_strict_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
8 | 27 | 32 .. 63 => true,
8 | 27 | 32 .. 65 => true,
_ => false,
},
_ => false,
......@@ -677,7 +677,7 @@ pub fn is_strict_keyword(tok: &Token) -> bool {
pub fn is_reserved_keyword(tok: &Token) -> bool {
match *tok {
token::IDENT(sid, false) => match sid.name {
64 => true,
66 => true,
_ => false,
},
_ => false,
......
......@@ -108,14 +108,14 @@ pub fn print_crate(cm: @CodeMap,
span_diagnostic: @diagnostic::span_handler,
crate: &ast::Crate,
filename: @str,
in: @io::Reader,
input: @io::Reader,
out: @io::Writer,
ann: pp_ann,
is_expanded: bool) {
let (cmnts, lits) = comments::gather_comments_and_literals(
span_diagnostic,
filename,
in
input
);
let s = @ps {
s: pp::mk_printer(out, default_columns),
......
......@@ -563,8 +563,8 @@ pub fn visit_expr<E:Clone>(ex: @expr, (e, v): (E, vt<E>)) {
expr_mac(ref mac) => visit_mac(mac, (e.clone(), v)),
expr_paren(x) => (v.visit_expr)(x, (e.clone(), v)),
expr_inline_asm(ref a) => {
for a.inputs.iter().advance |&(_, in)| {
(v.visit_expr)(in, (e.clone(), v));
for a.inputs.iter().advance |&(_, input)| {
(v.visit_expr)(input, (e.clone(), v));
}
for a.outputs.iter().advance |&(_, out)| {
(v.visit_expr)(out, (e.clone(), v));
......
......@@ -62,10 +62,10 @@ fn square_from_char(c: char) -> square {
}
}
fn read_board_grid<rdr:'static + io::Reader>(in: rdr) -> ~[~[square]] {
let in = @in as @io::Reader;
fn read_board_grid<rdr:'static + io::Reader>(input: rdr) -> ~[~[square]] {
let input = @input as @io::Reader;
let mut grid = ~[];
for in.each_line |line| {
for input.each_line |line| {
let mut row = ~[];
for line.iter().advance |c| {
row.push(square_from_char(c))
......
......@@ -27,11 +27,11 @@ pub fn main() {
assert_eq!(foobar, somefoobar.get());
}
fn optint(in: int) -> Option<int> {
if in == 0 {
fn optint(input: int) -> Option<int> {
if input == 0 {
return None;
}
else {
return Some(in);
return Some(input);
}
}
......@@ -12,8 +12,8 @@ enum t1 { a(int), b(uint), }
struct T2 {x: t1, y: int}
enum t3 { c(T2, uint), }
fn m(in: t3) -> int {
match in {
fn m(input: t3) -> int {
match input {
c(T2 {x: a(m), _}, _) => { return m; }
c(T2 {x: b(m), y: y}, z) => { return ((m + z) as int) + y; }
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册