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

feature: Add new crate gix-macros #992

Merged
merged 29 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6dae9e9
Add new crate `gix-macros`
NobodyXu Aug 26, 2023
58fbb08
Apply `momo` to mod `gix::discover`
NobodyXu Aug 26, 2023
46a9dfe
Apply `momo` to mod `gix::init`
NobodyXu Aug 26, 2023
d835526
Apply `momo` to `gix::object::tree`
NobodyXu Aug 26, 2023
3ce0144
Apply `momo` to mod `gix::open::repository`
NobodyXu Aug 26, 2023
767ec2d
Apply `momo` to `gix::pathspec`
NobodyXu Aug 26, 2023
3c205ab
Apply `momo` to `gix::reference`
NobodyXu Aug 26, 2023
ea5c2db
Apply `momo` to mod `remote::connection::fetch::receive_pack`
NobodyXu Aug 26, 2023
5a50537
Apply `momo` to mod `gix::repository`
NobodyXu Aug 26, 2023
ff210d8
Fix clippy lints in `gix/src/repository/remote.rs`
NobodyXu Aug 26, 2023
e760225
Manually de-`momo` `Repository::try_find_remote_{without_url_rewrite}`
NobodyXu Aug 28, 2023
95a1626
Remove `TryInto` support from `gix_macros::momo`
NobodyXu Aug 29, 2023
c72eaa0
Dramatically simplify `gix_macros::momo`
NobodyXu Aug 29, 2023
e1b9d51
Remove unnecessary `#[allow(clippy::needless_lifetimes)]`
NobodyXu Aug 29, 2023
86b8e50
Remove unnecessary change in `repository/config/transport.rs`
NobodyXu Aug 29, 2023
b5f78be
feat `momo`: Support parsing pattern in params
NobodyXu Aug 29, 2023
b619456
feat `momo`: Rm unnecessary `#[allow(unused_mut)]` on generated inner fn
NobodyXu Aug 29, 2023
89ae797
Rm unnecessary `#[allow(unused_mut)]` put on `momo`ed functions
NobodyXu Aug 29, 2023
cd3c289
Apply `momo` to mod `gix::create::into`
NobodyXu Aug 29, 2023
25912fe
Apply `momo` to mod `config::snapshot::access`
NobodyXu Aug 29, 2023
1d90301
Apply `momo` to fn `gix::revision::Spec::from_bstr`
NobodyXu Aug 29, 2023
875c287
Apply `momo` to fn `gix::Remote::save_as_to`
NobodyXu Aug 29, 2023
48a2088
refactor
Byron Sep 2, 2023
705f2f3
improve docs
Byron Sep 2, 2023
c4ed7c1
Remove `TODO` in `gix-macros/src/lib.rs`
NobodyXu Sep 2, 2023
c8e7324
Add test-suite for failure modes
Byron Sep 3, 2023
9be2622
Fix ui test `error_if_ineffective`
NobodyXu Sep 7, 2023
72545e9
Revert to use `item_fn.span()`
NobodyXu Sep 7, 2023
d76efdd
consolidate compile tests
Byron Sep 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ members = [
"gix-packetline",
"gix-packetline-blocking",
"gix-mailmap",
"gix-macros",
"gix-note",
"gix-negotiate",
"gix-fetchhead",
Expand Down
25 changes: 25 additions & 0 deletions gix-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "gix-macros"
version = "0.0.0"
edition = "2021"
description = "Proc-macro utilities for gix"
authors = [
"Jiahao XU <Jiahao_XU@outlook.com>",
"Andre Bogus <bogusandre@gmail.com>",
"Sebastian Thiel <sebastian.thiel@icloud.com>",
]
repository = "https://github.com/Byron/gitoxide"
license = "MIT OR Apache-2.0"
include = ["src/**/*", "LICENSE-*", "CHANGELOG.md"]
rust-version = "1.65"

[lib]
proc_macro = true

[dependencies]
syn = { version = "2.0", features = ["full", "fold"] }
quote = "1.0"
proc-macro2 = "1.0"

[dev-dependencies]
trybuild = "1.0"
1 change: 1 addition & 0 deletions gix-macros/LICENSE-APACHE
1 change: 1 addition & 0 deletions gix-macros/LICENSE-MIT
25 changes: 25 additions & 0 deletions gix-macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! A crate of useful macros used in `gix` primarily.
//!
//! Note that within `gix-*` crates, monomorphization should never be used for convenience, but only for performance
//! reasons. And in the latter case, manual denomophization should be considered if the trait in questions isn't called
//! often enough or measurements indicate that `&dyn Trait` is increasing the runtime. Thus, `gix-*` crates should probably
//! by default prefer using `&dyn` unless measurements indicate otherwise.
use proc_macro::TokenStream;

/// When applied to functions or methods, it will turn it into a wrapper that will immediately call
/// a de-monomorphized implementation (i.e. one that uses `&dyn Trait`).
///
/// That way, the landing-pads for convenience will be as small as possible which then delegate to a single
/// function or method for implementation.
///
/// The parameters using the following traits can be de-monomorphized:
///
/// * `Into`
/// * `AsRef`
/// * `AsMut`
#[proc_macro_attribute]
pub fn momo(_attrs: TokenStream, input: TokenStream) -> TokenStream {
momo::inner(input.into()).into()
}

mod momo;
Loading
Loading