Skip to content

Commit

Permalink
Import inventory-impl macros into inventory crate
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Nov 10, 2021
1 parent 7959dc7 commit 4a6f321
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 113 deletions.
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ rust-version = "1.31"
[dependencies]
ctor = "0.1"
ghost = "0.1.1"
inventory-impl = { version = "=0.1.11", path = "impl" }

[dev-dependencies]
rustversion = "1.0"
trybuild = "1.0"

[workspace]
members = ["impl"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
21 changes: 0 additions & 21 deletions impl/Cargo.toml

This file was deleted.

1 change: 0 additions & 1 deletion impl/LICENSE-APACHE

This file was deleted.

1 change: 0 additions & 1 deletion impl/LICENSE-MIT

This file was deleted.

78 changes: 0 additions & 78 deletions impl/src/lib.rs

This file was deleted.

34 changes: 27 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,6 @@ extern crate alloc;
#[doc(hidden)]
pub use ctor::ctor;

// Not public API.
#[doc(hidden)]
pub use inventory_impl as r#impl;

use alloc::boxed::Box;
use core::ops::Deref;
use core::ptr;
Expand Down Expand Up @@ -374,9 +370,33 @@ macro_rules! collect {
#[macro_export]
macro_rules! submit {
($($value:tt)*) => {
$crate::r#impl::submit! {
$($value)*
}
const _: () = {
#[allow(non_upper_case_globals)]
#[$crate::ctor]
fn __init() {
// TODO: once existential type is stable, store the caller's
// expression into a static and string those statics together
// into an intrusive linked list without needing allocation.
//
// existential type This;
//
// static mut VALUE: Option<inventory::Node<This>> = None;
//
// fn value() -> This {
// $($value)*
// }
//
// unsafe {
// VALUE = Some(inventory::Node {
// value: value(),
// next: None,
// });
// inventory::submit(VALUE.as_mut().unwrap());
// }

$crate::submit({ $($value)* });
}
};
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/submit-unrecognized.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ note: required by a bound in `submit`
|
| pub fn submit<T: Collect>(value: T) {
| ^^^^^^^ required by this bound in `submit`
= note: this error originates in the macro `$crate::impl::submit` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the macro `inventory::submit` (in Nightly builds, run with -Z macro-backtrace for more info)

0 comments on commit 4a6f321

Please sign in to comment.