Skip to content

Add dummy implementation for unsupported OsRng platforms - #505

Closed
pitdicker wants to merge 2 commits into
rust-random:0.5from
pitdicker:osrng_dummy_impl
Closed

pitdicker wants to merge 2 commits into
rust-random:0.5from
pitdicker:osrng_dummy_impl

Conversation

@pitdicker

Copy link
Copy Markdown
Contributor

Fixes #503.

@dhardy

dhardy commented Jun 12, 2018

Copy link
Copy Markdown
Member

I am not sure this is the right solution. I guess we could use it as a "quick fix" for 0.5, but we still let users attempt to use code that will panic at runtime.

@pitdicker

Copy link
Copy Markdown
Contributor Author

I wanted to make another PR to master that uses the second solution. But to keep breakage minimal, do it this way for 0.5.

@dhardy

dhardy commented Jun 13, 2018

Copy link
Copy Markdown
Member

The question is, are we usefully avoiding breakage with this, or just causing more potential confusion with run-time panics? Perhaps this is the best option for now though because it is a much less invasive change than cfg-ing all the affected parts would be.

@dhardy

dhardy commented Jun 13, 2018

Copy link
Copy Markdown
Member

Two things about this:

  • Do we want a general stub implementation? Normally if compilation fails on some platform it's either a bug or an unsupported platform; this only changes compile-time errors to run-time errors.
  • The previous WASM stub gave a hint: "not supported on WASM without stdweb"; this one doesn't hint to use stdweb

That said, I'm still not sure whether adding a stub for WASM actually helps anyone?

@pitdicker

pitdicker commented Jun 14, 2018 •

Copy link
Copy Markdown
Contributor Author
  • Do we want a general stub implementation? Normally if compilation fails on some platform it's either a bug or an unsupported platform; this only changes compile-time errors to run-time errors.

That said, I'm still not sure whether adding a stub for WASM actually helps anyone?

Currently Rand it always fails to compile, even if nothing uses OsRng (but does use XorShiftRng etc.). With this PR it will compile, but fail at runtime when using OsRng. With the alternative in #508 it will fail only if OsRng is used directly.

I have no problem rebasing #508 on the 0.5 branch, your choice. It is quite a bit more complicated.

@dhardy

dhardy commented Jun 15, 2018

Copy link
Copy Markdown
Member

#508 is the proper fix for this and I don't think it will break anything (except compiling where already broken by 0.5.1). Yes, if you don't mind, that would be the best option.

Should we merge #508 to the 0.5 branch then merge that into master? Hopefully it will merge cleanly, but it may not work.

@pitdicker

Copy link
Copy Markdown
Contributor Author

Should we merge #508 to the 0.5 branch then merge that into master? Hopefully it will merge cleanly, but it may not work.

It will miss the changes to deprecated.rs, so I'll have to split the PR. I'll try to figure things out this evening.

@dhardy

dhardy commented Jun 15, 2018

Copy link
Copy Markdown
Member

Oh, whichever is easier. Or we can use this solution for now, though in that case I think it should be specific to WASM.

@pitdicker

Copy link
Copy Markdown
Contributor Author

Closing in favour of #512.

@pitdicker pitdicker closed this Jun 15, 2018
@pitdicker
pitdicker deleted the osrng_dummy_impl branch June 22, 2018 06:21
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.

2 participants