1

I'm encountering two specific Rust errors while running avm install 0.29.0. These errors seem to involve type inference issues and a mismatched return type in my code. Below is the relevant code and the errors I'm facing.

pub fn parse_borrowed<const VERSION: usize>(
s: &str,) -> Result<Vec<crate::format_description::FormatItem<'_>>, crate::error::InvalidFormatDescription> {
validate_version!(VERSION);
let mut lexed = lexer::lex::<VERSION>(s.as_bytes());
let ast = ast::parse::<_, VERSION>(&mut lexed);
let format_items = format_item::parse(ast);
Ok(format_items
    .map(|res| res.and_then(TryInto::try_into))
    .collect::<Result<Vec<_>, _>>());}

2nd function:

pub fn parse_owned<const VERSION: usize>(
s: &str,) -> Result<crate::format_description::OwnedFormatItem, crate::error::InvalidFormatDescription> {
validate_version!(VERSION);
let mut lexed = lexer::lex::<VERSION>(s.as_bytes());
let ast = ast::parse::<_, VERSION>(&mut lexed);
let format_items = format_item::parse(ast);
let items: Box<_> = format_items
    .map(|res| res.map(Into::into))
    .collect::<Result<Box<_>, _>>()?;
Ok(items.into())}

errors:

eerror[E0308]: mismatched types --> /root/.cargo/registry/src/index.crates.io 6f17d22bba15001f/time-0.3.29/src/format_description/parse/mod.rs:55:6 | 53 | pub fn parse_borrowed<const VERSION: usize>( |-------------- implicitly returns `()` as its body has no tail or `return` expression 54 | s: &str, 55 | ) -> Result<Vec<crate::format_description::FormatItem<'_>>, crate::error::InvalidFormatDescription> |      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<Vec<BorrowedFormatItem<'_>>, ...>`, found `()`|= note: expected enum `std::result::Result<Vec<BorrowedFormatItem<'_>>, InvalidFormatDescription>`
       found unit type `()` error[E0282]: type annotations needed --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.29/src/format_description/parse/mod.rs:86:10 | 86 |         .collect::<Result<Box<_>, _>>()?; |^^^^^^^ cannot infer type of the type parameter `B` declared on the method `collect` 87 |     Ok(items.into()) |---- type must be known at this point | help: consider specifying the generic argument| 86 | .collect::<Vec<_>>()?; | ~~~~~~~~~~
1
  • What version rust are you running?
    – Jimii
    Commented Aug 22 at 8:55

1 Answer 1

0

install rustc < 1.80

rustup install 1.79

set default version

rustup default 1.79-x86_64-unknown-linux-gnu # (linux) rustup default 1.79-aarch64-apple-darwin # (MacOS)

proceed with normal install...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.