-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cee6db1
commit 9b2792d
Showing
17 changed files
with
203 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[package] | ||
name = "rustc_index_macros" | ||
version = "0.0.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
proc-macro = true | ||
|
||
[dependencies] | ||
synstructure = "0.13.0" | ||
syn = { version = "2.0.9", features = ["full"] } | ||
proc-macro2 = "1" | ||
quote = "1" | ||
|
||
[features] | ||
default = ["nightly"] | ||
nightly = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![cfg_attr(feature = "nightly", feature(allow_internal_unstable))] | ||
#![cfg_attr(feature = "nightly", allow(internal_features))] | ||
|
||
use proc_macro::TokenStream; | ||
|
||
mod newtype; | ||
|
||
/// Creates a struct type `S` that can be used as an index with | ||
/// `IndexVec` and so on. | ||
/// | ||
/// There are two ways of interacting with these indices: | ||
/// | ||
/// - The `From` impls are the preferred way. So you can do | ||
/// `S::from(v)` with a `usize` or `u32`. And you can convert back | ||
/// to an integer with `u32::from(s)`. | ||
/// | ||
/// - Alternatively, you can use the methods `S::new(v)` and `s.index()` | ||
/// to create/return a value. | ||
/// | ||
/// Internally, the index uses a u32, so the index must not exceed | ||
/// `u32::MAX`. You can also customize things like the `Debug` impl, | ||
/// what traits are derived, and so forth via the macro. | ||
#[proc_macro] | ||
#[cfg_attr( | ||
feature = "nightly", | ||
allow_internal_unstable(step_trait, rustc_attrs, trusted_step, spec_option_partial_eq) | ||
)] | ||
pub fn newtype_index(input: TokenStream) -> TokenStream { | ||
newtype::newtype(input) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.