Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit aa3ff71

Browse files
jebrosenSergioBenitez
authored andcommittedJul 11, 2020
Fix a minor compilation error, possibly caused by rust-lang/rust#64292.
1 parent 21e1917 commit aa3ff71

File tree

17 files changed

+80
-56
lines changed

17 files changed

+80
-56
lines changed
 

‎core/codegen/tests/route-ranking.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,16 @@ async fn test_ranking() {
2626
let mut response = client.get("/0").dispatch().await;
2727
assert_eq!(response.body_string().await.unwrap(), "0");
2828

29-
let mut response = client.get(format!("/{}", 1 << 8)).dispatch().await;
29+
let request = client.get(format!("/{}", 1 << 8));
30+
let mut response = request.dispatch().await;
3031
assert_eq!(response.body_string().await.unwrap(), "1");
3132

32-
let mut response = client.get(format!("/{}", 1 << 16)).dispatch().await;
33+
let request = client.get(format!("/{}", 1 << 16));
34+
let mut response = request.dispatch().await;
3335
assert_eq!(response.body_string().await.unwrap(), "2");
3436

35-
let mut response = client.get(format!("/{}", 1u64 << 32)).dispatch().await;
37+
let request = client.get(format!("/{}", 1u64 << 32));
38+
let mut response = request.dispatch().await;
3639
assert_eq!(response.body_string().await.unwrap(), "3");
3740
}
3841

‎core/codegen/tests/route.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,28 @@ async fn test_full_route() {
103103
let response = client.post(&uri).body(simple).dispatch().await;
104104
assert_eq!(response.status(), Status::NotFound);
105105

106-
let response = client.post(format!("/1{}", uri)).body(simple).dispatch().await;
106+
let request = client.post(format!("/1{}", uri)).body(simple);
107+
let response = request.dispatch().await;
107108
assert_eq!(response.status(), Status::NotFound);
108109

109-
let mut response = client
110+
let request = client
110111
.post(format!("/1{}", uri))
111112
.header(ContentType::JSON)
112-
.body(simple)
113-
.dispatch().await;
113+
.body(simple);
114+
let mut response = request.dispatch().await;
114115

115116
assert_eq!(response.body_string().await.unwrap(), format!("({}, {}, {}, {}, {}, {}) ({})",
116117
sky, name, "A A", "inside", path, simple, expected_uri));
117118

118-
let response = client.post(format!("/2{}", uri)).body(simple).dispatch().await;
119+
let request = client.post(format!("/2{}", uri)).body(simple);
120+
let response = request.dispatch().await;
119121
assert_eq!(response.status(), Status::NotFound);
120122

121-
let mut response = client
123+
let request = client
122124
.post(format!("/2{}", uri))
123125
.header(ContentType::JSON)
124-
.body(simple)
125-
.dispatch().await;
126+
.body(simple);
127+
let mut response = request.dispatch().await;
126128

127129
assert_eq!(response.body_string().await.unwrap(), format!("({}, {}, {}, {}, {}, {}) ({})",
128130
sky, name, "A A", "inside", path, simple, expected_uri));

‎core/lib/src/data/data.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ impl Data {
171171
pub fn stream_to_file<P: AsRef<Path> + Send + Unpin + 'static>(self, path: P) -> impl Future<Output = io::Result<u64>> {
172172
Box::pin(async move {
173173
let mut file = async_std::fs::File::create(path).await?;
174-
self.stream_to(&mut file).await
174+
let streaming = self.stream_to(&mut file);
175+
streaming.await
175176
})
176177
}
177178

‎core/lib/src/local/request.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ impl<'c> LocalRequest<'c> {
348348
#[inline(always)]
349349
pub async fn dispatch(mut self) -> LocalResponse<'c> {
350350
let r = self.long_lived_request();
351-
LocalRequest::_dispatch(self.client, r, self.request, &self.uri, self.data).await
351+
let dispatching = LocalRequest::_dispatch(self.client, r, self.request, &self.uri, self.data);
352+
dispatching.await
352353
}
353354

354355
/// Dispatches the request, returning the response.

‎core/lib/tests/form_value_decoding-issue-82.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ mod tests {
2222

2323
async fn check_decoding(raw: &str, decoded: &str) {
2424
let client = Client::new(rocket::ignite().mount("/", routes![bug])).unwrap();
25-
let mut response = client.post("/")
25+
let request = client.post("/")
2626
.header(ContentType::Form)
27-
.body(format!("form_data={}", raw))
28-
.dispatch().await;
27+
.body(format!("form_data={}", raw));
28+
let mut response = request.dispatch().await;
2929

3030
assert_eq!(response.status(), Status::Ok);
3131
assert_eq!(Some(decoded.to_string()), response.body_string().await);

‎core/lib/tests/segments-issues-41-86.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ mod tests {
4747
"/static", "/point/static"]
4848
{
4949
let path = "this/is/the/path/we/want";
50-
let mut response = client.get(format!("{}/{}", prefix, path)).dispatch().await;
50+
let request = client.get(format!("{}/{}", prefix, path));
51+
let mut response = request.dispatch().await;
5152
assert_eq!(response.body_string().await, Some(path.into()));
5253
}
5354
}

‎core/lib/tests/strict_and_lenient_forms.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,37 @@ mod strict_and_lenient_forms_tests {
3434
#[rocket::async_test]
3535
async fn test_strict_form() {
3636
let client = client();
37-
let mut response = client.post("/strict")
37+
let request = client.post("/strict")
3838
.header(ContentType::Form)
39-
.body(format!("field={}", FIELD_VALUE))
40-
.dispatch().await;
39+
.body(format!("field={}", FIELD_VALUE));
40+
let mut response = request.dispatch().await;
4141

4242
assert_eq!(response.status(), Status::Ok);
4343
assert_eq!(response.body_string().await, Some(FIELD_VALUE.into()));
4444

45-
let response = client.post("/strict")
45+
let request = client.post("/strict")
4646
.header(ContentType::Form)
47-
.body(format!("field={}&extra=whoops", FIELD_VALUE))
48-
.dispatch().await;
47+
.body(format!("field={}&extra=whoops", FIELD_VALUE));
48+
let response = request.dispatch().await;
4949

5050
assert_eq!(response.status(), Status::UnprocessableEntity);
5151
}
5252

5353
#[rocket::async_test]
5454
async fn test_lenient_form() {
5555
let client = client();
56-
let mut response = client.post("/lenient")
56+
let request = client.post("/lenient")
5757
.header(ContentType::Form)
58-
.body(format!("field={}", FIELD_VALUE))
59-
.dispatch().await;
58+
.body(format!("field={}", FIELD_VALUE));
59+
let mut response = request.dispatch().await;
6060

6161
assert_eq!(response.status(), Status::Ok);
6262
assert_eq!(response.body_string().await, Some(FIELD_VALUE.into()));
6363

64-
let mut response = client.post("/lenient")
64+
let request = client.post("/lenient")
6565
.header(ContentType::Form)
66-
.body(format!("field={}&extra=whoops", FIELD_VALUE))
67-
.dispatch().await;
66+
.body(format!("field={}&extra=whoops", FIELD_VALUE));
67+
let mut response = request.dispatch().await;
6868

6969
assert_eq!(response.status(), Status::Ok);
7070
assert_eq!(response.body_string().await, Some(FIELD_VALUE.into()));

‎core/lib/tests/uri-percent-encoding-issue-808.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ mod tests {
5252
async fn uri_percent_encoding_get() {
5353
let client = Client::new(rocket()).unwrap();
5454
let name = Uri::percent_encode(NAME);
55-
let mut response = client.get(format!("/hello/{}", name)).dispatch().await;
55+
let request = client.get(format!("/hello/{}", name));
56+
let mut response = request.dispatch().await;
5657
assert_eq!(response.status(), Status::Ok);
5758
assert_eq!(response.body_string().await.unwrap(), format!("Hello, {}!", NAME));
5859
}

‎examples/errors/src/tests.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ async fn test(uri: &str, status: Status, body: String) {
77
.register(catchers![super::not_found]);
88

99
let client = Client::new(rocket).unwrap();
10-
let mut response = client.get(uri).dispatch().await;
10+
let request = client.get(uri);
11+
let mut response = request.dispatch().await;
1112
assert_eq!(response.status(), status);
1213
assert_eq!(response.body_string().await, Some(body));
1314
}
@@ -16,7 +17,8 @@ async fn test(uri: &str, status: Status, body: String) {
1617
async fn test_hello() {
1718
let (name, age) = ("Arthur", 42);
1819
let uri = format!("/hello/{}/{}", name, age);
19-
test(&uri, Status::Ok, format!("Hello, {} year old named {}!", age, name)).await;
20+
let expected = format!("Hello, {} year old named {}!", age, name);
21+
test(&uri, Status::Ok, expected).await;
2022
}
2123

2224
#[rocket::async_test]

‎examples/hello_person/src/tests.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ async fn test_404(uri: &'static str) {
1818
#[rocket::async_test]
1919
async fn test_hello() {
2020
for &(name, age) in &[("Mike", 22), ("Michael", 80), ("A", 0), ("a", 127)] {
21-
test(format!("/hello/{}/{}", name, age),
22-
format!("Hello, {} year old named {}!", age, name)).await;
21+
let uri = format!("/hello/{}/{}", name, age);
22+
let expected = format!("Hello, {} year old named {}!", age, name);
23+
test(uri, expected).await;
2324
}
2425
}
2526

@@ -33,6 +34,7 @@ async fn test_failing_hello() {
3334
#[rocket::async_test]
3435
async fn test_hi() {
3536
for name in &["Mike", "A", "123", "hi", "c"] {
36-
test(format!("/hello/{}", name), name.to_string()).await;
37+
let uri = format!("/hello/{}", name);
38+
test(uri, name.to_string()).await;
3739
}
3840
}

‎examples/manual_routes/src/main.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ fn upload<'r>(req: &'r Request, data: Data) -> HandlerFuture<'r> {
5151
let file = File::create(env::temp_dir().join("upload.txt")).await;
5252
if let Ok(file) = file {
5353
if let Ok(n) = data.stream_to(file).await {
54-
return Outcome::from(req, format!("OK: {} bytes uploaded.", n)).await;
54+
let response = format!("OK: {} bytes uploaded.", n);
55+
return Outcome::from(req, response).await;
5556
}
5657

5758
println!(" => Failed copying.");
@@ -92,7 +93,8 @@ impl Handler for CustomHandler {
9293
.or_forward(data);
9394

9495
let id = try_outcome!(id_outcome);
95-
Outcome::from(req, format!("{} - {}", self_data, id)).await
96+
let response = format!("{} - {}", self_data, id);
97+
Outcome::from(req, response).await
9698
})
9799
}
98100
}

‎examples/manual_routes/src/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use rocket::http::{ContentType, Status};
55
fn test(uri: &str, content_type: ContentType, status: Status, body: String) {
66
rocket::async_test(async move {
77
let client = Client::new(rocket()).unwrap();
8-
let mut response = client.get(uri).header(content_type).dispatch().await;
8+
let request = client.get(uri).header(content_type);
9+
let mut response = request.dispatch().await;
910
assert_eq!(response.status(), status);
1011
assert_eq!(response.body_string().await, Some(body));
1112
})

‎examples/pastebin/src/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ async fn upload_paste(client: &Client, body: &str) -> String {
2525
}
2626

2727
async fn download_paste(client: &Client, id: &str) -> String {
28-
let mut response = client.get(format!("/{}", id)).dispatch().await;
28+
let request = client.get(format!("/{}", id));
29+
let mut response = request.dispatch().await;
2930
assert_eq!(response.status(), Status::Ok);
3031
response.body_string().await.unwrap()
3132
}

‎examples/query_params/src/tests.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@ use rocket::http::Status;
55
macro_rules! run_test {
66
($query:expr, |$response:ident| $body:expr) => ({
77
let client = Client::new(rocket()).unwrap();
8+
let request = client.get(format!("/hello{}", $query));
89
#[allow(unused_mut)]
9-
let mut $response = client.get(format!("/hello{}", $query)).dispatch().await;
10+
let mut $response = request.dispatch().await;
1011
$body
1112
})
1213
}

‎examples/ranking/src/tests.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,32 @@ use rocket::local::Client;
33
async fn test(uri: String, expected: String) {
44
let rocket = rocket::ignite().mount("/", routes![super::hello, super::hi]);
55
let client = Client::new(rocket).unwrap();
6-
let mut response = client.get(&uri).dispatch().await;
6+
let mut response = client.get(uri).dispatch().await;
77
assert_eq!(response.body_string().await, Some(expected));
88
}
99

1010
#[rocket::async_test]
1111
async fn test_hello() {
1212
for &(name, age) in &[("Mike", 22), ("Michael", 80), ("A", 0), ("a", 127)] {
13-
test(format!("/hello/{}/{}", name, age),
14-
format!("Hello, {} year old named {}!", age, name)).await;
13+
let uri = format!("/hello/{}/{}", name, age);
14+
let expected = format!("Hello, {} year old named {}!", age, name);
15+
test(uri, expected).await;
1516
}
1617
}
1718

1819
#[rocket::async_test]
1920
async fn test_failing_hello_hi() {
2021
// Invalid integers.
2122
for &(name, age) in &[("Mike", 1000), ("Michael", 128), ("A", -800), ("a", -200)] {
22-
test(format!("/hello/{}/{}", name, age),
23-
format!("Hi {}! Your age ({}) is kind of funky.", name, age)).await;
23+
let uri = format!("/hello/{}/{}", name, age);
24+
let expected = format!("Hi {}! Your age ({}) is kind of funky.", name, age);
25+
test(uri, expected).await;
2426
}
2527

2628
// Non-integers.
2729
for &(name, age) in &[("Mike", "!"), ("Michael", "hi"), ("A", "blah"), ("a", "0-1")] {
28-
test(format!("/hello/{}/{}", name, age),
29-
format!("Hi {}! Your age ({}) is kind of funky.", name, age)).await;
30+
let uri = format!("/hello/{}/{}", name, age);
31+
let expected = format!("Hi {}! Your age ({}) is kind of funky.", name, age);
32+
test(uri, expected).await;
3033
}
3134
}

‎examples/session/src/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ fn user_id_cookie(response: &Response<'_>) -> Option<Cookie<'static>> {
1414
}
1515

1616
async fn login(client: &Client, user: &str, pass: &str) -> Option<Cookie<'static>> {
17-
let response = client.post("/login")
17+
let request = client.post("/login")
1818
.header(ContentType::Form)
19-
.body(format!("username={}&password={}", user, pass))
20-
.dispatch().await;
19+
.body(format!("username={}&password={}", user, pass));
20+
let response = request.dispatch().await;
2121

2222
user_id_cookie(&response)
2323
}

‎examples/todo/src/tests.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ fn test_insertion_deletion() {
4949

5050
// Issue a request to delete the task.
5151
let id = new_tasks[0].id.unwrap();
52-
client.delete(format!("/todo/{}", id)).dispatch().await;
52+
let request = client.delete(format!("/todo/{}", id));
53+
request.dispatch().await;
5354

5455
// Ensure it's gone.
5556
let final_tasks = Task::all(&conn);
@@ -73,11 +74,13 @@ fn test_toggle() {
7374
assert_eq!(task.completed, false);
7475

7576
// Issue a request to toggle the task; ensure it is completed.
76-
client.put(format!("/todo/{}", task.id.unwrap())).dispatch().await;
77+
let request = client.put(format!("/todo/{}", task.id.unwrap()));
78+
request.dispatch().await;
7779
assert_eq!(Task::all(&conn)[0].completed, true);
7880

7981
// Issue a request to toggle the task; ensure it's not completed again.
80-
client.put(format!("/todo/{}", task.id.unwrap())).dispatch().await;
82+
let request = client.put(format!("/todo/{}", task.id.unwrap()));
83+
request.dispatch().await;
8184
assert_eq!(Task::all(&conn)[0].completed, false);
8285
})
8386
}
@@ -94,10 +97,10 @@ fn test_many_insertions() {
9497
for i in 0..ITER {
9598
// Issue a request to insert a new task with a random description.
9699
let desc: String = thread_rng().sample_iter(&Alphanumeric).take(12).collect();
97-
client.post("/todo")
100+
let request = client.post("/todo")
98101
.header(ContentType::Form)
99-
.body(format!("description={}", desc))
100-
.dispatch().await;
102+
.body(format!("description={}", desc));
103+
request.dispatch().await;
101104

102105
// Record the description we choose for this iteration.
103106
descs.insert(0, desc);

0 commit comments

Comments
 (0)
Please sign in to comment.