Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation fix #67

Merged

Conversation

michalkucharczyk
Copy link
Contributor

@michalkucharczyk michalkucharczyk commented Mar 28, 2024

fixing following error (introduced in #57):

error: the item `ToString` is imported redundantly
  --> src/lib.rs:48:26
error: the item `Vec` is imported redundantly
  --> src/lib.rs:48:44

error: could not compile `bip39` (lib) due to 2 previous errors

@michalkucharczyk
Copy link
Contributor Author

cc: @stevenroose @tcharding

Copy link
Member

@tcharding tcharding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just lint warnings, right? @stevenroose is in the process of releasing right now so I'm not sure this will go in. Thanks for coming back to do the fix!

src/lib.rs Outdated Show resolved Hide resolved
@michalkucharczyk
Copy link
Contributor Author

michalkucharczyk commented Mar 28, 2024

This is just lint warnings, right? @stevenroose is in the process of releasing right now so I'm not sure this will go in. Thanks for coming back to do the fix!

Actually compilation error, CI failed on master with new rustc version:
https://github.com/rust-bitcoin/rust-bip39/actions/runs/8472579312/job/23214974279

fixing:
error: the item `ToString` is imported redundantly
  --> src/lib.rs:48:26
error: the item `Vec` is imported redundantly
  --> src/lib.rs:48:44

error: could not compile `bip39` (lib) due to 2 previous errors
@stevenroose stevenroose merged commit 627aa96 into rust-bitcoin:master Apr 2, 2024
6 checks passed
@michalkucharczyk
Copy link
Contributor Author

michalkucharczyk commented Apr 3, 2024

It is not a compiler problem as I stated in previous comment.
This command will fail:

cargo build --release --no-default-features  --features=alloc --lib

Error message I see is:

error[E0412]: cannot find type `Vec` in this scope
   --> src/lib.rs:107:26
    |
107 |     pub fn to_vec(&self) -> Vec<Language> {
    |                             ^^^ not found in this scope
    |
help: consider importing this struct
    |
47  + use alloc::vec::Vec;
    |

error[E0412]: cannot find type `Vec` in this scope
   --> src/lib.rs:608:30
    |
608 |     pub fn to_entropy(&self) -> Vec<u8> {
    |                                 ^^^ not found in this scope
    |
help: consider importing this struct
    |
47  + use alloc::vec::Vec;
    |

error[E0599]: no method named `to_string` found for struct `Decompositions` in the current scope
    --> src/lib.rs:198:42
     |
198  |             *cow = Cow::Owned(cow.as_ref().nfkd().to_string());
     |                                                   ^^^^^^^^^ method not found in `Decompositions<Chars<'_>>`
     |
    ::: /home/miszka/.rustup/toolchains/1.75.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/string.rs:2589:8
     |
2589 |     fn to_string(&self) -> String;
     |        --------- the method is available for `Decompositions<Chars<'_>>` here
     |
     = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
     |
29   + use crate::alloc::string::ToString;
     |

All checks in contrib/test.sh are fine because of this line:

bip39 = { path = ".", features = ["rand"] }

As the result the crate cannot be used as a dep w/o std.

@tcharding @stevenroose do you think we can still have a fix in 2.1.0?

@tcharding
Copy link
Member

tcharding commented Apr 3, 2024

This is all caused by a recent rustc upgrade, here is an issue where we are discussing it in rust-bitcoin: rust-bitcoin/rust-bitcoin#2653

I'll push a fix, can we get a point release @stevenroose?

EDIT: huh? I don't get any errors on master right now?

@michalkucharczyk are you seeing errors on master?

@michalkucharczyk
Copy link
Contributor Author

michalkucharczyk commented Apr 4, 2024

@michalkucharczyk are you seeing errors on master?

Yes. Just run this on master (--lib option is crucial to make it fail):

cargo build --release --no-default-features  --features=alloc --lib

This happens for both:

rustc --version
rustc 1.75.0 (82e1608df 2023-12-21)

and:

rustc --version
rustc 1.79.0-nightly (c9f8f3438 2024-03-27)

@tcharding
Copy link
Member

Bizzare, I am not getting errors with

$ cargo +nightly --version
cargo 1.79.0-nightly (a59aba136 2024-03-28)
$ cargo +nightly build --release --no-default-features  --features=alloc --lib

Nor with

$ cargo --version
cargo 1.77.1 (e52e36006 2024-03-26)
$ cargo build --release --no-default-features  --features=alloc --lib

No clue what is going on.

@michalkucharczyk
Copy link
Contributor Author

dq: did you try cargo clean? Can you add -vvv and attach the output?

The other way to reproduce is creating a simple crate with bip39 as dep. Following the steps listed below generates the same error for me:

cargo new rust-bip39-dep-problem2
pushd rust-bip39-dep-problem2
cargo add bip39 --git "https://github.com/rust-bitcoin/rust-bip39"  --rev b100bf3 --no-default-features --features alloc
cargo build

@michalkucharczyk
Copy link
Contributor Author

michalkucharczyk commented Apr 5, 2024

Bizzare, I am not getting errors with

Wow, seems I am the wombat :) I had commented this line in Cargo.toml:

bip39 = { path = ".", features = ["rand"] }

But you should be able to reproduce problem with the commands I provided in my previous comment.

@michalkucharczyk
Copy link
Contributor Author

fix proposed in: #69

@tcharding
Copy link
Member

tcharding commented Apr 7, 2024

Oh boy, took me so long to work out that the bip39 path dev-dependency you mention above is enabling "std" (because of default features), and that is why I couldn't get the build warnings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants