How do I fix type mismatch and type annotation errors when running avm install 0.29.0?

How do I fix type mismatch and type annotation errors when running avm install 0.29.0?

Manage alerts

Loading saved threads...

jpepesi · External communityPost link
External question — Solana Stack Exchange Author: jpepesi Original post: https://solana.stackexchange.com/questions/16116 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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<_>>()?; | ~~~~~~~~~~
Quote
Report
wonder boz · External communityPost link
External answer — Solana Stack Exchange Author: wonder boz Original post: https://solana.stackexchange.com/a/16256 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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...
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Solana Stack Exchange Author: jpepesi Source score (net votes, not local likes): 1 Original post: https://solana.stackexchange.com/questions/16116 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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<_>>()?; | ~~~~~~~~~~

Cancel quote

Checking account access…