0

Running cargo build with the following dependencies:

[dependencies]
solana-sdk = "1.18.17"
solana-client = "1.18.17"

Results in the following compile errors:

error[E0659]: `solana_program` is ambiguous
 --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/error.rs:6:1
  |
6 | #[spl_program_error(hash_error_code_start = 1_202_666_432)]
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous name
  |
  = note: ambiguous because of a conflict between a name from a glob import and an outer scope during import or macro resolution
  = note: `solana_program` could refer to a crate passed with `--extern`
  = help: use `::solana_program` to refer to this crate unambiguously
note: `solana_program` could also refer to the crate imported here
 --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/error.rs:3:5
  |
3 | use spl_program_error::*;
  |     ^^^^^^^^^^^^^^^^^^^^
  = help: consider adding an explicit import of `solana_program` to disambiguate
  = help: or use `self::solana_program` to refer to this crate unambiguously
  = note: this error originates in the attribute macro `spl_program_error` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
  --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:49:10
   |
39 |   ) -> Result<TlvIndices, ProgramError> {
   |        -------------------------------- expected `solana_program::program_error::ProgramError` because of this
...
47 |           let discriminator = ArrayDiscriminator::try_from(
   |  _____________________________-
48 | |             &tlv_data[tlv_indices.type_start..tlv_indices.length_start],
49 | |         )?;
   | |         -^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<TlvIndices, solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
   | |_________|
   |           this can't be annotated with `?` because it has type `Result<_, spl_program_error::solana_program::program_error::ProgramError>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = help: the following other types implement trait `From<T>`:
             <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
             <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
             <solana_program::program_error::ProgramError as From<std::io::Error>>
             <solana_program::program_error::ProgramError as From<u64>>
   = note: required for `Result<TlvIndices, solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: the trait bound `solana_program::program_error::ProgramError: From<TlvError>` is not satisfied
  --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:63:51
   |
63 |                 return Err(TlvError::TypeNotFound.into());
   |                                                   ^^^^ the trait `From<TlvError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `TlvError: Into<_>`
   |
   = help: the following other types implement trait `From<T>`:
             <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
             <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
             <solana_program::program_error::ProgramError as From<std::io::Error>>
             <solana_program::program_error::ProgramError as From<u64>>
   = note: required for `TlvError` to implement `Into<solana_program::program_error::ProgramError>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
  --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:67:99
   |
39 | ) -> Result<TlvIndices, ProgramError> {
   |      -------------------------------- expected `solana_program::program_error::ProgramError` because of this
...
67 |             pod_from_bytes::<Length>(&tlv_data[tlv_indices.length_start..tlv_indices.value_start])?;
   |             --------------------------------------------------------------------------------------^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<TlvIndices, solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
   |             |
   |             this can't be annotated with `?` because it has type `Result<_, spl_program_error::solana_program::program_error::ProgramError>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = help: the following other types implement trait `From<T>`:
             <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
             <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
             <solana_program::program_error::ProgramError as From<std::io::Error>>
             <solana_program::program_error::ProgramError as From<u64>>
   = note: required for `Result<TlvIndices, solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
  --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:98:10
   |
80 |   ) -> Result<(Vec<ArrayDiscriminator>, usize), ProgramError> {
   |        ------------------------------------------------------ expected `solana_program::program_error::ProgramError` because of this
...
96 |           let discriminator = ArrayDiscriminator::try_from(
   |  _____________________________-
97 | |             &tlv_data[tlv_indices.type_start..tlv_indices.length_start],
98 | |         )?;
   | |         -^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<(Vec<ArrayDiscriminator>, usize), solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
   | |_________|
   |           this can't be annotated with `?` because it has type `Result<_, spl_program_error::solana_program::program_error::ProgramError>`
   |
   = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
   = help: the following other types implement trait `From<T>`:
             <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
             <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
             <solana_program::program_error::ProgramError as From<std::io::Error>>
             <solana_program::program_error::ProgramError as From<u64>>
   = note: required for `Result<(Vec<ArrayDiscriminator>, usize), solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:109:14
    |
80  |   ) -> Result<(Vec<ArrayDiscriminator>, usize), ProgramError> {
    |        ------------------------------------------------------ expected `solana_program::program_error::ProgramError` because of this
...
107 |               let length = pod_from_bytes::<Length>(
    |  __________________________-
108 | |                 &tlv_data[tlv_indices.length_start..tlv_indices.value_start],
109 | |             )?;
    | |             -^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<(Vec<ArrayDiscriminator>, usize), solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
    | |_____________|
    |               this can't be annotated with `?` because it has type `Result<_, spl_program_error::solana_program::program_error::ProgramError>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `Result<(Vec<ArrayDiscriminator>, usize), solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:141:80
    |
127 | ) -> Result<&[u8], ProgramError> {
    |      --------------------------- expected `solana_program::program_error::ProgramError` because of this
...
141 |     let length = pod_from_bytes::<Length>(&tlv_data[length_start..value_start])?;
    |                  --------------------------------------------------------------^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<&[u8], solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
    |                  |
    |                  this can't be annotated with `?` because it has type `Result<_, spl_program_error::solana_program::program_error::ProgramError>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `Result<&[u8], solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0308]: mismatched types
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:216:9
    |
214 |     ) -> Result<&V, ProgramError> {
    |          ------------------------ expected `Result<&V, solana_program::program_error::ProgramError>` because of return type
215 |         let data = get_bytes::<V>(self.get_data(), repetition_number)?;
216 |         pod_from_bytes::<V>(data)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ProgramError`, found a different `ProgramError`
    |
    = note: `ProgramError` and `ProgramError` have similar names, but are actually distinct types
note: `ProgramError` is defined in crate `solana_program`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-program-1.18.17/src/program_error.rs:14:1
    |
14  | pub enum ProgramError {
    | ^^^^^^^^^^^^^^^^^^^^^
note: `ProgramError` is defined in crate `solana_program`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-program-2.0.1/src/program_error.rs:15:1
    |
15  | pub enum ProgramError {
    | ^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0308]: mismatched types
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:333:9
    |
331 |     ) -> Result<&mut V, ProgramError> {
    |          ---------------------------- expected `Result<&mut V, solana_program::program_error::ProgramError>` because of return type
332 |         let data = self.get_bytes_with_repetition_mut::<V>(repetition_number)?;
333 |         pod_from_bytes_mut::<V>(data)
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `ProgramError`, found a different `ProgramError`
    |
    = note: `ProgramError` and `ProgramError` have similar names, but are actually distinct types
note: `ProgramError` is defined in crate `solana_program`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-program-1.18.17/src/program_error.rs:14:1
    |
14  | pub enum ProgramError {
    | ^^^^^^^^^^^^^^^^^^^^^
note: `ProgramError` is defined in crate `solana_program`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/solana-program-2.0.1/src/program_error.rs:15:1
    |
15  | pub enum ProgramError {
    | ^^^^^^^^^^^^^^^^^^^^^
    = note: perhaps two different versions of crate `solana_program` are being used?

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:362:85
    |
362 |         let length = pod_from_bytes::<Length>(&self.data[length_start..value_start])?;
    |                                                                                     ^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<&mut [u8], solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `Result<&mut [u8], solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:387:60
    |
387 |         let extension_ref = pod_from_bytes_mut::<V>(buffer)?;
    |                                                            ^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<(&mut V, usize), solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `Result<(&mut V, usize), solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:432:95
    |
432 |         let discriminator = ArrayDiscriminator::try_from(&self.data[type_start..length_start])?;
    |                                                                                               ^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<(&mut [u8], usize), solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `Result<(&mut [u8], usize), solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:439:88
    |
439 |                 pod_from_bytes_mut::<Length>(&mut self.data[length_start..value_start])?;
    |                                                                                        ^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<(&mut [u8], usize), solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `Result<(&mut [u8], usize), solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: the trait bound `solana_program::program_error::ProgramError: From<TlvError>` is not satisfied
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:451:45
    |
451 |             Err(TlvError::TypeAlreadyExists.into())
    |                                             ^^^^ the trait `From<TlvError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `TlvError: Into<_>`
    |
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `TlvError` to implement `Into<solana_program::program_error::ProgramError>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:490:97
    |
490 |         let length_ref = pod_from_bytes_mut::<Length>(&mut self.data[length_start..value_start])?;
    |                                                                                                 ^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<&mut [u8], solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `Result<&mut [u8], solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

error[E0277]: `?` couldn't convert the error to `solana_program::program_error::ProgramError`
   --> /Users/johnliu/.cargo/registry/src/index.crates.io-6f17d22bba15001f/spl-type-length-value-0.3.1/src/state.rs:556:84
    |
547 | ) -> Result<(), ProgramError> {
    |      ------------------------ expected `solana_program::program_error::ProgramError` because of this
...
556 |         usize::try_from(*pod_from_bytes::<Length>(&data[length_start..value_start])?)?
    |                          ----------------------------------------------------------^ the trait `From<spl_program_error::solana_program::program_error::ProgramError>` is not implemented for `solana_program::program_error::ProgramError`, which is required by `Result<(), solana_program::program_error::ProgramError>: FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`
    |                          |
    |                          this can't be annotated with `?` because it has type `Result<_, spl_program_error::solana_program::program_error::ProgramError>`
    |
    = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
    = help: the following other types implement trait `From<T>`:
              <solana_program::program_error::ProgramError as From<solana_program::pubkey::PubkeyError>>
              <solana_program::program_error::ProgramError as From<solana_program::stake::instruction::StakeError>>
              <solana_program::program_error::ProgramError as From<std::io::Error>>
              <solana_program::program_error::ProgramError as From<u64>>
    = note: required for `Result<(), solana_program::program_error::ProgramError>` to implement `FromResidual<Result<Infallible, spl_program_error::solana_program::program_error::ProgramError>>`

Some errors have detailed explanations: E0277, E0308, E0659.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `spl-type-length-value` (lib) due to 16 previous errors

1 Answer 1

1

Solution seems to be to add spl-type-length-value = "=0.3.0".

[dependencies]
solana-sdk = "1.18.17"
solana-client = "1.18.17"
spl-type-length-value = "=0.3.0"

https://github.com/cavemanloverboy/sol/pull/11

https://github.com/solana-labs/solana-program-library/issues/6897

1
  • The 0.3.1 crate has been yanked, so this should just work now
    – Jon C
    Commented Jun 28 at 21:04

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.