diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /third_party/rust/proc-macro-error/tests | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/proc-macro-error/tests')
33 files changed, 376 insertions, 0 deletions
diff --git a/third_party/rust/proc-macro-error/tests/macro-errors.rs b/third_party/rust/proc-macro-error/tests/macro-errors.rs new file mode 100644 index 0000000000..dd60f88a80 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/macro-errors.rs @@ -0,0 +1,8 @@ +extern crate trybuild; + +#[cfg_attr(skip_ui_tests, ignore)] +#[test] +fn ui() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/*.rs"); +} diff --git a/third_party/rust/proc-macro-error/tests/ok.rs b/third_party/rust/proc-macro-error/tests/ok.rs new file mode 100644 index 0000000000..cf64c027f8 --- /dev/null +++ b/third_party/rust/proc-macro-error/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/third_party/rust/proc-macro-error/tests/runtime-errors.rs b/third_party/rust/proc-macro-error/tests/runtime-errors.rs new file mode 100644 index 0000000000..13108a2d91 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/runtime-errors.rs @@ -0,0 +1,13 @@ +use proc_macro_error::*; + +#[test] +#[should_panic = "proc-macro-error API cannot be used outside of"] +fn missing_attr_emit() { + emit_call_site_error!("You won't see me"); +} + +#[test] +#[should_panic = "proc-macro-error API cannot be used outside of"] +fn missing_attr_abort() { + abort_call_site!("You won't see me"); +} diff --git a/third_party/rust/proc-macro-error/tests/ui/abort.rs b/third_party/rust/proc-macro-error/tests/ui/abort.rs new file mode 100644 index 0000000000..f63118251e --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/abort.rs @@ -0,0 +1,11 @@ +extern crate test_crate; +use test_crate::*; + +abort_from!(one, two); +abort_to_string!(one, two); +abort_format!(one, two); +direct_abort!(one, two); +abort_notes!(one, two); +abort_call_site_test!(one, two); + +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/abort.stderr b/third_party/rust/proc-macro-error/tests/ui/abort.stderr new file mode 100644 index 0000000000..c5399d9d91 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/abort.stderr @@ -0,0 +1,48 @@ +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); + | ^^^ + +error: This is an error + + = note: simple note + = help: simple help + = help: simple hint + = note: simple yay + = note: format note + = note: Some note + = note: spanned simple note + = note: spanned format note + = note: Some note + + --> $DIR/abort.rs:8:14 + | +8 | abort_notes!(one, two); + | ^^^ + +error: abort_call_site! test + --> $DIR/abort.rs:9:1 + | +9 | abort_call_site_test!(one, two); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/proc-macro-error/tests/ui/append_dummy.rs b/third_party/rust/proc-macro-error/tests/ui/append_dummy.rs new file mode 100644 index 0000000000..53d6feacc1 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/append_dummy.rs @@ -0,0 +1,13 @@ +extern crate test_crate; +use test_crate::*; + +enum NeedDefault { + A, + B +} + +append_dummy!(need_default); + +fn main() { + let _ = NeedDefault::default(); +} diff --git a/third_party/rust/proc-macro-error/tests/ui/append_dummy.stderr b/third_party/rust/proc-macro-error/tests/ui/append_dummy.stderr new file mode 100644 index 0000000000..8a47ddaac4 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/append_dummy.stderr @@ -0,0 +1,5 @@ +error: append_dummy test + --> $DIR/append_dummy.rs:9:15 + | +9 | append_dummy!(need_default); + | ^^^^^^^^^^^^ diff --git a/third_party/rust/proc-macro-error/tests/ui/children_messages.rs b/third_party/rust/proc-macro-error/tests/ui/children_messages.rs new file mode 100644 index 0000000000..fb9e6dc697 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/children_messages.rs @@ -0,0 +1,6 @@ +extern crate test_crate; +use test_crate::*; + +children_messages!(one, two, three, four); + +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/children_messages.stderr b/third_party/rust/proc-macro-error/tests/ui/children_messages.stderr new file mode 100644 index 0000000000..3b49d83165 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/children_messages.stderr @@ -0,0 +1,23 @@ +error: main macro message + --> $DIR/children_messages.rs:4:20 + | +4 | children_messages!(one, two, three, four); + | ^^^ + +error: child message + --> $DIR/children_messages.rs:4:25 + | +4 | children_messages!(one, two, three, four); + | ^^^ + +error: main syn::Error + --> $DIR/children_messages.rs:4:30 + | +4 | children_messages!(one, two, three, four); + | ^^^^^ + +error: child syn::Error + --> $DIR/children_messages.rs:4:37 + | +4 | children_messages!(one, two, three, four); + | ^^^^ diff --git a/third_party/rust/proc-macro-error/tests/ui/dummy.rs b/third_party/rust/proc-macro-error/tests/ui/dummy.rs new file mode 100644 index 0000000000..caa4827886 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/dummy.rs @@ -0,0 +1,13 @@ +extern crate test_crate; +use test_crate::*; + +enum NeedDefault { + A, + B +} + +dummy!(need_default); + +fn main() { + let _ = NeedDefault::default(); +} diff --git a/third_party/rust/proc-macro-error/tests/ui/dummy.stderr b/third_party/rust/proc-macro-error/tests/ui/dummy.stderr new file mode 100644 index 0000000000..bae078afa8 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/dummy.stderr @@ -0,0 +1,5 @@ +error: set_dummy test + --> $DIR/dummy.rs:9:8 + | +9 | dummy!(need_default); + | ^^^^^^^^^^^^ diff --git a/third_party/rust/proc-macro-error/tests/ui/emit.rs b/third_party/rust/proc-macro-error/tests/ui/emit.rs new file mode 100644 index 0000000000..c5c7db095f --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/emit.rs @@ -0,0 +1,7 @@ +extern crate test_crate; +use test_crate::*; + +emit!(one, two, three, four, five); +emit_notes!(one, two); + +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/emit.stderr b/third_party/rust/proc-macro-error/tests/ui/emit.stderr new file mode 100644 index 0000000000..9484bd628b --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/emit.stderr @@ -0,0 +1,48 @@ +error: emit!(span, from) test + --> $DIR/emit.rs:4:7 + | +4 | emit!(one, two, three, four, five); + | ^^^ + +error: emit!(span, expr1, expr2) test + --> $DIR/emit.rs:4:12 + | +4 | emit!(one, two, three, four, five); + | ^^^ + +error: emit!(span, single_expr) test + --> $DIR/emit.rs:4:17 + | +4 | emit!(one, two, three, four, five); + | ^^^^^ + +error: Diagnostic::emit() test + --> $DIR/emit.rs:4:24 + | +4 | emit!(one, two, three, four, five); + | ^^^^ + +error: emit_call_site_error!(expr) test + --> $DIR/emit.rs:4:1 + | +4 | emit!(one, two, three, four, five); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: This is an error + + = note: simple note + = help: simple help + = help: simple hint + = note: simple yay + = note: format note + = note: Some note + = note: spanned simple note + = note: spanned format note + = note: Some note + + --> $DIR/emit.rs:5:13 + | +5 | emit_notes!(one, two); + | ^^^ diff --git a/third_party/rust/proc-macro-error/tests/ui/explicit_span_range.rs b/third_party/rust/proc-macro-error/tests/ui/explicit_span_range.rs new file mode 100644 index 0000000000..82bbebcc55 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/explicit_span_range.rs @@ -0,0 +1,6 @@ +extern crate test_crate; +use test_crate::*; + +explicit_span_range!(one, two, three, four); + +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/explicit_span_range.stderr b/third_party/rust/proc-macro-error/tests/ui/explicit_span_range.stderr new file mode 100644 index 0000000000..781a71e76a --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/explicit_span_range.stderr @@ -0,0 +1,5 @@ +error: explicit SpanRange + --> $DIR/explicit_span_range.rs:4:22 + | +4 | explicit_span_range!(one, two, three, four); + | ^^^^^^^^^^^^^^^ diff --git a/third_party/rust/proc-macro-error/tests/ui/misuse.rs b/third_party/rust/proc-macro-error/tests/ui/misuse.rs new file mode 100644 index 0000000000..e6d2d24971 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/misuse.rs @@ -0,0 +1,11 @@ +extern crate proc_macro_error; +use proc_macro_error::abort; + +struct Foo; + +#[allow(unused)] +fn foo() { + abort!(Foo, "BOOM"); +} + +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/misuse.stderr b/third_party/rust/proc-macro-error/tests/ui/misuse.stderr new file mode 100644 index 0000000000..8eaf6456fd --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/misuse.stderr @@ -0,0 +1,13 @@ +error[E0599]: no method named `FIRST_ARG_MUST_EITHER_BE_Span_OR_IMPLEMENT_ToTokens_OR_BE_SpanRange` found for reference `&Foo` in the current scope + --> $DIR/misuse.rs:8:5 + | +4 | struct Foo; + | ----------- doesn't satisfy `Foo: quote::to_tokens::ToTokens` +... +8 | abort!(Foo, "BOOM"); + | ^^^^^^^^^^^^^^^^^^^^ method not found in `&Foo` + | + = note: the method `FIRST_ARG_MUST_EITHER_BE_Span_OR_IMPLEMENT_ToTokens_OR_BE_SpanRange` exists but the following trait bounds were not satisfied: + `Foo: quote::to_tokens::ToTokens` + which is required by `&Foo: proc_macro_error::__export::ToTokensAsSpanRange` + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/proc-macro-error/tests/ui/multiple_tokens.rs b/third_party/rust/proc-macro-error/tests/ui/multiple_tokens.rs new file mode 100644 index 0000000000..215928f6f4 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/multiple_tokens.rs @@ -0,0 +1,6 @@ +extern crate test_crate; + +#[test_crate::multiple_tokens] +type T = (); + +fn main() {}
\ No newline at end of file diff --git a/third_party/rust/proc-macro-error/tests/ui/multiple_tokens.stderr b/third_party/rust/proc-macro-error/tests/ui/multiple_tokens.stderr new file mode 100644 index 0000000000..c6172c6cc6 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/multiple_tokens.stderr @@ -0,0 +1,5 @@ +error: ... + --> $DIR/multiple_tokens.rs:4:1 + | +4 | type T = (); + | ^^^^^^^^^^^^ diff --git a/third_party/rust/proc-macro-error/tests/ui/not_proc_macro.rs b/third_party/rust/proc-macro-error/tests/ui/not_proc_macro.rs new file mode 100644 index 0000000000..e241c5cd28 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/not_proc_macro.rs @@ -0,0 +1,4 @@ +use proc_macro_error::proc_macro_error; + +#[proc_macro_error] +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/not_proc_macro.stderr b/third_party/rust/proc-macro-error/tests/ui/not_proc_macro.stderr new file mode 100644 index 0000000000..f19f01bd8e --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/not_proc_macro.stderr @@ -0,0 +1,10 @@ +error: #[proc_macro_error] attribute can be used only with procedural macros + + = 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 + | +3 | #[proc_macro_error] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/proc-macro-error/tests/ui/option_ext.rs b/third_party/rust/proc-macro-error/tests/ui/option_ext.rs new file mode 100644 index 0000000000..dfbfc03835 --- /dev/null +++ b/third_party/rust/proc-macro-error/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/third_party/rust/proc-macro-error/tests/ui/option_ext.stderr b/third_party/rust/proc-macro-error/tests/ui/option_ext.stderr new file mode 100644 index 0000000000..91b151ec2f --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/option_ext.stderr @@ -0,0 +1,7 @@ +error: Option::expect_or_abort() test + --> $DIR/option_ext.rs:4:1 + | +4 | option_ext!(one, two); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/proc-macro-error/tests/ui/proc_macro_hack.rs b/third_party/rust/proc-macro-error/tests/ui/proc_macro_hack.rs new file mode 100644 index 0000000000..2504bdd401 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/proc_macro_hack.rs @@ -0,0 +1,10 @@ +// Adapted from https://github.com/dtolnay/proc-macro-hack/blob/master/example/src/main.rs +// Licensed under either of Apache License, Version 2.0 or MIT license at your option. + +use proc_macro_hack_test::add_one; + +fn main() { + let two = 2; + let nine = add_one!(two) + add_one!(2 + 3); + println!("nine = {}", nine); +} diff --git a/third_party/rust/proc-macro-error/tests/ui/proc_macro_hack.stderr b/third_party/rust/proc-macro-error/tests/ui/proc_macro_hack.stderr new file mode 100644 index 0000000000..0e984f918d --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/proc_macro_hack.stderr @@ -0,0 +1,26 @@ +error: BOOM + --> $DIR/proc_macro_hack.rs:8:25 + | +8 | let nine = add_one!(two) + add_one!(2 + 3); + | ^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +error: BOOM + --> $DIR/proc_macro_hack.rs:8:41 + | +8 | let nine = add_one!(two) + add_one!(2 + 3); + | ^^^^^ + | + = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: unreachable expression + --> $DIR/proc_macro_hack.rs:8:32 + | +8 | let nine = add_one!(two) + add_one!(2 + 3); + | ------------- ^^^^^^^^^^^^^^^ unreachable expression + | | + | any code following this expression is unreachable + | + = note: `#[warn(unreachable_code)]` on by default + = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/third_party/rust/proc-macro-error/tests/ui/result_ext.rs b/third_party/rust/proc-macro-error/tests/ui/result_ext.rs new file mode 100644 index 0000000000..bdd560dba9 --- /dev/null +++ b/third_party/rust/proc-macro-error/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/third_party/rust/proc-macro-error/tests/ui/result_ext.stderr b/third_party/rust/proc-macro-error/tests/ui/result_ext.stderr new file mode 100644 index 0000000000..f2dc0e4235 --- /dev/null +++ b/third_party/rust/proc-macro-error/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/third_party/rust/proc-macro-error/tests/ui/to_tokens_span.rs b/third_party/rust/proc-macro-error/tests/ui/to_tokens_span.rs new file mode 100644 index 0000000000..a7c3fc976c --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/to_tokens_span.rs @@ -0,0 +1,6 @@ +extern crate test_crate; +use test_crate::*; + +to_tokens_span!(std::option::Option); + +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/to_tokens_span.stderr b/third_party/rust/proc-macro-error/tests/ui/to_tokens_span.stderr new file mode 100644 index 0000000000..b8c4968263 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/to_tokens_span.stderr @@ -0,0 +1,11 @@ +error: whole type + --> $DIR/to_tokens_span.rs:4:17 + | +4 | to_tokens_span!(std::option::Option); + | ^^^^^^^^^^^^^^^^^^^ + +error: explicit .span() + --> $DIR/to_tokens_span.rs:4:17 + | +4 | to_tokens_span!(std::option::Option); + | ^^^ diff --git a/third_party/rust/proc-macro-error/tests/ui/unknown_setting.rs b/third_party/rust/proc-macro-error/tests/ui/unknown_setting.rs new file mode 100644 index 0000000000..d8e58eaf87 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/unknown_setting.rs @@ -0,0 +1,4 @@ +use proc_macro_error::proc_macro_error; + +#[proc_macro_error(allow_not_macro, assert_unwind_safe, trololo)] +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/unknown_setting.stderr b/third_party/rust/proc-macro-error/tests/ui/unknown_setting.stderr new file mode 100644 index 0000000000..a55de0b31b --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/unknown_setting.stderr @@ -0,0 +1,5 @@ +error: unknown setting `trololo`, expected one of `assert_unwind_safe`, `allow_not_macro`, `proc_macro_hack` + --> $DIR/unknown_setting.rs:3:57 + | +3 | #[proc_macro_error(allow_not_macro, assert_unwind_safe, trololo)] + | ^^^^^^^ diff --git a/third_party/rust/proc-macro-error/tests/ui/unrelated_panic.rs b/third_party/rust/proc-macro-error/tests/ui/unrelated_panic.rs new file mode 100644 index 0000000000..c74e3e0623 --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/unrelated_panic.rs @@ -0,0 +1,6 @@ +extern crate test_crate; +use test_crate::*; + +unrelated_panic!(); + +fn main() {} diff --git a/third_party/rust/proc-macro-error/tests/ui/unrelated_panic.stderr b/third_party/rust/proc-macro-error/tests/ui/unrelated_panic.stderr new file mode 100644 index 0000000000..d46d689f2f --- /dev/null +++ b/third_party/rust/proc-macro-error/tests/ui/unrelated_panic.stderr @@ -0,0 +1,7 @@ +error: proc macro panicked + --> $DIR/unrelated_panic.rs:4:1 + | +4 | unrelated_panic!(); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: message: unrelated panic test |