From 326097c6eac87ca9e1301c4adfb2291da670c211 Mon Sep 17 00:00:00 2001 From: John P Mayer Jr Date: Sat, 10 Jan 2015 21:12:17 -0500 Subject: [PATCH 1/7] feature flags --- codegen/branchify.rs | 2 +- codegen/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/codegen/branchify.rs b/codegen/branchify.rs index d3071ac..6f94457 100644 --- a/codegen/branchify.rs +++ b/codegen/branchify.rs @@ -1,4 +1,4 @@ -#![macro_escape] +#![macro_use] use std::str::Chars; use std::vec::Vec; diff --git a/codegen/main.rs b/codegen/main.rs index ff08ba5..4522c1d 100644 --- a/codegen/main.rs +++ b/codegen/main.rs @@ -1,4 +1,4 @@ -#![feature(macro_rules, slicing_syntax)] +#![feature(slicing_syntax, box_syntax, int_uint)] use std::io::{File, Truncate, Write}; use std::os; From 36c87f6f51d3dcda3ddd88e7df7134d1009d5090 Mon Sep 17 00:00:00 2001 From: John P Mayer Jr Date: Sat, 10 Jan 2015 21:15:01 -0500 Subject: [PATCH 2/7] thread spawn now spawns a detached thread --- codegen/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codegen/main.rs b/codegen/main.rs index 4522c1d..1873f2d 100644 --- a/codegen/main.rs +++ b/codegen/main.rs @@ -12,7 +12,7 @@ fn main() { Thread::spawn(move || { let output_dir = Path::new(os::getenv("OUT_DIR").unwrap()); read_method::generate(output_dir).unwrap(); - }).detach(); + }); let output_dir = Path::new(os::getenv("OUT_DIR").unwrap()); status::generate(output_dir).unwrap(); From 13b598a86cc61135da942991e52eecb596f19491 Mon Sep 17 00:00:00 2001 From: John P Mayer Jr Date: Sat, 10 Jan 2015 21:21:01 -0500 Subject: [PATCH 3/7] switch to using as_slice --- codegen/branchify.rs | 4 ++-- codegen/status.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/codegen/branchify.rs b/codegen/branchify.rs index 6f94457..4e353b4 100644 --- a/codegen/branchify.rs +++ b/codegen/branchify.rs @@ -104,13 +104,13 @@ pub fn generate_branchified_method( let next_prefix = format!("{}{}", prefix, c as char); w!(format!("Ok(b'{}') => match {} {{", c as char, read_call)); for b in branch.children.iter() { - try!(r(writer, b, next_prefix[], indent + 1, read_call, end, max_len, valid, unknown)); + try!(r(writer, b, next_prefix.as_slice(), indent + 1, read_call, end, max_len, valid, unknown)); } match branch.result { Some(ref result) => w!(format!(" Ok(b' ') => return Ok({}),", *result)), None => w!(format!(" Ok(b' ') => return Ok({}),", - unknown.replace("{}", format!("String::from_str(\"{}\")", next_prefix)[]))), + unknown.replace("{}", format!("String::from_str(\"{}\")", next_prefix).as_slice()))), } w!(format!(" Ok(b) if {} => (\"{}\", b),", valid, next_prefix)); w!(" Ok(_) => return Err(::std::io::IoError { kind: ::std::io::OtherIoError, desc: \"bad value\", detail: None }),"); diff --git a/codegen/status.rs b/codegen/status.rs index 4643d25..ad0b03b 100644 --- a/codegen/status.rs +++ b/codegen/status.rs @@ -45,7 +45,7 @@ impl HttpStatus { fn padded_ident(&self) -> String { let mut s = self.ident(); - s.push_str(self.reason_padding_spaces()[]); + s.push_str(self.reason_padding_spaces().as_slice()); s } From 031b145977f593964d6a67010878bb9797323ed1 Mon Sep 17 00:00:00 2001 From: John P Mayer Jr Date: Sat, 10 Jan 2015 21:26:05 -0500 Subject: [PATCH 4/7] this is a hunch that mut is now inferred? works now --- src/http/buffer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http/buffer.rs b/src/http/buffer.rs index 429c311..7e51a1a 100644 --- a/src/http/buffer.rs +++ b/src/http/buffer.rs @@ -53,7 +53,7 @@ impl BufferedStream { (0, _) => panic!("poke called when buffer is full"), (_, _) => self.read_pos -= 1, } - self.read_buffer[mut][self.read_pos] = byte; + self.read_buffer[self.read_pos] = byte; } #[inline] From 24bc739ffaad9157ca720ba1f167faff93dfda5c Mon Sep 17 00:00:00 2001 From: John P Mayer Jr Date: Sat, 10 Jan 2015 21:31:46 -0500 Subject: [PATCH 5/7] closure syntax --- src/http/common.rs | 12 ++++++------ src/http/lib.rs | 3 --- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/http/common.rs b/src/http/common.rs index 9b8b623..bf15f9a 100644 --- a/src/http/common.rs +++ b/src/http/common.rs @@ -43,8 +43,8 @@ const ASCII_UPPER_F: u8 = b'F'; * * Should everything work as designed (i.e. none of these conditions occur) a `Some` is returned. */ -pub fn read_decimal - (reader: &mut R, expected_end: |u8| -> bool) +pub fn read_decimal bool> + (reader: &mut R, mut expected_end: F) -> IoResult { // Here and in `read_hexadecimal` there is the possibility of infinite sequence of zeroes. The // spec allows this, but it may not be a good thing to allow. It's not a particularly good @@ -89,8 +89,8 @@ pub fn read_decimal * * Should everything work as designed (i.e. none of these conditions occur) a `Some` is returned. */ -pub fn read_hexadecimal - (reader: &mut R, expected_end: |u8| -> bool) +pub fn read_hexadecimal bool> + (reader: &mut R, mut expected_end: F) -> IoResult { let mut n: N = Int::zero(); let mut got_content = false; @@ -142,8 +142,8 @@ pub fn read_hexadecimal * - A `Some`, if all goes well. */ #[inline] -pub fn read_http_version - (reader: &mut R, expected_end: |u8| -> bool) +pub fn read_http_version bool> + (reader: &mut R, mut expected_end: F) -> IoResult<(uint, uint)> { // I'd read into a [0u8, ..5], but that buffer is not guaranteed to be // filled, so I must read it byte by byte to guarantee correctness. diff --git a/src/http/lib.rs b/src/http/lib.rs index ec98c61..3a98f1a 100644 --- a/src/http/lib.rs +++ b/src/http/lib.rs @@ -7,11 +7,8 @@ #![allow(unknown_features)] #![feature(slicing_syntax)] -#![feature(default_type_params)] -#![feature(macro_rules)] #![feature(phase)] #![feature(globs)] -#![feature(associated_types)] #![feature(old_orphan_check)] #[phase(plugin, link)] extern crate log; From 3c55d90bcb2323e0fb5544355c7c1fa1a7e72a3d Mon Sep 17 00:00:00 2001 From: John P Mayer Jr Date: Sat, 10 Jan 2015 21:34:22 -0500 Subject: [PATCH 6/7] updating more feature pragmas --- src/http/lib.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/http/lib.rs b/src/http/lib.rs index 3a98f1a..cd84d5c 100644 --- a/src/http/lib.rs +++ b/src/http/lib.rs @@ -7,11 +7,9 @@ #![allow(unknown_features)] #![feature(slicing_syntax)] -#![feature(phase)] -#![feature(globs)] #![feature(old_orphan_check)] -#[phase(plugin, link)] extern crate log; +#[macro_use] extern crate log; extern crate url; extern crate time; extern crate collections; From 28dbc40769c77fd7696bffbe0d704ed0e441f8ec Mon Sep 17 00:00:00 2001 From: John P Mayer Jr Date: Sat, 10 Jan 2015 21:51:22 -0500 Subject: [PATCH 7/7] guessing on these too --- src/http/common.rs | 8 ++++---- src/http/lib.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/http/common.rs b/src/http/common.rs index bf15f9a..48b3c4b 100644 --- a/src/http/common.rs +++ b/src/http/common.rs @@ -169,7 +169,7 @@ pub fn read_http_version bool> // I couldn't think what to call it. Ah well. It's just trivial syntax sugar, anyway. macro_rules! test_reads { - ($func:ident $($value:expr => $expected:expr),*) => {{ + ($func:ident, $($value:expr => $expected:expr),*) => {{ $( assert_eq!( concat_idents!(read_, $func)(&mut MemReader::new($value.bytes().collect::>()), @@ -181,7 +181,7 @@ macro_rules! test_reads { #[test] fn test_read_http_version() { - test_reads!(http_version + test_reads!(http_version, "HTTP/25.17\0" => Some((25, 17)), "http/1.0\0" => Some((1, 0)), "http 1.0\0" => None, @@ -192,7 +192,7 @@ fn test_read_http_version() { #[test] fn test_read_decimal() { - test_reads!(decimal + test_reads!(decimal, "0\0" => Some(0u), "0\0" => Some(0u8), "0\0" => Some(0u64), @@ -219,7 +219,7 @@ fn test_read_decimal() { #[test] fn test_read_hexadecimal() { - test_reads!(hexadecimal + test_reads!(hexadecimal, "0\0" => Some(0u), "0\0" => Some(0u8), "0\0" => Some(0u64), diff --git a/src/http/lib.rs b/src/http/lib.rs index cd84d5c..b0e0bef 100644 --- a/src/http/lib.rs +++ b/src/http/lib.rs @@ -7,7 +7,7 @@ #![allow(unknown_features)] #![feature(slicing_syntax)] -#![feature(old_orphan_check)] +//#![feature(old_orphan_check)] #[macro_use] extern crate log; extern crate url;