Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

'call to unsafe function requires unsafe function or block' with rustc 1.26.0-nightly (f5631d9ac 2018-03-24) #79

Closed
shisoft opened this issue Mar 25, 2018 · 14 comments

Comments

@shisoft
Copy link

shisoft commented Mar 25, 2018

Hi. I use nightly rust on my project and got this compile error today after rustup update.

error[E0133]: call to unsafe function requires unsafe function or block
   --> /home/shisoft/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-await-0.1.0/src/lib.rs:123:19
    |
123 |             match self.0.resume() {
    |                   ^^^^^^^^^^^^^^^ call to unsafe function

error[E0133]: call to unsafe function requires unsafe function or block
   --> /home/shisoft/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-await-0.1.0/src/lib.rs:143:19
    |
143 |             match self.gen.resume() {
    |                   ^^^^^^^^^^^^^^^^^ call to unsafe function

error: aborting due to 2 previous errors

Is there anything need to be upgraded?

Thanks

@ngg
Copy link

ngg commented Mar 25, 2018

It's caused by rust-lang/rust#49194

@alexcrichton can you pls release a new version that fixes this but without depending on proc-macro2 0.2 nightly? (that would cause lots of other problems) The best would be a 0.1.1 version that "just" fixes this but otherwise works the same as 0.1.0?

Thanks!

@ngg
Copy link

ngg commented Mar 25, 2018

I have a branch where I cherry-picked all commits that are not 0.2 specific, I use it currently until a fixed version is in cargo: https://github.com/ngg/futures-await/commits/0.1
futures-await = { git = "https://github.com/ngg/futures-await", branch = "0.1", version = "0.1" }

@bbigras
Copy link

bbigras commented Mar 27, 2018

@ngg for some reason I got this error while using your version:

error: custom attribute panicked
   --> src\server.rs:403:1
    |
403 | #[async]
    | ^^^^^^^^
    |
    = help: message: failed to parse tokens as a function: ParseError(Some("failed to parse item: failed to parse"))

error: aborting due to previous error

@ngg
Copy link

ngg commented Mar 27, 2018

@bbigras It's strange... Did it work with the official 0.1.0 version? Can you send a file for which it fails (or a link to some crate it does not work with)?

@nayato
Copy link
Contributor

nayato commented Mar 29, 2018

@alexcrichton having 0.1.1 would sure be a good thing to have as it would take some time for everyone to move to futures 0.2 which is a prereq for futures-await master.

@ghost
Copy link

ghost commented Mar 31, 2018

For now it would be possible to just throw the two lines that error in an unsafe block, i'm not sure why resuming generators are now unsafe or if this would have a negative impact on futures-await, but it seems like an easy fix.

@Nemo157
Copy link
Contributor

Nemo157 commented Mar 31, 2018

Resuming generators is now unsafe because the generator may or may not be an immovable generator. For futures-await 0.1 your fine though because it only creates movable generators, so just wrapping the resume calls in unsafe blocks is valid.

@ghost
Copy link

ghost commented Mar 31, 2018

nice to know, thanks

@golddranks
Copy link

Using @ngg's branch solved this. Could you please send a pull request here and get 0.1.1 released? The current situation is no good.

@seunlanlege
Copy link

This change has broken a lot of crates, mine included. What's preventing this issue from being closed?
happy to help out where i can.

@withoutboats
Copy link
Collaborator

Sorry about being broken for so long! Everyone involved in maintaining this crate has been pretty busy with other things.

Now that the 0.2 version has been upstreamed into rust-lang-nursery/futures-rs, I think I'm going to revert this repo to just track version 0.1. Then we can merge a fix for this in & upload an 0.1.1 version.

@withoutboats
Copy link
Collaborator

withoutboats commented Apr 9, 2018

If anyone wants to take #86 over and get it passing CI, I will gladly merge it & release 0.1.1. Otherwise I will eventually get it to pass CI hopefully this week some time.

@withoutboats
Copy link
Collaborator

Uploaded futures-await 0.1.1 which should work on current nightlies 🎉

@ngg
Copy link

ngg commented Apr 12, 2018

Thanks a lot, it works perfectly :)

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

No branches or pull requests

8 participants