Skip to content

Commit

Permalink
Rename to proc-macro-error2
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Sep 1, 2024
1 parent e4e879d commit ccf8471
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "proc-macro-error"
name = "proc-macro-error2"
authors = [
"CreepySkeleton <creepy-skeleton@yandex.ru>",
"GnomedDev <david2005thomas@gmail.com>",
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Migrate from `panic!`-based errors for as little effort as possible!

Also, you can explicitly [append a dummy token stream][crate::dummy] to your errors.

To achieve his, this crate serves as a tiny shim around `proc_macro::Diagnostic` and
To achieve this, this crate serves as a tiny shim around `proc_macro::Diagnostic` and
`compile_error!`. It detects the most preferable way to emit errors based on compiler's version.
When the underlying diagnostic type is finally stabilized, this crate will be simply
delegating to it, requiring no changes in your code!
Expand All @@ -18,7 +18,7 @@ available on stable ahead of time and your error-reporting code future-proof.

```toml
[dependencies]
proc-macro-error = "1.0"
proc-macro-error2 = "2.0"
```

*Supports rustc 1.31 and up*
Expand Down Expand Up @@ -64,7 +64,7 @@ And this is what your users will see in their IDE:
### Panic-like usage

```rust
use proc_macro_error::{
use proc_macro_error2::{
proc_macro_error,
abort,
abort_call_site,
Expand Down Expand Up @@ -111,7 +111,7 @@ pub fn make_answer(input: TokenStream) -> TokenStream {
### `proc_macro::Diagnostic`-like usage

```rust
use proc_macro_error::*;
use proc_macro_error2::*;
use proc_macro::TokenStream;
use syn::{spanned::Spanned, DeriveInput, ItemStruct, Fields, Attribute , parse_macro_input};
use quote::quote;
Expand Down
2 changes: 1 addition & 1 deletion proc-macro-error-attr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ fn gen_body(block: TokenTree, settings: Settings) -> proc_macro2::TokenStream {
quote!(|| #block)
};

quote!( ::proc_macro_error::entry_point(#closure, #is_proc_macro_hack) )
quote!( ::proc_macro_error2::entry_point(#closure, #is_proc_macro_hack) )
}

fn detect_proc_macro_hack(attrs: &[Attribute]) -> bool {
Expand Down
4 changes: 2 additions & 2 deletions src/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
//!
//! ```rust,ignore
//! use proc_macro::TokenStream;
//! use proc_macro_error::*;
//! use proc_macro_error2::*;
//!
//! trait MyTrait {
//! fn do_thing();
Expand Down Expand Up @@ -72,7 +72,7 @@
//!
//! ```rust,ignore
//! use proc_macro::TokenStream;
//! use proc_macro_error::*;
//! use proc_macro_error2::*;
//!
//! trait MyTrait {
//! fn do_thing();
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
//! > If you have some type from `proc_macro` or `syn` to point to, do not call `.span()`
//! > on it but rather use it directly:
//! > ```no_run
//! > # use proc_macro_error::abort;
//! > # use proc_macro_error2::abort;
//! > # let input = proc_macro2::TokenStream::new();
//! > let ty: syn::Type = syn::parse2(input).unwrap();
//! > abort!(ty, "BOOM");
Expand Down
2 changes: 1 addition & 1 deletion test-crate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ path = "lib.rs"
proc-macro = true

[dependencies]
proc-macro-error = { path = "../" }
proc-macro-error2 = { path = "../" }
quote = "1"
proc-macro2 = "1"

Expand Down
4 changes: 2 additions & 2 deletions test-crate/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use proc_macro2::{Span, TokenStream};
use proc_macro_error::{
use proc_macro_error2::{
abort, abort_call_site, diagnostic, emit_call_site_error, emit_call_site_warning, emit_error,
emit_warning, proc_macro_error, set_dummy, Diagnostic, Level, OptionExt, ResultExt, SpanRange,
};
Expand Down Expand Up @@ -199,7 +199,7 @@ pub fn append_dummy(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
impl Default for NeedDefault
});

proc_macro_error::append_dummy(quote!({
proc_macro_error2::append_dummy(quote!({
fn default() -> Self {
NeedDefault::A
}
Expand Down
2 changes: 1 addition & 1 deletion tests/runtime-errors.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use proc_macro_error::*;
use proc_macro_error2::*;

#[test]
#[should_panic = "proc-macro-error API cannot be used outside of"]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/misuse.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use proc_macro_error::abort;
use proc_macro_error2::abort;

struct Foo;

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/not_proc_macro.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use proc_macro_error::proc_macro_error;
use proc_macro_error2::proc_macro_error;

#[proc_macro_error]
fn main() {}
2 changes: 1 addition & 1 deletion tests/ui/unknown_setting.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use proc_macro_error::proc_macro_error;
use proc_macro_error2::proc_macro_error;

#[proc_macro_error(allow_not_macro, assert_unwind_safe, trololo)]
fn main() {}

0 comments on commit ccf8471

Please sign in to comment.