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

Update inventory requirement from 0.1.10 to 0.2.0 #158

Merged
merged 6 commits into from
Nov 16, 2021

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Nov 10, 2021

Updates the requirements on inventory to permit the latest version.

Release notes

Sourced from inventory's releases.

0.2.0

  • Enforce that elements given to inventory::submit are const constructible (#43) and Sync (#42)
Commits
  • 71b6c1f Release 0.2.0
  • 7d81709 Document compiler requirement of 1.37
  • 8291011 Add ui test of nonconst construction
  • b499293 Merge pull request #43 from dtolnay/const
  • b853350 Require inventory element type to be const constructed
  • 762b5ce Merge pull request #42 from dtolnay/sync
  • ea173f9 Add ui test of sync bound
  • e1e347d Require inventory element type to be Sync
  • 95501ae Merge pull request #41 from dtolnay/macrorules
  • 4a6f321 Import inventory-impl macros into inventory crate
  • Additional commits viewable in compare view

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Updates the requirements on [inventory](https://github.com/dtolnay/inventory) to permit the latest version.
- [Release notes](https://github.com/dtolnay/inventory/releases)
- [Commits](dtolnay/inventory@0.1.10...0.2.0)

---
updated-dependencies:
- dependency-name: inventory
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added k::dependencies Pull requests that update a dependency file rust Pull requests that update Rust code labels Nov 10, 2021
@tyranron
Copy link
Member

cc @ilslv

@ilslv
Copy link
Member

ilslv commented Nov 11, 2021

@tyranron this became quite a rabbit hole.

For now we are generating 3 structs (each for given, when and then) inside WorldInit macros and implement StepConstructor trait on them

pub trait StepConstructor<W> {
    fn new(_: step::Location, _: Regex, _: Step<W>) -> Self;
    fn inner(&self) -> (step::Location, Regex, Step<W>);
}

This is done to have an ability to construct those struct using only World type and inventory::submit!() them.
Since 0.2 inventory::submit!() requires const, so we have to remove fn new() from StepConstructor and use simple impl pub const fn new(). But there is a catch: function pointers cannot appear in constant functions (Playground). To be fair I don't understand why this is the case, but ok.

Then I've tried ditching const fn new() and create step struct with <World as WorldInit>::Given { .. }, but this syntax isn't supported yet: rust-lang/rust#86935

So the only way I see this can be possible on stable Rust is to mem::transmute into *const () on both sides. But wait, there is one more catch. From 0.2 step structs have to be Sync.
To overcome this we'll need a bit more unsafety

#[derive(Clone, Copy)]
#[repr(C)]
pub struct SyncFriend(*const ());

#[allow(unsafe_code)]
unsafe impl Sync for SyncFriend {}

All this does work, but unfortunately we have to expand code with unsafe into users codebase. All this while not having obvious benefits from upgrading to the latest version of inventory. Maybe we should postpone this upgrade until rust-lang/rust#86935 is stabilised?

@tyranron
Copy link
Member

@ilslv

Then I've tried ditching const fn new() and create step struct with <World as WorldInit>::Given { .. }, but this syntax isn't supported yet: rust-lang/rust#86935

Maybe we can workaround it with introducing in-place type alias?

@ilslv
Copy link
Member

ilslv commented Nov 15, 2021

@tyranron in-place type alias still runs into function pointers cannot appear in constant functions, but it looks like I've figured out a way to do it: Playground
It looks like it's forbidden to cast fn items to fn pointers in const functions, while in basic consts it's ok.

@tyranron
Copy link
Member

@ilslv ahaha... brilliant! 🙈

What we love Rust for - is squating 😁

@tyranron
Copy link
Member

@ilslv so, is it ready for review then? If so, request the one please.

@ilslv
Copy link
Member

ilslv commented Nov 15, 2021

@tyranron not yet, as I've just discovered this trick. I'll request review, once it's done

@tyranron tyranron added this to the 0.11 milestone Nov 15, 2021
@ilslv
Copy link
Member

ilslv commented Nov 16, 2021

FCM

Upgrade `inventory` to 0.2 (#158)

Additionally:
- simplify code examples in docs with using `#[tokio::main]` macro

@ilslv ilslv requested a review from tyranron November 16, 2021 06:33
@tyranron tyranron merged commit 2d18256 into main Nov 16, 2021
@dependabot dependabot bot deleted the dependabot/cargo/inventory-0.2.0 branch November 16, 2021 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
k::dependencies Pull requests that update a dependency file rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants