diff --git a/src/error.rs b/src/error.rs index 861669bfa..3e372537c 100644 --- a/src/error.rs +++ b/src/error.rs @@ -766,7 +766,7 @@ mod tests { e @ $error => { assert!(format!("{}", e).len() >= 5); } , - e => panic!("{:?}", e) + e => unreachable!("{:?}", e) } } } @@ -778,7 +778,7 @@ mod tests { let desc = format!("{}", e.cause().unwrap()); assert_eq!(desc, $from.description().to_owned()); }, - _ => panic!("{:?}", $from) + _ => unreachable!("{:?}", $from) } } } diff --git a/src/httpmessage.rs b/src/httpmessage.rs index 33b7d046f..79ebeab8c 100644 --- a/src/httpmessage.rs +++ b/src/httpmessage.rs @@ -581,27 +581,27 @@ mod tests { let req = TestRequest::with_header(header::CONTENT_LENGTH, "xxxx").finish(); match req.body().poll().err().unwrap() { PayloadError::UnknownLength => (), - _ => panic!("error"), + _ => unreachable!("error"), } let req = TestRequest::with_header(header::CONTENT_LENGTH, "1000000").finish(); match req.body().poll().err().unwrap() { PayloadError::Overflow => (), - _ => panic!("error"), + _ => unreachable!("error"), } let mut req = HttpRequest::default(); req.payload_mut().unread_data(Bytes::from_static(b"test")); match req.body().poll().ok().unwrap() { Async::Ready(bytes) => assert_eq!(bytes, Bytes::from_static(b"test")), - _ => panic!("error"), + _ => unreachable!("error"), } let mut req = HttpRequest::default(); req.payload_mut().unread_data(Bytes::from_static(b"11111111111111")); match req.body().limit(5).poll().err().unwrap() { PayloadError::Overflow => (), - _ => panic!("error"), + _ => unreachable!("error"), } } } diff --git a/src/multipart.rs b/src/multipart.rs index 45126a2a6..4ac7b2a15 100644 --- a/src/multipart.rs +++ b/src/multipart.rs @@ -632,7 +632,7 @@ mod tests { let headers = HeaderMap::new(); match Multipart::boundary(&headers) { Err(MultipartError::NoContentType) => (), - _ => panic!("should not happen"), + _ => unreachable!("should not happen"), } let mut headers = HeaderMap::new(); @@ -641,7 +641,7 @@ mod tests { match Multipart::boundary(&headers) { Err(MultipartError::ParseContentType) => (), - _ => panic!("should not happen"), + _ => unreachable!("should not happen"), } let mut headers = HeaderMap::new(); @@ -650,7 +650,7 @@ mod tests { header::HeaderValue::from_static("multipart/mixed")); match Multipart::boundary(&headers) { Err(MultipartError::Boundary) => (), - _ => panic!("should not happen"), + _ => unreachable!("should not happen"), } let mut headers = HeaderMap::new(); diff --git a/src/server/h1.rs b/src/server/h1.rs index 6d504e41c..71ca51ffa 100644 --- a/src/server/h1.rs +++ b/src/server/h1.rs @@ -932,8 +932,8 @@ mod tests { macro_rules! not_ready { ($e:expr) => (match $e { Ok(Async::NotReady) => (), - Err(err) => panic!("Unexpected error: {:?}", err), - _ => panic!("Should not be ready"), + Err(err) => unreachable!("Unexpected error: {:?}", err), + _ => unreachable!("Should not be ready"), }) } @@ -943,8 +943,8 @@ mod tests { Vec::new(), KeepAlive::Os); match Reader::new().parse($e, &mut BytesMut::new(), &settings) { Ok(Async::Ready(req)) => req, - Ok(_) => panic!("Eof during parsing http request"), - Err(err) => panic!("Error during parsing http request: {:?}", err), + Ok(_) => unreachable!("Eof during parsing http request"), + Err(err) => unreachable!("Error during parsing http request: {:?}", err), } }) } @@ -953,8 +953,8 @@ mod tests { ($e:expr) => ( match $e { Ok(Async::Ready(req)) => req, - Ok(_) => panic!("Eof during parsing http request"), - Err(err) => panic!("Error during parsing http request: {:?}", err), + Ok(_) => unreachable!("Eof during parsing http request"), + Err(err) => unreachable!("Error during parsing http request: {:?}", err), } ) } @@ -968,10 +968,10 @@ mod tests { match Reader::new().parse($e, &mut buf, &settings) { Err(err) => match err { ReaderError::Error(_) => (), - _ => panic!("Parse error expected"), + _ => unreachable!("Parse error expected"), }, _ => { - panic!("Error expected") + unreachable!("Error expected") } }} ) @@ -991,7 +991,7 @@ mod tests { assert_eq!(*req.method(), Method::GET); assert_eq!(req.path(), "/test"); } - Ok(_) | Err(_) => panic!("Error during parsing http request"), + Ok(_) | Err(_) => unreachable!("Error during parsing http request"), } } @@ -1005,7 +1005,7 @@ mod tests { let mut reader = Reader::new(); match reader.parse(&mut buf, &mut readbuf, &settings) { Ok(Async::NotReady) => (), - _ => panic!("Error"), + _ => unreachable!("Error"), } buf.feed_data(".1\r\n\r\n"); @@ -1015,7 +1015,7 @@ mod tests { assert_eq!(*req.method(), Method::PUT); assert_eq!(req.path(), "/test"); } - Ok(_) | Err(_) => panic!("Error during parsing http request"), + Ok(_) | Err(_) => unreachable!("Error during parsing http request"), } } @@ -1033,7 +1033,7 @@ mod tests { assert_eq!(*req.method(), Method::POST); assert_eq!(req.path(), "/test2"); } - Ok(_) | Err(_) => panic!("Error during parsing http request"), + Ok(_) | Err(_) => unreachable!("Error during parsing http request"), } } @@ -1052,7 +1052,7 @@ mod tests { assert_eq!(req.path(), "/test"); assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"body"); } - Ok(_) | Err(_) => panic!("Error during parsing http request"), + Ok(_) | Err(_) => unreachable!("Error during parsing http request"), } } @@ -1072,7 +1072,7 @@ mod tests { assert_eq!(req.path(), "/test"); assert_eq!(req.payload_mut().readall().unwrap().as_ref(), b"body"); } - Ok(_) | Err(_) => panic!("Error during parsing http request"), + Ok(_) | Err(_) => unreachable!("Error during parsing http request"), } } @@ -1093,7 +1093,7 @@ mod tests { assert_eq!(*req.method(), Method::GET); assert_eq!(req.path(), "/test"); } - Ok(_) | Err(_) => panic!("Error during parsing http request"), + Ok(_) | Err(_) => unreachable!("Error during parsing http request"), } } @@ -1121,7 +1121,7 @@ mod tests { assert_eq!(req.path(), "/test"); assert_eq!(req.headers().get("test").unwrap().as_bytes(), b"value"); } - Ok(_) | Err(_) => panic!("Error during parsing http request"), + Ok(_) | Err(_) => unreachable!("Error during parsing http request"), } } @@ -1143,7 +1143,7 @@ mod tests { assert_eq!(val[0], "c1=cookie1"); assert_eq!(val[1], "c2=cookie2"); } - Ok(_) | Err(_) => panic!("Error during parsing http request"), + Ok(_) | Err(_) => unreachable!("Error during parsing http request"), } } @@ -1256,7 +1256,7 @@ mod tests { if let Ok(val) = req.chunked() { assert!(val); } else { - panic!("Error"); + unreachable!("Error"); } // type in chunked @@ -1268,7 +1268,7 @@ mod tests { if let Ok(val) = req.chunked() { assert!(!val); } else { - panic!("Error"); + unreachable!("Error"); } } @@ -1501,7 +1501,7 @@ mod tests { let mut reader = Reader::new(); match reader.parse(&mut buf) { Ok(res) => (), - Err(err) => panic!("{:?}", err), + Err(err) => unreachable!("{:?}", err), } }*/ } diff --git a/src/ws/frame.rs b/src/ws/frame.rs index 030ae17af..2afcd0358 100644 --- a/src/ws/frame.rs +++ b/src/ws/frame.rs @@ -364,7 +364,7 @@ mod tests { fn extract(frm: Poll, ProtocolError>) -> Frame { match frm { Ok(Async::Ready(Some(frame))) => frame, - _ => panic!("error"), + _ => unreachable!("error"), } } @@ -468,7 +468,7 @@ mod tests { if let Err(ProtocolError::Overflow) = Frame::parse(&mut buf, false, 0) { } else { - panic!("error"); + unreachable!("error"); } } diff --git a/src/ws/proto.rs b/src/ws/proto.rs index e17f749a0..5f077a4b9 100644 --- a/src/ws/proto.rs +++ b/src/ws/proto.rs @@ -210,7 +210,7 @@ mod test { ($from:expr => $opcode:pat) => { match OpCode::from($from) { e @ $opcode => (), - e => panic!("{:?}", e) + e => unreachable!("{:?}", e) } } } @@ -220,7 +220,7 @@ mod test { let res: u8 = $from.into(); match res { e @ $opcode => (), - e => panic!("{:?}", e) + e => unreachable!("{:?}", e) } } }