Closed JKRhb closed 2 years ago
Seems like most of these issues are a result of missing imports, as types like Vec
or String
are usually part of the std
prelude, but have to be imported manually if the alloc
crate is used.
PS: We should probably add tests to our CI pipeline that run with no-std
to prevent these compile-time errors in the future.
When adding
dcaf
to ano_std
project (withdefault-features
set tofalse
), the build process fails with the following error messages:Terminal output of the error messages
``` Compiling dcaf v0.3.1 error[E0433]: failed to resolve: use of undeclared crate or module `std` --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:53:5 | 53 | use std::any::type_name; | ^^^ use of undeclared crate or module `std` error[E0433]: failed to resolve: use of undeclared crate or module `std` --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/error/mod.rs:16:5 | 16 | use std::marker::PhantomData; | ^^^ use of undeclared crate or module `std` error[E0433]: failed to resolve: use of undeclared crate or module `std` --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/error/mod.rs:17:5 | 17 | use std::num::TryFromIntError; | ^^^ use of undeclared crate or module `std` error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_values/mod.rs:192:21 | 192 | vec![( | ^^^ | = note: consider importing this macro: alloc::vec error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_values/mod.rs:199:21 | 199 | vec![( | ^^^ | = note: consider importing this macro: alloc::vec error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_values/mod.rs:208:21 | 208 | vec![(x, Some(Box::new(Value::Bytes(kid.clone()))))] | ^^^ | = note: consider importing this macro: alloc::vec error: cannot find macro `format` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_values/mod.rs:226:63 | 226 | ... TryFromCborMapError::from_message(format!( | ^^^^^^ | = note: consider importing this macro: alloc::format error: cannot find macro `format` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_values/mod.rs:233:63 | 233 | ... TryFromCborMapError::from_message(format!( | ^^^^^^ | = note: consider importing this macro: alloc::format error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/scope/mod.rs:675:20 | 675 | Ok(vec![self.0.as_slice()]) | ^^^ | = note: consider importing this macro: alloc::vec error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/scope/mod.rs:770:26 | 770 | Value::Array(vec![ | ^^^ | = note: consider importing this macro: alloc::vec error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/scope/mod.rs:824:26 | 824 | Value::Array(vec![ | ^^^ | = note: consider importing this macro: alloc::vec error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/scope/mod.rs:918:13 | 918 | vec![self.element()] | ^^^ | = note: consider importing this macro: alloc::vec error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/scope/mod.rs:924:13 | 924 | vec![self.to_element()] | ^^^ | = note: consider importing this macro: alloc::vec error: cannot find macro `format` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/error/mod.rs:110:22 | 110 | message: format!("couldn't build {name}: {builder_error}"), | ^^^^^^ | = note: consider importing this macro: alloc::format error: cannot find macro `format` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/error/mod.rs:98:22 | 98 | message: format!("unknown field with key {key} encountered"), | ^^^^^^ | = note: consider importing this macro: alloc::format error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:85:10 | 85 | vec![$( | ^^^ | ::: /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/endpoints/creation_hint/mod.rs:138:20 | 138 | return cbor_map_vec! { | ____________________- 139 | | creation_hint::AS => self.auth_server.as_ref(), 140 | | creation_hint::KID => self.kid.as_ref(), 141 | | creation_hint::AUDIENCE => self.audience.as_ref(), 142 | | creation_hint::SCOPE => self.scope.as_ref(), 143 | | creation_hint::CNONCE => self.client_nonce.as_ref().map(|v| Value::Bytes(v.clone())) 144 | | }; | |_____________- in this macro invocation | = note: consider importing this macro: alloc::vec = note: this error originates in the macro `cbor_map_vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find macro `format` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:320:43 | 320 | TryFromCborMapError::from_message(format!( | ^^^^^^ | = note: consider importing this macro: alloc::format error: cannot find macro `format` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:299:58 | 299 | return Err(TryFromCborMapError::from_message(format!( | ^^^^^^ | = note: consider importing this macro: alloc::format error: cannot find macro `format` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:285:56 | 285 | .map_err(|e| TryFromCborMapError::from_message(format!("couldn't decode scope: {e}"))) | ^^^^^^ | = note: consider importing this macro: alloc::format error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:85:10 | 85 | vec![$( | ^^^ | ::: /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/endpoints/token_req/mod.rs:838:13 | 838 | / cbor_map_vec! { 839 | | token::ERROR => Some(error), 840 | | token::ERROR_DESCRIPTION => self.description.as_ref(), 841 | | token::ERROR_URI => self.uri.as_ref() 842 | | } | |_____________- in this macro invocation | = note: consider importing this macro: alloc::vec = note: this error originates in the macro `cbor_map_vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:85:10 | 85 | vec![$( | ^^^ | ::: /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/endpoints/token_req/mod.rs:777:13 | 777 | / ... cbor_map_vec! { 778 | | ... token::ACCESS_TOKEN => Some(Value::Bytes(self.access_token.clone())), 779 | | ... token::EXPIRES_IN => self.expires_in, 780 | | ... introspection::ISSUED_AT => self.issued_at.as_ref().map(|x| x.clone().to_cbor_value().expect("serialization of issued_at failed... ... | 786 | | ... token::RS_CNF => self.rs_cnf.as_ref().map(ToCborMap::to_ciborium_value) 787 | | ... } | |_______- in this macro invocation | = note: consider importing this macro: alloc::vec = note: this error originates in the macro `cbor_map_vec` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot find macro `vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:85:10 | 85 | vec![$( | ^^^ | ::: /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/endpoints/token_req/mod.rs:727:13 | 727 | / cbor_map_vec! { 728 | | introspection::ISSUER => self.issuer.as_ref(), 729 | | token::REQ_CNF => self.req_cnf.as_ref().map(ToCborMap::to_ciborium_value), 730 | | token::AUDIENCE => self.audience.as_ref(), ... | 736 | | token::CNONCE => self.client_nonce.as_ref().map(|v| Value::Bytes(v.clone())) 737 | | } | |_____________- in this macro invocation | = note: consider importing this macro: alloc::vec = note: this error originates in the macro `cbor_map_vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0412]: cannot find type `Vec` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_map/mod.rs:404:30 | 404 | let map: Vec<(i128, Value)> = | ^^^ not found in this scope | help: consider importing one of these items | 367 | use alloc::vec::Vec; | 367 | use crate::common::cbor_map::Vec; | 367 | use serde::__private::Vec; | error[E0412]: cannot find type `Box` in this scope --> /home/janro/.cargo/registry/src/github.com-1ecc6299db9ec823/dcaf-0.3.1/src/common/cbor_values/mod.rs:187:52 | 187 | fn to_cbor_map(&self) -> Vec<(i128, Option