Repository: rwf2/Rocket (language: rust)

Issue:
Unable to build with custom target JSON spec
I'm unable to build a project with Rocket when using a custom JSON target spec.

### Rocket version
0.4.6

### Operating system
```
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.1 LTS
Release:	20.04
Codename:	focal
```

### What is expected
A successful build.

### What actually happens
```
$ cargo build -Z build-std --target x86_64-custom-linux-gnu.json

...

error[E0107]: wrong number of type arguments: expected 3, found 2
   --> /home/yungkneez/.cargo/registry/src/github.com-1ecc6299db9ec823/rocket_http-0.4.6/src/header.rs:124:14
    |
124 |     headers: IndexMap<Uncased<'h>, Vec<Cow<'h, str>>>
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 3 type arguments

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.
error: could not compile `rocket_http`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
```

### Steps to reproduce (with nightly)

1. `cargo new rocket-custom-target && cd rocket-custom-target`
2. `rustc -Z unstable-options --print target-spec-json --target x86_64-unknown-linux-gnu > x86_64-custom-linux-gnu.json`
#### Cargo.toml
```
[package]
name = "rocket-custom-target"
version = "0.1.0"
authors = ["yungkneez"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rocket = "0.4.6"

```

#### src/main.rs
```
#![feature(decl_macro)]

#[macro_use] extern crate rocket;

#[get("/<name>/<age>")]
fn hello(name: String, age: u8) -> String {
    format!("Hello, {} year old named {}!", age, name)
}

fn main() {
	let _r = rocket::ignite().mount("/hello", routes![hello]);
}

```
3. `cargo build -Z build-std --target x86_64-custom-linux-gnu.json`

### What is happening
indexmap (a dependency in rocket_http) uses autocfg to determine if std is available. If autocfg cannot find std, `S = RandomState` is not provided by default. See https://github.com/bluss/indexmap/pull/145.

To support custom targets for which std is available, we can enable the `std` feature for indexmap.



Discussion / hints:

Fix patch:
diff --git a/core/http/Cargo.toml b/core/http/Cargo.toml
index b4bd1c317f..9e0d4947ee 100644
--- a/core/http/Cargo.toml
+++ b/core/http/Cargo.toml
@@ -26,7 +26,7 @@ hyper = { version = "0.13.0", default-features = false, features = ["runtime"] }
 http = "0.2"
 mime = "0.3.13"
 time = "0.2.11"
-indexmap = "1.0"
+indexmap = { version = "1.5.2", features = ["std"] }
 state = "0.4"
 tokio-rustls = { version = "0.14.0", optional = true }
 tokio = { version = "0.2.9", features = ["sync", "tcp", "time"] }


Test patch:
diff --git a/core/codegen/tests/ui-fail-stable/from_form_type_errors.stderr b/core/codegen/tests/ui-fail-stable/from_form_type_errors.stderr
index dfc48ea809..db8525ba0f 100644
--- a/core/codegen/tests/ui-fail-stable/from_form_type_errors.stderr
+++ b/core/codegen/tests/ui-fail-stable/from_form_type_errors.stderr
@@ -3,9 +3,13 @@ error[E0277]: the trait bound `Unknown: FromFormValue<'_>` is not satisfied
   |
 7 |     field: Unknown,
   |     ^^^^^ the trait `FromFormValue<'_>` is not implemented for `Unknown`
+  |
+  = note: required by `from_form_value`
 
 error[E0277]: the trait bound `Foo<usize>: FromFormValue<'_>` is not satisfied
   --> $DIR/from_form_type_errors.rs:14:5
    |
 14 |     field: Foo<usize>,
    |     ^^^^^ the trait `FromFormValue<'_>` is not implemented for `Foo<usize>`
+   |
+   = note: required by `from_form_value`
diff --git a/core/codegen/tests/ui-fail-stable/route-type-errors.stderr b/core/codegen/tests/ui-fail-stable/route-type-errors.stderr
index bfc5f6df7a..26a525ff7e 100644
--- a/core/codegen/tests/ui-fail-stable/route-type-errors.stderr
+++ b/core/codegen/tests/ui-fail-stable/route-type-errors.stderr
@@ -3,30 +3,43 @@ error[E0277]: the trait bound `Q: FromParam<'_>` is not satisfied
   |
 6 | fn f0(foo: Q) {}
   |            ^ the trait `FromParam<'_>` is not implemented for `Q`
+  |
+  = note: required by `from_param`
 
 error[E0277]: the trait bound `Q: FromSegments<'_>` is not satisfied
  --> $DIR/route-type-errors.rs:9:12
   |
 9 | fn f1(foo: Q) {}
   |            ^ the trait `FromSegments<'_>` is not implemented for `Q`
+  |
+  = note: required by `from_segments`
 
 error[E0277]: the trait bound `Q: FromFormValue<'_>` is not satisfied
   --> $DIR/route-type-errors.rs:12:12
    |
 12 | fn f2(foo: Q) {}
    |            ^ the trait `FromFormValue<'_>` is not implemented for `Q`
+   |
+   = note: required by `from_form_value`
 
 error[E0277]: the trait bound `Q: FromFormValue<'_>` is not satisfied
-  --> $DIR/route-type-errors.rs:12:7
-   |
-12 | fn f2(foo: Q) {}
-   |       ^^^^^^ the trait `FromFormValue<'_>` is not implemented for `Q`
+   --> $DIR/route-type-errors.rs:12:7
+    |
+12  | fn f2(foo: Q) {}
+    |       ^^^^^^ the trait `FromFormValue<'_>` is not implemented for `Q`
+    |
+   ::: $WORKSPACE/core/lib/src/request/form/from_form_value.rs
+    |
+    | pub trait FromFormValue<'v>: Sized {
+    | ---------------------------------- required by this bound in `FromFormValue`
 
 error[E0277]: the trait bound `Q: FromQuery<'_>` is not satisfied
   --> $DIR/route-type-errors.rs:15:12
    |
 15 | fn f3(foo: Q) {}
    |            ^ the trait `FromQuery<'_>` is not implemented for `Q`
+   |
+   = note: required by `from_query`
 
 error[E0277]: the trait bound `Q: FromData` is not satisfied
   --> $DIR/route-type-errors.rs:18:12
@@ -37,31 +50,47 @@ error[E0277]: the trait bound `Q: FromData` is not satisfied
    = note: required because of the requirements on the impl of `FromTransformedData<'_>` for `Q`
 
 error[E0277]: the trait bound `Q: FromRequest<'_, '_>` is not satisfied
-  --> $DIR/route-type-errors.rs:21:10
-   |
-21 | fn f5(a: Q, foo: Q) {}
-   |          ^ the trait `FromRequest<'_, '_>` is not implemented for `Q`
+   --> $DIR/route-type-errors.rs:21:10
+    |
+21  | fn f5(a: Q, foo: Q) {}
+    |          ^ the trait `FromRequest<'_, '_>` is not implemented for `Q`
+    |
+   ::: $WORKSPACE/core/lib/src/request/from_request.rs
+    |
+    | #[crate::async_trait]
+    | --------------------- required by this bound in `from_request`
 
 error[E0277]: the trait bound `Q: FromParam<'_>` is not satisfied
   --> $DIR/route-type-errors.rs:21:18
    |
 21 | fn f5(a: Q, foo: Q) {}
    |                  ^ the trait `FromParam<'_>` is not implemented for `Q`
+   |
+   = note: required by `from_param`
 
 error[E0277]: the trait bound `Q: FromRequest<'_, '_>` is not satisfied
-  --> $DIR/route-type-errors.rs:24:10
-   |
-24 | fn f6(a: Q, foo: Q, good: usize, bar: Q) {}
-   |          ^ the trait `FromRequest<'_, '_>` is not implemented for `Q`
+   --> $DIR/route-type-errors.rs:24:10
+    |
+24  | fn f6(a: Q, foo: Q, good: usize, bar: Q) {}
+    |          ^ the trait `FromRequest<'_, '_>` is not implemented for `Q`
+    |
+   ::: $WORKSPACE/core/lib/src/request/from_request.rs
+    |
+    | #[crate::async_trait]
+    | --------------------- required by this bound in `from_request`
 
 error[E0277]: the trait bound `Q: FromParam<'_>` is not satisfied
   --> $DIR/route-type-errors.rs:24:18
    |
 24 | fn f6(a: Q, foo: Q, good: usize, bar: Q) {}
    |                  ^ the trait `FromParam<'_>` is not implemented for `Q`
+   |
+   = note: required by `from_param`
 
 error[E0277]: the trait bound `Q: FromParam<'_>` is not satisfied
   --> $DIR/route-type-errors.rs:24:39
    |
 24 | fn f6(a: Q, foo: Q, good: usize, bar: Q) {}
    |                                       ^ the trait `FromParam<'_>` is not implemented for `Q`
+   |
+   = note: required by `from_param`
diff --git a/core/codegen/tests/ui-fail-stable/typed-uri-bad-type.stderr b/core/codegen/tests/ui-fail-stable/typed-uri-bad-type.stderr
index 0ef33a7afd..b5b6164115 100644
--- a/core/codegen/tests/ui-fail-stable/typed-uri-bad-type.stderr
+++ b/core/codegen/tests/ui-fail-stable/typed-uri-bad-type.stderr
@@ -39,6 +39,8 @@ error[E0277]: the trait bound `S: FromUriParam<rocket::http::uri::Path, _>` is n
    |
 48 |     uri!(not_uri_display: 10, S);
    |                               ^ the trait `FromUriParam<rocket::http::uri::Path, _>` is not implemented for `S`
+   |
+   = note: required by `from_uri_param`
 
 error[E0277]: the trait bound `i32: FromUriParam<rocket::http::uri::Path, std::option::Option<{integer}>>` is not satisfied
   --> $DIR/typed-uri-bad-type.rs:53:26
@@ -51,6 +53,7 @@ error[E0277]: the trait bound `i32: FromUriParam<rocket::http::uri::Path, std::o
              <i32 as FromUriParam<P, &'x mut i32>>
              <i32 as FromUriParam<P, i32>>
    = note: required because of the requirements on the impl of `FromUriParam<rocket::http::uri::Path, std::option::Option<{integer}>>` for `std::option::Option<i32>`
+   = note: required by `from_uri_param`
 
 error[E0277]: the trait bound `std::string::String: FromUriParam<rocket::http::uri::Path, std::result::Result<_, _>>` is not satisfied
   --> $DIR/typed-uri-bad-type.rs:53:43
@@ -65,6 +68,7 @@ error[E0277]: the trait bound `std::string::String: FromUriParam<rocket::http::u
              <std::string::String as FromUriParam<P, &'x mut std::string::String>>
            and 2 others
    = note: required because of the requirements on the impl of `FromUriParam<rocket::http::uri::Path, std::result::Result<_, _>>` for `std::result::Result<std::string::String, &RawStr>`
+   = note: required by `from_uri_param`
 
 error[E0277]: the trait bound `isize: FromUriParam<rocket::http::uri::Query, &str>` is not satisfied
   --> $DIR/typed-uri-bad-type.rs:55:20
@@ -95,12 +99,16 @@ error[E0277]: the trait bound `S: FromUriParam<rocket::http::uri::Query, _>` is
    |
 59 |     uri!(other_q: 100, S);
    |                        ^ the trait `FromUriParam<rocket::http::uri::Query, _>` is not implemented for `S`
+   |
+   = note: required by `from_uri_param`
 
 error[E0277]: the trait bound `S: FromUriParam<rocket::http::uri::Query, _>` is not satisfied
   --> $DIR/typed-uri-bad-type.rs:61:26
    |
 61 |     uri!(other_q: rest = S, id = 100);
    |                          ^ the trait `FromUriParam<rocket::http::uri::Query, _>` is not implemented for `S`
+   |
+   = note: required by `from_uri_param`
 
 error[E0277]: the trait bound `S: Ignorable<rocket::http::uri::Query>` is not satisfied
    --> $DIR/typed-uri-bad-type.rs:36:29
@@ -139,6 +147,8 @@ error[E0277]: the trait bound `S: FromUriParam<rocket::http::uri::Query, _>` is
    |
 65 |     uri!(other_q: rest = S, id = _);
    |                          ^ the trait `FromUriParam<rocket::http::uri::Query, _>` is not implemented for `S`
+   |
+   = note: required by `from_uri_param`
 
 error[E0277]: the trait bound `std::option::Option<i32>: FromUriParam<rocket::http::uri::Query, {integer}>` is not satisfied
   --> $DIR/typed-uri-bad-type.rs:69:28