diff --git a/.gitignore b/.gitignore index 9d538f2..5e81b66 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ /target **/*.rs.bk Cargo.lock -.fuse_hidden* \ No newline at end of file +.fuse_hidden* diff --git a/Cargo.toml b/Cargo.toml index fa3120f..2ab85d6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "proc-macro-error" -version = "0.4.4" +version = "0.4.6" authors = ["CreepySkeleton "] description = "Almost drop-in replacement to panics in proc-macros" @@ -20,7 +20,13 @@ maintenance = { status = "actively-developed" } quote = "1" proc-macro2 = "1" syn = { version = "1", default-features = false } -proc-macro-error-attr = { path = "./proc-macro-error-attr", version = "0.4.3"} +proc-macro-error-attr = { path = "./proc-macro-error-attr", version = "=0.4.6"} [build-dependencies] rustversion = "1.0" + +[dev-dependencies] +test-crate = { path = "./test-crate" } +rustversion = "1.0" +trybuild = { version = "1.0.19", features = ["diff"] } +toml = "=0.5.2" # DO NOT BUMP \ No newline at end of file diff --git a/build.rs b/build.rs index 04ddc11..f6fb3c1 100644 --- a/build.rs +++ b/build.rs @@ -1,11 +1,11 @@ -#[rustversion::nightly] -fn nightly() { - println!("cargo:rustc-cfg=pme_nightly"); +#[rustversion::not(nightly)] +fn check() { + println!("cargo:rustc-cfg=use_fallback"); } -#[rustversion::not(nightly)] -fn nightly() {} +#[rustversion::nightly] +fn check() {} fn main() { - nightly() + check() } diff --git a/proc-macro-error-attr/.gitignore b/proc-macro-error-attr/.gitignore new file mode 100644 index 0000000..5e81b66 --- /dev/null +++ b/proc-macro-error-attr/.gitignore @@ -0,0 +1,4 @@ +/target +**/*.rs.bk +Cargo.lock +.fuse_hidden* diff --git a/proc-macro-error-attr/Cargo.toml b/proc-macro-error-attr/Cargo.toml index 321a33b..3e9c61c 100644 --- a/proc-macro-error-attr/Cargo.toml +++ b/proc-macro-error-attr/Cargo.toml @@ -1,9 +1,9 @@ [package] name = "proc-macro-error-attr" -version = "0.4.5" +version = "0.4.6" authors = ["CreepySkeleton "] edition = "2018" -description = "attribute macro for proc-macro-error crate" +description = "Attribute macro for proc-macro-error crate" license = "MIT OR Apache-2.0" repository = "https://gitlab.com/CreepySkeleton/proc-macro-error" @@ -14,5 +14,5 @@ proc-macro = true quote = "1" proc-macro2 = "1" syn = { version = "1", default-features = false, features = ["derive", "parsing", "proc-macro"] } -syn-mid = "0.4" +syn-mid = "0.5" rustversion = "1.0" diff --git a/proc-macro-error-attr/src/lib.rs b/proc-macro-error-attr/src/lib.rs index e105f36..d49c20b 100644 --- a/proc-macro-error-attr/src/lib.rs +++ b/proc-macro-error-attr/src/lib.rs @@ -1,3 +1,6 @@ +//! This is `#[proc_macro_error]` attribute to be used with +//! [`proc-macro-error`](https://docs.rs/proc-macro-error/). There you go. + extern crate proc_macro; use proc_macro::TokenStream; @@ -12,8 +15,6 @@ use syn::{ }; use syn_mid::{Block, ItemFn}; -//! This is `#[proc_macro_error]` attribute to be used with -//! [`proc-macro-error`](https://docs.rs/proc-macro-error/). There you go. use self::Setting::*; @@ -44,8 +45,9 @@ pub fn proc_macro_error(attr: TokenStream, input: TokenStream) -> TokenStream { if !(settings.is_set(AllowNotMacro) || is_proc_macro) { return quote!( #input - compile_error!("#[proc_macro_error] attribute can be used only with a proc-macro\n\n \ - hint: if you are really sure that #[proc_macro_error] should be applied \ + compile_error!( + "#[proc_macro_error] attribute can be used only with a proc-macro\n\n \ + = hint: if you are really sure that #[proc_macro_error] should be applied \ to this exact function use #[proc_macro_error(allow_not_macro)]\n"); ) .into(); @@ -54,34 +56,16 @@ pub fn proc_macro_error(attr: TokenStream, input: TokenStream) -> TokenStream { let ItemFn { attrs, vis, - constness, - asyncness, - unsafety, - abi, - fn_token, - ident, - generics, - inputs, - output, + sig, block, - .. } = input; - let body = gen_body(block, settings); + let body = gen_body(*block, settings); quote!( #(#attrs)* #vis - #constness - #asyncness - #unsafety - #abi - #fn_token - #ident - #generics - (#inputs) - #output - + #sig { #body } ) .into() diff --git a/proc-macro-error/Cargo.toml b/proc-macro-error/Cargo.toml deleted file mode 100644 index e69de29..0000000 diff --git a/src/nightly.rs b/src/diagnostic.rs similarity index 95% rename from src/nightly.rs rename to src/diagnostic.rs index 2d18577..be44a64 100644 --- a/src/nightly.rs +++ b/src/diagnostic.rs @@ -1,3 +1,5 @@ +//! This implementation uses [`proc_macro::Diagnostic`] + use std::cell::Cell; use proc_macro::{Diagnostic as PDiag, Level as PLevel}; diff --git a/src/stable.rs b/src/fallback.rs similarity index 100% rename from src/stable.rs rename to src/fallback.rs diff --git a/src/lib.rs b/src/lib.rs index a4ffdef..f12fd11 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -214,12 +214,12 @@ pub mod dummy; mod macros; -#[cfg(not(any(pme_nightly, nightly_fmt)))] -#[path = "stable.rs"] +#[cfg(use_fallback)] +#[path = "fallback.rs"] mod imp; -#[cfg(any(pme_nightly, nightly_fmt))] -#[path = "nightly.rs"] +#[cfg(not(use_fallback))] +#[path = "diagnostic.rs"] mod imp; /// Represents a diagnostic level diff --git a/test-crate/.gitignore b/test-crate/.gitignore new file mode 100644 index 0000000..5e81b66 --- /dev/null +++ b/test-crate/.gitignore @@ -0,0 +1,4 @@ +/target +**/*.rs.bk +Cargo.lock +.fuse_hidden* diff --git a/test-crate/Cargo.toml b/test-crate/Cargo.toml index 96dadc3..aca40b6 100644 --- a/test-crate/Cargo.toml +++ b/test-crate/Cargo.toml @@ -6,15 +6,12 @@ edition = "2018" publish = false [lib] +path = "lib.rs" proc-macro = true [dependencies] -proc-macro-error = { path = "../proc-macro-error"} +proc-macro-error = { path = "../" } quote = "1" proc-macro2 = "1" syn = {version = "1", default-features = false } -[dev-dependencies] -trybuild = "1.0" -rustversion = "1.0" -toml = "=0.5.2" # DO NOT BUMP diff --git a/test-crate/lib.rs b/test-crate/lib.rs new file mode 100644 index 0000000..5fc850c --- /dev/null +++ b/test-crate/lib.rs @@ -0,0 +1,104 @@ +#[macro_use] +extern crate proc_macro_error; +extern crate proc_macro; + +use proc_macro2::{Span, TokenStream}; +use proc_macro_error::{set_dummy, Diagnostic, Level, OptionExt, ResultExt}; + + +#[proc_macro] +#[proc_macro_error] +pub fn abort_from(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let span = input.into_iter().next().unwrap().span(); + abort!(span, syn::Error::new(Span::call_site(), "abort!(span, from) test")) +} + +#[proc_macro] +#[proc_macro_error] +pub fn abort_to_string(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let span = input.into_iter().next().unwrap().span(); + abort!(span, "abort!(span, single_expr) test") +} + +#[proc_macro] +#[proc_macro_error] +pub fn abort_format(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let span = input.into_iter().next().unwrap().span(); + abort!(span, "abort!(span, expr1, {}) test", "expr2") +} + +#[proc_macro] +#[proc_macro_error] +pub fn direct_abort(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let span = input.into_iter().next().unwrap().span(); + Diagnostic::spanned(span.into(), Level::Error, "Diagnostic::abort() test".into()).abort() +} + +#[proc_macro] +#[proc_macro_error] +pub fn emit(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let mut spans = input.into_iter().step_by(2).map(|t| t.span()); + emit_error!(spans.next().unwrap(), syn::Error::new(Span::call_site(), "emit!(span, from) test")); + emit_error!(spans.next().unwrap(), "emit!(span, expr1, {}) test", "expr2"); + emit_error!(spans.next().unwrap(), "emit!(span, single_expr) test"); + Diagnostic::spanned( + spans.next().unwrap().into(), + Level::Error, + "Diagnostic::emit() test".into() + ).emit(); + + quote!().into() +} + +#[proc_macro] +#[proc_macro_error] +pub fn option_ext(_input: proc_macro::TokenStream) -> proc_macro::TokenStream { + Option::::None.expect_or_abort("Option::expect_or_abort() test"); + quote!().into() +} + +#[proc_macro] +#[proc_macro_error] +pub fn result_unwrap_or_abort(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let span = input.into_iter().next().unwrap().span(); + let err = syn::Error::new(span.into(), "Result::unwrap_or_abort() test"); + Result::<(), _>::Err(err).unwrap_or_abort(); + quote!().into() +} + +#[proc_macro] +#[proc_macro_error] +pub fn result_expect_or_abort(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let span = input.into_iter().next().unwrap().span(); + let err = syn::Error::new(span.into(), "Result::expect_or_abort() test"); + Result::<(), _>::Err(err).expect_or_abort("BOOM"); + quote!().into() +} + + +#[proc_macro] +#[proc_macro_error] +pub fn dummy(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let span = input.into_iter().next().unwrap().span(); + set_dummy(quote! { + impl Default for NeedDefault { + fn default() -> Self { NeedDefault::A } + } + }); + + abort!(span, "set_dummy test") +} + +#[proc_macro] +#[proc_macro_error] +pub fn unrelated_panic(_input: proc_macro::TokenStream) -> proc_macro::TokenStream { + panic!("unrelated panic test") +} + + +#[proc_macro] +#[proc_macro_error] +pub fn ok(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + let input = TokenStream::from(input); + quote!(fn #input() {}).into() +} \ No newline at end of file diff --git a/test-crate/src/lib.rs b/test-crate/src/lib.rs deleted file mode 100644 index 2ea9175..0000000 --- a/test-crate/src/lib.rs +++ /dev/null @@ -1,123 +0,0 @@ -#[macro_use] -extern crate proc_macro_error; -#[macro_use] -extern crate syn; -extern crate proc_macro; - -use proc_macro2::Span; -use proc_macro_error::{set_dummy, Level, OptionExt, ResultExt}; -use syn::{ - parse::{Parse, ParseStream}, - punctuated::Punctuated, - spanned::Spanned, - Ident, -}; - -struct IdentOrUnderscore { - span: Span, - part: String, -} - -impl IdentOrUnderscore { - fn new(span: Span, part: String) -> Self { - IdentOrUnderscore { span, part } - } -} - -impl Parse for IdentOrUnderscore { - fn parse(input: ParseStream) -> syn::Result { - let la = input.lookahead1(); - - if la.peek(Ident) { - let t = input.parse::().unwrap(); - Ok(IdentOrUnderscore::new(t.span(), t.to_string())) - } else if la.peek(Token![_]) { - let t = input.parse::().unwrap(); - Ok(IdentOrUnderscore::new(t.span(), "_".to_string())) - } else { - Err(la.error()) - } - } -} - -struct Args(Vec); - -impl Parse for Args { - fn parse(input: ParseStream) -> syn::Result { - let args = Punctuated::<_, Token![,]>::parse_terminated(input)?; - Ok(Args(args.into_iter().collect())) - } -} - -#[proc_macro] -#[proc_macro_error] -pub fn make_fn(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - let mut name = String::new(); - let input = parse_macro_input!(input as Args); - - for arg in input.0 { - match &*arg.part { - "abort" => abort!( - arg.span, - "abort! 3{} args {}", "+", "test"; - hint = "help {} test", "message" - ), - - "abort_call_site" => abort_call_site!( - "abort_call_site! 2{} args {}", "+", "test"; - help = "help {} test", "message" - ), - - "direct_abort" => { - diagnostic!(arg.span, Level::Error, "direct MacroError::abort() test").abort() - } - - "result_expect" => { - let e = syn::Error::new(arg.span, "error"); - Err(e).expect_or_abort("Result::expect_or_abort() test") - } - - "result_unwrap" => { - let e = syn::Error::new(arg.span, "Result::unwrap_or_abort() test"); - Err(e).unwrap_or_abort() - } - - "option_expect" => None.expect_or_abort("Option::expect_or_abort() test"), - - "need_default" => { - set_dummy(quote! { - impl Default for NeedDefault { - fn default() -> Self { - NeedDefault::A - } - } - }); - - abort!(arg.span, "set_dummy test") - } - - part if part.starts_with("multi") => { - let no_help: Option = Option::None; - let help = Some("Option help test"); - emit_error!( - arg.span, - "multiple error part: {}", part; - note = "help {} test", "message"; - hint =? help; - wow = "I see what you did here..."; - help =? no_help - ) - } - - _ => name.push_str(&arg.part), - } - } - - // test that unrelated panics are not affected - if name.is_empty() { - panic!("unrelated panic test") - } - - let name = Ident::new(&name, Span::call_site()); - quote!( fn #name() {} ).into() -} diff --git a/test-crate/tests/ok.rs b/test-crate/tests/ok.rs deleted file mode 100644 index 9b6a3d1..0000000 --- a/test-crate/tests/ok.rs +++ /dev/null @@ -1,9 +0,0 @@ -extern crate test_crate; - -use test_crate::make_fn; - -make_fn!(it, _, works); - -fn main() { - it_works(); -} diff --git a/test-crate/tests/ui/abort.rs b/test-crate/tests/ui/abort.rs deleted file mode 100644 index 717d772..0000000 --- a/test-crate/tests/ui/abort.rs +++ /dev/null @@ -1,6 +0,0 @@ -extern crate test_crate; -use test_crate::make_fn; - -make_fn!(abort); - -fn main() {} diff --git a/test-crate/tests/ui/abort.stderr b/test-crate/tests/ui/abort.stderr deleted file mode 100644 index 7c4e6a0..0000000 --- a/test-crate/tests/ui/abort.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: abort! 3+ args test - - = help: help message test - - --> $DIR/abort.rs:4:10 - | -4 | make_fn!(abort); - | ^^^^^ diff --git a/test-crate/tests/ui/call_site.rs b/test-crate/tests/ui/call_site.rs deleted file mode 100644 index 7184cc4..0000000 --- a/test-crate/tests/ui/call_site.rs +++ /dev/null @@ -1,6 +0,0 @@ -extern crate test_crate; -use test_crate::make_fn; - -make_fn!(abort_call_site); - -fn main() {} diff --git a/test-crate/tests/ui/call_site.stderr b/test-crate/tests/ui/call_site.stderr deleted file mode 100644 index d630a3a..0000000 --- a/test-crate/tests/ui/call_site.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: abort_call_site! 2+ args test - - = help: help message test - - --> $DIR/call_site.rs:4:1 - | -4 | make_fn!(abort_call_site); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation diff --git a/test-crate/tests/ui/direct_abort.rs b/test-crate/tests/ui/direct_abort.rs deleted file mode 100644 index b5a4c97..0000000 --- a/test-crate/tests/ui/direct_abort.rs +++ /dev/null @@ -1,6 +0,0 @@ -extern crate test_crate; -use test_crate::make_fn; - -make_fn!(direct_abort); - -fn main() {} diff --git a/test-crate/tests/ui/direct_abort.stderr b/test-crate/tests/ui/direct_abort.stderr deleted file mode 100644 index 7cfbae8..0000000 --- a/test-crate/tests/ui/direct_abort.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: direct MacroError::abort() test - --> $DIR/direct_abort.rs:4:10 - | -4 | make_fn!(direct_abort); - | ^^^^^^^^^^^^ diff --git a/test-crate/tests/ui/dummy.stderr b/test-crate/tests/ui/dummy.stderr deleted file mode 100644 index fd531be..0000000 --- a/test-crate/tests/ui/dummy.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: set_dummy test - --> $DIR/dummy.rs:9:10 - | -9 | make_fn!(need_default); - | ^^^^^^^^^^^^ diff --git a/test-crate/tests/ui/multi-error.rs b/test-crate/tests/ui/multi-error.rs deleted file mode 100644 index 07fbb03..0000000 --- a/test-crate/tests/ui/multi-error.rs +++ /dev/null @@ -1,6 +0,0 @@ -extern crate test_crate; -use test_crate::make_fn; - -make_fn!(multi1, multi2, _, multi3); - -fn main() {} diff --git a/test-crate/tests/ui/multi-error.stderr b/test-crate/tests/ui/multi-error.stderr deleted file mode 100644 index 25174d5..0000000 --- a/test-crate/tests/ui/multi-error.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error: multiple error part: multi1 - - = note: help message test - = help: Option help test - = note: I see what you did here... - - --> $DIR/multi-error.rs:4:10 - | -4 | make_fn!(multi1, multi2, _, multi3); - | ^^^^^^ - -error: multiple error part: multi2 - - = note: help message test - = help: Option help test - = note: I see what you did here... - - --> $DIR/multi-error.rs:4:18 - | -4 | make_fn!(multi1, multi2, _, multi3); - | ^^^^^^ - -error: multiple error part: multi3 - - = note: help message test - = help: Option help test - = note: I see what you did here... - - --> $DIR/multi-error.rs:4:29 - | -4 | make_fn!(multi1, multi2, _, multi3); - | ^^^^^^ diff --git a/test-crate/tests/ui/option_expect.rs b/test-crate/tests/ui/option_expect.rs deleted file mode 100644 index 20288ca..0000000 --- a/test-crate/tests/ui/option_expect.rs +++ /dev/null @@ -1,6 +0,0 @@ -extern crate test_crate; -use test_crate::make_fn; - -make_fn!(option_expect); - -fn main() {} diff --git a/test-crate/tests/ui/option_expect.stderr b/test-crate/tests/ui/option_expect.stderr deleted file mode 100644 index dd9ecd8..0000000 --- a/test-crate/tests/ui/option_expect.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Option::expect_or_abort() test - --> $DIR/option_expect.rs:4:1 - | -4 | make_fn!(option_expect); - | ^^^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation diff --git a/test-crate/tests/ui/result_expect.rs b/test-crate/tests/ui/result_expect.rs deleted file mode 100644 index a42740b..0000000 --- a/test-crate/tests/ui/result_expect.rs +++ /dev/null @@ -1,6 +0,0 @@ -extern crate test_crate; -use test_crate::make_fn; - -make_fn!(result_expect); - -fn main() {} diff --git a/test-crate/tests/ui/result_expect.stderr b/test-crate/tests/ui/result_expect.stderr deleted file mode 100644 index c2dd81c..0000000 --- a/test-crate/tests/ui/result_expect.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Result::expect_or_abort() test: error - --> $DIR/result_expect.rs:4:10 - | -4 | make_fn!(result_expect); - | ^^^^^^^^^^^^^ diff --git a/test-crate/tests/ui/result_unwrap.rs b/test-crate/tests/ui/result_unwrap.rs deleted file mode 100644 index 9b7fb1c..0000000 --- a/test-crate/tests/ui/result_unwrap.rs +++ /dev/null @@ -1,6 +0,0 @@ -extern crate test_crate; -use test_crate::make_fn; - -make_fn!(result_unwrap); - -fn main() {} diff --git a/test-crate/tests/ui/result_unwrap.stderr b/test-crate/tests/ui/result_unwrap.stderr deleted file mode 100644 index 2e614bd..0000000 --- a/test-crate/tests/ui/result_unwrap.stderr +++ /dev/null @@ -1,5 +0,0 @@ -error: Result::unwrap_or_abort() test - --> $DIR/result_unwrap.rs:4:10 - | -4 | make_fn!(result_unwrap); - | ^^^^^^^^^^^^^ diff --git a/test-crate/tests/macro-errors.rs b/tests/macro-errors.rs similarity index 75% rename from test-crate/tests/macro-errors.rs rename to tests/macro-errors.rs index 8c672eb..2ee3c09 100644 --- a/test-crate/tests/macro-errors.rs +++ b/tests/macro-errors.rs @@ -1,3 +1,6 @@ +extern crate trybuild; +extern crate rustversion; + #[rustversion::attr(any(not(stable), before(1.39)), ignore)] #[test] fn ui() { diff --git a/tests/ok.rs b/tests/ok.rs new file mode 100644 index 0000000..cf64c02 --- /dev/null +++ b/tests/ok.rs @@ -0,0 +1,10 @@ +extern crate test_crate; + +use test_crate::*; + +ok!(it_works); + +#[test] +fn check_it_works() { + it_works(); +} diff --git a/tests/ui/abort.rs b/tests/ui/abort.rs new file mode 100644 index 0000000..dc0241d --- /dev/null +++ b/tests/ui/abort.rs @@ -0,0 +1,9 @@ +extern crate test_crate; +use test_crate::*; + +abort_from!(one, two); +abort_to_string!(one, two); +abort_format!(one, two); +direct_abort!(one, two); + +fn main() {} diff --git a/tests/ui/abort.stderr b/tests/ui/abort.stderr new file mode 100644 index 0000000..06ba1bb --- /dev/null +++ b/tests/ui/abort.stderr @@ -0,0 +1,23 @@ +error: abort!(span, from) test + --> $DIR/abort.rs:4:13 + | +4 | abort_from!(one, two); + | ^^^ + +error: abort!(span, single_expr) test + --> $DIR/abort.rs:5:18 + | +5 | abort_to_string!(one, two); + | ^^^ + +error: abort!(span, expr1, expr2) test + --> $DIR/abort.rs:6:15 + | +6 | abort_format!(one, two); + | ^^^ + +error: Diagnostic::abort() test + --> $DIR/abort.rs:7:15 + | +7 | direct_abort!(one, two); + | ^^^ diff --git a/test-crate/tests/ui/dummy.rs b/tests/ui/dummy.rs similarity index 70% rename from test-crate/tests/ui/dummy.rs rename to tests/ui/dummy.rs index 7514fe0..49ae1ed 100644 --- a/test-crate/tests/ui/dummy.rs +++ b/tests/ui/dummy.rs @@ -1,12 +1,12 @@ extern crate test_crate; -use test_crate::make_fn; +use test_crate::*; enum NeedDefault { A, B } -make_fn!(need_default); +dummy!(need_default); fn main() { let _ = NeedDefault::default(); diff --git a/tests/ui/dummy.stderr b/tests/ui/dummy.stderr new file mode 100644 index 0000000..bae078a --- /dev/null +++ b/tests/ui/dummy.stderr @@ -0,0 +1,5 @@ +error: set_dummy test + --> $DIR/dummy.rs:9:8 + | +9 | dummy!(need_default); + | ^^^^^^^^^^^^ diff --git a/tests/ui/emit.rs b/tests/ui/emit.rs new file mode 100644 index 0000000..e4dbb6f --- /dev/null +++ b/tests/ui/emit.rs @@ -0,0 +1,6 @@ +extern crate test_crate; +use test_crate::*; + +emit!(one, two, three, four); + +fn main() {} diff --git a/tests/ui/emit.stderr b/tests/ui/emit.stderr new file mode 100644 index 0000000..4cf046b --- /dev/null +++ b/tests/ui/emit.stderr @@ -0,0 +1,23 @@ +error: emit!(span, from) test + --> $DIR/emit.rs:4:7 + | +4 | emit!(one, two, three, four); + | ^^^ + +error: emit!(span, expr1, expr2) test + --> $DIR/emit.rs:4:12 + | +4 | emit!(one, two, three, four); + | ^^^ + +error: emit!(span, single_expr) test + --> $DIR/emit.rs:4:17 + | +4 | emit!(one, two, three, four); + | ^^^^^ + +error: Diagnostic::emit() test + --> $DIR/emit.rs:4:24 + | +4 | emit!(one, two, three, four); + | ^^^^ diff --git a/test-crate/tests/ui/not_proc_macro.rs b/tests/ui/not_proc_macro.rs similarity index 100% rename from test-crate/tests/ui/not_proc_macro.rs rename to tests/ui/not_proc_macro.rs diff --git a/test-crate/tests/ui/not_proc_macro.stderr b/tests/ui/not_proc_macro.stderr similarity index 53% rename from test-crate/tests/ui/not_proc_macro.stderr rename to tests/ui/not_proc_macro.stderr index 52d6a09..35c14b8 100644 --- a/test-crate/tests/ui/not_proc_macro.stderr +++ b/tests/ui/not_proc_macro.stderr @@ -1,6 +1,6 @@ error: #[proc_macro_error] attribute can be used only with a proc-macro - hint: if you are really sure that #[proc_macro_error] should be applied to this exact function use #[proc_macro_error(allow_not_macro)] + = hint: if you are really sure that #[proc_macro_error] should be applied to this exact function use #[proc_macro_error(allow_not_macro)] --> $DIR/not_proc_macro.rs:3:1 | diff --git a/tests/ui/option_ext.rs b/tests/ui/option_ext.rs new file mode 100644 index 0000000..dfbfc03 --- /dev/null +++ b/tests/ui/option_ext.rs @@ -0,0 +1,6 @@ +extern crate test_crate; +use test_crate::*; + +option_ext!(one, two); + +fn main() {} diff --git a/tests/ui/option_ext.stderr b/tests/ui/option_ext.stderr new file mode 100644 index 0000000..f63abc0 --- /dev/null +++ b/tests/ui/option_ext.stderr @@ -0,0 +1,5 @@ +error: Option::expect_or_abort() test + --> $DIR/option_ext.rs:4:1 + | +4 | option_ext!(one, two); + | ^^^^^^^^^^^^^^^^^^^^^^ in this macro invocation diff --git a/tests/ui/result_ext.rs b/tests/ui/result_ext.rs new file mode 100644 index 0000000..bdd560d --- /dev/null +++ b/tests/ui/result_ext.rs @@ -0,0 +1,7 @@ +extern crate test_crate; +use test_crate::*; + +result_unwrap_or_abort!(one, two); +result_expect_or_abort!(one, two); + +fn main() {} diff --git a/tests/ui/result_ext.stderr b/tests/ui/result_ext.stderr new file mode 100644 index 0000000..f2dc0e4 --- /dev/null +++ b/tests/ui/result_ext.stderr @@ -0,0 +1,11 @@ +error: Result::unwrap_or_abort() test + --> $DIR/result_ext.rs:4:25 + | +4 | result_unwrap_or_abort!(one, two); + | ^^^ + +error: BOOM: Result::expect_or_abort() test + --> $DIR/result_ext.rs:5:25 + | +5 | result_expect_or_abort!(one, two); + | ^^^ diff --git a/test-crate/tests/ui/unknown_setting.rs b/tests/ui/unknown_setting.rs similarity index 100% rename from test-crate/tests/ui/unknown_setting.rs rename to tests/ui/unknown_setting.rs diff --git a/test-crate/tests/ui/unknown_setting.stderr b/tests/ui/unknown_setting.stderr similarity index 100% rename from test-crate/tests/ui/unknown_setting.stderr rename to tests/ui/unknown_setting.stderr diff --git a/test-crate/tests/ui/unrelated_panic.rs b/tests/ui/unrelated_panic.rs similarity index 50% rename from test-crate/tests/ui/unrelated_panic.rs rename to tests/ui/unrelated_panic.rs index 4863e5b..c74e3e0 100644 --- a/test-crate/tests/ui/unrelated_panic.rs +++ b/tests/ui/unrelated_panic.rs @@ -1,6 +1,6 @@ extern crate test_crate; -use test_crate::make_fn; +use test_crate::*; -make_fn!(); +unrelated_panic!(); fn main() {} diff --git a/test-crate/tests/ui/unrelated_panic.stderr b/tests/ui/unrelated_panic.stderr similarity index 69% rename from test-crate/tests/ui/unrelated_panic.stderr rename to tests/ui/unrelated_panic.stderr index b852cfd..d46d689 100644 --- a/test-crate/tests/ui/unrelated_panic.stderr +++ b/tests/ui/unrelated_panic.stderr @@ -1,7 +1,7 @@ error: proc macro panicked --> $DIR/unrelated_panic.rs:4:1 | -4 | make_fn!(); - | ^^^^^^^^^^^ +4 | unrelated_panic!(); + | ^^^^^^^^^^^^^^^^^^^ | = help: message: unrelated panic test