From fcca22cb4072097fc2cd1ae78ff84c7d59aacda2 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 20 Mar 2018 22:19:52 +0200 Subject: tests: move all proc_macro tests from -fulldeps. --- src/bootstrap/builder.rs | 1 - src/bootstrap/test.rs | 6 - .../proc-macro/attr-invalid-exprs.rs | 37 ----- .../proc-macro/attr-stmt-expr.rs | 37 ----- .../proc-macro/attribute-with-error.rs | 53 ------- .../compile-fail-fulldeps/proc-macro/attribute.rs | 63 -------- .../proc-macro/attributes-included.rs | 32 ----- .../proc-macro/auxiliary/attr-stmt-expr.rs | 58 -------- .../proc-macro/auxiliary/attribute-with-error.rs | 23 --- .../proc-macro/auxiliary/attributes-included.rs | 160 --------------------- .../proc-macro/auxiliary/bang_proc_macro2.rs | 23 --- .../proc-macro/auxiliary/derive-a-b.rs | 27 ---- .../proc-macro/auxiliary/derive-a.rs | 23 --- .../proc-macro/auxiliary/derive-b.rs | 23 --- .../proc-macro/auxiliary/derive-bad.rs | 24 ---- .../proc-macro/auxiliary/derive-clona.rs | 23 --- .../proc-macro/auxiliary/derive-foo.rs | 23 --- .../proc-macro/auxiliary/derive-unstable-2.rs | 27 ---- .../proc-macro/auxiliary/derive-unstable.rs | 24 ---- .../proc-macro/auxiliary/issue-41211.rs | 22 --- .../proc-macro/auxiliary/issue_38586.rs | 21 --- .../proc-macro/auxiliary/issue_50493.rs | 31 ---- .../proc-macro/auxiliary/more-gates.rs | 44 ------ .../proc-macro/auxiliary/proc-macro-gates.rs | 28 ---- .../proc-macro/auxiliary/test-macros.rs | 35 ----- .../compile-fail-fulldeps/proc-macro/define-two.rs | 27 ---- .../compile-fail-fulldeps/proc-macro/derive-bad.rs | 23 --- .../proc-macro/derive-still-gated.rs | 21 --- .../proc-macro/expand-to-unstable-2.rs | 24 ---- .../proc-macro/expand-to-unstable.rs | 24 ---- .../proc-macro/export-macro.rs | 18 --- .../compile-fail-fulldeps/proc-macro/exports.rs | 22 --- .../proc-macro/illegal-proc-macro-derive-use.rs | 25 ---- .../compile-fail-fulldeps/proc-macro/import.rs | 21 --- .../proc-macro/issue-37788.rs | 19 --- .../proc-macro/issue-38586.rs | 19 --- .../proc-macro/issue-41211.rs | 23 --- .../proc-macro/issue-50493.rs | 24 ---- .../compile-fail-fulldeps/proc-macro/item-error.rs | 25 ---- .../proc-macro/lints_in_proc_macros.rs | 26 ---- .../proc-macro/macros-in-extern.rs | 35 ----- .../compile-fail-fulldeps/proc-macro/more-gates.rs | 30 ---- .../proc-macro/no-macro-use-attr.rs | 20 --- .../proc-macro/proc-macro-attributes.rs | 24 ---- .../proc-macro/proc-macro-gates.rs | 71 --------- .../proc-macro/proc-macro-gates2.rs | 35 ----- .../proc-macro/pub-at-crate-root.rs | 29 ---- .../proc-macro/shadow-builtin.rs | 21 --- .../compile-fail-fulldeps/proc-macro/shadow.rs | 18 --- .../proc-macro/two-crate-types-1.rs | 14 -- .../proc-macro/two-crate-types-2.rs | 12 -- .../compile-fail/proc-macro/attr-invalid-exprs.rs | 37 +++++ src/test/compile-fail/proc-macro/attr-stmt-expr.rs | 37 +++++ .../proc-macro/attribute-with-error.rs | 53 +++++++ src/test/compile-fail/proc-macro/attribute.rs | 63 ++++++++ .../compile-fail/proc-macro/attributes-included.rs | 32 +++++ .../proc-macro/auxiliary/attr-stmt-expr.rs | 58 ++++++++ .../proc-macro/auxiliary/attribute-with-error.rs | 23 +++ .../proc-macro/auxiliary/attributes-included.rs | 160 +++++++++++++++++++++ .../proc-macro/auxiliary/bang_proc_macro2.rs | 23 +++ .../proc-macro/auxiliary/derive-a-b.rs | 27 ++++ .../compile-fail/proc-macro/auxiliary/derive-a.rs | 23 +++ .../compile-fail/proc-macro/auxiliary/derive-b.rs | 23 +++ .../proc-macro/auxiliary/derive-bad.rs | 24 ++++ .../proc-macro/auxiliary/derive-clona.rs | 23 +++ .../proc-macro/auxiliary/derive-foo.rs | 23 +++ .../proc-macro/auxiliary/derive-unstable-2.rs | 27 ++++ .../proc-macro/auxiliary/derive-unstable.rs | 24 ++++ .../proc-macro/auxiliary/issue-41211.rs | 22 +++ .../proc-macro/auxiliary/issue_38586.rs | 21 +++ .../proc-macro/auxiliary/issue_50493.rs | 31 ++++ .../proc-macro/auxiliary/more-gates.rs | 44 ++++++ .../proc-macro/auxiliary/proc-macro-gates.rs | 28 ++++ .../proc-macro/auxiliary/test-macros.rs | 35 +++++ src/test/compile-fail/proc-macro/define-two.rs | 27 ++++ src/test/compile-fail/proc-macro/derive-bad.rs | 23 +++ .../compile-fail/proc-macro/derive-still-gated.rs | 21 +++ .../proc-macro/expand-to-unstable-2.rs | 24 ++++ .../compile-fail/proc-macro/expand-to-unstable.rs | 24 ++++ src/test/compile-fail/proc-macro/export-macro.rs | 18 +++ src/test/compile-fail/proc-macro/exports.rs | 22 +++ .../proc-macro/illegal-proc-macro-derive-use.rs | 25 ++++ src/test/compile-fail/proc-macro/import.rs | 21 +++ src/test/compile-fail/proc-macro/issue-37788.rs | 19 +++ src/test/compile-fail/proc-macro/issue-38586.rs | 19 +++ src/test/compile-fail/proc-macro/issue-41211.rs | 23 +++ src/test/compile-fail/proc-macro/issue-50493.rs | 24 ++++ src/test/compile-fail/proc-macro/item-error.rs | 25 ++++ .../proc-macro/lints_in_proc_macros.rs | 26 ++++ .../compile-fail/proc-macro/macros-in-extern.rs | 35 +++++ src/test/compile-fail/proc-macro/more-gates.rs | 30 ++++ .../compile-fail/proc-macro/no-macro-use-attr.rs | 20 +++ .../proc-macro/proc-macro-attributes.rs | 24 ++++ .../compile-fail/proc-macro/proc-macro-gates.rs | 71 +++++++++ .../compile-fail/proc-macro/proc-macro-gates2.rs | 35 +++++ .../compile-fail/proc-macro/pub-at-crate-root.rs | 29 ++++ src/test/compile-fail/proc-macro/shadow-builtin.rs | 21 +++ src/test/compile-fail/proc-macro/shadow.rs | 18 +++ .../compile-fail/proc-macro/two-crate-types-1.rs | 14 ++ .../compile-fail/proc-macro/two-crate-types-2.rs | 12 ++ .../auxiliary/incremental_proc_macro_aux.rs | 31 ---- .../auxiliary/issue_49482_macro_def.rs | 49 ------- .../auxiliary/issue_49482_reexport.rs | 16 --- .../incremental-fulldeps/auxiliary/issue_54059.rs | 59 -------- .../incremental-fulldeps/incremental_proc_macro.rs | 26 ---- src/test/incremental-fulldeps/issue-49482.rs | 40 ------ src/test/incremental-fulldeps/issue-54059.rs | 18 --- .../auxiliary/incremental_proc_macro_aux.rs | 31 ++++ .../incremental/auxiliary/issue_49482_macro_def.rs | 49 +++++++ .../incremental/auxiliary/issue_49482_reexport.rs | 16 +++ src/test/incremental/auxiliary/issue_54059.rs | 59 ++++++++ src/test/incremental/incremental_proc_macro.rs | 26 ++++ src/test/incremental/issue-49482.rs | 40 ++++++ src/test/incremental/issue-54059.rs | 18 +++ .../rustc-macro-dep-files/Makefile | 6 - .../run-make-fulldeps/rustc-macro-dep-files/bar.rs | 19 --- .../run-make-fulldeps/rustc-macro-dep-files/foo.rs | 22 --- src/test/run-make/rustc-macro-dep-files/Makefile | 6 + src/test/run-make/rustc-macro-dep-files/bar.rs | 19 +++ src/test/run-make/rustc-macro-dep-files/foo.rs | 22 +++ .../run-pass-fulldeps/auxiliary/cond_plugin.rs | 47 ------ .../run-pass-fulldeps/auxiliary/hello_macro.rs | 30 ---- .../auxiliary/issue-40001-plugin.rs | 69 +++++++++ .../run-pass-fulldeps/auxiliary/proc_macro_def.rs | 44 ------ src/test/run-pass-fulldeps/issue-40001.rs | 18 +++ src/test/run-pass-fulldeps/macro-quote-cond.rs | 56 -------- src/test/run-pass-fulldeps/macro-quote-test.rs | 21 --- src/test/run-pass-fulldeps/proc-macro/add-impl.rs | 23 --- .../run-pass-fulldeps/proc-macro/append-impl.rs | 31 ---- src/test/run-pass-fulldeps/proc-macro/attr-args.rs | 22 --- src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs | 36 ----- .../run-pass-fulldeps/proc-macro/attr-on-trait.rs | 28 ---- .../run-pass-fulldeps/proc-macro/attr-stmt-expr.rs | 45 ------ .../proc-macro/auxiliary/add-impl.rs | 30 ---- .../proc-macro/auxiliary/append-impl.rs | 26 ---- .../proc-macro/auxiliary/attr-args.rs | 37 ----- .../proc-macro/auxiliary/attr-cfg.rs | 32 ----- .../proc-macro/auxiliary/attr-on-trait.rs | 24 ---- .../proc-macro/auxiliary/attr-stmt-expr.rs | 60 -------- .../proc-macro/auxiliary/bang-macro.rs | 26 ---- .../proc-macro/auxiliary/call-site.rs | 36 ----- .../proc-macro/auxiliary/count_compound_ops.rs | 41 ------ .../auxiliary/custom-attr-only-one-derive.rs | 27 ---- .../proc-macro/auxiliary/derive-a.rs | 24 ---- .../proc-macro/auxiliary/derive-atob.rs | 24 ---- .../proc-macro/auxiliary/derive-attr-cfg.rs | 23 --- .../proc-macro/auxiliary/derive-b.rs | 26 ---- .../proc-macro/auxiliary/derive-ctod.rs | 24 ---- .../proc-macro/auxiliary/derive-nothing.rs | 22 --- .../proc-macro/auxiliary/derive-same-struct.rs | 29 ---- .../proc-macro/auxiliary/derive-two-attrs.rs | 22 --- .../proc-macro/auxiliary/derive-union.rs | 27 ---- .../proc-macro/auxiliary/double.rs | 24 ---- .../proc-macro/auxiliary/empty-crate.rs | 14 -- .../proc-macro/auxiliary/expand-with-a-macro.rs | 32 ----- .../proc-macro/auxiliary/external-crate-var.rs | 51 ------- .../proc-macro/auxiliary/gen-lifetime-token.rs | 34 ----- .../proc-macro/auxiliary/hygiene_example.rs | 17 --- .../auxiliary/hygiene_example_codegen.rs | 36 ----- .../proc-macro/auxiliary/issue-39889.rs | 27 ---- .../proc-macro/auxiliary/issue-40001-plugin.rs | 69 --------- .../proc-macro/auxiliary/issue-42708.rs | 27 ---- .../proc-macro/auxiliary/issue-50061.rs | 21 --- .../proc-macro/auxiliary/lifetimes.rs | 35 ----- .../proc-macro/auxiliary/modify-ast.rs | 56 -------- .../proc-macro/auxiliary/negative-token.rs | 27 ---- .../proc-macro/auxiliary/not-joint.rs | 39 ----- .../proc-macro/auxiliary/span-api-tests.rs | 45 ------ .../proc-macro/auxiliary/span-test-macros.rs | 19 --- .../proc-macro/auxiliary/test-macros.rs | 35 ----- .../run-pass-fulldeps/proc-macro/bang-macro.rs | 20 --- src/test/run-pass-fulldeps/proc-macro/call-site.rs | 24 ---- .../proc-macro/count_compound_ops.rs | 20 --- src/test/run-pass-fulldeps/proc-macro/crate-var.rs | 70 --------- .../proc-macro/custom-attr-only-one-derive.rs | 25 ---- .../proc-macro/derive-attr-cfg.rs | 25 ---- src/test/run-pass-fulldeps/proc-macro/derive-b.rs | 30 ---- .../proc-macro/derive-same-struct.rs | 23 --- .../proc-macro/derive-same-struct.stdout | 1 - .../run-pass-fulldeps/proc-macro/derive-test.rs | 31 ---- .../proc-macro/derive-two-attrs.rs | 23 --- .../run-pass-fulldeps/proc-macro/derive-union.rs | 25 ---- .../run-pass-fulldeps/proc-macro/empty-crate.rs | 17 --- .../proc-macro/expand-with-a-macro.rs | 28 ---- .../proc-macro/gen-lifetime-token.rs | 20 --- .../proc-macro/hygiene_example.rs | 28 ---- .../run-pass-fulldeps/proc-macro/issue-39889.rs | 20 --- .../run-pass-fulldeps/proc-macro/issue-40001.rs | 18 --- .../run-pass-fulldeps/proc-macro/issue-42708.rs | 35 ----- .../run-pass-fulldeps/proc-macro/issue-50061.rs | 31 ---- src/test/run-pass-fulldeps/proc-macro/lifetimes.rs | 34 ----- src/test/run-pass-fulldeps/proc-macro/load-two.rs | 31 ---- .../proc-macro/macros-in-extern.rs | 34 ----- .../run-pass-fulldeps/proc-macro/modify-ast.rs | 35 ----- .../run-pass-fulldeps/proc-macro/negative-token.rs | 22 --- src/test/run-pass-fulldeps/proc-macro/not-joint.rs | 33 ----- src/test/run-pass-fulldeps/proc-macro/smoke.rs | 28 ---- .../run-pass-fulldeps/proc-macro/span-api-tests.rs | 41 ------ .../proc-macro/struct-field-macro.rs | 26 ---- src/test/run-pass-fulldeps/proc_macro.rs | 48 ------- src/test/run-pass/auxiliary/cond_plugin.rs | 47 ++++++ src/test/run-pass/auxiliary/hello_macro.rs | 30 ++++ src/test/run-pass/auxiliary/proc_macro_def.rs | 44 ++++++ src/test/run-pass/macro-quote-cond.rs | 56 ++++++++ src/test/run-pass/macro-quote-test.rs | 21 +++ src/test/run-pass/proc-macro/add-impl.rs | 23 +++ src/test/run-pass/proc-macro/append-impl.rs | 31 ++++ src/test/run-pass/proc-macro/attr-args.rs | 22 +++ src/test/run-pass/proc-macro/attr-cfg.rs | 36 +++++ src/test/run-pass/proc-macro/attr-on-trait.rs | 28 ++++ src/test/run-pass/proc-macro/attr-stmt-expr.rs | 45 ++++++ src/test/run-pass/proc-macro/auxiliary/add-impl.rs | 30 ++++ .../run-pass/proc-macro/auxiliary/append-impl.rs | 26 ++++ .../run-pass/proc-macro/auxiliary/attr-args.rs | 37 +++++ src/test/run-pass/proc-macro/auxiliary/attr-cfg.rs | 32 +++++ .../run-pass/proc-macro/auxiliary/attr-on-trait.rs | 24 ++++ .../proc-macro/auxiliary/attr-stmt-expr.rs | 60 ++++++++ .../run-pass/proc-macro/auxiliary/bang-macro.rs | 26 ++++ .../run-pass/proc-macro/auxiliary/call-site.rs | 36 +++++ .../proc-macro/auxiliary/count_compound_ops.rs | 41 ++++++ .../auxiliary/custom-attr-only-one-derive.rs | 27 ++++ src/test/run-pass/proc-macro/auxiliary/derive-a.rs | 24 ++++ .../run-pass/proc-macro/auxiliary/derive-atob.rs | 24 ++++ .../proc-macro/auxiliary/derive-attr-cfg.rs | 23 +++ src/test/run-pass/proc-macro/auxiliary/derive-b.rs | 26 ++++ .../run-pass/proc-macro/auxiliary/derive-ctod.rs | 24 ++++ .../proc-macro/auxiliary/derive-nothing.rs | 22 +++ .../proc-macro/auxiliary/derive-same-struct.rs | 29 ++++ .../proc-macro/auxiliary/derive-two-attrs.rs | 22 +++ .../run-pass/proc-macro/auxiliary/derive-union.rs | 27 ++++ src/test/run-pass/proc-macro/auxiliary/double.rs | 24 ++++ .../run-pass/proc-macro/auxiliary/empty-crate.rs | 14 ++ .../proc-macro/auxiliary/expand-with-a-macro.rs | 32 +++++ .../proc-macro/auxiliary/external-crate-var.rs | 51 +++++++ .../proc-macro/auxiliary/gen-lifetime-token.rs | 34 +++++ .../proc-macro/auxiliary/hygiene_example.rs | 17 +++ .../auxiliary/hygiene_example_codegen.rs | 36 +++++ .../run-pass/proc-macro/auxiliary/issue-39889.rs | 27 ++++ .../run-pass/proc-macro/auxiliary/issue-42708.rs | 27 ++++ .../run-pass/proc-macro/auxiliary/issue-50061.rs | 21 +++ .../run-pass/proc-macro/auxiliary/lifetimes.rs | 35 +++++ .../run-pass/proc-macro/auxiliary/modify-ast.rs | 56 ++++++++ .../proc-macro/auxiliary/negative-token.rs | 27 ++++ .../run-pass/proc-macro/auxiliary/not-joint.rs | 39 +++++ .../proc-macro/auxiliary/span-api-tests.rs | 45 ++++++ .../proc-macro/auxiliary/span-test-macros.rs | 19 +++ .../run-pass/proc-macro/auxiliary/test-macros.rs | 35 +++++ src/test/run-pass/proc-macro/bang-macro.rs | 20 +++ src/test/run-pass/proc-macro/call-site.rs | 24 ++++ src/test/run-pass/proc-macro/count_compound_ops.rs | 20 +++ src/test/run-pass/proc-macro/crate-var.rs | 70 +++++++++ .../proc-macro/custom-attr-only-one-derive.rs | 25 ++++ src/test/run-pass/proc-macro/derive-attr-cfg.rs | 25 ++++ src/test/run-pass/proc-macro/derive-b.rs | 30 ++++ src/test/run-pass/proc-macro/derive-same-struct.rs | 23 +++ .../run-pass/proc-macro/derive-same-struct.stdout | 1 + src/test/run-pass/proc-macro/derive-test.rs | 31 ++++ src/test/run-pass/proc-macro/derive-two-attrs.rs | 23 +++ src/test/run-pass/proc-macro/derive-union.rs | 25 ++++ src/test/run-pass/proc-macro/empty-crate.rs | 17 +++ .../run-pass/proc-macro/expand-with-a-macro.rs | 28 ++++ src/test/run-pass/proc-macro/gen-lifetime-token.rs | 20 +++ src/test/run-pass/proc-macro/hygiene_example.rs | 28 ++++ src/test/run-pass/proc-macro/issue-39889.rs | 20 +++ src/test/run-pass/proc-macro/issue-42708.rs | 35 +++++ src/test/run-pass/proc-macro/issue-50061.rs | 31 ++++ src/test/run-pass/proc-macro/lifetimes.rs | 34 +++++ src/test/run-pass/proc-macro/load-two.rs | 31 ++++ src/test/run-pass/proc-macro/macros-in-extern.rs | 34 +++++ src/test/run-pass/proc-macro/modify-ast.rs | 35 +++++ src/test/run-pass/proc-macro/negative-token.rs | 22 +++ src/test/run-pass/proc-macro/not-joint.rs | 33 +++++ src/test/run-pass/proc-macro/smoke.rs | 28 ++++ src/test/run-pass/proc-macro/span-api-tests.rs | 41 ++++++ src/test/run-pass/proc-macro/struct-field-macro.rs | 26 ++++ src/test/run-pass/proc_macro.rs | 48 +++++++ src/test/ui-fulldeps/attribute-order-restricted.rs | 14 -- .../ui-fulldeps/attribute-order-restricted.stderr | 8 -- src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs | 23 --- src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs | 23 --- src/test/ui-fulldeps/auxiliary/derive-clona.rs | 23 --- src/test/ui-fulldeps/auxiliary/derive-foo.rs | 23 --- .../ui-fulldeps/auxiliary/invalid-punct-ident.rs | 38 ----- src/test/ui-fulldeps/auxiliary/lifetimes.rs | 29 ---- src/test/ui-fulldeps/auxiliary/subspan.rs | 47 ------ .../ui-fulldeps/custom-derive/auxiliary/plugin.rs | 37 ----- .../ui-fulldeps/custom-derive/derive-in-mod.rs | 13 -- .../helper-attr-blocked-by-import-ambig.rs | 12 -- .../helper-attr-blocked-by-import-ambig.stderr | 21 --- .../custom-derive/helper-attr-blocked-by-import.rs | 28 ---- src/test/ui-fulldeps/custom-derive/issue-36935.rs | 22 --- .../ui-fulldeps/custom-derive/issue-36935.stderr | 10 -- src/test/ui-fulldeps/invalid-punct-ident-1.rs | 16 --- src/test/ui-fulldeps/invalid-punct-ident-1.stderr | 10 -- src/test/ui-fulldeps/invalid-punct-ident-2.rs | 16 --- src/test/ui-fulldeps/invalid-punct-ident-2.stderr | 10 -- src/test/ui-fulldeps/invalid-punct-ident-3.rs | 16 --- src/test/ui-fulldeps/invalid-punct-ident-3.stderr | 10 -- src/test/ui-fulldeps/invalid-punct-ident-4.rs | 17 --- src/test/ui-fulldeps/invalid-punct-ident-4.stderr | 14 -- src/test/ui-fulldeps/lifetimes.rs | 19 --- src/test/ui-fulldeps/lifetimes.stderr | 8 -- .../proc-macro/ambiguous-builtin-attrs-test.rs | 20 --- .../proc-macro/ambiguous-builtin-attrs-test.stderr | 9 -- .../proc-macro/ambiguous-builtin-attrs.rs | 31 ---- .../proc-macro/ambiguous-builtin-attrs.stderr | 80 ----------- .../proc-macro/attribute-spans-preserved.rs | 20 --- .../proc-macro/attribute-spans-preserved.stderr | 21 --- .../proc-macro/attribute-spans-preserved.stdout | 1 - .../proc-macro/auxiliary/attr_proc_macro.rs | 23 --- .../auxiliary/attribute-spans-preserved.rs | 44 ------ .../proc-macro/auxiliary/bang_proc_macro.rs | 23 --- .../proc-macro/auxiliary/builtin-attrs.rs | 36 ----- .../auxiliary/derive-helper-shadowed-2.rs | 2 - .../proc-macro/auxiliary/derive-helper-shadowed.rs | 11 -- .../auxiliary/derive-helper-shadowing.rs | 16 --- .../proc-macro/auxiliary/derive-panic.rs | 23 --- .../proc-macro/auxiliary/generate-mod.rs | 66 --------- .../proc-macro/auxiliary/issue-53481.rs | 12 -- .../proc-macro/auxiliary/macro-brackets.rs | 21 --- .../ui-fulldeps/proc-macro/auxiliary/multispan.rs | 46 ------ .../proc-macro/auxiliary/nested-item-spans.rs | 22 --- .../proc-macro/auxiliary/parent-source-spans.rs | 52 ------- .../proc-macro/auxiliary/span-preservation.rs | 12 -- .../proc-macro/auxiliary/three-equals.rs | 58 -------- .../proc-macro/derive-helper-shadowed.rs | 16 --- .../proc-macro/derive-helper-shadowing.rs | 10 -- .../proc-macro/derive-helper-shadowing.stderr | 21 --- .../extern-prelude-extern-crate-proc-macro.rs | 7 - src/test/ui-fulldeps/proc-macro/generate-mod.rs | 43 ------ .../ui-fulldeps/proc-macro/generate-mod.stderr | 64 --------- .../ui-fulldeps/proc-macro/invalid-attributes.rs | 35 ----- .../proc-macro/invalid-attributes.stderr | 38 ----- src/test/ui-fulldeps/proc-macro/issue-53481.rs | 22 --- src/test/ui-fulldeps/proc-macro/load-panic.rs | 21 --- src/test/ui-fulldeps/proc-macro/load-panic.stderr | 10 -- src/test/ui-fulldeps/proc-macro/macro-brackets.rs | 24 ---- .../ui-fulldeps/proc-macro/macro-brackets.stderr | 9 -- .../proc-macro/macro-namespace-reserved-2.rs | 55 ------- .../proc-macro/macro-namespace-reserved-2.stderr | 56 -------- .../proc-macro/macro-namespace-reserved.rs | 47 ------ .../proc-macro/macro-namespace-reserved.stderr | 47 ------ src/test/ui-fulldeps/proc-macro/macro-use-attr.rs | 21 --- src/test/ui-fulldeps/proc-macro/macro-use-bang.rs | 21 --- src/test/ui-fulldeps/proc-macro/multispan.rs | 37 ----- src/test/ui-fulldeps/proc-macro/multispan.stderr | 86 ----------- .../ui-fulldeps/proc-macro/nested-item-spans.rs | 34 ----- .../proc-macro/nested-item-spans.stderr | 21 --- src/test/ui-fulldeps/proc-macro/non-root.rs | 24 ---- src/test/ui-fulldeps/proc-macro/non-root.stderr | 8 -- .../ui-fulldeps/proc-macro/parent-source-spans.rs | 61 -------- .../proc-macro/parent-source-spans.stderr | 128 ----------------- .../ui-fulldeps/proc-macro/reserved-macro-names.rs | 22 --- .../proc-macro/reserved-macro-names.stderr | 20 --- src/test/ui-fulldeps/proc-macro/signature.rs | 20 --- src/test/ui-fulldeps/proc-macro/signature.stderr | 15 -- .../ui-fulldeps/proc-macro/span-preservation.rs | 51 ------- .../proc-macro/span-preservation.stderr | 49 ------- src/test/ui-fulldeps/proc-macro/three-equals.rs | 38 ----- .../ui-fulldeps/proc-macro/three-equals.stderr | 48 ------- src/test/ui-fulldeps/resolve-error.rs | 70 --------- src/test/ui-fulldeps/resolve-error.stderr | 50 ------- .../auxiliary/suggestions-not-always-applicable.rs | 22 --- .../rust-2018/proc-macro-crate-in-paths.rs | 24 ---- .../suggestions-not-always-applicable.fixed | 37 ----- .../rust-2018/suggestions-not-always-applicable.rs | 37 ----- .../suggestions-not-always-applicable.stderr | 24 ---- src/test/ui-fulldeps/subspan.rs | 36 ----- src/test/ui-fulldeps/subspan.stderr | 98 ------------- src/test/ui-fulldeps/unnecessary-extern-crate.rs | 85 ----------- .../ui-fulldeps/unnecessary-extern-crate.stderr | 44 ------ src/test/ui/custom-derive/auxiliary/plugin.rs | 37 +++++ src/test/ui/custom-derive/derive-in-mod.rs | 13 ++ .../helper-attr-blocked-by-import-ambig.rs | 12 ++ .../helper-attr-blocked-by-import-ambig.stderr | 21 +++ .../custom-derive/helper-attr-blocked-by-import.rs | 28 ++++ src/test/ui/custom-derive/issue-36935.rs | 22 +++ src/test/ui/custom-derive/issue-36935.stderr | 10 ++ .../ui/proc-macro/ambiguous-builtin-attrs-test.rs | 20 +++ .../proc-macro/ambiguous-builtin-attrs-test.stderr | 9 ++ src/test/ui/proc-macro/ambiguous-builtin-attrs.rs | 31 ++++ .../ui/proc-macro/ambiguous-builtin-attrs.stderr | 80 +++++++++++ .../ui/proc-macro/attribute-order-restricted.rs | 14 ++ .../proc-macro/attribute-order-restricted.stderr | 8 ++ .../ui/proc-macro/attribute-spans-preserved.rs | 20 +++ .../ui/proc-macro/attribute-spans-preserved.stderr | 21 +++ .../ui/proc-macro/attribute-spans-preserved.stdout | 1 + .../ui/proc-macro/auxiliary/attr_proc_macro.rs | 23 +++ .../auxiliary/attribute-spans-preserved.rs | 44 ++++++ .../ui/proc-macro/auxiliary/bang_proc_macro.rs | 23 +++ src/test/ui/proc-macro/auxiliary/builtin-attrs.rs | 36 +++++ src/test/ui/proc-macro/auxiliary/derive-clona.rs | 23 +++ src/test/ui/proc-macro/auxiliary/derive-foo.rs | 23 +++ .../auxiliary/derive-helper-shadowed-2.rs | 2 + .../proc-macro/auxiliary/derive-helper-shadowed.rs | 11 ++ .../auxiliary/derive-helper-shadowing.rs | 16 +++ src/test/ui/proc-macro/auxiliary/derive-panic.rs | 23 +++ src/test/ui/proc-macro/auxiliary/generate-mod.rs | 66 +++++++++ .../ui/proc-macro/auxiliary/invalid-punct-ident.rs | 38 +++++ src/test/ui/proc-macro/auxiliary/issue-53481.rs | 12 ++ src/test/ui/proc-macro/auxiliary/lifetimes.rs | 29 ++++ src/test/ui/proc-macro/auxiliary/macro-brackets.rs | 21 +++ src/test/ui/proc-macro/auxiliary/multispan.rs | 46 ++++++ .../ui/proc-macro/auxiliary/nested-item-spans.rs | 22 +++ .../ui/proc-macro/auxiliary/parent-source-spans.rs | 52 +++++++ .../ui/proc-macro/auxiliary/span-preservation.rs | 12 ++ src/test/ui/proc-macro/auxiliary/subspan.rs | 47 ++++++ src/test/ui/proc-macro/auxiliary/three-equals.rs | 58 ++++++++ src/test/ui/proc-macro/derive-helper-shadowed.rs | 16 +++ src/test/ui/proc-macro/derive-helper-shadowing.rs | 10 ++ .../ui/proc-macro/derive-helper-shadowing.stderr | 21 +++ .../extern-prelude-extern-crate-proc-macro.rs | 7 + src/test/ui/proc-macro/generate-mod.rs | 43 ++++++ src/test/ui/proc-macro/generate-mod.stderr | 64 +++++++++ src/test/ui/proc-macro/invalid-attributes.rs | 35 +++++ src/test/ui/proc-macro/invalid-attributes.stderr | 38 +++++ src/test/ui/proc-macro/invalid-punct-ident-1.rs | 16 +++ .../ui/proc-macro/invalid-punct-ident-1.stderr | 10 ++ src/test/ui/proc-macro/invalid-punct-ident-2.rs | 16 +++ .../ui/proc-macro/invalid-punct-ident-2.stderr | 10 ++ src/test/ui/proc-macro/invalid-punct-ident-3.rs | 16 +++ .../ui/proc-macro/invalid-punct-ident-3.stderr | 10 ++ src/test/ui/proc-macro/invalid-punct-ident-4.rs | 17 +++ .../ui/proc-macro/invalid-punct-ident-4.stderr | 14 ++ src/test/ui/proc-macro/issue-53481.rs | 22 +++ src/test/ui/proc-macro/lifetimes.rs | 19 +++ src/test/ui/proc-macro/lifetimes.stderr | 8 ++ src/test/ui/proc-macro/load-panic.rs | 21 +++ src/test/ui/proc-macro/load-panic.stderr | 10 ++ src/test/ui/proc-macro/macro-brackets.rs | 24 ++++ src/test/ui/proc-macro/macro-brackets.stderr | 9 ++ .../ui/proc-macro/macro-namespace-reserved-2.rs | 55 +++++++ .../proc-macro/macro-namespace-reserved-2.stderr | 56 ++++++++ src/test/ui/proc-macro/macro-namespace-reserved.rs | 47 ++++++ .../ui/proc-macro/macro-namespace-reserved.stderr | 47 ++++++ src/test/ui/proc-macro/macro-use-attr.rs | 21 +++ src/test/ui/proc-macro/macro-use-bang.rs | 21 +++ src/test/ui/proc-macro/multispan.rs | 37 +++++ src/test/ui/proc-macro/multispan.stderr | 86 +++++++++++ src/test/ui/proc-macro/nested-item-spans.rs | 34 +++++ src/test/ui/proc-macro/nested-item-spans.stderr | 21 +++ src/test/ui/proc-macro/non-root.rs | 24 ++++ src/test/ui/proc-macro/non-root.stderr | 8 ++ src/test/ui/proc-macro/parent-source-spans.rs | 61 ++++++++ src/test/ui/proc-macro/parent-source-spans.stderr | 128 +++++++++++++++++ src/test/ui/proc-macro/reserved-macro-names.rs | 22 +++ src/test/ui/proc-macro/reserved-macro-names.stderr | 20 +++ src/test/ui/proc-macro/resolve-error.rs | 70 +++++++++ src/test/ui/proc-macro/resolve-error.stderr | 50 +++++++ src/test/ui/proc-macro/signature.rs | 20 +++ src/test/ui/proc-macro/signature.stderr | 15 ++ src/test/ui/proc-macro/span-preservation.rs | 51 +++++++ src/test/ui/proc-macro/span-preservation.stderr | 49 +++++++ src/test/ui/proc-macro/subspan.rs | 36 +++++ src/test/ui/proc-macro/subspan.stderr | 98 +++++++++++++ src/test/ui/proc-macro/three-equals.rs | 38 +++++ src/test/ui/proc-macro/three-equals.stderr | 48 +++++++ .../auxiliary/suggestions-not-always-applicable.rs | 22 +++ src/test/ui/rust-2018/proc-macro-crate-in-paths.rs | 24 ++++ .../suggestions-not-always-applicable.fixed | 37 +++++ .../rust-2018/suggestions-not-always-applicable.rs | 37 +++++ .../suggestions-not-always-applicable.stderr | 24 ++++ src/test/ui/unnecessary-extern-crate.rs | 85 +++++++++++ src/test/ui/unnecessary-extern-crate.stderr | 44 ++++++ 464 files changed, 7060 insertions(+), 7113 deletions(-) delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/attribute.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/attribute-with-error.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/bang_proc_macro2.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-b.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-clona.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-foo.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue-41211.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_38586.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_50493.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/more-gates.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/auxiliary/test-macros.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/define-two.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/export-macro.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/exports.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/illegal-proc-macro-derive-use.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/import.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/issue-37788.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/issue-41211.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/issue-50493.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/item-error.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/macros-in-extern.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/more-gates.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/no-macro-use-attr.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/pub-at-crate-root.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/shadow.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs delete mode 100644 src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs create mode 100644 src/test/compile-fail/proc-macro/attr-invalid-exprs.rs create mode 100644 src/test/compile-fail/proc-macro/attr-stmt-expr.rs create mode 100644 src/test/compile-fail/proc-macro/attribute-with-error.rs create mode 100644 src/test/compile-fail/proc-macro/attribute.rs create mode 100644 src/test/compile-fail/proc-macro/attributes-included.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/attr-stmt-expr.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/attribute-with-error.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/attributes-included.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/bang_proc_macro2.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/derive-a-b.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/derive-a.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/derive-b.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/derive-bad.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/derive-clona.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/derive-foo.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/derive-unstable-2.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/derive-unstable.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/issue-41211.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/issue_38586.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/issue_50493.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/more-gates.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/proc-macro-gates.rs create mode 100644 src/test/compile-fail/proc-macro/auxiliary/test-macros.rs create mode 100644 src/test/compile-fail/proc-macro/define-two.rs create mode 100644 src/test/compile-fail/proc-macro/derive-bad.rs create mode 100644 src/test/compile-fail/proc-macro/derive-still-gated.rs create mode 100644 src/test/compile-fail/proc-macro/expand-to-unstable-2.rs create mode 100644 src/test/compile-fail/proc-macro/expand-to-unstable.rs create mode 100644 src/test/compile-fail/proc-macro/export-macro.rs create mode 100644 src/test/compile-fail/proc-macro/exports.rs create mode 100644 src/test/compile-fail/proc-macro/illegal-proc-macro-derive-use.rs create mode 100644 src/test/compile-fail/proc-macro/import.rs create mode 100644 src/test/compile-fail/proc-macro/issue-37788.rs create mode 100644 src/test/compile-fail/proc-macro/issue-38586.rs create mode 100644 src/test/compile-fail/proc-macro/issue-41211.rs create mode 100644 src/test/compile-fail/proc-macro/issue-50493.rs create mode 100644 src/test/compile-fail/proc-macro/item-error.rs create mode 100644 src/test/compile-fail/proc-macro/lints_in_proc_macros.rs create mode 100644 src/test/compile-fail/proc-macro/macros-in-extern.rs create mode 100644 src/test/compile-fail/proc-macro/more-gates.rs create mode 100644 src/test/compile-fail/proc-macro/no-macro-use-attr.rs create mode 100644 src/test/compile-fail/proc-macro/proc-macro-attributes.rs create mode 100644 src/test/compile-fail/proc-macro/proc-macro-gates.rs create mode 100644 src/test/compile-fail/proc-macro/proc-macro-gates2.rs create mode 100644 src/test/compile-fail/proc-macro/pub-at-crate-root.rs create mode 100644 src/test/compile-fail/proc-macro/shadow-builtin.rs create mode 100644 src/test/compile-fail/proc-macro/shadow.rs create mode 100644 src/test/compile-fail/proc-macro/two-crate-types-1.rs create mode 100644 src/test/compile-fail/proc-macro/two-crate-types-2.rs delete mode 100644 src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs delete mode 100644 src/test/incremental-fulldeps/auxiliary/issue_49482_macro_def.rs delete mode 100644 src/test/incremental-fulldeps/auxiliary/issue_49482_reexport.rs delete mode 100644 src/test/incremental-fulldeps/auxiliary/issue_54059.rs delete mode 100644 src/test/incremental-fulldeps/incremental_proc_macro.rs delete mode 100644 src/test/incremental-fulldeps/issue-49482.rs delete mode 100644 src/test/incremental-fulldeps/issue-54059.rs create mode 100644 src/test/incremental/auxiliary/incremental_proc_macro_aux.rs create mode 100644 src/test/incremental/auxiliary/issue_49482_macro_def.rs create mode 100644 src/test/incremental/auxiliary/issue_49482_reexport.rs create mode 100644 src/test/incremental/auxiliary/issue_54059.rs create mode 100644 src/test/incremental/incremental_proc_macro.rs create mode 100644 src/test/incremental/issue-49482.rs create mode 100644 src/test/incremental/issue-54059.rs delete mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile delete mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs delete mode 100644 src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs create mode 100644 src/test/run-make/rustc-macro-dep-files/Makefile create mode 100644 src/test/run-make/rustc-macro-dep-files/bar.rs create mode 100644 src/test/run-make/rustc-macro-dep-files/foo.rs delete mode 100644 src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs delete mode 100644 src/test/run-pass-fulldeps/auxiliary/hello_macro.rs create mode 100644 src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs delete mode 100644 src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs create mode 100644 src/test/run-pass-fulldeps/issue-40001.rs delete mode 100644 src/test/run-pass-fulldeps/macro-quote-cond.rs delete mode 100644 src/test/run-pass-fulldeps/macro-quote-test.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/add-impl.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/append-impl.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/attr-args.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-on-trait.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/bang-macro.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/call-site.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-nothing.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-union.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/double.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/empty-crate.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/external-crate-var.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/gen-lifetime-token.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-39889.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-42708.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-50061.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/lifetimes.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/negative-token.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/span-api-tests.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/span-test-macros.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/auxiliary/test-macros.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/bang-macro.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/call-site.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/crate-var.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-b.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout delete mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-test.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/derive-union.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/empty-crate.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/gen-lifetime-token.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/issue-39889.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/issue-40001.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/issue-42708.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/issue-50061.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/lifetimes.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/load-two.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/modify-ast.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/negative-token.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/not-joint.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/smoke.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/span-api-tests.rs delete mode 100644 src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs delete mode 100644 src/test/run-pass-fulldeps/proc_macro.rs create mode 100644 src/test/run-pass/auxiliary/cond_plugin.rs create mode 100644 src/test/run-pass/auxiliary/hello_macro.rs create mode 100644 src/test/run-pass/auxiliary/proc_macro_def.rs create mode 100644 src/test/run-pass/macro-quote-cond.rs create mode 100644 src/test/run-pass/macro-quote-test.rs create mode 100644 src/test/run-pass/proc-macro/add-impl.rs create mode 100644 src/test/run-pass/proc-macro/append-impl.rs create mode 100644 src/test/run-pass/proc-macro/attr-args.rs create mode 100644 src/test/run-pass/proc-macro/attr-cfg.rs create mode 100644 src/test/run-pass/proc-macro/attr-on-trait.rs create mode 100644 src/test/run-pass/proc-macro/attr-stmt-expr.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/add-impl.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/append-impl.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/attr-args.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/attr-cfg.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/attr-on-trait.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/attr-stmt-expr.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/bang-macro.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/call-site.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/count_compound_ops.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/custom-attr-only-one-derive.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-a.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-atob.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-attr-cfg.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-b.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-ctod.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-nothing.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-same-struct.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-two-attrs.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/derive-union.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/double.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/empty-crate.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/expand-with-a-macro.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/external-crate-var.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/gen-lifetime-token.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/hygiene_example.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/hygiene_example_codegen.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/issue-39889.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/issue-42708.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/issue-50061.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/lifetimes.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/modify-ast.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/negative-token.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/not-joint.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/span-api-tests.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/span-test-macros.rs create mode 100644 src/test/run-pass/proc-macro/auxiliary/test-macros.rs create mode 100644 src/test/run-pass/proc-macro/bang-macro.rs create mode 100644 src/test/run-pass/proc-macro/call-site.rs create mode 100644 src/test/run-pass/proc-macro/count_compound_ops.rs create mode 100644 src/test/run-pass/proc-macro/crate-var.rs create mode 100644 src/test/run-pass/proc-macro/custom-attr-only-one-derive.rs create mode 100644 src/test/run-pass/proc-macro/derive-attr-cfg.rs create mode 100644 src/test/run-pass/proc-macro/derive-b.rs create mode 100644 src/test/run-pass/proc-macro/derive-same-struct.rs create mode 100644 src/test/run-pass/proc-macro/derive-same-struct.stdout create mode 100644 src/test/run-pass/proc-macro/derive-test.rs create mode 100644 src/test/run-pass/proc-macro/derive-two-attrs.rs create mode 100644 src/test/run-pass/proc-macro/derive-union.rs create mode 100644 src/test/run-pass/proc-macro/empty-crate.rs create mode 100644 src/test/run-pass/proc-macro/expand-with-a-macro.rs create mode 100644 src/test/run-pass/proc-macro/gen-lifetime-token.rs create mode 100644 src/test/run-pass/proc-macro/hygiene_example.rs create mode 100644 src/test/run-pass/proc-macro/issue-39889.rs create mode 100644 src/test/run-pass/proc-macro/issue-42708.rs create mode 100644 src/test/run-pass/proc-macro/issue-50061.rs create mode 100644 src/test/run-pass/proc-macro/lifetimes.rs create mode 100644 src/test/run-pass/proc-macro/load-two.rs create mode 100644 src/test/run-pass/proc-macro/macros-in-extern.rs create mode 100644 src/test/run-pass/proc-macro/modify-ast.rs create mode 100644 src/test/run-pass/proc-macro/negative-token.rs create mode 100644 src/test/run-pass/proc-macro/not-joint.rs create mode 100644 src/test/run-pass/proc-macro/smoke.rs create mode 100644 src/test/run-pass/proc-macro/span-api-tests.rs create mode 100644 src/test/run-pass/proc-macro/struct-field-macro.rs create mode 100644 src/test/run-pass/proc_macro.rs delete mode 100644 src/test/ui-fulldeps/attribute-order-restricted.rs delete mode 100644 src/test/ui-fulldeps/attribute-order-restricted.stderr delete mode 100644 src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs delete mode 100644 src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs delete mode 100644 src/test/ui-fulldeps/auxiliary/derive-clona.rs delete mode 100644 src/test/ui-fulldeps/auxiliary/derive-foo.rs delete mode 100644 src/test/ui-fulldeps/auxiliary/invalid-punct-ident.rs delete mode 100644 src/test/ui-fulldeps/auxiliary/lifetimes.rs delete mode 100644 src/test/ui-fulldeps/auxiliary/subspan.rs delete mode 100644 src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs delete mode 100644 src/test/ui-fulldeps/custom-derive/derive-in-mod.rs delete mode 100644 src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs delete mode 100644 src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr delete mode 100644 src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs delete mode 100644 src/test/ui-fulldeps/custom-derive/issue-36935.rs delete mode 100644 src/test/ui-fulldeps/custom-derive/issue-36935.stderr delete mode 100644 src/test/ui-fulldeps/invalid-punct-ident-1.rs delete mode 100644 src/test/ui-fulldeps/invalid-punct-ident-1.stderr delete mode 100644 src/test/ui-fulldeps/invalid-punct-ident-2.rs delete mode 100644 src/test/ui-fulldeps/invalid-punct-ident-2.stderr delete mode 100644 src/test/ui-fulldeps/invalid-punct-ident-3.rs delete mode 100644 src/test/ui-fulldeps/invalid-punct-ident-3.stderr delete mode 100644 src/test/ui-fulldeps/invalid-punct-ident-4.rs delete mode 100644 src/test/ui-fulldeps/invalid-punct-ident-4.stderr delete mode 100644 src/test/ui-fulldeps/lifetimes.rs delete mode 100644 src/test/ui-fulldeps/lifetimes.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stdout delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/attribute-spans-preserved.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/bang_proc_macro.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed-2.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowing.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/derive-panic.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/generate-mod.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/issue-53481.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/nested-item-spans.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/span-preservation.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/derive-helper-shadowed.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/generate-mod.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/generate-mod.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/invalid-attributes.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/issue-53481.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/load-panic.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/load-panic.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/macro-brackets.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/macro-brackets.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/macro-use-attr.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/macro-use-bang.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/multispan.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/multispan.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/nested-item-spans.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/nested-item-spans.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/non-root.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/non-root.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/parent-source-spans.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/signature.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/signature.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/span-preservation.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/span-preservation.stderr delete mode 100644 src/test/ui-fulldeps/proc-macro/three-equals.rs delete mode 100644 src/test/ui-fulldeps/proc-macro/three-equals.stderr delete mode 100644 src/test/ui-fulldeps/resolve-error.rs delete mode 100644 src/test/ui-fulldeps/resolve-error.stderr delete mode 100644 src/test/ui-fulldeps/rust-2018/auxiliary/suggestions-not-always-applicable.rs delete mode 100644 src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs delete mode 100644 src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.fixed delete mode 100644 src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.rs delete mode 100644 src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr delete mode 100644 src/test/ui-fulldeps/subspan.rs delete mode 100644 src/test/ui-fulldeps/subspan.stderr delete mode 100644 src/test/ui-fulldeps/unnecessary-extern-crate.rs delete mode 100644 src/test/ui-fulldeps/unnecessary-extern-crate.stderr create mode 100644 src/test/ui/custom-derive/auxiliary/plugin.rs create mode 100644 src/test/ui/custom-derive/derive-in-mod.rs create mode 100644 src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.rs create mode 100644 src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.stderr create mode 100644 src/test/ui/custom-derive/helper-attr-blocked-by-import.rs create mode 100644 src/test/ui/custom-derive/issue-36935.rs create mode 100644 src/test/ui/custom-derive/issue-36935.stderr create mode 100644 src/test/ui/proc-macro/ambiguous-builtin-attrs-test.rs create mode 100644 src/test/ui/proc-macro/ambiguous-builtin-attrs-test.stderr create mode 100644 src/test/ui/proc-macro/ambiguous-builtin-attrs.rs create mode 100644 src/test/ui/proc-macro/ambiguous-builtin-attrs.stderr create mode 100644 src/test/ui/proc-macro/attribute-order-restricted.rs create mode 100644 src/test/ui/proc-macro/attribute-order-restricted.stderr create mode 100644 src/test/ui/proc-macro/attribute-spans-preserved.rs create mode 100644 src/test/ui/proc-macro/attribute-spans-preserved.stderr create mode 100644 src/test/ui/proc-macro/attribute-spans-preserved.stdout create mode 100644 src/test/ui/proc-macro/auxiliary/attr_proc_macro.rs create mode 100644 src/test/ui/proc-macro/auxiliary/attribute-spans-preserved.rs create mode 100644 src/test/ui/proc-macro/auxiliary/bang_proc_macro.rs create mode 100644 src/test/ui/proc-macro/auxiliary/builtin-attrs.rs create mode 100644 src/test/ui/proc-macro/auxiliary/derive-clona.rs create mode 100644 src/test/ui/proc-macro/auxiliary/derive-foo.rs create mode 100644 src/test/ui/proc-macro/auxiliary/derive-helper-shadowed-2.rs create mode 100644 src/test/ui/proc-macro/auxiliary/derive-helper-shadowed.rs create mode 100644 src/test/ui/proc-macro/auxiliary/derive-helper-shadowing.rs create mode 100644 src/test/ui/proc-macro/auxiliary/derive-panic.rs create mode 100644 src/test/ui/proc-macro/auxiliary/generate-mod.rs create mode 100644 src/test/ui/proc-macro/auxiliary/invalid-punct-ident.rs create mode 100644 src/test/ui/proc-macro/auxiliary/issue-53481.rs create mode 100644 src/test/ui/proc-macro/auxiliary/lifetimes.rs create mode 100644 src/test/ui/proc-macro/auxiliary/macro-brackets.rs create mode 100644 src/test/ui/proc-macro/auxiliary/multispan.rs create mode 100644 src/test/ui/proc-macro/auxiliary/nested-item-spans.rs create mode 100644 src/test/ui/proc-macro/auxiliary/parent-source-spans.rs create mode 100644 src/test/ui/proc-macro/auxiliary/span-preservation.rs create mode 100644 src/test/ui/proc-macro/auxiliary/subspan.rs create mode 100644 src/test/ui/proc-macro/auxiliary/three-equals.rs create mode 100644 src/test/ui/proc-macro/derive-helper-shadowed.rs create mode 100644 src/test/ui/proc-macro/derive-helper-shadowing.rs create mode 100644 src/test/ui/proc-macro/derive-helper-shadowing.stderr create mode 100644 src/test/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs create mode 100644 src/test/ui/proc-macro/generate-mod.rs create mode 100644 src/test/ui/proc-macro/generate-mod.stderr create mode 100644 src/test/ui/proc-macro/invalid-attributes.rs create mode 100644 src/test/ui/proc-macro/invalid-attributes.stderr create mode 100644 src/test/ui/proc-macro/invalid-punct-ident-1.rs create mode 100644 src/test/ui/proc-macro/invalid-punct-ident-1.stderr create mode 100644 src/test/ui/proc-macro/invalid-punct-ident-2.rs create mode 100644 src/test/ui/proc-macro/invalid-punct-ident-2.stderr create mode 100644 src/test/ui/proc-macro/invalid-punct-ident-3.rs create mode 100644 src/test/ui/proc-macro/invalid-punct-ident-3.stderr create mode 100644 src/test/ui/proc-macro/invalid-punct-ident-4.rs create mode 100644 src/test/ui/proc-macro/invalid-punct-ident-4.stderr create mode 100644 src/test/ui/proc-macro/issue-53481.rs create mode 100644 src/test/ui/proc-macro/lifetimes.rs create mode 100644 src/test/ui/proc-macro/lifetimes.stderr create mode 100644 src/test/ui/proc-macro/load-panic.rs create mode 100644 src/test/ui/proc-macro/load-panic.stderr create mode 100644 src/test/ui/proc-macro/macro-brackets.rs create mode 100644 src/test/ui/proc-macro/macro-brackets.stderr create mode 100644 src/test/ui/proc-macro/macro-namespace-reserved-2.rs create mode 100644 src/test/ui/proc-macro/macro-namespace-reserved-2.stderr create mode 100644 src/test/ui/proc-macro/macro-namespace-reserved.rs create mode 100644 src/test/ui/proc-macro/macro-namespace-reserved.stderr create mode 100644 src/test/ui/proc-macro/macro-use-attr.rs create mode 100644 src/test/ui/proc-macro/macro-use-bang.rs create mode 100644 src/test/ui/proc-macro/multispan.rs create mode 100644 src/test/ui/proc-macro/multispan.stderr create mode 100644 src/test/ui/proc-macro/nested-item-spans.rs create mode 100644 src/test/ui/proc-macro/nested-item-spans.stderr create mode 100644 src/test/ui/proc-macro/non-root.rs create mode 100644 src/test/ui/proc-macro/non-root.stderr create mode 100644 src/test/ui/proc-macro/parent-source-spans.rs create mode 100644 src/test/ui/proc-macro/parent-source-spans.stderr create mode 100644 src/test/ui/proc-macro/reserved-macro-names.rs create mode 100644 src/test/ui/proc-macro/reserved-macro-names.stderr create mode 100644 src/test/ui/proc-macro/resolve-error.rs create mode 100644 src/test/ui/proc-macro/resolve-error.stderr create mode 100644 src/test/ui/proc-macro/signature.rs create mode 100644 src/test/ui/proc-macro/signature.stderr create mode 100644 src/test/ui/proc-macro/span-preservation.rs create mode 100644 src/test/ui/proc-macro/span-preservation.stderr create mode 100644 src/test/ui/proc-macro/subspan.rs create mode 100644 src/test/ui/proc-macro/subspan.stderr create mode 100644 src/test/ui/proc-macro/three-equals.rs create mode 100644 src/test/ui/proc-macro/three-equals.stderr create mode 100644 src/test/ui/rust-2018/auxiliary/suggestions-not-always-applicable.rs create mode 100644 src/test/ui/rust-2018/proc-macro-crate-in-paths.rs create mode 100644 src/test/ui/rust-2018/suggestions-not-always-applicable.fixed create mode 100644 src/test/ui/rust-2018/suggestions-not-always-applicable.rs create mode 100644 src/test/ui/rust-2018/suggestions-not-always-applicable.stderr create mode 100644 src/test/ui/unnecessary-extern-crate.rs create mode 100644 src/test/ui/unnecessary-extern-crate.stderr (limited to 'src') diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 900f336ef8c..079fdee7e86 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -390,7 +390,6 @@ impl<'a> Builder<'a> { test::RunPassFullDeps, test::RunFailFullDeps, test::CompileFailFullDeps, - test::IncrementalFullDeps, test::Rustdoc, test::Pretty, test::RunPassPretty, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e55773011df..dbff26ee9e3 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -839,12 +839,6 @@ host_test!(CompileFailFullDeps { suite: "compile-fail-fulldeps" }); -host_test!(IncrementalFullDeps { - path: "src/test/incremental-fulldeps", - mode: "incremental", - suite: "incremental-fulldeps" -}); - host_test!(Rustdoc { path: "src/test/rustdoc", mode: "rustdoc", diff --git a/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs b/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs deleted file mode 100644 index 798cd1406ac..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/attr-invalid-exprs.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attr-stmt-expr.rs - -//! Attributes producing expressions in invalid locations - -#![feature(stmt_expr_attributes, proc_macro_hygiene)] - -extern crate attr_stmt_expr; -use attr_stmt_expr::{duplicate, no_output}; - -fn main() { - let _ = #[no_output] "Hello, world!"; - //~^ ERROR expected expression, found `` - - let _ = #[duplicate] "Hello, world!"; - //~^ ERROR macro expansion ignores token `,` and any following - - let _ = { - #[no_output] - "Hello, world!" - }; - - let _ = { - #[duplicate] - //~^ ERROR macro expansion ignores token `,` and any following - "Hello, world!" - }; -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs b/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs deleted file mode 100644 index 6d1d5dfe8cc..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/attr-stmt-expr.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attr-stmt-expr.rs - -#![feature(proc_macro_hygiene)] - -extern crate attr_stmt_expr; -use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr}; - -fn print_str(string: &'static str) { - // macros are handled a bit differently - #[expect_print_expr] - //~^ ERROR attributes on expressions are experimental - //~| HELP add #![feature(stmt_expr_attributes)] to the crate attributes to enable - println!("{}", string) -} - -fn main() { - #[expect_let] - let string = "Hello, world!"; - - #[expect_print_stmt] - println!("{}", string); - - #[expect_expr] - //~^ ERROR attributes on expressions are experimental - //~| HELP add #![feature(stmt_expr_attributes)] to the crate attributes to enable - print_str("string") -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs b/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs deleted file mode 100644 index ed2e8ec00a9..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/attribute-with-error.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attribute-with-error.rs - -#![feature(custom_inner_attributes)] - -extern crate attribute_with_error; - -use attribute_with_error::foo; - -#[foo] -fn test1() { - let a: i32 = "foo"; - //~^ ERROR: mismatched types - let b: i32 = "f'oo"; - //~^ ERROR: mismatched types -} - -fn test2() { - #![foo] - - // FIXME: should have a type error here and assert it works but it doesn't -} - -trait A { - // FIXME: should have a #[foo] attribute here and assert that it works - fn foo(&self) { - let a: i32 = "foo"; - //~^ ERROR: mismatched types - } -} - -struct B; - -impl A for B { - #[foo] - fn foo(&self) { - let a: i32 = "foo"; - //~^ ERROR: mismatched types - } -} - -#[foo] -fn main() { -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/attribute.rs b/src/test/compile-fail-fulldeps/proc-macro/attribute.rs deleted file mode 100644 index 5d5e61270b6..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/attribute.rs +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -#[proc_macro_derive] -//~^ ERROR: attribute must be of form: #[proc_macro_derive(TraitName)] -pub fn foo1(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - input -} - -#[proc_macro_derive = "foo"] -//~^ ERROR: attribute must be of form: #[proc_macro_derive(TraitName)] -pub fn foo2(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - input -} - -#[proc_macro_derive( - a = "b" -)] -//~^^ ERROR: must only be one word -pub fn foo3(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - input -} - -#[proc_macro_derive(b, c, d)] -//~^ ERROR: attribute must have either one or two arguments -pub fn foo4(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - input -} - -#[proc_macro_derive(d(e))] -//~^ ERROR: must only be one word -pub fn foo5(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - input -} - -#[proc_macro_derive(f, attributes(g = "h"))] -//~^ ERROR: must only be one word -pub fn foo6(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - input -} - -#[proc_macro_derive(i, attributes(j(k)))] -//~^ ERROR: must only be one word -pub fn foo7(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - input -} - -#[proc_macro_derive(l, attributes(m), n)] -//~^ ERROR: attribute must have either one or two arguments -pub fn foo8(input: proc_macro::TokenStream) -> proc_macro::TokenStream { - input -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs b/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs deleted file mode 100644 index e129711129a..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/attributes-included.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attributes-included.rs -// compile-pass - -#![warn(unused)] - -extern crate attributes_included; - -use attributes_included::*; - -#[bar] -#[inline] -/// doc -#[foo] -#[inline] -/// doc -fn foo() { - let a: i32 = "foo"; //~ WARN: unused variable -} - -fn main() { - foo() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs deleted file mode 100644 index 22ddc913995..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "let string = \"Hello, world!\";"); - item -} - -#[proc_macro_attribute] -pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "println!(\"{}\" , string);"); - item -} - -#[proc_macro_attribute] -pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "print_str(\"string\")"); - item -} - -#[proc_macro_attribute] -pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "println!(\"{}\" , string)"); - item -} - -#[proc_macro_attribute] -pub fn duplicate(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - format!("{}, {}", item, item).parse().unwrap() -} - -#[proc_macro_attribute] -pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert!(!item.to_string().is_empty()); - "".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attribute-with-error.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attribute-with-error.rs deleted file mode 100644 index 14284092669..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attribute-with-error.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn foo(_attr: TokenStream, input: TokenStream) -> TokenStream { - input.into_iter().collect() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs deleted file mode 100644 index a1f4209662d..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::{TokenStream, TokenTree, Delimiter, Literal, Spacing, Group}; - -#[proc_macro_attribute] -pub fn foo(attr: TokenStream, input: TokenStream) -> TokenStream { - assert!(attr.is_empty()); - let input = input.into_iter().collect::>(); - { - let mut cursor = &input[..]; - assert_inline(&mut cursor); - assert_doc(&mut cursor); - assert_inline(&mut cursor); - assert_doc(&mut cursor); - assert_foo(&mut cursor); - assert!(cursor.is_empty()); - } - fold_stream(input.into_iter().collect()) -} - -#[proc_macro_attribute] -pub fn bar(attr: TokenStream, input: TokenStream) -> TokenStream { - assert!(attr.is_empty()); - let input = input.into_iter().collect::>(); - { - let mut cursor = &input[..]; - assert_inline(&mut cursor); - assert_doc(&mut cursor); - assert_invoc(&mut cursor); - assert_inline(&mut cursor); - assert_doc(&mut cursor); - assert_foo(&mut cursor); - assert!(cursor.is_empty()); - } - input.into_iter().collect() -} - -fn assert_inline(slice: &mut &[TokenTree]) { - match &slice[0] { - TokenTree::Punct(tt) => assert_eq!(tt.as_char(), '#'), - _ => panic!("expected '#' char"), - } - match &slice[1] { - TokenTree::Group(tt) => assert_eq!(tt.delimiter(), Delimiter::Bracket), - _ => panic!("expected brackets"), - } - *slice = &slice[2..]; -} - -fn assert_doc(slice: &mut &[TokenTree]) { - match &slice[0] { - TokenTree::Punct(tt) => { - assert_eq!(tt.as_char(), '#'); - assert_eq!(tt.spacing(), Spacing::Alone); - } - _ => panic!("expected #"), - } - let inner = match &slice[1] { - TokenTree::Group(tt) => { - assert_eq!(tt.delimiter(), Delimiter::Bracket); - tt.stream() - } - _ => panic!("expected brackets"), - }; - let tokens = inner.into_iter().collect::>(); - let tokens = &tokens[..]; - - if tokens.len() != 3 { - panic!("expected three tokens in doc") - } - - match &tokens[0] { - TokenTree::Ident(tt) => assert_eq!("doc", &*tt.to_string()), - _ => panic!("expected `doc`"), - } - match &tokens[1] { - TokenTree::Punct(tt) => { - assert_eq!(tt.as_char(), '='); - assert_eq!(tt.spacing(), Spacing::Alone); - } - _ => panic!("expected equals"), - } - match tokens[2] { - TokenTree::Literal(_) => {} - _ => panic!("expected literal"), - } - - *slice = &slice[2..]; -} - -fn assert_invoc(slice: &mut &[TokenTree]) { - match &slice[0] { - TokenTree::Punct(tt) => assert_eq!(tt.as_char(), '#'), - _ => panic!("expected '#' char"), - } - match &slice[1] { - TokenTree::Group(tt) => assert_eq!(tt.delimiter(), Delimiter::Bracket), - _ => panic!("expected brackets"), - } - *slice = &slice[2..]; -} - -fn assert_foo(slice: &mut &[TokenTree]) { - match &slice[0] { - TokenTree::Ident(tt) => assert_eq!(&*tt.to_string(), "fn"), - _ => panic!("expected fn"), - } - match &slice[1] { - TokenTree::Ident(tt) => assert_eq!(&*tt.to_string(), "foo"), - _ => panic!("expected foo"), - } - match &slice[2] { - TokenTree::Group(tt) => { - assert_eq!(tt.delimiter(), Delimiter::Parenthesis); - assert!(tt.stream().is_empty()); - } - _ => panic!("expected parens"), - } - match &slice[3] { - TokenTree::Group(tt) => assert_eq!(tt.delimiter(), Delimiter::Brace), - _ => panic!("expected braces"), - } - *slice = &slice[4..]; -} - -fn fold_stream(input: TokenStream) -> TokenStream { - input.into_iter().map(fold_tree).collect() -} - -fn fold_tree(input: TokenTree) -> TokenTree { - match input { - TokenTree::Group(b) => { - TokenTree::Group(Group::new(b.delimiter(), fold_stream(b.stream()))) - } - TokenTree::Punct(b) => TokenTree::Punct(b), - TokenTree::Ident(a) => TokenTree::Ident(a), - TokenTree::Literal(a) => { - if a.to_string() != "\"foo\"" { - TokenTree::Literal(a) - } else { - TokenTree::Literal(Literal::i32_unsuffixed(3)) - } - } - } -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/bang_proc_macro2.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/bang_proc_macro2.rs deleted file mode 100644 index 3f0a4574367..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/bang_proc_macro2.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro] -pub fn bang_proc_macro2(_: TokenStream) -> TokenStream { - "let x = foobar2;".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-b.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-b.rs deleted file mode 100644 index cd8750bc89c..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-b.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive_a(_: TokenStream) -> TokenStream { - "".parse().unwrap() -} - -#[proc_macro_derive(B)] -pub fn derive_b(_: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs deleted file mode 100644 index 53b2c23e5d7..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive_a(input: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs deleted file mode 100644 index 5787546fb1e..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-b.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(B, attributes(B))] -pub fn derive_b(input: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs deleted file mode 100644 index 841b39eaed0..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// force-host - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive_a(_input: TokenStream) -> TokenStream { - "struct A { inner }".parse().unwrap() -} - diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-clona.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-clona.rs deleted file mode 100644 index 719fbdb15ef..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-clona.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Clona)] -pub fn derive_clonea(input: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-foo.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-foo.rs deleted file mode 100644 index 64dcf72ba20..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-foo.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(FooWithLongName)] -pub fn derive_foo(input: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs deleted file mode 100644 index 2d492d341eb..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Unstable)] -pub fn derive(_input: TokenStream) -> TokenStream { - - " - #[rustc_foo] - fn foo() {} - ".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs deleted file mode 100644 index a7b5d1e3e54..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Unstable)] -pub fn derive(_input: TokenStream) -> TokenStream { - - "unsafe fn foo() -> u32 { ::std::intrinsics::init() }".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue-41211.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue-41211.rs deleted file mode 100644 index 5365e8238e9..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue-41211.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn emit_unchanged(_args: TokenStream, input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_38586.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_38586.rs deleted file mode 100644 index e1a7ffaa26c..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_38586.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -#[proc_macro_derive(A)] -pub fn derive_a(_: proc_macro::TokenStream) -> proc_macro::TokenStream { - "fn f() { println!(\"{}\", foo); }".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_50493.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_50493.rs deleted file mode 100644 index e71b792a48a..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/issue_50493.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::TokenStream; - -#[proc_macro_derive(Derive)] -pub fn derive(_: TokenStream) -> TokenStream { - let code = " - fn one(r: Restricted) { - r.field; - } - fn two(r: Restricted) { - r.field; - } - "; - - code.parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/more-gates.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/more-gates.rs deleted file mode 100644 index 67fe93058aa..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/more-gates.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro_attribute] -pub fn attr2mac1(_: TokenStream, _: TokenStream) -> TokenStream { - "macro_rules! foo1 { (a) => (a) }".parse().unwrap() -} - -#[proc_macro_attribute] -pub fn attr2mac2(_: TokenStream, _: TokenStream) -> TokenStream { - "macro foo2(a) { a }".parse().unwrap() -} - -#[proc_macro] -pub fn mac2mac1(_: TokenStream) -> TokenStream { - "macro_rules! foo3 { (a) => (a) }".parse().unwrap() -} - -#[proc_macro] -pub fn mac2mac2(_: TokenStream) -> TokenStream { - "macro foo4(a) { a }".parse().unwrap() -} - -#[proc_macro] -pub fn tricky(_: TokenStream) -> TokenStream { - "fn foo() { - macro_rules! foo { (a) => (a) } - }".parse().unwrap() -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs deleted file mode 100644 index 0f8fd5b5709..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/proc-macro-gates.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// force-host - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro] -pub fn m(a: TokenStream) -> TokenStream { - a -} - -#[proc_macro_attribute] -pub fn a(_a: TokenStream, b: TokenStream) -> TokenStream { - b -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/test-macros.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/test-macros.rs deleted file mode 100644 index 581c7cb15a5..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/auxiliary/test-macros.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn nop_attr(_attr: TokenStream, input: TokenStream) -> TokenStream { - assert!(_attr.to_string().is_empty()); - input -} - -#[proc_macro_attribute] -pub fn no_output(_attr: TokenStream, _input: TokenStream) -> TokenStream { - assert!(_attr.to_string().is_empty()); - assert!(!_input.to_string().is_empty()); - "".parse().unwrap() -} - -#[proc_macro] -pub fn emit_input(input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/define-two.rs b/src/test/compile-fail-fulldeps/proc-macro/define-two.rs deleted file mode 100644 index 8321c471b2a..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/define-two.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn foo(input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_derive(A)] //~ ERROR the name `A` is defined multiple times -pub fn bar(input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs deleted file mode 100644 index ac27e87ace1..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-bad.rs - -#[macro_use] -extern crate derive_bad; - -#[derive( - A -)] -//~^^ ERROR proc-macro derive produced unparseable tokens -//~| ERROR expected `:`, found `}` -struct A; - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs b/src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs deleted file mode 100644 index f36236c5356..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-a.rs - -#![allow(warnings)] - -#[macro_use] -extern crate derive_a; - -#[derive_A] //~ ERROR: attributes of the form `#[derive_*]` are reserved for the compiler -struct A; - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs deleted file mode 100644 index e4fcbb117a5..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-unstable-2.rs - -#![allow(warnings)] - -#[macro_use] -extern crate derive_unstable_2; - -#[derive(Unstable)] -//~^ ERROR: reserved for internal compiler -struct A; - -fn main() { - foo(); -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs deleted file mode 100644 index 836e336fc22..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-unstable.rs - -#![allow(warnings)] - -#[macro_use] -extern crate derive_unstable; - -#[derive(Unstable)] -//~^ ERROR: use of unstable library feature -struct A; - -fn main() { - unsafe { foo(); } -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/export-macro.rs b/src/test/compile-fail-fulldeps/proc-macro/export-macro.rs deleted file mode 100644 index 477039bd7a2..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/export-macro.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: cannot export macro_rules! macros from a `proc-macro` crate - -#![crate_type = "proc-macro"] - -#[macro_export] -macro_rules! foo { - ($e:expr) => ($e) -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/exports.rs b/src/test/compile-fail-fulldeps/proc-macro/exports.rs deleted file mode 100644 index 41b94d04e8c..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/exports.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] -#![allow(warnings)] - -pub fn a() {} //~ ERROR: cannot export any items -pub struct B; //~ ERROR: cannot export any items -pub enum C {} //~ ERROR: cannot export any items -pub mod d {} //~ ERROR: cannot export any items - -mod e {} -struct F; -enum G {} -fn h() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/illegal-proc-macro-derive-use.rs b/src/test/compile-fail-fulldeps/proc-macro/illegal-proc-macro-derive-use.rs deleted file mode 100644 index f37980c5e0f..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/illegal-proc-macro-derive-use.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate proc_macro; - -#[proc_macro_derive(Foo)] -//~^ ERROR: only usable with crates of the `proc-macro` crate type -pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream { - a -} - -// Issue #37590 -#[proc_macro_derive(Foo)] -//~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions -pub struct Foo { -} - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/import.rs b/src/test/compile-fail-fulldeps/proc-macro/import.rs deleted file mode 100644 index fae2439344f..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/import.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-a.rs - -#![allow(warnings)] - -#[macro_use] -extern crate derive_a; - -use derive_a::derive_a; -//~^ ERROR: unresolved import `derive_a::derive_a` - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-37788.rs b/src/test/compile-fail-fulldeps/proc-macro/issue-37788.rs deleted file mode 100644 index 691c2805801..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/issue-37788.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-a-b.rs - -#[macro_use] -extern crate derive_a_b; - -fn main() { - // Test that constructing the `visible_parent_map` (in `cstore_impl.rs`) does not ICE. - std::cell::Cell::new(0) //~ ERROR mismatched types -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs b/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs deleted file mode 100644 index 649220ac401..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/issue-38586.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_38586.rs - -#[macro_use] -extern crate issue_38586; - -#[derive(A)] //~ ERROR `foo` -struct A; - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-41211.rs b/src/test/compile-fail-fulldeps/proc-macro/issue-41211.rs deleted file mode 100644 index e0922c452b5..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/issue-41211.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue-41211.rs - -// FIXME: https://github.com/rust-lang/rust/issues/41430 -// This is a temporary regression test for the ICE reported in #41211 - -#![feature(custom_inner_attributes)] - -#![emit_unchanged] -//~^ ERROR attribute `emit_unchanged` is currently unknown to the compiler -extern crate issue_41211; -use issue_41211::emit_unchanged; - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/issue-50493.rs b/src/test/compile-fail-fulldeps/proc-macro/issue-50493.rs deleted file mode 100644 index 635da570497..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/issue-50493.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_50493.rs - -#[macro_use] -extern crate issue_50493; - -#[derive(Derive)] //~ ERROR field `field` of struct `Restricted` is private -struct Restricted { - pub(in restricted) field: usize, //~ visibilities can only be restricted to ancestor modules -} - -mod restricted {} - -fn main() {} - diff --git a/src/test/compile-fail-fulldeps/proc-macro/item-error.rs b/src/test/compile-fail-fulldeps/proc-macro/item-error.rs deleted file mode 100644 index 4133e75e3a6..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/item-error.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-b.rs - -#![allow(warnings)] - -#[macro_use] -extern crate derive_b; - -#[derive(B)] -struct A { - a: &u64 -//~^ ERROR: missing lifetime specifier -} - -fn main() { -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs b/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs deleted file mode 100644 index d49c6120271..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/lints_in_proc_macros.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:bang_proc_macro2.rs - -#![feature(proc_macro_hygiene)] -#![allow(unused_macros)] - -extern crate bang_proc_macro2; - -use bang_proc_macro2::bang_proc_macro2; - -fn main() { - let foobar = 42; - bang_proc_macro2!(); - //~^ ERROR cannot find value `foobar2` in this scope - //~^^ did you mean `foobar`? - println!("{}", x); -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/macros-in-extern.rs b/src/test/compile-fail-fulldeps/proc-macro/macros-in-extern.rs deleted file mode 100644 index 43d7077d022..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/macros-in-extern.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:test-macros.rs -// ignore-wasm32 - -extern crate test_macros; - -use test_macros::{nop_attr, no_output, emit_input}; - -fn main() { - assert_eq!(unsafe { rust_get_test_int() }, 0isize); - assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEF); -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - #[no_output] - //~^ ERROR macro invocations in `extern {}` blocks are experimental - fn some_definitely_unknown_symbol_which_should_be_removed(); - - #[nop_attr] - //~^ ERROR macro invocations in `extern {}` blocks are experimental - fn rust_get_test_int() -> isize; - - emit_input!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;); - //~^ ERROR macro invocations in `extern {}` blocks are experimental -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/more-gates.rs b/src/test/compile-fail-fulldeps/proc-macro/more-gates.rs deleted file mode 100644 index 4c038179544..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/more-gates.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:more-gates.rs - -extern crate more_gates as foo; - -use foo::*; - -#[attr2mac1] -//~^ ERROR: cannot expand to macro definitions -pub fn a() {} -#[attr2mac2] -//~^ ERROR: cannot expand to macro definitions -pub fn a() {} - -mac2mac1!(); //~ ERROR: cannot expand to macro definitions -mac2mac2!(); //~ ERROR: cannot expand to macro definitions - -tricky!(); -//~^ ERROR: cannot expand to macro definitions - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/no-macro-use-attr.rs b/src/test/compile-fail-fulldeps/proc-macro/no-macro-use-attr.rs deleted file mode 100644 index ab05ca28386..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/no-macro-use-attr.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-a.rs - -#![feature(rustc_attrs)] -#![warn(unused_extern_crates)] - -extern crate derive_a; -//~^ WARN unused extern crate - -#[rustc_error] -fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs deleted file mode 100644 index 6e52411500e..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-b.rs - -#[macro_use] -extern crate derive_b; - -#[B] -#[C] //~ ERROR attribute `C` is currently unknown to the compiler -#[B(D)] -#[B(E = "foo")] -#[B(arbitrary tokens)] -#[derive(B)] -struct B; - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs deleted file mode 100644 index 5049a474dd2..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates.rs +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:proc-macro-gates.rs -// gate-test-proc_macro_hygiene - -#![feature(stmt_expr_attributes)] - -extern crate proc_macro_gates as foo; - -use foo::*; - -fn _test_inner() { - #![a] //~ ERROR: non-builtin inner attributes are unstable -} - -#[a] //~ ERROR: custom attributes cannot be applied to modules -mod _test2 {} - -mod _test2_inner { - #![a] //~ ERROR: custom attributes cannot be applied to modules - //~| ERROR: non-builtin inner attributes are unstable -} - -#[a = y] //~ ERROR: must only be followed by a delimiter token -fn _test3() {} - -fn attrs() { - // Statement, item - #[a] // OK - struct S; - - // Statement, macro - #[a] //~ ERROR: custom attributes cannot be applied to statements - println!(); - - // Statement, semi - #[a] //~ ERROR: custom attributes cannot be applied to statements - S; - - // Statement, local - #[a] //~ ERROR: custom attributes cannot be applied to statements - let _x = 2; - - // Expr - let _x = #[a] 2; //~ ERROR: custom attributes cannot be applied to expressions - - // Opt expr - let _x = [#[a] 2]; //~ ERROR: custom attributes cannot be applied to expressions - - // Expr macro - let _x = #[a] println!(); //~ ERROR: custom attributes cannot be applied to expressions -} - -fn main() { - let _x: m!(u32) = 3; //~ ERROR: procedural macros cannot be expanded to types - if let m!(Some(_x)) = Some(3) {} //~ ERROR: procedural macros cannot be expanded to patterns - - m!(struct S;); //~ ERROR: procedural macros cannot be expanded to statements - m!(let _x = 3;); //~ ERROR: procedural macros cannot be expanded to statements - - let _x = m!(3); //~ ERROR: procedural macros cannot be expanded to expressions - let _x = [m!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs deleted file mode 100644 index dc182414a1d..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-gates2.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:proc-macro-gates.rs - -#![feature(stmt_expr_attributes)] - -extern crate proc_macro_gates as foo; - -use foo::*; - -// NB. these errors aren't the best errors right now, but they're definitely -// intended to be errors. Somehow using a custom attribute in these positions -// should either require a feature gate or not be allowed on stable. - -fn _test6<#[a] T>() {} -//~^ ERROR: unknown to the compiler - -fn _test7() { - match 1 { - #[a] //~ ERROR: unknown to the compiler - 0 => {} - _ => {} - } -} - -fn main() { -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/pub-at-crate-root.rs b/src/test/compile-fail-fulldeps/proc-macro/pub-at-crate-root.rs deleted file mode 100644 index 238dde5160c..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/pub-at-crate-root.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -pub mod a { //~ `proc-macro` crate types cannot export any items - use proc_macro::TokenStream; - - #[proc_macro_derive(B)] - pub fn bar(a: TokenStream) -> TokenStream { - //~^ ERROR: must currently reside in the root of the crate - a - } -} - -#[proc_macro_derive(B)] -fn bar(a: proc_macro::TokenStream) -> proc_macro::TokenStream { -//~^ ERROR: functions tagged with `#[proc_macro_derive]` must be `pub` - a -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs b/src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs deleted file mode 100644 index 8c5affb7b5a..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(PartialEq)] -//~^ ERROR: cannot override a built-in #[derive] mode -pub fn foo(input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/compile-fail-fulldeps/proc-macro/shadow.rs b/src/test/compile-fail-fulldeps/proc-macro/shadow.rs deleted file mode 100644 index 9bff1c57ae4..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/shadow.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-a.rs - -#[macro_use] -extern crate derive_a; -#[macro_use] -extern crate derive_a; //~ ERROR the name `derive_a` is defined multiple times - -fn main() {} diff --git a/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs b/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs deleted file mode 100644 index db646fb7815..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: cannot mix `proc-macro` crate type with others - -#![crate_type = "proc-macro"] -#![crate_type = "rlib"] diff --git a/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs b/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs deleted file mode 100644 index 97b0f844604..00000000000 --- a/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// error-pattern: cannot mix `proc-macro` crate type with others -// compile-flags: --crate-type rlib --crate-type proc-macro diff --git a/src/test/compile-fail/proc-macro/attr-invalid-exprs.rs b/src/test/compile-fail/proc-macro/attr-invalid-exprs.rs new file mode 100644 index 00000000000..798cd1406ac --- /dev/null +++ b/src/test/compile-fail/proc-macro/attr-invalid-exprs.rs @@ -0,0 +1,37 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr-stmt-expr.rs + +//! Attributes producing expressions in invalid locations + +#![feature(stmt_expr_attributes, proc_macro_hygiene)] + +extern crate attr_stmt_expr; +use attr_stmt_expr::{duplicate, no_output}; + +fn main() { + let _ = #[no_output] "Hello, world!"; + //~^ ERROR expected expression, found `` + + let _ = #[duplicate] "Hello, world!"; + //~^ ERROR macro expansion ignores token `,` and any following + + let _ = { + #[no_output] + "Hello, world!" + }; + + let _ = { + #[duplicate] + //~^ ERROR macro expansion ignores token `,` and any following + "Hello, world!" + }; +} diff --git a/src/test/compile-fail/proc-macro/attr-stmt-expr.rs b/src/test/compile-fail/proc-macro/attr-stmt-expr.rs new file mode 100644 index 00000000000..6d1d5dfe8cc --- /dev/null +++ b/src/test/compile-fail/proc-macro/attr-stmt-expr.rs @@ -0,0 +1,37 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr-stmt-expr.rs + +#![feature(proc_macro_hygiene)] + +extern crate attr_stmt_expr; +use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr}; + +fn print_str(string: &'static str) { + // macros are handled a bit differently + #[expect_print_expr] + //~^ ERROR attributes on expressions are experimental + //~| HELP add #![feature(stmt_expr_attributes)] to the crate attributes to enable + println!("{}", string) +} + +fn main() { + #[expect_let] + let string = "Hello, world!"; + + #[expect_print_stmt] + println!("{}", string); + + #[expect_expr] + //~^ ERROR attributes on expressions are experimental + //~| HELP add #![feature(stmt_expr_attributes)] to the crate attributes to enable + print_str("string") +} diff --git a/src/test/compile-fail/proc-macro/attribute-with-error.rs b/src/test/compile-fail/proc-macro/attribute-with-error.rs new file mode 100644 index 00000000000..ed2e8ec00a9 --- /dev/null +++ b/src/test/compile-fail/proc-macro/attribute-with-error.rs @@ -0,0 +1,53 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attribute-with-error.rs + +#![feature(custom_inner_attributes)] + +extern crate attribute_with_error; + +use attribute_with_error::foo; + +#[foo] +fn test1() { + let a: i32 = "foo"; + //~^ ERROR: mismatched types + let b: i32 = "f'oo"; + //~^ ERROR: mismatched types +} + +fn test2() { + #![foo] + + // FIXME: should have a type error here and assert it works but it doesn't +} + +trait A { + // FIXME: should have a #[foo] attribute here and assert that it works + fn foo(&self) { + let a: i32 = "foo"; + //~^ ERROR: mismatched types + } +} + +struct B; + +impl A for B { + #[foo] + fn foo(&self) { + let a: i32 = "foo"; + //~^ ERROR: mismatched types + } +} + +#[foo] +fn main() { +} diff --git a/src/test/compile-fail/proc-macro/attribute.rs b/src/test/compile-fail/proc-macro/attribute.rs new file mode 100644 index 00000000000..5d5e61270b6 --- /dev/null +++ b/src/test/compile-fail/proc-macro/attribute.rs @@ -0,0 +1,63 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +#[proc_macro_derive] +//~^ ERROR: attribute must be of form: #[proc_macro_derive(TraitName)] +pub fn foo1(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive = "foo"] +//~^ ERROR: attribute must be of form: #[proc_macro_derive(TraitName)] +pub fn foo2(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive( + a = "b" +)] +//~^^ ERROR: must only be one word +pub fn foo3(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(b, c, d)] +//~^ ERROR: attribute must have either one or two arguments +pub fn foo4(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(d(e))] +//~^ ERROR: must only be one word +pub fn foo5(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(f, attributes(g = "h"))] +//~^ ERROR: must only be one word +pub fn foo6(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(i, attributes(j(k)))] +//~^ ERROR: must only be one word +pub fn foo7(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(l, attributes(m), n)] +//~^ ERROR: attribute must have either one or two arguments +pub fn foo8(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} diff --git a/src/test/compile-fail/proc-macro/attributes-included.rs b/src/test/compile-fail/proc-macro/attributes-included.rs new file mode 100644 index 00000000000..e129711129a --- /dev/null +++ b/src/test/compile-fail/proc-macro/attributes-included.rs @@ -0,0 +1,32 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attributes-included.rs +// compile-pass + +#![warn(unused)] + +extern crate attributes_included; + +use attributes_included::*; + +#[bar] +#[inline] +/// doc +#[foo] +#[inline] +/// doc +fn foo() { + let a: i32 = "foo"; //~ WARN: unused variable +} + +fn main() { + foo() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/compile-fail/proc-macro/auxiliary/attr-stmt-expr.rs new file mode 100644 index 00000000000..22ddc913995 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/attr-stmt-expr.rs @@ -0,0 +1,58 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert_eq!(item.to_string(), "let string = \"Hello, world!\";"); + item +} + +#[proc_macro_attribute] +pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert_eq!(item.to_string(), "println!(\"{}\" , string);"); + item +} + +#[proc_macro_attribute] +pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert_eq!(item.to_string(), "print_str(\"string\")"); + item +} + +#[proc_macro_attribute] +pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert_eq!(item.to_string(), "println!(\"{}\" , string)"); + item +} + +#[proc_macro_attribute] +pub fn duplicate(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + format!("{}, {}", item, item).parse().unwrap() +} + +#[proc_macro_attribute] +pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert!(!item.to_string().is_empty()); + "".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/attribute-with-error.rs b/src/test/compile-fail/proc-macro/auxiliary/attribute-with-error.rs new file mode 100644 index 00000000000..14284092669 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/attribute-with-error.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn foo(_attr: TokenStream, input: TokenStream) -> TokenStream { + input.into_iter().collect() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/attributes-included.rs b/src/test/compile-fail/proc-macro/auxiliary/attributes-included.rs new file mode 100644 index 00000000000..a1f4209662d --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/attributes-included.rs @@ -0,0 +1,160 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::{TokenStream, TokenTree, Delimiter, Literal, Spacing, Group}; + +#[proc_macro_attribute] +pub fn foo(attr: TokenStream, input: TokenStream) -> TokenStream { + assert!(attr.is_empty()); + let input = input.into_iter().collect::>(); + { + let mut cursor = &input[..]; + assert_inline(&mut cursor); + assert_doc(&mut cursor); + assert_inline(&mut cursor); + assert_doc(&mut cursor); + assert_foo(&mut cursor); + assert!(cursor.is_empty()); + } + fold_stream(input.into_iter().collect()) +} + +#[proc_macro_attribute] +pub fn bar(attr: TokenStream, input: TokenStream) -> TokenStream { + assert!(attr.is_empty()); + let input = input.into_iter().collect::>(); + { + let mut cursor = &input[..]; + assert_inline(&mut cursor); + assert_doc(&mut cursor); + assert_invoc(&mut cursor); + assert_inline(&mut cursor); + assert_doc(&mut cursor); + assert_foo(&mut cursor); + assert!(cursor.is_empty()); + } + input.into_iter().collect() +} + +fn assert_inline(slice: &mut &[TokenTree]) { + match &slice[0] { + TokenTree::Punct(tt) => assert_eq!(tt.as_char(), '#'), + _ => panic!("expected '#' char"), + } + match &slice[1] { + TokenTree::Group(tt) => assert_eq!(tt.delimiter(), Delimiter::Bracket), + _ => panic!("expected brackets"), + } + *slice = &slice[2..]; +} + +fn assert_doc(slice: &mut &[TokenTree]) { + match &slice[0] { + TokenTree::Punct(tt) => { + assert_eq!(tt.as_char(), '#'); + assert_eq!(tt.spacing(), Spacing::Alone); + } + _ => panic!("expected #"), + } + let inner = match &slice[1] { + TokenTree::Group(tt) => { + assert_eq!(tt.delimiter(), Delimiter::Bracket); + tt.stream() + } + _ => panic!("expected brackets"), + }; + let tokens = inner.into_iter().collect::>(); + let tokens = &tokens[..]; + + if tokens.len() != 3 { + panic!("expected three tokens in doc") + } + + match &tokens[0] { + TokenTree::Ident(tt) => assert_eq!("doc", &*tt.to_string()), + _ => panic!("expected `doc`"), + } + match &tokens[1] { + TokenTree::Punct(tt) => { + assert_eq!(tt.as_char(), '='); + assert_eq!(tt.spacing(), Spacing::Alone); + } + _ => panic!("expected equals"), + } + match tokens[2] { + TokenTree::Literal(_) => {} + _ => panic!("expected literal"), + } + + *slice = &slice[2..]; +} + +fn assert_invoc(slice: &mut &[TokenTree]) { + match &slice[0] { + TokenTree::Punct(tt) => assert_eq!(tt.as_char(), '#'), + _ => panic!("expected '#' char"), + } + match &slice[1] { + TokenTree::Group(tt) => assert_eq!(tt.delimiter(), Delimiter::Bracket), + _ => panic!("expected brackets"), + } + *slice = &slice[2..]; +} + +fn assert_foo(slice: &mut &[TokenTree]) { + match &slice[0] { + TokenTree::Ident(tt) => assert_eq!(&*tt.to_string(), "fn"), + _ => panic!("expected fn"), + } + match &slice[1] { + TokenTree::Ident(tt) => assert_eq!(&*tt.to_string(), "foo"), + _ => panic!("expected foo"), + } + match &slice[2] { + TokenTree::Group(tt) => { + assert_eq!(tt.delimiter(), Delimiter::Parenthesis); + assert!(tt.stream().is_empty()); + } + _ => panic!("expected parens"), + } + match &slice[3] { + TokenTree::Group(tt) => assert_eq!(tt.delimiter(), Delimiter::Brace), + _ => panic!("expected braces"), + } + *slice = &slice[4..]; +} + +fn fold_stream(input: TokenStream) -> TokenStream { + input.into_iter().map(fold_tree).collect() +} + +fn fold_tree(input: TokenTree) -> TokenTree { + match input { + TokenTree::Group(b) => { + TokenTree::Group(Group::new(b.delimiter(), fold_stream(b.stream()))) + } + TokenTree::Punct(b) => TokenTree::Punct(b), + TokenTree::Ident(a) => TokenTree::Ident(a), + TokenTree::Literal(a) => { + if a.to_string() != "\"foo\"" { + TokenTree::Literal(a) + } else { + TokenTree::Literal(Literal::i32_unsuffixed(3)) + } + } + } +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/bang_proc_macro2.rs b/src/test/compile-fail/proc-macro/auxiliary/bang_proc_macro2.rs new file mode 100644 index 00000000000..3f0a4574367 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/bang_proc_macro2.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn bang_proc_macro2(_: TokenStream) -> TokenStream { + "let x = foobar2;".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/derive-a-b.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-a-b.rs new file mode 100644 index 00000000000..cd8750bc89c --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-a-b.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive_a(_: TokenStream) -> TokenStream { + "".parse().unwrap() +} + +#[proc_macro_derive(B)] +pub fn derive_b(_: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/derive-a.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-a.rs new file mode 100644 index 00000000000..53b2c23e5d7 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-a.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive_a(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/derive-b.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-b.rs new file mode 100644 index 00000000000..5787546fb1e --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-b.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(B, attributes(B))] +pub fn derive_b(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/derive-bad.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-bad.rs new file mode 100644 index 00000000000..841b39eaed0 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-bad.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// force-host + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive_a(_input: TokenStream) -> TokenStream { + "struct A { inner }".parse().unwrap() +} + diff --git a/src/test/compile-fail/proc-macro/auxiliary/derive-clona.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-clona.rs new file mode 100644 index 00000000000..719fbdb15ef --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-clona.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Clona)] +pub fn derive_clonea(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/derive-foo.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-foo.rs new file mode 100644 index 00000000000..64dcf72ba20 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-foo.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(FooWithLongName)] +pub fn derive_foo(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/derive-unstable-2.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-unstable-2.rs new file mode 100644 index 00000000000..2d492d341eb --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-unstable-2.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Unstable)] +pub fn derive(_input: TokenStream) -> TokenStream { + + " + #[rustc_foo] + fn foo() {} + ".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/derive-unstable.rs b/src/test/compile-fail/proc-macro/auxiliary/derive-unstable.rs new file mode 100644 index 00000000000..a7b5d1e3e54 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/derive-unstable.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Unstable)] +pub fn derive(_input: TokenStream) -> TokenStream { + + "unsafe fn foo() -> u32 { ::std::intrinsics::init() }".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/issue-41211.rs b/src/test/compile-fail/proc-macro/auxiliary/issue-41211.rs new file mode 100644 index 00000000000..5365e8238e9 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/issue-41211.rs @@ -0,0 +1,22 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn emit_unchanged(_args: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/issue_38586.rs b/src/test/compile-fail/proc-macro/auxiliary/issue_38586.rs new file mode 100644 index 00000000000..e1a7ffaa26c --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/issue_38586.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +#[proc_macro_derive(A)] +pub fn derive_a(_: proc_macro::TokenStream) -> proc_macro::TokenStream { + "fn f() { println!(\"{}\", foo); }".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/issue_50493.rs b/src/test/compile-fail/proc-macro/auxiliary/issue_50493.rs new file mode 100644 index 00000000000..e71b792a48a --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/issue_50493.rs @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_derive(Derive)] +pub fn derive(_: TokenStream) -> TokenStream { + let code = " + fn one(r: Restricted) { + r.field; + } + fn two(r: Restricted) { + r.field; + } + "; + + code.parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/more-gates.rs b/src/test/compile-fail/proc-macro/auxiliary/more-gates.rs new file mode 100644 index 00000000000..67fe93058aa --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/more-gates.rs @@ -0,0 +1,44 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_attribute] +pub fn attr2mac1(_: TokenStream, _: TokenStream) -> TokenStream { + "macro_rules! foo1 { (a) => (a) }".parse().unwrap() +} + +#[proc_macro_attribute] +pub fn attr2mac2(_: TokenStream, _: TokenStream) -> TokenStream { + "macro foo2(a) { a }".parse().unwrap() +} + +#[proc_macro] +pub fn mac2mac1(_: TokenStream) -> TokenStream { + "macro_rules! foo3 { (a) => (a) }".parse().unwrap() +} + +#[proc_macro] +pub fn mac2mac2(_: TokenStream) -> TokenStream { + "macro foo4(a) { a }".parse().unwrap() +} + +#[proc_macro] +pub fn tricky(_: TokenStream) -> TokenStream { + "fn foo() { + macro_rules! foo { (a) => (a) } + }".parse().unwrap() +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/proc-macro-gates.rs b/src/test/compile-fail/proc-macro/auxiliary/proc-macro-gates.rs new file mode 100644 index 00000000000..0f8fd5b5709 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/proc-macro-gates.rs @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// force-host + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro] +pub fn m(a: TokenStream) -> TokenStream { + a +} + +#[proc_macro_attribute] +pub fn a(_a: TokenStream, b: TokenStream) -> TokenStream { + b +} diff --git a/src/test/compile-fail/proc-macro/auxiliary/test-macros.rs b/src/test/compile-fail/proc-macro/auxiliary/test-macros.rs new file mode 100644 index 00000000000..581c7cb15a5 --- /dev/null +++ b/src/test/compile-fail/proc-macro/auxiliary/test-macros.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn nop_attr(_attr: TokenStream, input: TokenStream) -> TokenStream { + assert!(_attr.to_string().is_empty()); + input +} + +#[proc_macro_attribute] +pub fn no_output(_attr: TokenStream, _input: TokenStream) -> TokenStream { + assert!(_attr.to_string().is_empty()); + assert!(!_input.to_string().is_empty()); + "".parse().unwrap() +} + +#[proc_macro] +pub fn emit_input(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/compile-fail/proc-macro/define-two.rs b/src/test/compile-fail/proc-macro/define-two.rs new file mode 100644 index 00000000000..8321c471b2a --- /dev/null +++ b/src/test/compile-fail/proc-macro/define-two.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn foo(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_derive(A)] //~ ERROR the name `A` is defined multiple times +pub fn bar(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/compile-fail/proc-macro/derive-bad.rs b/src/test/compile-fail/proc-macro/derive-bad.rs new file mode 100644 index 00000000000..ac27e87ace1 --- /dev/null +++ b/src/test/compile-fail/proc-macro/derive-bad.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-bad.rs + +#[macro_use] +extern crate derive_bad; + +#[derive( + A +)] +//~^^ ERROR proc-macro derive produced unparseable tokens +//~| ERROR expected `:`, found `}` +struct A; + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/derive-still-gated.rs b/src/test/compile-fail/proc-macro/derive-still-gated.rs new file mode 100644 index 00000000000..f36236c5356 --- /dev/null +++ b/src/test/compile-fail/proc-macro/derive-still-gated.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-a.rs + +#![allow(warnings)] + +#[macro_use] +extern crate derive_a; + +#[derive_A] //~ ERROR: attributes of the form `#[derive_*]` are reserved for the compiler +struct A; + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/expand-to-unstable-2.rs b/src/test/compile-fail/proc-macro/expand-to-unstable-2.rs new file mode 100644 index 00000000000..e4fcbb117a5 --- /dev/null +++ b/src/test/compile-fail/proc-macro/expand-to-unstable-2.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-unstable-2.rs + +#![allow(warnings)] + +#[macro_use] +extern crate derive_unstable_2; + +#[derive(Unstable)] +//~^ ERROR: reserved for internal compiler +struct A; + +fn main() { + foo(); +} diff --git a/src/test/compile-fail/proc-macro/expand-to-unstable.rs b/src/test/compile-fail/proc-macro/expand-to-unstable.rs new file mode 100644 index 00000000000..836e336fc22 --- /dev/null +++ b/src/test/compile-fail/proc-macro/expand-to-unstable.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-unstable.rs + +#![allow(warnings)] + +#[macro_use] +extern crate derive_unstable; + +#[derive(Unstable)] +//~^ ERROR: use of unstable library feature +struct A; + +fn main() { + unsafe { foo(); } +} diff --git a/src/test/compile-fail/proc-macro/export-macro.rs b/src/test/compile-fail/proc-macro/export-macro.rs new file mode 100644 index 00000000000..477039bd7a2 --- /dev/null +++ b/src/test/compile-fail/proc-macro/export-macro.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: cannot export macro_rules! macros from a `proc-macro` crate + +#![crate_type = "proc-macro"] + +#[macro_export] +macro_rules! foo { + ($e:expr) => ($e) +} diff --git a/src/test/compile-fail/proc-macro/exports.rs b/src/test/compile-fail/proc-macro/exports.rs new file mode 100644 index 00000000000..41b94d04e8c --- /dev/null +++ b/src/test/compile-fail/proc-macro/exports.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] +#![allow(warnings)] + +pub fn a() {} //~ ERROR: cannot export any items +pub struct B; //~ ERROR: cannot export any items +pub enum C {} //~ ERROR: cannot export any items +pub mod d {} //~ ERROR: cannot export any items + +mod e {} +struct F; +enum G {} +fn h() {} diff --git a/src/test/compile-fail/proc-macro/illegal-proc-macro-derive-use.rs b/src/test/compile-fail/proc-macro/illegal-proc-macro-derive-use.rs new file mode 100644 index 00000000000..f37980c5e0f --- /dev/null +++ b/src/test/compile-fail/proc-macro/illegal-proc-macro-derive-use.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate proc_macro; + +#[proc_macro_derive(Foo)] +//~^ ERROR: only usable with crates of the `proc-macro` crate type +pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream { + a +} + +// Issue #37590 +#[proc_macro_derive(Foo)] +//~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions +pub struct Foo { +} + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/import.rs b/src/test/compile-fail/proc-macro/import.rs new file mode 100644 index 00000000000..fae2439344f --- /dev/null +++ b/src/test/compile-fail/proc-macro/import.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-a.rs + +#![allow(warnings)] + +#[macro_use] +extern crate derive_a; + +use derive_a::derive_a; +//~^ ERROR: unresolved import `derive_a::derive_a` + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/issue-37788.rs b/src/test/compile-fail/proc-macro/issue-37788.rs new file mode 100644 index 00000000000..691c2805801 --- /dev/null +++ b/src/test/compile-fail/proc-macro/issue-37788.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-a-b.rs + +#[macro_use] +extern crate derive_a_b; + +fn main() { + // Test that constructing the `visible_parent_map` (in `cstore_impl.rs`) does not ICE. + std::cell::Cell::new(0) //~ ERROR mismatched types +} diff --git a/src/test/compile-fail/proc-macro/issue-38586.rs b/src/test/compile-fail/proc-macro/issue-38586.rs new file mode 100644 index 00000000000..649220ac401 --- /dev/null +++ b/src/test/compile-fail/proc-macro/issue-38586.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_38586.rs + +#[macro_use] +extern crate issue_38586; + +#[derive(A)] //~ ERROR `foo` +struct A; + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/issue-41211.rs b/src/test/compile-fail/proc-macro/issue-41211.rs new file mode 100644 index 00000000000..e0922c452b5 --- /dev/null +++ b/src/test/compile-fail/proc-macro/issue-41211.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-41211.rs + +// FIXME: https://github.com/rust-lang/rust/issues/41430 +// This is a temporary regression test for the ICE reported in #41211 + +#![feature(custom_inner_attributes)] + +#![emit_unchanged] +//~^ ERROR attribute `emit_unchanged` is currently unknown to the compiler +extern crate issue_41211; +use issue_41211::emit_unchanged; + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/issue-50493.rs b/src/test/compile-fail/proc-macro/issue-50493.rs new file mode 100644 index 00000000000..635da570497 --- /dev/null +++ b/src/test/compile-fail/proc-macro/issue-50493.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_50493.rs + +#[macro_use] +extern crate issue_50493; + +#[derive(Derive)] //~ ERROR field `field` of struct `Restricted` is private +struct Restricted { + pub(in restricted) field: usize, //~ visibilities can only be restricted to ancestor modules +} + +mod restricted {} + +fn main() {} + diff --git a/src/test/compile-fail/proc-macro/item-error.rs b/src/test/compile-fail/proc-macro/item-error.rs new file mode 100644 index 00000000000..4133e75e3a6 --- /dev/null +++ b/src/test/compile-fail/proc-macro/item-error.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-b.rs + +#![allow(warnings)] + +#[macro_use] +extern crate derive_b; + +#[derive(B)] +struct A { + a: &u64 +//~^ ERROR: missing lifetime specifier +} + +fn main() { +} diff --git a/src/test/compile-fail/proc-macro/lints_in_proc_macros.rs b/src/test/compile-fail/proc-macro/lints_in_proc_macros.rs new file mode 100644 index 00000000000..d49c6120271 --- /dev/null +++ b/src/test/compile-fail/proc-macro/lints_in_proc_macros.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:bang_proc_macro2.rs + +#![feature(proc_macro_hygiene)] +#![allow(unused_macros)] + +extern crate bang_proc_macro2; + +use bang_proc_macro2::bang_proc_macro2; + +fn main() { + let foobar = 42; + bang_proc_macro2!(); + //~^ ERROR cannot find value `foobar2` in this scope + //~^^ did you mean `foobar`? + println!("{}", x); +} diff --git a/src/test/compile-fail/proc-macro/macros-in-extern.rs b/src/test/compile-fail/proc-macro/macros-in-extern.rs new file mode 100644 index 00000000000..43d7077d022 --- /dev/null +++ b/src/test/compile-fail/proc-macro/macros-in-extern.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:test-macros.rs +// ignore-wasm32 + +extern crate test_macros; + +use test_macros::{nop_attr, no_output, emit_input}; + +fn main() { + assert_eq!(unsafe { rust_get_test_int() }, 0isize); + assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEF); +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + #[no_output] + //~^ ERROR macro invocations in `extern {}` blocks are experimental + fn some_definitely_unknown_symbol_which_should_be_removed(); + + #[nop_attr] + //~^ ERROR macro invocations in `extern {}` blocks are experimental + fn rust_get_test_int() -> isize; + + emit_input!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;); + //~^ ERROR macro invocations in `extern {}` blocks are experimental +} diff --git a/src/test/compile-fail/proc-macro/more-gates.rs b/src/test/compile-fail/proc-macro/more-gates.rs new file mode 100644 index 00000000000..4c038179544 --- /dev/null +++ b/src/test/compile-fail/proc-macro/more-gates.rs @@ -0,0 +1,30 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:more-gates.rs + +extern crate more_gates as foo; + +use foo::*; + +#[attr2mac1] +//~^ ERROR: cannot expand to macro definitions +pub fn a() {} +#[attr2mac2] +//~^ ERROR: cannot expand to macro definitions +pub fn a() {} + +mac2mac1!(); //~ ERROR: cannot expand to macro definitions +mac2mac2!(); //~ ERROR: cannot expand to macro definitions + +tricky!(); +//~^ ERROR: cannot expand to macro definitions + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/no-macro-use-attr.rs b/src/test/compile-fail/proc-macro/no-macro-use-attr.rs new file mode 100644 index 00000000000..ab05ca28386 --- /dev/null +++ b/src/test/compile-fail/proc-macro/no-macro-use-attr.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-a.rs + +#![feature(rustc_attrs)] +#![warn(unused_extern_crates)] + +extern crate derive_a; +//~^ WARN unused extern crate + +#[rustc_error] +fn main() {} //~ ERROR compilation successful diff --git a/src/test/compile-fail/proc-macro/proc-macro-attributes.rs b/src/test/compile-fail/proc-macro/proc-macro-attributes.rs new file mode 100644 index 00000000000..6e52411500e --- /dev/null +++ b/src/test/compile-fail/proc-macro/proc-macro-attributes.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-b.rs + +#[macro_use] +extern crate derive_b; + +#[B] +#[C] //~ ERROR attribute `C` is currently unknown to the compiler +#[B(D)] +#[B(E = "foo")] +#[B(arbitrary tokens)] +#[derive(B)] +struct B; + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/proc-macro-gates.rs b/src/test/compile-fail/proc-macro/proc-macro-gates.rs new file mode 100644 index 00000000000..5049a474dd2 --- /dev/null +++ b/src/test/compile-fail/proc-macro/proc-macro-gates.rs @@ -0,0 +1,71 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:proc-macro-gates.rs +// gate-test-proc_macro_hygiene + +#![feature(stmt_expr_attributes)] + +extern crate proc_macro_gates as foo; + +use foo::*; + +fn _test_inner() { + #![a] //~ ERROR: non-builtin inner attributes are unstable +} + +#[a] //~ ERROR: custom attributes cannot be applied to modules +mod _test2 {} + +mod _test2_inner { + #![a] //~ ERROR: custom attributes cannot be applied to modules + //~| ERROR: non-builtin inner attributes are unstable +} + +#[a = y] //~ ERROR: must only be followed by a delimiter token +fn _test3() {} + +fn attrs() { + // Statement, item + #[a] // OK + struct S; + + // Statement, macro + #[a] //~ ERROR: custom attributes cannot be applied to statements + println!(); + + // Statement, semi + #[a] //~ ERROR: custom attributes cannot be applied to statements + S; + + // Statement, local + #[a] //~ ERROR: custom attributes cannot be applied to statements + let _x = 2; + + // Expr + let _x = #[a] 2; //~ ERROR: custom attributes cannot be applied to expressions + + // Opt expr + let _x = [#[a] 2]; //~ ERROR: custom attributes cannot be applied to expressions + + // Expr macro + let _x = #[a] println!(); //~ ERROR: custom attributes cannot be applied to expressions +} + +fn main() { + let _x: m!(u32) = 3; //~ ERROR: procedural macros cannot be expanded to types + if let m!(Some(_x)) = Some(3) {} //~ ERROR: procedural macros cannot be expanded to patterns + + m!(struct S;); //~ ERROR: procedural macros cannot be expanded to statements + m!(let _x = 3;); //~ ERROR: procedural macros cannot be expanded to statements + + let _x = m!(3); //~ ERROR: procedural macros cannot be expanded to expressions + let _x = [m!(3)]; //~ ERROR: procedural macros cannot be expanded to expressions +} diff --git a/src/test/compile-fail/proc-macro/proc-macro-gates2.rs b/src/test/compile-fail/proc-macro/proc-macro-gates2.rs new file mode 100644 index 00000000000..dc182414a1d --- /dev/null +++ b/src/test/compile-fail/proc-macro/proc-macro-gates2.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:proc-macro-gates.rs + +#![feature(stmt_expr_attributes)] + +extern crate proc_macro_gates as foo; + +use foo::*; + +// NB. these errors aren't the best errors right now, but they're definitely +// intended to be errors. Somehow using a custom attribute in these positions +// should either require a feature gate or not be allowed on stable. + +fn _test6<#[a] T>() {} +//~^ ERROR: unknown to the compiler + +fn _test7() { + match 1 { + #[a] //~ ERROR: unknown to the compiler + 0 => {} + _ => {} + } +} + +fn main() { +} diff --git a/src/test/compile-fail/proc-macro/pub-at-crate-root.rs b/src/test/compile-fail/proc-macro/pub-at-crate-root.rs new file mode 100644 index 00000000000..238dde5160c --- /dev/null +++ b/src/test/compile-fail/proc-macro/pub-at-crate-root.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +pub mod a { //~ `proc-macro` crate types cannot export any items + use proc_macro::TokenStream; + + #[proc_macro_derive(B)] + pub fn bar(a: TokenStream) -> TokenStream { + //~^ ERROR: must currently reside in the root of the crate + a + } +} + +#[proc_macro_derive(B)] +fn bar(a: proc_macro::TokenStream) -> proc_macro::TokenStream { +//~^ ERROR: functions tagged with `#[proc_macro_derive]` must be `pub` + a +} diff --git a/src/test/compile-fail/proc-macro/shadow-builtin.rs b/src/test/compile-fail/proc-macro/shadow-builtin.rs new file mode 100644 index 00000000000..8c5affb7b5a --- /dev/null +++ b/src/test/compile-fail/proc-macro/shadow-builtin.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(PartialEq)] +//~^ ERROR: cannot override a built-in #[derive] mode +pub fn foo(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/compile-fail/proc-macro/shadow.rs b/src/test/compile-fail/proc-macro/shadow.rs new file mode 100644 index 00000000000..9bff1c57ae4 --- /dev/null +++ b/src/test/compile-fail/proc-macro/shadow.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-a.rs + +#[macro_use] +extern crate derive_a; +#[macro_use] +extern crate derive_a; //~ ERROR the name `derive_a` is defined multiple times + +fn main() {} diff --git a/src/test/compile-fail/proc-macro/two-crate-types-1.rs b/src/test/compile-fail/proc-macro/two-crate-types-1.rs new file mode 100644 index 00000000000..db646fb7815 --- /dev/null +++ b/src/test/compile-fail/proc-macro/two-crate-types-1.rs @@ -0,0 +1,14 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: cannot mix `proc-macro` crate type with others + +#![crate_type = "proc-macro"] +#![crate_type = "rlib"] diff --git a/src/test/compile-fail/proc-macro/two-crate-types-2.rs b/src/test/compile-fail/proc-macro/two-crate-types-2.rs new file mode 100644 index 00000000000..97b0f844604 --- /dev/null +++ b/src/test/compile-fail/proc-macro/two-crate-types-2.rs @@ -0,0 +1,12 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// error-pattern: cannot mix `proc-macro` crate type with others +// compile-flags: --crate-type rlib --crate-type proc-macro diff --git a/src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs b/src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs deleted file mode 100644 index e9f9ba86f23..00000000000 --- a/src/test/incremental-fulldeps/auxiliary/incremental_proc_macro_aux.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -// Add a function to shift DefIndex of registrar function -#[cfg(cfail2)] -fn foo() {} - -#[proc_macro_derive(IncrementalMacro)] -pub fn derive(input: TokenStream) -> TokenStream { - #[cfg(cfail2)] - { - foo(); - } - - "".parse().unwrap() -} diff --git a/src/test/incremental-fulldeps/auxiliary/issue_49482_macro_def.rs b/src/test/incremental-fulldeps/auxiliary/issue_49482_macro_def.rs deleted file mode 100644 index 763c9eb138e..00000000000 --- a/src/test/incremental-fulldeps/auxiliary/issue_49482_macro_def.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type="proc-macro"] -#![allow(non_snake_case)] - -extern crate proc_macro; - -macro_rules! proc_macro_expr_impl { - ($( - $( #[$attr:meta] )* - pub fn $func:ident($input:ident: &str) -> String; - )+) => { - $( - $( #[$attr] )* - #[proc_macro_derive($func)] - pub fn $func(_input: ::proc_macro::TokenStream) -> ::proc_macro::TokenStream { - panic!() - } - )+ - }; -} - -proc_macro_expr_impl! { - pub fn f1(input: &str) -> String; - pub fn f2(input: &str) -> String; - pub fn f3(input: &str) -> String; - pub fn f4(input: &str) -> String; - pub fn f5(input: &str) -> String; - pub fn f6(input: &str) -> String; - pub fn f7(input: &str) -> String; - pub fn f8(input: &str) -> String; - pub fn f9(input: &str) -> String; - pub fn fA(input: &str) -> String; - pub fn fB(input: &str) -> String; - pub fn fC(input: &str) -> String; - pub fn fD(input: &str) -> String; - pub fn fE(input: &str) -> String; - pub fn fF(input: &str) -> String; -} diff --git a/src/test/incremental-fulldeps/auxiliary/issue_49482_reexport.rs b/src/test/incremental-fulldeps/auxiliary/issue_49482_reexport.rs deleted file mode 100644 index aa9aa3b58b9..00000000000 --- a/src/test/incremental-fulldeps/auxiliary/issue_49482_reexport.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate issue_49482_macro_def; - -pub use issue_49482_macro_def::*; - -pub fn foo() {} diff --git a/src/test/incremental-fulldeps/auxiliary/issue_54059.rs b/src/test/incremental-fulldeps/auxiliary/issue_54059.rs deleted file mode 100644 index ec0d044d4bf..00000000000 --- a/src/test/incremental-fulldeps/auxiliary/issue_54059.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -// check that having extern "C" functions in a proc macro doesn't crash. - -#![crate_type="proc-macro"] -#![allow(non_snake_case)] - -extern crate proc_macro; - -macro_rules! proc_macro_tokenstream { - () => { - ::proc_macro::TokenStream - }; -} - -macro_rules! proc_macro_expr_impl { - ($( - $( #[$attr:meta] )* - pub fn $func:ident($input:ident: &str) -> String $body:block - )+) => { - $( - // Parses an input that looks like: - // - // ``` - // #[allow(unused)] - // enum ProcMacroHack { - // Input = (stringify!(ARGS), 0).1, - // } - // ``` - $( #[$attr] )* - #[proc_macro_derive($func)] - pub fn $func(input: proc_macro_tokenstream!()) -> proc_macro_tokenstream!() { - unsafe { rust_dbg_extern_identity_u64(0); } - panic!() - } - )+ - }; -} - -proc_macro_expr_impl! { - pub fn base2_impl(input: &str) -> String { - panic!() - } -} - -#[link(name="rust_test_helpers")] -extern "C" { - pub fn rust_dbg_extern_identity_u64(v: u64) -> u64; -} diff --git a/src/test/incremental-fulldeps/incremental_proc_macro.rs b/src/test/incremental-fulldeps/incremental_proc_macro.rs deleted file mode 100644 index 495f4ff0ed0..00000000000 --- a/src/test/incremental-fulldeps/incremental_proc_macro.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:incremental_proc_macro_aux.rs -// revisions: cfail1 cfail2 -// compile-pass - -// This test makes sure that we still find the proc-macro registrar function -// when we compile proc-macros incrementally (see #47292). - -#![crate_type = "rlib"] - -#[macro_use] -extern crate incremental_proc_macro_aux; - -#[derive(IncrementalMacro)] -pub struct Foo { - x: u32 -} diff --git a/src/test/incremental-fulldeps/issue-49482.rs b/src/test/incremental-fulldeps/issue-49482.rs deleted file mode 100644 index 65e86e868bb..00000000000 --- a/src/test/incremental-fulldeps/issue-49482.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_49482_macro_def.rs -// aux-build:issue_49482_reexport.rs -// revisions: rpass1 - -extern crate issue_49482_reexport; - -pub trait KvStorage -{ - fn get(&self); -} - -impl KvStorage for Box -where - K: KvStorage + ?Sized, -{ - fn get(&self) { - (**self).get() - } -} - -impl KvStorage for u32 { - fn get(&self) {} -} - -fn main() { - /* force issue_49482_reexport to be loaded */ - issue_49482_reexport::foo(); - - Box::new(2).get(); -} diff --git a/src/test/incremental-fulldeps/issue-54059.rs b/src/test/incremental-fulldeps/issue-54059.rs deleted file mode 100644 index 2f4ea72b066..00000000000 --- a/src/test/incremental-fulldeps/issue-54059.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue_54059.rs -// ignore-wasm32-bare no libc for ffi testing -// ignore-windows - dealing with weird symbols issues on dylibs isn't worth it -// revisions: rpass1 - -extern crate issue_54059; - -fn main() {} diff --git a/src/test/incremental/auxiliary/incremental_proc_macro_aux.rs b/src/test/incremental/auxiliary/incremental_proc_macro_aux.rs new file mode 100644 index 00000000000..e9f9ba86f23 --- /dev/null +++ b/src/test/incremental/auxiliary/incremental_proc_macro_aux.rs @@ -0,0 +1,31 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +// Add a function to shift DefIndex of registrar function +#[cfg(cfail2)] +fn foo() {} + +#[proc_macro_derive(IncrementalMacro)] +pub fn derive(input: TokenStream) -> TokenStream { + #[cfg(cfail2)] + { + foo(); + } + + "".parse().unwrap() +} diff --git a/src/test/incremental/auxiliary/issue_49482_macro_def.rs b/src/test/incremental/auxiliary/issue_49482_macro_def.rs new file mode 100644 index 00000000000..763c9eb138e --- /dev/null +++ b/src/test/incremental/auxiliary/issue_49482_macro_def.rs @@ -0,0 +1,49 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type="proc-macro"] +#![allow(non_snake_case)] + +extern crate proc_macro; + +macro_rules! proc_macro_expr_impl { + ($( + $( #[$attr:meta] )* + pub fn $func:ident($input:ident: &str) -> String; + )+) => { + $( + $( #[$attr] )* + #[proc_macro_derive($func)] + pub fn $func(_input: ::proc_macro::TokenStream) -> ::proc_macro::TokenStream { + panic!() + } + )+ + }; +} + +proc_macro_expr_impl! { + pub fn f1(input: &str) -> String; + pub fn f2(input: &str) -> String; + pub fn f3(input: &str) -> String; + pub fn f4(input: &str) -> String; + pub fn f5(input: &str) -> String; + pub fn f6(input: &str) -> String; + pub fn f7(input: &str) -> String; + pub fn f8(input: &str) -> String; + pub fn f9(input: &str) -> String; + pub fn fA(input: &str) -> String; + pub fn fB(input: &str) -> String; + pub fn fC(input: &str) -> String; + pub fn fD(input: &str) -> String; + pub fn fE(input: &str) -> String; + pub fn fF(input: &str) -> String; +} diff --git a/src/test/incremental/auxiliary/issue_49482_reexport.rs b/src/test/incremental/auxiliary/issue_49482_reexport.rs new file mode 100644 index 00000000000..aa9aa3b58b9 --- /dev/null +++ b/src/test/incremental/auxiliary/issue_49482_reexport.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use] +extern crate issue_49482_macro_def; + +pub use issue_49482_macro_def::*; + +pub fn foo() {} diff --git a/src/test/incremental/auxiliary/issue_54059.rs b/src/test/incremental/auxiliary/issue_54059.rs new file mode 100644 index 00000000000..ec0d044d4bf --- /dev/null +++ b/src/test/incremental/auxiliary/issue_54059.rs @@ -0,0 +1,59 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +// check that having extern "C" functions in a proc macro doesn't crash. + +#![crate_type="proc-macro"] +#![allow(non_snake_case)] + +extern crate proc_macro; + +macro_rules! proc_macro_tokenstream { + () => { + ::proc_macro::TokenStream + }; +} + +macro_rules! proc_macro_expr_impl { + ($( + $( #[$attr:meta] )* + pub fn $func:ident($input:ident: &str) -> String $body:block + )+) => { + $( + // Parses an input that looks like: + // + // ``` + // #[allow(unused)] + // enum ProcMacroHack { + // Input = (stringify!(ARGS), 0).1, + // } + // ``` + $( #[$attr] )* + #[proc_macro_derive($func)] + pub fn $func(input: proc_macro_tokenstream!()) -> proc_macro_tokenstream!() { + unsafe { rust_dbg_extern_identity_u64(0); } + panic!() + } + )+ + }; +} + +proc_macro_expr_impl! { + pub fn base2_impl(input: &str) -> String { + panic!() + } +} + +#[link(name="rust_test_helpers")] +extern "C" { + pub fn rust_dbg_extern_identity_u64(v: u64) -> u64; +} diff --git a/src/test/incremental/incremental_proc_macro.rs b/src/test/incremental/incremental_proc_macro.rs new file mode 100644 index 00000000000..495f4ff0ed0 --- /dev/null +++ b/src/test/incremental/incremental_proc_macro.rs @@ -0,0 +1,26 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:incremental_proc_macro_aux.rs +// revisions: cfail1 cfail2 +// compile-pass + +// This test makes sure that we still find the proc-macro registrar function +// when we compile proc-macros incrementally (see #47292). + +#![crate_type = "rlib"] + +#[macro_use] +extern crate incremental_proc_macro_aux; + +#[derive(IncrementalMacro)] +pub struct Foo { + x: u32 +} diff --git a/src/test/incremental/issue-49482.rs b/src/test/incremental/issue-49482.rs new file mode 100644 index 00000000000..65e86e868bb --- /dev/null +++ b/src/test/incremental/issue-49482.rs @@ -0,0 +1,40 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_49482_macro_def.rs +// aux-build:issue_49482_reexport.rs +// revisions: rpass1 + +extern crate issue_49482_reexport; + +pub trait KvStorage +{ + fn get(&self); +} + +impl KvStorage for Box +where + K: KvStorage + ?Sized, +{ + fn get(&self) { + (**self).get() + } +} + +impl KvStorage for u32 { + fn get(&self) {} +} + +fn main() { + /* force issue_49482_reexport to be loaded */ + issue_49482_reexport::foo(); + + Box::new(2).get(); +} diff --git a/src/test/incremental/issue-54059.rs b/src/test/incremental/issue-54059.rs new file mode 100644 index 00000000000..2f4ea72b066 --- /dev/null +++ b/src/test/incremental/issue-54059.rs @@ -0,0 +1,18 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue_54059.rs +// ignore-wasm32-bare no libc for ffi testing +// ignore-windows - dealing with weird symbols issues on dylibs isn't worth it +// revisions: rpass1 + +extern crate issue_54059; + +fn main() {} diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile b/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile deleted file mode 100644 index c1e453fb721..00000000000 --- a/src/test/run-make-fulldeps/rustc-macro-dep-files/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - $(RUSTC) foo.rs - $(RUSTC) bar.rs --emit dep-info - $(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs b/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs deleted file mode 100644 index 03330c3d170..00000000000 --- a/src/test/run-make-fulldeps/rustc-macro-dep-files/bar.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -extern crate foo; - -#[derive(A)] -struct A; - -fn main() { - let _b = B; -} diff --git a/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs b/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs deleted file mode 100644 index 2f2524f6ef1..00000000000 --- a/src/test/run-make-fulldeps/rustc-macro-dep-files/foo.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert!(input.contains("struct A;")); - "struct B;".parse().unwrap() -} diff --git a/src/test/run-make/rustc-macro-dep-files/Makefile b/src/test/run-make/rustc-macro-dep-files/Makefile new file mode 100644 index 00000000000..68405851f9d --- /dev/null +++ b/src/test/run-make/rustc-macro-dep-files/Makefile @@ -0,0 +1,6 @@ +-include ../../run-make-fulldeps/tools.mk + +all: + $(RUSTC) foo.rs + $(RUSTC) bar.rs --emit dep-info + $(CGREP) -v "proc-macro source" < $(TMPDIR)/bar.d diff --git a/src/test/run-make/rustc-macro-dep-files/bar.rs b/src/test/run-make/rustc-macro-dep-files/bar.rs new file mode 100644 index 00000000000..03330c3d170 --- /dev/null +++ b/src/test/run-make/rustc-macro-dep-files/bar.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_use] +extern crate foo; + +#[derive(A)] +struct A; + +fn main() { + let _b = B; +} diff --git a/src/test/run-make/rustc-macro-dep-files/foo.rs b/src/test/run-make/rustc-macro-dep-files/foo.rs new file mode 100644 index 00000000000..2f2524f6ef1 --- /dev/null +++ b/src/test/run-make/rustc-macro-dep-files/foo.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert!(input.contains("struct A;")); + "struct B;".parse().unwrap() +} diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs deleted file mode 100644 index e7545f954da..00000000000 --- a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_hygiene)] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro] -pub fn cond(input: TokenStream) -> TokenStream { - let mut conds = Vec::new(); - let mut input = input.into_iter().peekable(); - while let Some(tree) = input.next() { - let cond = match tree { - TokenTree::Group(tt) => tt.stream(), - _ => panic!("Invalid input"), - }; - let mut cond_trees = cond.clone().into_iter(); - let test = cond_trees.next().expect("Unexpected empty condition in `cond!`"); - let rhs = cond_trees.collect::(); - if rhs.is_empty() { - panic!("Invalid macro usage in cond: {}", cond); - } - let is_else = match test { - TokenTree::Ident(ref word) => &*word.to_string() == "else", - _ => false, - }; - conds.push(if is_else || input.peek().is_none() { - quote!({ $rhs }) - } else { - quote!(if $test { $rhs } else) - }); - } - - conds.into_iter().flat_map(|x| x.into_iter()).collect() -} diff --git a/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs b/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs deleted file mode 100644 index caf56dabf79..00000000000 --- a/src/test/run-pass-fulldeps/auxiliary/hello_macro.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_hygiene, proc_macro_quote)] - -extern crate proc_macro; - -use proc_macro::{TokenStream, quote}; - -// This macro is not very interesting, but it does contain delimited tokens with -// no content - `()` and `{}` - which has caused problems in the past. -// Also, it tests that we can escape `$` via `$$`. -#[proc_macro] -pub fn hello(_: TokenStream) -> TokenStream { - quote!({ - fn hello() {} - macro_rules! m { ($$($$t:tt)*) => { $$($$t)* } } - m!(hello()); - }) -} diff --git a/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs new file mode 100644 index 00000000000..f4d3f2c94ca --- /dev/null +++ b/src/test/run-pass-fulldeps/auxiliary/issue-40001-plugin.rs @@ -0,0 +1,69 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(box_syntax, plugin, plugin_registrar, rustc_private)] +#![crate_type = "dylib"] + +#[macro_use] +extern crate rustc; +extern crate rustc_plugin; +extern crate syntax; + +use rustc_plugin::Registry; +use syntax::attr; +use syntax::ext::base::*; +use syntax::feature_gate::AttributeType::Whitelisted; +use syntax::symbol::Symbol; + +use rustc::hir; +use rustc::hir::intravisit; +use rustc::hir::map as hir_map; +use hir::Node; +use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; +use rustc::ty; +use syntax::{ast, source_map}; + +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_late_lint_pass(box MissingWhitelistedAttrPass); + reg.register_attribute("whitelisted_attr".to_string(), Whitelisted); +} + +declare_lint!(MISSING_WHITELISTED_ATTR, Deny, + "Checks for missing `whitelisted_attr` attribute"); + +struct MissingWhitelistedAttrPass; + +impl LintPass for MissingWhitelistedAttrPass { + fn get_lints(&self) -> LintArray { + lint_array!(MISSING_WHITELISTED_ATTR) + } +} + +impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass { + fn check_fn(&mut self, + cx: &LateContext<'a, 'tcx>, + _: intravisit::FnKind<'tcx>, + _: &'tcx hir::FnDecl, + _: &'tcx hir::Body, + span: source_map::Span, + id: ast::NodeId) { + + let item = match cx.tcx.hir.get(id) { + Node::Item(item) => item, + _ => cx.tcx.hir.expect_item(cx.tcx.hir.get_parent(id)), + }; + + if !attr::contains_name(&item.attrs, "whitelisted_attr") { + cx.span_lint(MISSING_WHITELISTED_ATTR, span, + "Missing 'whitelisted_attr' attribute"); + } + } +} diff --git a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs b/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs deleted file mode 100644 index 847db0098ff..00000000000 --- a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_hygiene)] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro_attribute] -pub fn attr_tru(_attr: TokenStream, item: TokenStream) -> TokenStream { - let name = item.into_iter().nth(1).unwrap(); - quote!(fn $name() -> bool { true }) -} - -#[proc_macro_attribute] -pub fn attr_identity(_attr: TokenStream, item: TokenStream) -> TokenStream { - quote!($item) -} - -#[proc_macro] -pub fn tru(_ts: TokenStream) -> TokenStream { - quote!(true) -} - -#[proc_macro] -pub fn ret_tru(_ts: TokenStream) -> TokenStream { - quote!(return true;) -} - -#[proc_macro] -pub fn identity(ts: TokenStream) -> TokenStream { - quote!($ts) -} diff --git a/src/test/run-pass-fulldeps/issue-40001.rs b/src/test/run-pass-fulldeps/issue-40001.rs new file mode 100644 index 00000000000..b828199883f --- /dev/null +++ b/src/test/run-pass-fulldeps/issue-40001.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-40001-plugin.rs +// ignore-stage1 + +#![feature(plugin)] +#![plugin(issue_40001_plugin)] + +#[whitelisted_attr] +fn main() {} diff --git a/src/test/run-pass-fulldeps/macro-quote-cond.rs b/src/test/run-pass-fulldeps/macro-quote-cond.rs deleted file mode 100644 index d8e36336028..00000000000 --- a/src/test/run-pass-fulldeps/macro-quote-cond.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_parens)] -// aux-build:cond_plugin.rs - -#![feature(proc_macro_hygiene)] - -extern crate cond_plugin; - -use cond_plugin::cond; - -fn fact(n : i64) -> i64 { - if n == 0 { - 1 - } else { - n * fact(n - 1) - } -} - -fn fact_cond(n : i64) -> i64 { - cond!( - ((n == 0) 1) - (else (n * fact_cond(n-1))) - ) -} - -fn fib(n : i64) -> i64 { - if n == 0 || n == 1 { - 1 - } else { - fib(n-1) + fib(n-2) - } -} - -fn fib_cond(n : i64) -> i64 { - cond!( - ((n == 0) 1) - ((n == 1) 1) - (else (fib_cond(n-1) + fib_cond(n-2))) - ) -} - -fn main() { - assert_eq!(fact(3), fact_cond(3)); - assert_eq!(fact(5), fact_cond(5)); - assert_eq!(fib(5), fib_cond(5)); - assert_eq!(fib(8), fib_cond(8)); -} diff --git a/src/test/run-pass-fulldeps/macro-quote-test.rs b/src/test/run-pass-fulldeps/macro-quote-test.rs deleted file mode 100644 index 473f92f7b74..00000000000 --- a/src/test/run-pass-fulldeps/macro-quote-test.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that a macro can emit delimiters with nothing inside - `()`, `{}` - -// aux-build:hello_macro.rs - -#![feature(proc_macro_hygiene)] - -extern crate hello_macro; - -fn main() { - hello_macro::hello!(); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/add-impl.rs b/src/test/run-pass-fulldeps/proc-macro/add-impl.rs deleted file mode 100644 index 7ea7ceafc28..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/add-impl.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:add-impl.rs - -#[macro_use] -extern crate add_impl; - -#[derive(AddImpl)] -struct B; - -fn main() { - B.foo(); - foo(); - bar::foo(); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/append-impl.rs b/src/test/run-pass-fulldeps/proc-macro/append-impl.rs deleted file mode 100644 index 591f3331d28..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/append-impl.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:append-impl.rs - -#![allow(warnings)] - -#[macro_use] -extern crate append_impl; - -trait Append { - fn foo(&self); -} - -#[derive(PartialEq, - Append, - Eq)] -struct A { - inner: u32, -} - -fn main() { - A { inner: 3 }.foo(); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs b/src/test/run-pass-fulldeps/proc-macro/attr-args.rs deleted file mode 100644 index b2ee5c2a20a..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/attr-args.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attr-args.rs - -#![allow(warnings)] - -extern crate attr_args; -use attr_args::{attr_with_args, identity}; - -#[attr_with_args(text = "Hello, world!")] -fn foo() {} - -#[identity(fn main() { assert_eq!(foo(), "Hello, world!"); })] -struct Dummy; diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs b/src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs deleted file mode 100644 index 58ffd0ce8b0..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/attr-cfg.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attr-cfg.rs -// revisions: foo bar - -extern crate attr_cfg; -use attr_cfg::attr_cfg; - -#[attr_cfg] -fn outer() -> u8 { - #[cfg(foo)] - fn inner() -> u8 { 1 } - - #[cfg(bar)] - fn inner() -> u8 { 2 } - - inner() -} - -#[cfg(foo)] -fn main() { - assert_eq!(outer(), 1); -} - -#[cfg(bar)] -fn main() { - assert_eq!(outer(), 2); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs b/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs deleted file mode 100644 index 383c193ddb4..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/attr-on-trait.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attr-on-trait.rs - -extern crate attr_on_trait; - -use attr_on_trait::foo; - -trait Foo { - #[foo] - fn foo() {} -} - -impl Foo for i32 { - fn foo(&self) {} -} - -fn main() { - 3i32.foo(); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs b/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs deleted file mode 100644 index 43a5695f1b7..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/attr-stmt-expr.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attr-stmt-expr.rs - -#![feature(stmt_expr_attributes, proc_macro_hygiene)] - -extern crate attr_stmt_expr; -use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr, - no_output, noop}; - -fn print_str(string: &'static str) { - // macros are handled a bit differently - #[expect_print_expr] - println!("{}", string) -} - -fn main() { - #[expect_let] - let string = "Hello, world!"; - - #[expect_print_stmt] - println!("{}", string); - - let _: () = { - #[no_output] - "Hello, world!" - }; - - let _: &'static str = #[noop] "Hello, world!"; - - let _: &'static str = { - #[noop] "Hello, world!" - }; - - #[expect_expr] - print_str("string") -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs deleted file mode 100644 index 3959eccd81e..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(AddImpl)] -// #[cfg(proc_macro)] -pub fn derive(input: TokenStream) -> TokenStream { - "impl B { - fn foo(&self) {} - } - - fn foo() {} - - mod bar { pub fn foo() {} } - ".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs deleted file mode 100644 index fdce709e5ba..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Append)] -pub fn derive_a(input: TokenStream) -> TokenStream { - "impl Append for A { - fn foo(&self) {} - } - ".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs deleted file mode 100644 index 655bfa3ff63..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-args.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn attr_with_args(args: TokenStream, input: TokenStream) -> TokenStream { - let args = args.to_string(); - - assert_eq!(args, r#"text = "Hello, world!""#); - - let input = input.to_string(); - - assert_eq!(input, "fn foo() { }"); - - r#" - fn foo() -> &'static str { "Hello, world!" } - "#.parse().unwrap() -} - -#[proc_macro_attribute] -pub fn identity(attr_args: TokenStream, _: TokenStream) -> TokenStream { - attr_args -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs deleted file mode 100644 index f9037aa8bf9..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-cfg.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn attr_cfg(args: TokenStream, input: TokenStream) -> TokenStream { - let input_str = input.to_string(); - - assert_eq!(input_str, "fn outer() -> u8 { - #[cfg(foo)] - fn inner() -> u8 { 1 } - #[cfg(bar)] - fn inner() -> u8 { 2 } - inner() -}"); - - input -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-on-trait.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-on-trait.rs deleted file mode 100644 index 5e5c775b1ff..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-on-trait.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn foo(attr: TokenStream, item: TokenStream) -> TokenStream { - drop(attr); - assert_eq!(item.to_string(), "fn foo() { }"); - "fn foo(&self);".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs deleted file mode 100644 index 4d5e22b4eb6..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/attr-stmt-expr.rs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "let string = \"Hello, world!\";"); - item -} - -#[proc_macro_attribute] -pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "println!(\"{}\" , string);"); - item -} - -#[proc_macro_attribute] -pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "print_str(\"string\")"); - item -} - -#[proc_macro_attribute] -pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert_eq!(item.to_string(), "println!(\"{}\" , string)"); - item -} - -#[proc_macro_attribute] -pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert!(!item.to_string().is_empty()); - "".parse().unwrap() - -} - -#[proc_macro_attribute] -pub fn noop(attr: TokenStream, item: TokenStream) -> TokenStream { - assert!(attr.to_string().is_empty()); - assert!(!item.to_string().is_empty()); - item -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/bang-macro.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/bang-macro.rs deleted file mode 100644 index 8b7c6cd10b8..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/bang-macro.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro] -pub fn rewrite(input: TokenStream) -> TokenStream { - let input = input.to_string(); - - assert_eq!(input, r#""Hello, world!""#); - - r#""NOT Hello, world!""#.parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/call-site.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/call-site.rs deleted file mode 100644 index 65eb8f4bec2..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/call-site.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro] -pub fn check(input: TokenStream) -> TokenStream { - // Parsed `x2` can refer to `x2` from `input` - let parsed1: TokenStream = "let x3 = x2;".parse().unwrap(); - // `x3` parsed from one string can refer to `x3` parsed from another string. - let parsed2: TokenStream = "let x4 = x3;".parse().unwrap(); - // Manually assembled `x4` can refer to parsed `x4`. - let manual: Vec = vec![ - Ident::new("let", Span::call_site()).into(), - Ident::new("x5", Span::call_site()).into(), - Punct::new('=', Spacing::Alone).into(), - Ident::new("x4", Span::call_site()).into(), - Punct::new(';', Spacing::Alone).into(), - ]; - input.into_iter().chain(parsed1.into_iter()) - .chain(parsed2.into_iter()) - .chain(manual.into_iter()) - .collect() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs deleted file mode 100644 index 77d0d9339fe..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/count_compound_ops.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![feature(proc_macro_hygiene, proc_macro_quote)] -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::{TokenStream, TokenTree, Spacing, Literal, quote}; - -#[proc_macro] -pub fn count_compound_ops(input: TokenStream) -> TokenStream { - assert_eq!(count_compound_ops_helper(quote!(++ (&&) 4@a)), 3); - let l = Literal::u32_suffixed(count_compound_ops_helper(input)); - TokenTree::from(l).into() -} - -fn count_compound_ops_helper(input: TokenStream) -> u32 { - let mut count = 0; - for token in input { - match &token { - TokenTree::Punct(tt) if tt.spacing() == Spacing::Alone => { - count += 1; - } - TokenTree::Group(tt) => { - count += count_compound_ops_helper(tt.stream()); - } - _ => {} - } - } - count -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs deleted file mode 100644 index 4609f57bddf..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/custom-attr-only-one-derive.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Foo)] -pub fn foo(a: TokenStream) -> TokenStream { - "".parse().unwrap() -} - -#[proc_macro_derive(Bar, attributes(custom))] -pub fn bar(a: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs deleted file mode 100644 index b7374a07e42..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert!(input.contains("struct A;")); - "".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs deleted file mode 100644 index 67d828d92a7..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(AToB)] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert_eq!(input, "struct A;"); - "struct B;".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs deleted file mode 100644 index 2b413579a9a..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-attr-cfg.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Foo, attributes(foo))] -pub fn derive(input: TokenStream) -> TokenStream { - assert!(!input.to_string().contains("#[cfg(any())]")); - "".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs deleted file mode 100644 index e1aabad4142..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-b.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(B, attributes(B, C))] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert!(input.contains("#[B [ arbitrary tokens ]]")); - assert!(input.contains("struct B {")); - assert!(input.contains("#[C]")); - "".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs deleted file mode 100644 index 550ffe9400d..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(CToD)] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert_eq!(input, "struct C;"); - "struct D;".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-nothing.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-nothing.rs deleted file mode 100644 index cfe428bf5f3..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-nothing.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Nothing)] -pub fn nothing(input: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs deleted file mode 100644 index cf96f52823f..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags:--crate-type proc-macro - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(AToB)] -pub fn derive1(input: TokenStream) -> TokenStream { - println!("input1: {:?}", input.to_string()); - assert_eq!(input.to_string(), "struct A;"); - "#[derive(BToC)] struct B;".parse().unwrap() -} - -#[proc_macro_derive(BToC)] -pub fn derive2(input: TokenStream) -> TokenStream { - assert_eq!(input.to_string(), "struct B;"); - "struct C;".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs deleted file mode 100644 index d02edb50fb2..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-two-attrs.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro_derive(A, attributes(b))] -pub fn foo(_x: TokenStream) -> TokenStream { - TokenStream::new() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-union.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-union.rs deleted file mode 100644 index 41bb88a0a92..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-union.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(UnionTest)] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert!(input.contains("#[repr(C)]")); - assert!(input.contains("union Test {")); - assert!(input.contains("a: u8,")); - assert!(input.contains("}")); - "".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/double.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/double.rs deleted file mode 100644 index a6c9817f247..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/double.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -// Outputs another copy of the struct. Useful for testing the tokens -// seen by the proc_macro. -#[proc_macro_derive(Double)] -pub fn derive(input: TokenStream) -> TokenStream { - format!("mod foo {{ {} }}", input.to_string()).parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/empty-crate.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/empty-crate.rs deleted file mode 100644 index b45d4bf41d6..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/empty-crate.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![deny(unused_variables)] diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs deleted file mode 100644 index e6831b6bfdf..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![deny(warnings)] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive(input: TokenStream) -> TokenStream { - let input = input.to_string(); - assert!(input.contains("struct A;")); - r#" - impl A { - fn a(&self) { - panic!("hello"); - } - } - "#.parse().unwrap() -} - diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/external-crate-var.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/external-crate-var.rs deleted file mode 100644 index 030c53b3e6f..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/external-crate-var.rs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub struct ExternFoo; - -pub trait ExternTrait { - const CONST: u32; - type Assoc; -} - -impl ExternTrait for ExternFoo { - const CONST: u32 = 0; - type Assoc = ExternFoo; -} - -#[macro_export] -macro_rules! external { () => { - mod bar { - #[derive(Double)] - struct Bar($crate::ExternFoo); - } - - mod qself { - #[derive(Double)] - struct QSelf(<$crate::ExternFoo as $crate::ExternTrait>::Assoc); - } - - mod qself_recurse { - #[derive(Double)] - struct QSelfRecurse(< - <$crate::ExternFoo as $crate::ExternTrait>::Assoc - as $crate::ExternTrait>::Assoc - ); - } - - mod qself_in_const { - #[derive(Double)] - #[repr(u32)] - enum QSelfInConst { - Variant = <$crate::ExternFoo as $crate::ExternTrait>::CONST, - } - } -} } - diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/gen-lifetime-token.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/gen-lifetime-token.rs deleted file mode 100644 index 978de27b70a..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/gen-lifetime-token.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro] -pub fn bar(_input: TokenStream) -> TokenStream { - let mut ret = Vec::::new(); - ret.push(Ident::new("static", Span::call_site()).into()); - ret.push(Ident::new("FOO", Span::call_site()).into()); - ret.push(Punct::new(':', Spacing::Alone).into()); - ret.push(Punct::new('&', Spacing::Alone).into()); - ret.push(Punct::new('\'', Spacing::Joint).into()); - ret.push(Ident::new("static", Span::call_site()).into()); - ret.push(Ident::new("i32", Span::call_site()).into()); - ret.push(Punct::new('=', Spacing::Alone).into()); - ret.push(Punct::new('&', Spacing::Alone).into()); - ret.push(Literal::i32_unsuffixed(1).into()); - ret.push(Punct::new(';', Spacing::Alone).into()); - ret.into_iter().collect() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example.rs deleted file mode 100644 index ca88482064b..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -extern crate hygiene_example_codegen; - -pub use hygiene_example_codegen::hello; - -pub fn print(string: &str) { - println!("{}", string); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs deleted file mode 100644 index 551ac3863e1..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/hygiene_example_codegen.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![feature(proc_macro_quote, proc_macro_hygiene)] -#![crate_type = "proc-macro"] - -extern crate proc_macro as proc_macro_renamed; // This does not break `quote!` - -use proc_macro_renamed::{TokenStream, quote}; - -#[proc_macro] -pub fn hello(input: TokenStream) -> TokenStream { - quote!(hello_helper!($input)) - //^ `hello_helper!` always resolves to the following proc macro, - //| no matter where `hello!` is used. -} - -#[proc_macro] -pub fn hello_helper(input: TokenStream) -> TokenStream { - quote! { - extern crate hygiene_example; // This is never a conflict error - let string = format!("hello {}", $input); - //^ `format!` always resolves to the prelude macro, - //| even if a different `format!` is in scope where `hello!` is used. - hygiene_example::print(&string) - } -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-39889.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-39889.rs deleted file mode 100644 index 9094310fb3e..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-39889.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::TokenStream; - -#[proc_macro_derive(Issue39889)] -pub fn f(_input: TokenStream) -> TokenStream { - let rules = r#" - macro_rules! id { - ($($tt:tt)*) => { $($tt)* }; - } - "#; - rules.parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs deleted file mode 100644 index f4d3f2c94ca..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-40001-plugin.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(box_syntax, plugin, plugin_registrar, rustc_private)] -#![crate_type = "dylib"] - -#[macro_use] -extern crate rustc; -extern crate rustc_plugin; -extern crate syntax; - -use rustc_plugin::Registry; -use syntax::attr; -use syntax::ext::base::*; -use syntax::feature_gate::AttributeType::Whitelisted; -use syntax::symbol::Symbol; - -use rustc::hir; -use rustc::hir::intravisit; -use rustc::hir::map as hir_map; -use hir::Node; -use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext}; -use rustc::ty; -use syntax::{ast, source_map}; - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_late_lint_pass(box MissingWhitelistedAttrPass); - reg.register_attribute("whitelisted_attr".to_string(), Whitelisted); -} - -declare_lint!(MISSING_WHITELISTED_ATTR, Deny, - "Checks for missing `whitelisted_attr` attribute"); - -struct MissingWhitelistedAttrPass; - -impl LintPass for MissingWhitelistedAttrPass { - fn get_lints(&self) -> LintArray { - lint_array!(MISSING_WHITELISTED_ATTR) - } -} - -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingWhitelistedAttrPass { - fn check_fn(&mut self, - cx: &LateContext<'a, 'tcx>, - _: intravisit::FnKind<'tcx>, - _: &'tcx hir::FnDecl, - _: &'tcx hir::Body, - span: source_map::Span, - id: ast::NodeId) { - - let item = match cx.tcx.hir.get(id) { - Node::Item(item) => item, - _ => cx.tcx.hir.expect_item(cx.tcx.hir.get_parent(id)), - }; - - if !attr::contains_name(&item.attrs, "whitelisted_attr") { - cx.span_lint(MISSING_WHITELISTED_ATTR, span, - "Missing 'whitelisted_attr' attribute"); - } - } -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-42708.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-42708.rs deleted file mode 100644 index 906caceb869..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-42708.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Test)] -pub fn derive(_input: TokenStream) -> TokenStream { - "fn f(s: S) { s.x }".parse().unwrap() -} - -#[proc_macro_attribute] -pub fn attr_test(_attr: TokenStream, input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-50061.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-50061.rs deleted file mode 100644 index 6de17522fc9..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/issue-50061.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn check(_a: TokenStream, b: TokenStream) -> TokenStream { - b.into_iter().collect() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/lifetimes.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/lifetimes.rs deleted file mode 100644 index 0ee26b6a1b9..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/lifetimes.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro] -pub fn lifetimes_bang(input: TokenStream) -> TokenStream { - // Roundtrip through token trees - input.into_iter().collect() -} - -#[proc_macro_attribute] -pub fn lifetimes_attr(_: TokenStream, input: TokenStream) -> TokenStream { - // Roundtrip through AST - input -} - -#[proc_macro_derive(Lifetimes)] -pub fn lifetimes_derive(input: TokenStream) -> TokenStream { - // Roundtrip through a string - format!("mod m {{ {} }}", input).parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs deleted file mode 100644 index 498c6811d9c..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/modify-ast.rs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro_attribute] -pub fn assert1(_a: TokenStream, b: TokenStream) -> TokenStream { - assert_eq(b.clone(), "pub fn foo() {}".parse().unwrap()); - b -} - -#[proc_macro_derive(Foo, attributes(foo))] -pub fn assert2(a: TokenStream) -> TokenStream { - assert_eq(a, "pub struct MyStructc { _a: i32, }".parse().unwrap()); - TokenStream::new() -} - -fn assert_eq(a: TokenStream, b: TokenStream) { - let mut a = a.into_iter(); - let mut b = b.into_iter(); - for (a, b) in a.by_ref().zip(&mut b) { - match (a, b) { - (TokenTree::Group(a), TokenTree::Group(b)) => { - assert_eq!(a.delimiter(), b.delimiter()); - assert_eq(a.stream(), b.stream()); - } - (TokenTree::Punct(a), TokenTree::Punct(b)) => { - assert_eq!(a.as_char(), b.as_char()); - assert_eq!(a.spacing(), b.spacing()); - } - (TokenTree::Literal(a), TokenTree::Literal(b)) => { - assert_eq!(a.to_string(), b.to_string()); - } - (TokenTree::Ident(a), TokenTree::Ident(b)) => { - assert_eq!(a.to_string(), b.to_string()); - } - (a, b) => panic!("{:?} != {:?}", a, b), - } - } - - assert!(a.next().is_none()); - assert!(b.next().is_none()); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/negative-token.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/negative-token.rs deleted file mode 100644 index fd639696991..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/negative-token.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro] -pub fn neg_one(_input: TokenStream) -> TokenStream { - TokenTree::Literal(Literal::i32_suffixed(-1)).into() -} - -#[proc_macro] -pub fn neg_one_float(_input: TokenStream) -> TokenStream { - TokenTree::Literal(Literal::f32_suffixed(-1.0)).into() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs deleted file mode 100644 index e00a4d89e8d..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/not-joint.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro] -pub fn tokens(input: TokenStream) -> TokenStream { - assert_nothing_joint(input); - TokenStream::new() -} - -#[proc_macro_attribute] -pub fn nothing(_: TokenStream, input: TokenStream) -> TokenStream { - assert_nothing_joint(input); - TokenStream::new() -} - -fn assert_nothing_joint(s: TokenStream) { - for tt in s { - match tt { - TokenTree::Group(g) => assert_nothing_joint(g.stream()), - TokenTree::Punct(p) => assert_eq!(p.spacing(), Spacing::Alone), - _ => {} - } - } -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/span-api-tests.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/span-api-tests.rs deleted file mode 100644 index 8e2c5c0a088..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/span-api-tests.rs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_span)] - -extern crate proc_macro; - -use proc_macro::*; - -// Re-emits the input tokens by parsing them from strings -#[proc_macro] -pub fn reemit(input: TokenStream) -> TokenStream { - input.to_string().parse().unwrap() -} - -#[proc_macro] -pub fn assert_fake_source_file(input: TokenStream) -> TokenStream { - for tk in input { - let source_file = tk.span().source_file(); - assert!(!source_file.is_real(), "Source file is real: {:?}", source_file); - } - - "".parse().unwrap() -} - -#[proc_macro] -pub fn assert_source_file(input: TokenStream) -> TokenStream { - for tk in input { - let source_file = tk.span().source_file(); - assert!(source_file.is_real(), "Source file is not real: {:?}", source_file); - } - - "".parse().unwrap() -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/span-test-macros.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/span-test-macros.rs deleted file mode 100644 index b4666e2cb61..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/span-test-macros.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_export] -macro_rules! reemit_legacy { - ($($tok:tt)*) => ($($tok)*) -} - -#[macro_export] -macro_rules! say_hello_extern { - ($macname:ident) => ( $macname! { "Hello, world!" }) -} diff --git a/src/test/run-pass-fulldeps/proc-macro/auxiliary/test-macros.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/test-macros.rs deleted file mode 100644 index 581c7cb15a5..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/auxiliary/test-macros.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn nop_attr(_attr: TokenStream, input: TokenStream) -> TokenStream { - assert!(_attr.to_string().is_empty()); - input -} - -#[proc_macro_attribute] -pub fn no_output(_attr: TokenStream, _input: TokenStream) -> TokenStream { - assert!(_attr.to_string().is_empty()); - assert!(!_input.to_string().is_empty()); - "".parse().unwrap() -} - -#[proc_macro] -pub fn emit_input(input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs b/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs deleted file mode 100644 index f433bc64c6e..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/bang-macro.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:bang-macro.rs - -#![feature(proc_macro_hygiene)] - -extern crate bang_macro; -use bang_macro::rewrite; - -fn main() { - assert_eq!(rewrite!("Hello, world!"), "NOT Hello, world!"); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/call-site.rs b/src/test/run-pass-fulldeps/proc-macro/call-site.rs deleted file mode 100644 index ccbf33cc73b..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/call-site.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_variables)] -#![allow(unused_imports)] -// aux-build:call-site.rs - -#![feature(proc_macro_hygiene)] - -extern crate call_site; -use call_site::*; - -fn main() { - let x1 = 10; - call_site::check!(let x2 = x1;); - let x6 = x5; -} diff --git a/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs b/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs deleted file mode 100644 index 46a5906e46a..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/count_compound_ops.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:count_compound_ops.rs - -#![feature(proc_macro_hygiene)] - -extern crate count_compound_ops; -use count_compound_ops::count_compound_ops; - -fn main() { - assert_eq!(count_compound_ops!(foo<=>bar << or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:double.rs -// aux-build:external-crate-var.rs - -#![allow(unused)] - -#[macro_use] -extern crate double; -#[macro_use] -extern crate external_crate_var; - -struct Foo; - -trait Trait { - const CONST: u32; - type Assoc; -} - -impl Trait for Foo { - const CONST: u32 = 0; - type Assoc = Foo; -} - -macro_rules! local { () => { - // derive_Double outputs secondary copies of each definition - // to test what the proc_macro sees. - mod bar { - #[derive(Double)] - struct Bar($crate::Foo); - } - - mod qself { - #[derive(Double)] - struct QSelf(<::Foo as $crate::Trait>::Assoc); - } - - mod qself_recurse { - #[derive(Double)] - struct QSelfRecurse(<<$crate::Foo as $crate::Trait>::Assoc as $crate::Trait>::Assoc); - } - - mod qself_in_const { - #[derive(Double)] - #[repr(u32)] - enum QSelfInConst { - Variant = <::Foo as $crate::Trait>::CONST, - } - } -} } - -mod local { - local!(); -} - -// and now repeat the above tests, using a macro defined in another crate - -mod external { - external!{} -} - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs b/src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs deleted file mode 100644 index 3b2833a4bcf..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/custom-attr-only-one-derive.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:custom-attr-only-one-derive.rs - -#![feature(rust_2018_preview)] - -#[macro_use] -extern crate custom_attr_only_one_derive; - -#[derive(Bar, Foo)] -#[custom = "test"] -pub enum A { - B, - C, -} - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs b/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs deleted file mode 100644 index f804042374d..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/derive-attr-cfg.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -// aux-build:derive-attr-cfg.rs - -extern crate derive_attr_cfg; -use derive_attr_cfg::Foo; - -#[derive(Foo)] -#[foo] -struct S { - #[cfg(any())] - x: i32 -} - -fn main() { -} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-b.rs b/src/test/run-pass-fulldeps/proc-macro/derive-b.rs deleted file mode 100644 index 60a6cf7662d..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/derive-b.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-b.rs - -#![feature(unrestricted_attribute_tokens)] - -extern crate derive_b; - -#[derive(Debug, PartialEq, derive_b::B, Eq, Copy, Clone)] -#[cfg_attr(all(), B[arbitrary tokens])] -struct B { - #[C] - a: u64 -} - -fn main() { - B { a: 3 }; - assert_eq!(B { a: 3 }, B { a: 3 }); - let b = B { a: 3 }; - let _d = b; - let _e = b; -} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs b/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs deleted file mode 100644 index 7aff32e16ce..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(path_statements)] -#![allow(dead_code)] -// aux-build:derive-same-struct.rs - -#[macro_use] -extern crate derive_same_struct; - -#[derive(AToB)] -struct A; - -fn main() { - C; -} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout b/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout deleted file mode 100644 index 77605de5e33..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.stdout +++ /dev/null @@ -1 +0,0 @@ -input1: "struct A;" diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-test.rs b/src/test/run-pass-fulldeps/proc-macro/derive-test.rs deleted file mode 100644 index 5a53a4e8db3..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/derive-test.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// compile-flags: --test - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -// ``` -// assert!(true); -// ``` -#[proc_macro_derive(Foo)] -pub fn derive_foo(_input: TokenStream) -> TokenStream { - "".parse().unwrap() -} - -#[test] -pub fn test_derive() { - assert!(true); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs b/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs deleted file mode 100644 index 9c2ba481f5e..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/derive-two-attrs.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -// aux-build:derive-two-attrs.rs - -extern crate derive_two_attrs as foo; - -use foo::A; - -#[derive(A)] -#[b] -#[b] -struct B; - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/derive-union.rs b/src/test/run-pass-fulldeps/proc-macro/derive-union.rs deleted file mode 100644 index 2aae1d8635f..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/derive-union.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_variables)] -// aux-build:derive-union.rs - -#[macro_use] -extern crate derive_union; - -#[repr(C)] -#[derive(UnionTest)] -union Test { - a: u8, -} - -fn main() { - let t = Test { a: 0 }; -} diff --git a/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs b/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs deleted file mode 100644 index 1a0c0506112..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/empty-crate.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_imports)] -// aux-build:empty-crate.rs - -#[macro_use] -extern crate empty_crate; - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs b/src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs deleted file mode 100644 index 6a0669c4bb2..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:expand-with-a-macro.rs - -#![deny(warnings)] - -#[macro_use] -extern crate expand_with_a_macro; - -use std::panic; - -#[derive(A)] -struct A; - -fn main() { - assert!(panic::catch_unwind(|| { - A.a(); - }).is_err()); -} - diff --git a/src/test/run-pass-fulldeps/proc-macro/gen-lifetime-token.rs b/src/test/run-pass-fulldeps/proc-macro/gen-lifetime-token.rs deleted file mode 100644 index ce2fed86e46..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/gen-lifetime-token.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:gen-lifetime-token.rs - -extern crate gen_lifetime_token as bar; - -bar::bar!(); - -fn main() { - let x: &'static i32 = FOO; - assert_eq!(*x, 1); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs b/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs deleted file mode 100644 index 41857fde269..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/hygiene_example.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_macros)] -// aux-build:hygiene_example_codegen.rs -// aux-build:hygiene_example.rs - -#![feature(proc_macro_hygiene)] - -extern crate hygiene_example; -use hygiene_example::hello; - -fn main() { - mod hygiene_example {} // no conflict with `extern crate hygiene_example;` from the proc macro - macro_rules! format { () => {} } // does not interfere with `format!` from the proc macro - macro_rules! hello_helper { () => {} } // similarly does not intefere with the proc macro - - let string = "world"; // no conflict with `string` from the proc macro - hello!(string); - hello!(string); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs b/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs deleted file mode 100644 index 99500a77f09..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/issue-39889.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -// aux-build:issue-39889.rs - -extern crate issue_39889; -use issue_39889::Issue39889; - -#[derive(Issue39889)] -struct S; - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-40001.rs b/src/test/run-pass-fulldeps/proc-macro/issue-40001.rs deleted file mode 100644 index b828199883f..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/issue-40001.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue-40001-plugin.rs -// ignore-stage1 - -#![feature(plugin)] -#![plugin(issue_40001_plugin)] - -#[whitelisted_attr] -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs b/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs deleted file mode 100644 index 8f9c8723953..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/issue-42708.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:issue-42708.rs - -#![feature(decl_macro)] -#![allow(unused)] - -extern crate issue_42708; - -macro m() { - #[derive(issue_42708::Test)] - struct S { x: () } - - #[issue_42708::attr_test] - struct S2 { x: () } - - #[derive(Clone)] - struct S3 { x: () } - - fn g(s: S, s2: S2, s3: S3) { - (s.x, s2.x, s3.x); - } -} - -m!(); - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs b/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs deleted file mode 100644 index 1a751161a44..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/issue-50061.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(path_statements)] -// aux-build:issue-50061.rs - -#![feature(decl_macro)] - -extern crate issue_50061; - -macro inner(any_token $v: tt) { - $v -} - -macro outer($v: tt) { - inner!(any_token $v) -} - -#[issue_50061::check] -fn main() { - //! this doc comment forces roundtrip through a string - let checkit = 0; - outer!(checkit); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs b/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs deleted file mode 100644 index 7cd234df650..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/lifetimes.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_variables)] -// aux-build:lifetimes.rs - -extern crate lifetimes; -use lifetimes::*; - -lifetimes_bang! { - fn bang<'a>() -> &'a u8 { &0 } -} - -#[lifetimes_attr] -fn attr<'a>() -> &'a u8 { &1 } - -#[derive(Lifetimes)] -pub struct Lifetimes<'a> { - pub field: &'a u8, -} - -fn main() { - assert_eq!(bang::<'static>(), &0); - assert_eq!(attr::<'static>(), &1); - let l1 = Lifetimes { field: &0 }; - let l2 = m::Lifetimes { field: &1 }; -} diff --git a/src/test/run-pass-fulldeps/proc-macro/load-two.rs b/src/test/run-pass-fulldeps/proc-macro/load-two.rs deleted file mode 100644 index 319e99d4e44..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/load-two.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(path_statements)] -#![allow(dead_code)] -// aux-build:derive-atob.rs -// aux-build:derive-ctod.rs - -#[macro_use] -extern crate derive_atob; -#[macro_use] -extern crate derive_ctod; - -#[derive(Copy, Clone)] -#[derive(AToB)] -struct A; - -#[derive(CToD)] -struct C; - -fn main() { - B; - D; -} diff --git a/src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs b/src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs deleted file mode 100644 index ce62cabf281..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/macros-in-extern.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:test-macros.rs -// ignore-wasm32 - -#![feature(macros_in_extern)] - -extern crate test_macros; - -use test_macros::{nop_attr, no_output, emit_input}; - -fn main() { - assert_eq!(unsafe { rust_get_test_int() }, 1isize); - assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEF); -} - -#[link(name = "rust_test_helpers", kind = "static")] -extern { - #[no_output] - fn some_definitely_unknown_symbol_which_should_be_removed(); - - #[nop_attr] - fn rust_get_test_int() -> isize; - - emit_input!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/modify-ast.rs b/src/test/run-pass-fulldeps/proc-macro/modify-ast.rs deleted file mode 100644 index d6f7cc4699a..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/modify-ast.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:modify-ast.rs - -extern crate modify_ast; - -use modify_ast::*; - -#[derive(Foo)] -pub struct MyStructc { - #[cfg_attr(my_cfg, foo)] - _a: i32, -} - -macro_rules! a { - ($i:item) => ($i) -} - -a! { - #[assert1] - pub fn foo() {} -} - -fn main() { - let _a = MyStructc { _a: 0 }; - foo(); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/negative-token.rs b/src/test/run-pass-fulldeps/proc-macro/negative-token.rs deleted file mode 100644 index f953ba8df7e..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/negative-token.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:negative-token.rs - -#![feature(proc_macro_hygiene)] - -extern crate negative_token; - -use negative_token::*; - -fn main() { - assert_eq!(-1, neg_one!()); - assert_eq!(-1.0, neg_one_float!()); -} diff --git a/src/test/run-pass-fulldeps/proc-macro/not-joint.rs b/src/test/run-pass-fulldeps/proc-macro/not-joint.rs deleted file mode 100644 index 7a53348f963..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/not-joint.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:not-joint.rs - -extern crate not_joint as bar; -use bar::{tokens, nothing}; - -tokens![< -]; - -#[nothing] -a![< -]; - -#[nothing] -b!{< -} - -#[nothing] -c!(< -); - -#[nothing] -fn foo() { - //! dox - let x = 2 < - 3; -} - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/smoke.rs b/src/test/run-pass-fulldeps/proc-macro/smoke.rs deleted file mode 100644 index ba0cd3b398d..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/smoke.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_must_use)] -#![allow(path_statements)] -// aux-build:derive-a.rs - -#[macro_use] -extern crate derive_a; - -#[derive(Debug, PartialEq, A, Eq, Copy, Clone)] -struct A; - -fn main() { - A; - assert_eq!(A, A); - A.clone(); - let a = A; - let _c = a; - let _d = a; -} diff --git a/src/test/run-pass-fulldeps/proc-macro/span-api-tests.rs b/src/test/run-pass-fulldeps/proc-macro/span-api-tests.rs deleted file mode 100644 index 415cada265e..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/span-api-tests.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:span-api-tests.rs -// aux-build:span-test-macros.rs - -// ignore-pretty - -#[macro_use] -extern crate span_test_macros; - -extern crate span_api_tests; - -use span_api_tests::{reemit, assert_fake_source_file, assert_source_file}; - -macro_rules! say_hello { - ($macname:ident) => ( $macname! { "Hello, world!" }) -} - -assert_source_file! { "Hello, world!" } - -say_hello! { assert_source_file } - -reemit_legacy! { - assert_source_file! { "Hello, world!" } -} - -say_hello_extern! { assert_fake_source_file } - -reemit! { - assert_source_file! { "Hello, world!" } -} - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs b/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs deleted file mode 100644 index b1ac8038fa2..00000000000 --- a/src/test/run-pass-fulldeps/proc-macro/struct-field-macro.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(dead_code)] -// aux-build:derive-nothing.rs - -#[macro_use] -extern crate derive_nothing; - -macro_rules! int { - () => { i32 } -} - -#[derive(Nothing)] -struct S { - x: int!(), -} - -fn main() {} diff --git a/src/test/run-pass-fulldeps/proc_macro.rs b/src/test/run-pass-fulldeps/proc_macro.rs deleted file mode 100644 index e14ceca8e42..00000000000 --- a/src/test/run-pass-fulldeps/proc_macro.rs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:proc_macro_def.rs -// ignore-cross-compile - -#![feature(proc_macro_hygiene)] - -extern crate proc_macro_def; - -use proc_macro_def::{attr_tru, attr_identity, identity, ret_tru, tru}; - -#[attr_tru] -fn f1() -> bool { - return false; -} - -#[attr_identity] -fn f2() -> bool { - return identity!(true); -} - -fn f3() -> identity!(bool) { - ret_tru!(); -} - -fn f4(x: bool) -> bool { - match x { - identity!(true) => false, - identity!(false) => true, - } -} - -fn main() { - assert!(f1()); - assert!(f2()); - assert!(tru!()); - assert!(f3()); - assert!(identity!(5 == 5)); - assert!(f4(false)); -} diff --git a/src/test/run-pass/auxiliary/cond_plugin.rs b/src/test/run-pass/auxiliary/cond_plugin.rs new file mode 100644 index 00000000000..e7545f954da --- /dev/null +++ b/src/test/run-pass/auxiliary/cond_plugin.rs @@ -0,0 +1,47 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_hygiene)] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro] +pub fn cond(input: TokenStream) -> TokenStream { + let mut conds = Vec::new(); + let mut input = input.into_iter().peekable(); + while let Some(tree) = input.next() { + let cond = match tree { + TokenTree::Group(tt) => tt.stream(), + _ => panic!("Invalid input"), + }; + let mut cond_trees = cond.clone().into_iter(); + let test = cond_trees.next().expect("Unexpected empty condition in `cond!`"); + let rhs = cond_trees.collect::(); + if rhs.is_empty() { + panic!("Invalid macro usage in cond: {}", cond); + } + let is_else = match test { + TokenTree::Ident(ref word) => &*word.to_string() == "else", + _ => false, + }; + conds.push(if is_else || input.peek().is_none() { + quote!({ $rhs }) + } else { + quote!(if $test { $rhs } else) + }); + } + + conds.into_iter().flat_map(|x| x.into_iter()).collect() +} diff --git a/src/test/run-pass/auxiliary/hello_macro.rs b/src/test/run-pass/auxiliary/hello_macro.rs new file mode 100644 index 00000000000..caf56dabf79 --- /dev/null +++ b/src/test/run-pass/auxiliary/hello_macro.rs @@ -0,0 +1,30 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_hygiene, proc_macro_quote)] + +extern crate proc_macro; + +use proc_macro::{TokenStream, quote}; + +// This macro is not very interesting, but it does contain delimited tokens with +// no content - `()` and `{}` - which has caused problems in the past. +// Also, it tests that we can escape `$` via `$$`. +#[proc_macro] +pub fn hello(_: TokenStream) -> TokenStream { + quote!({ + fn hello() {} + macro_rules! m { ($$($$t:tt)*) => { $$($$t)* } } + m!(hello()); + }) +} diff --git a/src/test/run-pass/auxiliary/proc_macro_def.rs b/src/test/run-pass/auxiliary/proc_macro_def.rs new file mode 100644 index 00000000000..847db0098ff --- /dev/null +++ b/src/test/run-pass/auxiliary/proc_macro_def.rs @@ -0,0 +1,44 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_hygiene)] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_attribute] +pub fn attr_tru(_attr: TokenStream, item: TokenStream) -> TokenStream { + let name = item.into_iter().nth(1).unwrap(); + quote!(fn $name() -> bool { true }) +} + +#[proc_macro_attribute] +pub fn attr_identity(_attr: TokenStream, item: TokenStream) -> TokenStream { + quote!($item) +} + +#[proc_macro] +pub fn tru(_ts: TokenStream) -> TokenStream { + quote!(true) +} + +#[proc_macro] +pub fn ret_tru(_ts: TokenStream) -> TokenStream { + quote!(return true;) +} + +#[proc_macro] +pub fn identity(ts: TokenStream) -> TokenStream { + quote!($ts) +} diff --git a/src/test/run-pass/macro-quote-cond.rs b/src/test/run-pass/macro-quote-cond.rs new file mode 100644 index 00000000000..d8e36336028 --- /dev/null +++ b/src/test/run-pass/macro-quote-cond.rs @@ -0,0 +1,56 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_parens)] +// aux-build:cond_plugin.rs + +#![feature(proc_macro_hygiene)] + +extern crate cond_plugin; + +use cond_plugin::cond; + +fn fact(n : i64) -> i64 { + if n == 0 { + 1 + } else { + n * fact(n - 1) + } +} + +fn fact_cond(n : i64) -> i64 { + cond!( + ((n == 0) 1) + (else (n * fact_cond(n-1))) + ) +} + +fn fib(n : i64) -> i64 { + if n == 0 || n == 1 { + 1 + } else { + fib(n-1) + fib(n-2) + } +} + +fn fib_cond(n : i64) -> i64 { + cond!( + ((n == 0) 1) + ((n == 1) 1) + (else (fib_cond(n-1) + fib_cond(n-2))) + ) +} + +fn main() { + assert_eq!(fact(3), fact_cond(3)); + assert_eq!(fact(5), fact_cond(5)); + assert_eq!(fib(5), fib_cond(5)); + assert_eq!(fib(8), fib_cond(8)); +} diff --git a/src/test/run-pass/macro-quote-test.rs b/src/test/run-pass/macro-quote-test.rs new file mode 100644 index 00000000000..473f92f7b74 --- /dev/null +++ b/src/test/run-pass/macro-quote-test.rs @@ -0,0 +1,21 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a macro can emit delimiters with nothing inside - `()`, `{}` + +// aux-build:hello_macro.rs + +#![feature(proc_macro_hygiene)] + +extern crate hello_macro; + +fn main() { + hello_macro::hello!(); +} diff --git a/src/test/run-pass/proc-macro/add-impl.rs b/src/test/run-pass/proc-macro/add-impl.rs new file mode 100644 index 00000000000..7ea7ceafc28 --- /dev/null +++ b/src/test/run-pass/proc-macro/add-impl.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:add-impl.rs + +#[macro_use] +extern crate add_impl; + +#[derive(AddImpl)] +struct B; + +fn main() { + B.foo(); + foo(); + bar::foo(); +} diff --git a/src/test/run-pass/proc-macro/append-impl.rs b/src/test/run-pass/proc-macro/append-impl.rs new file mode 100644 index 00000000000..591f3331d28 --- /dev/null +++ b/src/test/run-pass/proc-macro/append-impl.rs @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:append-impl.rs + +#![allow(warnings)] + +#[macro_use] +extern crate append_impl; + +trait Append { + fn foo(&self); +} + +#[derive(PartialEq, + Append, + Eq)] +struct A { + inner: u32, +} + +fn main() { + A { inner: 3 }.foo(); +} diff --git a/src/test/run-pass/proc-macro/attr-args.rs b/src/test/run-pass/proc-macro/attr-args.rs new file mode 100644 index 00000000000..b2ee5c2a20a --- /dev/null +++ b/src/test/run-pass/proc-macro/attr-args.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr-args.rs + +#![allow(warnings)] + +extern crate attr_args; +use attr_args::{attr_with_args, identity}; + +#[attr_with_args(text = "Hello, world!")] +fn foo() {} + +#[identity(fn main() { assert_eq!(foo(), "Hello, world!"); })] +struct Dummy; diff --git a/src/test/run-pass/proc-macro/attr-cfg.rs b/src/test/run-pass/proc-macro/attr-cfg.rs new file mode 100644 index 00000000000..58ffd0ce8b0 --- /dev/null +++ b/src/test/run-pass/proc-macro/attr-cfg.rs @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr-cfg.rs +// revisions: foo bar + +extern crate attr_cfg; +use attr_cfg::attr_cfg; + +#[attr_cfg] +fn outer() -> u8 { + #[cfg(foo)] + fn inner() -> u8 { 1 } + + #[cfg(bar)] + fn inner() -> u8 { 2 } + + inner() +} + +#[cfg(foo)] +fn main() { + assert_eq!(outer(), 1); +} + +#[cfg(bar)] +fn main() { + assert_eq!(outer(), 2); +} diff --git a/src/test/run-pass/proc-macro/attr-on-trait.rs b/src/test/run-pass/proc-macro/attr-on-trait.rs new file mode 100644 index 00000000000..383c193ddb4 --- /dev/null +++ b/src/test/run-pass/proc-macro/attr-on-trait.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr-on-trait.rs + +extern crate attr_on_trait; + +use attr_on_trait::foo; + +trait Foo { + #[foo] + fn foo() {} +} + +impl Foo for i32 { + fn foo(&self) {} +} + +fn main() { + 3i32.foo(); +} diff --git a/src/test/run-pass/proc-macro/attr-stmt-expr.rs b/src/test/run-pass/proc-macro/attr-stmt-expr.rs new file mode 100644 index 00000000000..43a5695f1b7 --- /dev/null +++ b/src/test/run-pass/proc-macro/attr-stmt-expr.rs @@ -0,0 +1,45 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attr-stmt-expr.rs + +#![feature(stmt_expr_attributes, proc_macro_hygiene)] + +extern crate attr_stmt_expr; +use attr_stmt_expr::{expect_let, expect_print_stmt, expect_expr, expect_print_expr, + no_output, noop}; + +fn print_str(string: &'static str) { + // macros are handled a bit differently + #[expect_print_expr] + println!("{}", string) +} + +fn main() { + #[expect_let] + let string = "Hello, world!"; + + #[expect_print_stmt] + println!("{}", string); + + let _: () = { + #[no_output] + "Hello, world!" + }; + + let _: &'static str = #[noop] "Hello, world!"; + + let _: &'static str = { + #[noop] "Hello, world!" + }; + + #[expect_expr] + print_str("string") +} diff --git a/src/test/run-pass/proc-macro/auxiliary/add-impl.rs b/src/test/run-pass/proc-macro/auxiliary/add-impl.rs new file mode 100644 index 00000000000..3959eccd81e --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/add-impl.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(AddImpl)] +// #[cfg(proc_macro)] +pub fn derive(input: TokenStream) -> TokenStream { + "impl B { + fn foo(&self) {} + } + + fn foo() {} + + mod bar { pub fn foo() {} } + ".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/append-impl.rs b/src/test/run-pass/proc-macro/auxiliary/append-impl.rs new file mode 100644 index 00000000000..fdce709e5ba --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/append-impl.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Append)] +pub fn derive_a(input: TokenStream) -> TokenStream { + "impl Append for A { + fn foo(&self) {} + } + ".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/attr-args.rs b/src/test/run-pass/proc-macro/auxiliary/attr-args.rs new file mode 100644 index 00000000000..655bfa3ff63 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/attr-args.rs @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn attr_with_args(args: TokenStream, input: TokenStream) -> TokenStream { + let args = args.to_string(); + + assert_eq!(args, r#"text = "Hello, world!""#); + + let input = input.to_string(); + + assert_eq!(input, "fn foo() { }"); + + r#" + fn foo() -> &'static str { "Hello, world!" } + "#.parse().unwrap() +} + +#[proc_macro_attribute] +pub fn identity(attr_args: TokenStream, _: TokenStream) -> TokenStream { + attr_args +} diff --git a/src/test/run-pass/proc-macro/auxiliary/attr-cfg.rs b/src/test/run-pass/proc-macro/auxiliary/attr-cfg.rs new file mode 100644 index 00000000000..f9037aa8bf9 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/attr-cfg.rs @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn attr_cfg(args: TokenStream, input: TokenStream) -> TokenStream { + let input_str = input.to_string(); + + assert_eq!(input_str, "fn outer() -> u8 { + #[cfg(foo)] + fn inner() -> u8 { 1 } + #[cfg(bar)] + fn inner() -> u8 { 2 } + inner() +}"); + + input +} diff --git a/src/test/run-pass/proc-macro/auxiliary/attr-on-trait.rs b/src/test/run-pass/proc-macro/auxiliary/attr-on-trait.rs new file mode 100644 index 00000000000..5e5c775b1ff --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/attr-on-trait.rs @@ -0,0 +1,24 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn foo(attr: TokenStream, item: TokenStream) -> TokenStream { + drop(attr); + assert_eq!(item.to_string(), "fn foo() { }"); + "fn foo(&self);".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/attr-stmt-expr.rs b/src/test/run-pass/proc-macro/auxiliary/attr-stmt-expr.rs new file mode 100644 index 00000000000..4d5e22b4eb6 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/attr-stmt-expr.rs @@ -0,0 +1,60 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn expect_let(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert_eq!(item.to_string(), "let string = \"Hello, world!\";"); + item +} + +#[proc_macro_attribute] +pub fn expect_print_stmt(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert_eq!(item.to_string(), "println!(\"{}\" , string);"); + item +} + +#[proc_macro_attribute] +pub fn expect_expr(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert_eq!(item.to_string(), "print_str(\"string\")"); + item +} + +#[proc_macro_attribute] +pub fn expect_print_expr(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert_eq!(item.to_string(), "println!(\"{}\" , string)"); + item +} + +#[proc_macro_attribute] +pub fn no_output(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert!(!item.to_string().is_empty()); + "".parse().unwrap() + +} + +#[proc_macro_attribute] +pub fn noop(attr: TokenStream, item: TokenStream) -> TokenStream { + assert!(attr.to_string().is_empty()); + assert!(!item.to_string().is_empty()); + item +} diff --git a/src/test/run-pass/proc-macro/auxiliary/bang-macro.rs b/src/test/run-pass/proc-macro/auxiliary/bang-macro.rs new file mode 100644 index 00000000000..8b7c6cd10b8 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/bang-macro.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn rewrite(input: TokenStream) -> TokenStream { + let input = input.to_string(); + + assert_eq!(input, r#""Hello, world!""#); + + r#""NOT Hello, world!""#.parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/call-site.rs b/src/test/run-pass/proc-macro/auxiliary/call-site.rs new file mode 100644 index 00000000000..65eb8f4bec2 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/call-site.rs @@ -0,0 +1,36 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro] +pub fn check(input: TokenStream) -> TokenStream { + // Parsed `x2` can refer to `x2` from `input` + let parsed1: TokenStream = "let x3 = x2;".parse().unwrap(); + // `x3` parsed from one string can refer to `x3` parsed from another string. + let parsed2: TokenStream = "let x4 = x3;".parse().unwrap(); + // Manually assembled `x4` can refer to parsed `x4`. + let manual: Vec = vec![ + Ident::new("let", Span::call_site()).into(), + Ident::new("x5", Span::call_site()).into(), + Punct::new('=', Spacing::Alone).into(), + Ident::new("x4", Span::call_site()).into(), + Punct::new(';', Spacing::Alone).into(), + ]; + input.into_iter().chain(parsed1.into_iter()) + .chain(parsed2.into_iter()) + .chain(manual.into_iter()) + .collect() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/count_compound_ops.rs b/src/test/run-pass/proc-macro/auxiliary/count_compound_ops.rs new file mode 100644 index 00000000000..77d0d9339fe --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/count_compound_ops.rs @@ -0,0 +1,41 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![feature(proc_macro_hygiene, proc_macro_quote)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::{TokenStream, TokenTree, Spacing, Literal, quote}; + +#[proc_macro] +pub fn count_compound_ops(input: TokenStream) -> TokenStream { + assert_eq!(count_compound_ops_helper(quote!(++ (&&) 4@a)), 3); + let l = Literal::u32_suffixed(count_compound_ops_helper(input)); + TokenTree::from(l).into() +} + +fn count_compound_ops_helper(input: TokenStream) -> u32 { + let mut count = 0; + for token in input { + match &token { + TokenTree::Punct(tt) if tt.spacing() == Spacing::Alone => { + count += 1; + } + TokenTree::Group(tt) => { + count += count_compound_ops_helper(tt.stream()); + } + _ => {} + } + } + count +} diff --git a/src/test/run-pass/proc-macro/auxiliary/custom-attr-only-one-derive.rs b/src/test/run-pass/proc-macro/auxiliary/custom-attr-only-one-derive.rs new file mode 100644 index 00000000000..4609f57bddf --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/custom-attr-only-one-derive.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Foo)] +pub fn foo(a: TokenStream) -> TokenStream { + "".parse().unwrap() +} + +#[proc_macro_derive(Bar, attributes(custom))] +pub fn bar(a: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-a.rs b/src/test/run-pass/proc-macro/auxiliary/derive-a.rs new file mode 100644 index 00000000000..b7374a07e42 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-a.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert!(input.contains("struct A;")); + "".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-atob.rs b/src/test/run-pass/proc-macro/auxiliary/derive-atob.rs new file mode 100644 index 00000000000..67d828d92a7 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-atob.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(AToB)] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert_eq!(input, "struct A;"); + "struct B;".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-attr-cfg.rs b/src/test/run-pass/proc-macro/auxiliary/derive-attr-cfg.rs new file mode 100644 index 00000000000..2b413579a9a --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-attr-cfg.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Foo, attributes(foo))] +pub fn derive(input: TokenStream) -> TokenStream { + assert!(!input.to_string().contains("#[cfg(any())]")); + "".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-b.rs b/src/test/run-pass/proc-macro/auxiliary/derive-b.rs new file mode 100644 index 00000000000..e1aabad4142 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-b.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(B, attributes(B, C))] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert!(input.contains("#[B [ arbitrary tokens ]]")); + assert!(input.contains("struct B {")); + assert!(input.contains("#[C]")); + "".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-ctod.rs b/src/test/run-pass/proc-macro/auxiliary/derive-ctod.rs new file mode 100644 index 00000000000..550ffe9400d --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-ctod.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(CToD)] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert_eq!(input, "struct C;"); + "struct D;".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-nothing.rs b/src/test/run-pass/proc-macro/auxiliary/derive-nothing.rs new file mode 100644 index 00000000000..cfe428bf5f3 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-nothing.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Nothing)] +pub fn nothing(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-same-struct.rs b/src/test/run-pass/proc-macro/auxiliary/derive-same-struct.rs new file mode 100644 index 00000000000..cf96f52823f --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-same-struct.rs @@ -0,0 +1,29 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags:--crate-type proc-macro + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(AToB)] +pub fn derive1(input: TokenStream) -> TokenStream { + println!("input1: {:?}", input.to_string()); + assert_eq!(input.to_string(), "struct A;"); + "#[derive(BToC)] struct B;".parse().unwrap() +} + +#[proc_macro_derive(BToC)] +pub fn derive2(input: TokenStream) -> TokenStream { + assert_eq!(input.to_string(), "struct B;"); + "struct C;".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-two-attrs.rs b/src/test/run-pass/proc-macro/auxiliary/derive-two-attrs.rs new file mode 100644 index 00000000000..d02edb50fb2 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-two-attrs.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_derive(A, attributes(b))] +pub fn foo(_x: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/derive-union.rs b/src/test/run-pass/proc-macro/auxiliary/derive-union.rs new file mode 100644 index 00000000000..41bb88a0a92 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/derive-union.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(UnionTest)] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert!(input.contains("#[repr(C)]")); + assert!(input.contains("union Test {")); + assert!(input.contains("a: u8,")); + assert!(input.contains("}")); + "".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/double.rs b/src/test/run-pass/proc-macro/auxiliary/double.rs new file mode 100644 index 00000000000..a6c9817f247 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/double.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +// Outputs another copy of the struct. Useful for testing the tokens +// seen by the proc_macro. +#[proc_macro_derive(Double)] +pub fn derive(input: TokenStream) -> TokenStream { + format!("mod foo {{ {} }}", input.to_string()).parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/empty-crate.rs b/src/test/run-pass/proc-macro/auxiliary/empty-crate.rs new file mode 100644 index 00000000000..b45d4bf41d6 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/empty-crate.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![deny(unused_variables)] diff --git a/src/test/run-pass/proc-macro/auxiliary/expand-with-a-macro.rs b/src/test/run-pass/proc-macro/auxiliary/expand-with-a-macro.rs new file mode 100644 index 00000000000..e6831b6bfdf --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/expand-with-a-macro.rs @@ -0,0 +1,32 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![deny(warnings)] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive(input: TokenStream) -> TokenStream { + let input = input.to_string(); + assert!(input.contains("struct A;")); + r#" + impl A { + fn a(&self) { + panic!("hello"); + } + } + "#.parse().unwrap() +} + diff --git a/src/test/run-pass/proc-macro/auxiliary/external-crate-var.rs b/src/test/run-pass/proc-macro/auxiliary/external-crate-var.rs new file mode 100644 index 00000000000..030c53b3e6f --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/external-crate-var.rs @@ -0,0 +1,51 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub struct ExternFoo; + +pub trait ExternTrait { + const CONST: u32; + type Assoc; +} + +impl ExternTrait for ExternFoo { + const CONST: u32 = 0; + type Assoc = ExternFoo; +} + +#[macro_export] +macro_rules! external { () => { + mod bar { + #[derive(Double)] + struct Bar($crate::ExternFoo); + } + + mod qself { + #[derive(Double)] + struct QSelf(<$crate::ExternFoo as $crate::ExternTrait>::Assoc); + } + + mod qself_recurse { + #[derive(Double)] + struct QSelfRecurse(< + <$crate::ExternFoo as $crate::ExternTrait>::Assoc + as $crate::ExternTrait>::Assoc + ); + } + + mod qself_in_const { + #[derive(Double)] + #[repr(u32)] + enum QSelfInConst { + Variant = <$crate::ExternFoo as $crate::ExternTrait>::CONST, + } + } +} } + diff --git a/src/test/run-pass/proc-macro/auxiliary/gen-lifetime-token.rs b/src/test/run-pass/proc-macro/auxiliary/gen-lifetime-token.rs new file mode 100644 index 00000000000..978de27b70a --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/gen-lifetime-token.rs @@ -0,0 +1,34 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro] +pub fn bar(_input: TokenStream) -> TokenStream { + let mut ret = Vec::::new(); + ret.push(Ident::new("static", Span::call_site()).into()); + ret.push(Ident::new("FOO", Span::call_site()).into()); + ret.push(Punct::new(':', Spacing::Alone).into()); + ret.push(Punct::new('&', Spacing::Alone).into()); + ret.push(Punct::new('\'', Spacing::Joint).into()); + ret.push(Ident::new("static", Span::call_site()).into()); + ret.push(Ident::new("i32", Span::call_site()).into()); + ret.push(Punct::new('=', Spacing::Alone).into()); + ret.push(Punct::new('&', Spacing::Alone).into()); + ret.push(Literal::i32_unsuffixed(1).into()); + ret.push(Punct::new(';', Spacing::Alone).into()); + ret.into_iter().collect() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/hygiene_example.rs b/src/test/run-pass/proc-macro/auxiliary/hygiene_example.rs new file mode 100644 index 00000000000..ca88482064b --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/hygiene_example.rs @@ -0,0 +1,17 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +extern crate hygiene_example_codegen; + +pub use hygiene_example_codegen::hello; + +pub fn print(string: &str) { + println!("{}", string); +} diff --git a/src/test/run-pass/proc-macro/auxiliary/hygiene_example_codegen.rs b/src/test/run-pass/proc-macro/auxiliary/hygiene_example_codegen.rs new file mode 100644 index 00000000000..551ac3863e1 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/hygiene_example_codegen.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![feature(proc_macro_quote, proc_macro_hygiene)] +#![crate_type = "proc-macro"] + +extern crate proc_macro as proc_macro_renamed; // This does not break `quote!` + +use proc_macro_renamed::{TokenStream, quote}; + +#[proc_macro] +pub fn hello(input: TokenStream) -> TokenStream { + quote!(hello_helper!($input)) + //^ `hello_helper!` always resolves to the following proc macro, + //| no matter where `hello!` is used. +} + +#[proc_macro] +pub fn hello_helper(input: TokenStream) -> TokenStream { + quote! { + extern crate hygiene_example; // This is never a conflict error + let string = format!("hello {}", $input); + //^ `format!` always resolves to the prelude macro, + //| even if a different `format!` is in scope where `hello!` is used. + hygiene_example::print(&string) + } +} diff --git a/src/test/run-pass/proc-macro/auxiliary/issue-39889.rs b/src/test/run-pass/proc-macro/auxiliary/issue-39889.rs new file mode 100644 index 00000000000..9094310fb3e --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/issue-39889.rs @@ -0,0 +1,27 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_derive(Issue39889)] +pub fn f(_input: TokenStream) -> TokenStream { + let rules = r#" + macro_rules! id { + ($($tt:tt)*) => { $($tt)* }; + } + "#; + rules.parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/issue-42708.rs b/src/test/run-pass/proc-macro/auxiliary/issue-42708.rs new file mode 100644 index 00000000000..906caceb869 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/issue-42708.rs @@ -0,0 +1,27 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Test)] +pub fn derive(_input: TokenStream) -> TokenStream { + "fn f(s: S) { s.x }".parse().unwrap() +} + +#[proc_macro_attribute] +pub fn attr_test(_attr: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/run-pass/proc-macro/auxiliary/issue-50061.rs b/src/test/run-pass/proc-macro/auxiliary/issue-50061.rs new file mode 100644 index 00000000000..6de17522fc9 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/issue-50061.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn check(_a: TokenStream, b: TokenStream) -> TokenStream { + b.into_iter().collect() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/lifetimes.rs b/src/test/run-pass/proc-macro/auxiliary/lifetimes.rs new file mode 100644 index 00000000000..0ee26b6a1b9 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/lifetimes.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro] +pub fn lifetimes_bang(input: TokenStream) -> TokenStream { + // Roundtrip through token trees + input.into_iter().collect() +} + +#[proc_macro_attribute] +pub fn lifetimes_attr(_: TokenStream, input: TokenStream) -> TokenStream { + // Roundtrip through AST + input +} + +#[proc_macro_derive(Lifetimes)] +pub fn lifetimes_derive(input: TokenStream) -> TokenStream { + // Roundtrip through a string + format!("mod m {{ {} }}", input).parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/modify-ast.rs b/src/test/run-pass/proc-macro/auxiliary/modify-ast.rs new file mode 100644 index 00000000000..498c6811d9c --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/modify-ast.rs @@ -0,0 +1,56 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_attribute] +pub fn assert1(_a: TokenStream, b: TokenStream) -> TokenStream { + assert_eq(b.clone(), "pub fn foo() {}".parse().unwrap()); + b +} + +#[proc_macro_derive(Foo, attributes(foo))] +pub fn assert2(a: TokenStream) -> TokenStream { + assert_eq(a, "pub struct MyStructc { _a: i32, }".parse().unwrap()); + TokenStream::new() +} + +fn assert_eq(a: TokenStream, b: TokenStream) { + let mut a = a.into_iter(); + let mut b = b.into_iter(); + for (a, b) in a.by_ref().zip(&mut b) { + match (a, b) { + (TokenTree::Group(a), TokenTree::Group(b)) => { + assert_eq!(a.delimiter(), b.delimiter()); + assert_eq(a.stream(), b.stream()); + } + (TokenTree::Punct(a), TokenTree::Punct(b)) => { + assert_eq!(a.as_char(), b.as_char()); + assert_eq!(a.spacing(), b.spacing()); + } + (TokenTree::Literal(a), TokenTree::Literal(b)) => { + assert_eq!(a.to_string(), b.to_string()); + } + (TokenTree::Ident(a), TokenTree::Ident(b)) => { + assert_eq!(a.to_string(), b.to_string()); + } + (a, b) => panic!("{:?} != {:?}", a, b), + } + } + + assert!(a.next().is_none()); + assert!(b.next().is_none()); +} diff --git a/src/test/run-pass/proc-macro/auxiliary/negative-token.rs b/src/test/run-pass/proc-macro/auxiliary/negative-token.rs new file mode 100644 index 00000000000..fd639696991 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/negative-token.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro] +pub fn neg_one(_input: TokenStream) -> TokenStream { + TokenTree::Literal(Literal::i32_suffixed(-1)).into() +} + +#[proc_macro] +pub fn neg_one_float(_input: TokenStream) -> TokenStream { + TokenTree::Literal(Literal::f32_suffixed(-1.0)).into() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/not-joint.rs b/src/test/run-pass/proc-macro/auxiliary/not-joint.rs new file mode 100644 index 00000000000..e00a4d89e8d --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/not-joint.rs @@ -0,0 +1,39 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro] +pub fn tokens(input: TokenStream) -> TokenStream { + assert_nothing_joint(input); + TokenStream::new() +} + +#[proc_macro_attribute] +pub fn nothing(_: TokenStream, input: TokenStream) -> TokenStream { + assert_nothing_joint(input); + TokenStream::new() +} + +fn assert_nothing_joint(s: TokenStream) { + for tt in s { + match tt { + TokenTree::Group(g) => assert_nothing_joint(g.stream()), + TokenTree::Punct(p) => assert_eq!(p.spacing(), Spacing::Alone), + _ => {} + } + } +} diff --git a/src/test/run-pass/proc-macro/auxiliary/span-api-tests.rs b/src/test/run-pass/proc-macro/auxiliary/span-api-tests.rs new file mode 100644 index 00000000000..8e2c5c0a088 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/span-api-tests.rs @@ -0,0 +1,45 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_span)] + +extern crate proc_macro; + +use proc_macro::*; + +// Re-emits the input tokens by parsing them from strings +#[proc_macro] +pub fn reemit(input: TokenStream) -> TokenStream { + input.to_string().parse().unwrap() +} + +#[proc_macro] +pub fn assert_fake_source_file(input: TokenStream) -> TokenStream { + for tk in input { + let source_file = tk.span().source_file(); + assert!(!source_file.is_real(), "Source file is real: {:?}", source_file); + } + + "".parse().unwrap() +} + +#[proc_macro] +pub fn assert_source_file(input: TokenStream) -> TokenStream { + for tk in input { + let source_file = tk.span().source_file(); + assert!(source_file.is_real(), "Source file is not real: {:?}", source_file); + } + + "".parse().unwrap() +} diff --git a/src/test/run-pass/proc-macro/auxiliary/span-test-macros.rs b/src/test/run-pass/proc-macro/auxiliary/span-test-macros.rs new file mode 100644 index 00000000000..b4666e2cb61 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/span-test-macros.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[macro_export] +macro_rules! reemit_legacy { + ($($tok:tt)*) => ($($tok)*) +} + +#[macro_export] +macro_rules! say_hello_extern { + ($macname:ident) => ( $macname! { "Hello, world!" }) +} diff --git a/src/test/run-pass/proc-macro/auxiliary/test-macros.rs b/src/test/run-pass/proc-macro/auxiliary/test-macros.rs new file mode 100644 index 00000000000..581c7cb15a5 --- /dev/null +++ b/src/test/run-pass/proc-macro/auxiliary/test-macros.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn nop_attr(_attr: TokenStream, input: TokenStream) -> TokenStream { + assert!(_attr.to_string().is_empty()); + input +} + +#[proc_macro_attribute] +pub fn no_output(_attr: TokenStream, _input: TokenStream) -> TokenStream { + assert!(_attr.to_string().is_empty()); + assert!(!_input.to_string().is_empty()); + "".parse().unwrap() +} + +#[proc_macro] +pub fn emit_input(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/run-pass/proc-macro/bang-macro.rs b/src/test/run-pass/proc-macro/bang-macro.rs new file mode 100644 index 00000000000..f433bc64c6e --- /dev/null +++ b/src/test/run-pass/proc-macro/bang-macro.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:bang-macro.rs + +#![feature(proc_macro_hygiene)] + +extern crate bang_macro; +use bang_macro::rewrite; + +fn main() { + assert_eq!(rewrite!("Hello, world!"), "NOT Hello, world!"); +} diff --git a/src/test/run-pass/proc-macro/call-site.rs b/src/test/run-pass/proc-macro/call-site.rs new file mode 100644 index 00000000000..ccbf33cc73b --- /dev/null +++ b/src/test/run-pass/proc-macro/call-site.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_variables)] +#![allow(unused_imports)] +// aux-build:call-site.rs + +#![feature(proc_macro_hygiene)] + +extern crate call_site; +use call_site::*; + +fn main() { + let x1 = 10; + call_site::check!(let x2 = x1;); + let x6 = x5; +} diff --git a/src/test/run-pass/proc-macro/count_compound_ops.rs b/src/test/run-pass/proc-macro/count_compound_ops.rs new file mode 100644 index 00000000000..46a5906e46a --- /dev/null +++ b/src/test/run-pass/proc-macro/count_compound_ops.rs @@ -0,0 +1,20 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:count_compound_ops.rs + +#![feature(proc_macro_hygiene)] + +extern crate count_compound_ops; +use count_compound_ops::count_compound_ops; + +fn main() { + assert_eq!(count_compound_ops!(foo<=>bar << or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:double.rs +// aux-build:external-crate-var.rs + +#![allow(unused)] + +#[macro_use] +extern crate double; +#[macro_use] +extern crate external_crate_var; + +struct Foo; + +trait Trait { + const CONST: u32; + type Assoc; +} + +impl Trait for Foo { + const CONST: u32 = 0; + type Assoc = Foo; +} + +macro_rules! local { () => { + // derive_Double outputs secondary copies of each definition + // to test what the proc_macro sees. + mod bar { + #[derive(Double)] + struct Bar($crate::Foo); + } + + mod qself { + #[derive(Double)] + struct QSelf(<::Foo as $crate::Trait>::Assoc); + } + + mod qself_recurse { + #[derive(Double)] + struct QSelfRecurse(<<$crate::Foo as $crate::Trait>::Assoc as $crate::Trait>::Assoc); + } + + mod qself_in_const { + #[derive(Double)] + #[repr(u32)] + enum QSelfInConst { + Variant = <::Foo as $crate::Trait>::CONST, + } + } +} } + +mod local { + local!(); +} + +// and now repeat the above tests, using a macro defined in another crate + +mod external { + external!{} +} + +fn main() {} diff --git a/src/test/run-pass/proc-macro/custom-attr-only-one-derive.rs b/src/test/run-pass/proc-macro/custom-attr-only-one-derive.rs new file mode 100644 index 00000000000..3b2833a4bcf --- /dev/null +++ b/src/test/run-pass/proc-macro/custom-attr-only-one-derive.rs @@ -0,0 +1,25 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:custom-attr-only-one-derive.rs + +#![feature(rust_2018_preview)] + +#[macro_use] +extern crate custom_attr_only_one_derive; + +#[derive(Bar, Foo)] +#[custom = "test"] +pub enum A { + B, + C, +} + +fn main() {} diff --git a/src/test/run-pass/proc-macro/derive-attr-cfg.rs b/src/test/run-pass/proc-macro/derive-attr-cfg.rs new file mode 100644 index 00000000000..f804042374d --- /dev/null +++ b/src/test/run-pass/proc-macro/derive-attr-cfg.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +// aux-build:derive-attr-cfg.rs + +extern crate derive_attr_cfg; +use derive_attr_cfg::Foo; + +#[derive(Foo)] +#[foo] +struct S { + #[cfg(any())] + x: i32 +} + +fn main() { +} diff --git a/src/test/run-pass/proc-macro/derive-b.rs b/src/test/run-pass/proc-macro/derive-b.rs new file mode 100644 index 00000000000..60a6cf7662d --- /dev/null +++ b/src/test/run-pass/proc-macro/derive-b.rs @@ -0,0 +1,30 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-b.rs + +#![feature(unrestricted_attribute_tokens)] + +extern crate derive_b; + +#[derive(Debug, PartialEq, derive_b::B, Eq, Copy, Clone)] +#[cfg_attr(all(), B[arbitrary tokens])] +struct B { + #[C] + a: u64 +} + +fn main() { + B { a: 3 }; + assert_eq!(B { a: 3 }, B { a: 3 }); + let b = B { a: 3 }; + let _d = b; + let _e = b; +} diff --git a/src/test/run-pass/proc-macro/derive-same-struct.rs b/src/test/run-pass/proc-macro/derive-same-struct.rs new file mode 100644 index 00000000000..7aff32e16ce --- /dev/null +++ b/src/test/run-pass/proc-macro/derive-same-struct.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(path_statements)] +#![allow(dead_code)] +// aux-build:derive-same-struct.rs + +#[macro_use] +extern crate derive_same_struct; + +#[derive(AToB)] +struct A; + +fn main() { + C; +} diff --git a/src/test/run-pass/proc-macro/derive-same-struct.stdout b/src/test/run-pass/proc-macro/derive-same-struct.stdout new file mode 100644 index 00000000000..77605de5e33 --- /dev/null +++ b/src/test/run-pass/proc-macro/derive-same-struct.stdout @@ -0,0 +1 @@ +input1: "struct A;" diff --git a/src/test/run-pass/proc-macro/derive-test.rs b/src/test/run-pass/proc-macro/derive-test.rs new file mode 100644 index 00000000000..5a53a4e8db3 --- /dev/null +++ b/src/test/run-pass/proc-macro/derive-test.rs @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// compile-flags: --test + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +// ``` +// assert!(true); +// ``` +#[proc_macro_derive(Foo)] +pub fn derive_foo(_input: TokenStream) -> TokenStream { + "".parse().unwrap() +} + +#[test] +pub fn test_derive() { + assert!(true); +} diff --git a/src/test/run-pass/proc-macro/derive-two-attrs.rs b/src/test/run-pass/proc-macro/derive-two-attrs.rs new file mode 100644 index 00000000000..9c2ba481f5e --- /dev/null +++ b/src/test/run-pass/proc-macro/derive-two-attrs.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +// aux-build:derive-two-attrs.rs + +extern crate derive_two_attrs as foo; + +use foo::A; + +#[derive(A)] +#[b] +#[b] +struct B; + +fn main() {} diff --git a/src/test/run-pass/proc-macro/derive-union.rs b/src/test/run-pass/proc-macro/derive-union.rs new file mode 100644 index 00000000000..2aae1d8635f --- /dev/null +++ b/src/test/run-pass/proc-macro/derive-union.rs @@ -0,0 +1,25 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_variables)] +// aux-build:derive-union.rs + +#[macro_use] +extern crate derive_union; + +#[repr(C)] +#[derive(UnionTest)] +union Test { + a: u8, +} + +fn main() { + let t = Test { a: 0 }; +} diff --git a/src/test/run-pass/proc-macro/empty-crate.rs b/src/test/run-pass/proc-macro/empty-crate.rs new file mode 100644 index 00000000000..1a0c0506112 --- /dev/null +++ b/src/test/run-pass/proc-macro/empty-crate.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_imports)] +// aux-build:empty-crate.rs + +#[macro_use] +extern crate empty_crate; + +fn main() {} diff --git a/src/test/run-pass/proc-macro/expand-with-a-macro.rs b/src/test/run-pass/proc-macro/expand-with-a-macro.rs new file mode 100644 index 00000000000..6a0669c4bb2 --- /dev/null +++ b/src/test/run-pass/proc-macro/expand-with-a-macro.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:expand-with-a-macro.rs + +#![deny(warnings)] + +#[macro_use] +extern crate expand_with_a_macro; + +use std::panic; + +#[derive(A)] +struct A; + +fn main() { + assert!(panic::catch_unwind(|| { + A.a(); + }).is_err()); +} + diff --git a/src/test/run-pass/proc-macro/gen-lifetime-token.rs b/src/test/run-pass/proc-macro/gen-lifetime-token.rs new file mode 100644 index 00000000000..ce2fed86e46 --- /dev/null +++ b/src/test/run-pass/proc-macro/gen-lifetime-token.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:gen-lifetime-token.rs + +extern crate gen_lifetime_token as bar; + +bar::bar!(); + +fn main() { + let x: &'static i32 = FOO; + assert_eq!(*x, 1); +} diff --git a/src/test/run-pass/proc-macro/hygiene_example.rs b/src/test/run-pass/proc-macro/hygiene_example.rs new file mode 100644 index 00000000000..41857fde269 --- /dev/null +++ b/src/test/run-pass/proc-macro/hygiene_example.rs @@ -0,0 +1,28 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_macros)] +// aux-build:hygiene_example_codegen.rs +// aux-build:hygiene_example.rs + +#![feature(proc_macro_hygiene)] + +extern crate hygiene_example; +use hygiene_example::hello; + +fn main() { + mod hygiene_example {} // no conflict with `extern crate hygiene_example;` from the proc macro + macro_rules! format { () => {} } // does not interfere with `format!` from the proc macro + macro_rules! hello_helper { () => {} } // similarly does not intefere with the proc macro + + let string = "world"; // no conflict with `string` from the proc macro + hello!(string); + hello!(string); +} diff --git a/src/test/run-pass/proc-macro/issue-39889.rs b/src/test/run-pass/proc-macro/issue-39889.rs new file mode 100644 index 00000000000..99500a77f09 --- /dev/null +++ b/src/test/run-pass/proc-macro/issue-39889.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +// aux-build:issue-39889.rs + +extern crate issue_39889; +use issue_39889::Issue39889; + +#[derive(Issue39889)] +struct S; + +fn main() {} diff --git a/src/test/run-pass/proc-macro/issue-42708.rs b/src/test/run-pass/proc-macro/issue-42708.rs new file mode 100644 index 00000000000..8f9c8723953 --- /dev/null +++ b/src/test/run-pass/proc-macro/issue-42708.rs @@ -0,0 +1,35 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-42708.rs + +#![feature(decl_macro)] +#![allow(unused)] + +extern crate issue_42708; + +macro m() { + #[derive(issue_42708::Test)] + struct S { x: () } + + #[issue_42708::attr_test] + struct S2 { x: () } + + #[derive(Clone)] + struct S3 { x: () } + + fn g(s: S, s2: S2, s3: S3) { + (s.x, s2.x, s3.x); + } +} + +m!(); + +fn main() {} diff --git a/src/test/run-pass/proc-macro/issue-50061.rs b/src/test/run-pass/proc-macro/issue-50061.rs new file mode 100644 index 00000000000..1a751161a44 --- /dev/null +++ b/src/test/run-pass/proc-macro/issue-50061.rs @@ -0,0 +1,31 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(path_statements)] +// aux-build:issue-50061.rs + +#![feature(decl_macro)] + +extern crate issue_50061; + +macro inner(any_token $v: tt) { + $v +} + +macro outer($v: tt) { + inner!(any_token $v) +} + +#[issue_50061::check] +fn main() { + //! this doc comment forces roundtrip through a string + let checkit = 0; + outer!(checkit); +} diff --git a/src/test/run-pass/proc-macro/lifetimes.rs b/src/test/run-pass/proc-macro/lifetimes.rs new file mode 100644 index 00000000000..7cd234df650 --- /dev/null +++ b/src/test/run-pass/proc-macro/lifetimes.rs @@ -0,0 +1,34 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_variables)] +// aux-build:lifetimes.rs + +extern crate lifetimes; +use lifetimes::*; + +lifetimes_bang! { + fn bang<'a>() -> &'a u8 { &0 } +} + +#[lifetimes_attr] +fn attr<'a>() -> &'a u8 { &1 } + +#[derive(Lifetimes)] +pub struct Lifetimes<'a> { + pub field: &'a u8, +} + +fn main() { + assert_eq!(bang::<'static>(), &0); + assert_eq!(attr::<'static>(), &1); + let l1 = Lifetimes { field: &0 }; + let l2 = m::Lifetimes { field: &1 }; +} diff --git a/src/test/run-pass/proc-macro/load-two.rs b/src/test/run-pass/proc-macro/load-two.rs new file mode 100644 index 00000000000..319e99d4e44 --- /dev/null +++ b/src/test/run-pass/proc-macro/load-two.rs @@ -0,0 +1,31 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(path_statements)] +#![allow(dead_code)] +// aux-build:derive-atob.rs +// aux-build:derive-ctod.rs + +#[macro_use] +extern crate derive_atob; +#[macro_use] +extern crate derive_ctod; + +#[derive(Copy, Clone)] +#[derive(AToB)] +struct A; + +#[derive(CToD)] +struct C; + +fn main() { + B; + D; +} diff --git a/src/test/run-pass/proc-macro/macros-in-extern.rs b/src/test/run-pass/proc-macro/macros-in-extern.rs new file mode 100644 index 00000000000..ce62cabf281 --- /dev/null +++ b/src/test/run-pass/proc-macro/macros-in-extern.rs @@ -0,0 +1,34 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:test-macros.rs +// ignore-wasm32 + +#![feature(macros_in_extern)] + +extern crate test_macros; + +use test_macros::{nop_attr, no_output, emit_input}; + +fn main() { + assert_eq!(unsafe { rust_get_test_int() }, 1isize); + assert_eq!(unsafe { rust_dbg_extern_identity_u32(0xDEADBEEF) }, 0xDEADBEEF); +} + +#[link(name = "rust_test_helpers", kind = "static")] +extern { + #[no_output] + fn some_definitely_unknown_symbol_which_should_be_removed(); + + #[nop_attr] + fn rust_get_test_int() -> isize; + + emit_input!(fn rust_dbg_extern_identity_u32(arg: u32) -> u32;); +} diff --git a/src/test/run-pass/proc-macro/modify-ast.rs b/src/test/run-pass/proc-macro/modify-ast.rs new file mode 100644 index 00000000000..d6f7cc4699a --- /dev/null +++ b/src/test/run-pass/proc-macro/modify-ast.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:modify-ast.rs + +extern crate modify_ast; + +use modify_ast::*; + +#[derive(Foo)] +pub struct MyStructc { + #[cfg_attr(my_cfg, foo)] + _a: i32, +} + +macro_rules! a { + ($i:item) => ($i) +} + +a! { + #[assert1] + pub fn foo() {} +} + +fn main() { + let _a = MyStructc { _a: 0 }; + foo(); +} diff --git a/src/test/run-pass/proc-macro/negative-token.rs b/src/test/run-pass/proc-macro/negative-token.rs new file mode 100644 index 00000000000..f953ba8df7e --- /dev/null +++ b/src/test/run-pass/proc-macro/negative-token.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:negative-token.rs + +#![feature(proc_macro_hygiene)] + +extern crate negative_token; + +use negative_token::*; + +fn main() { + assert_eq!(-1, neg_one!()); + assert_eq!(-1.0, neg_one_float!()); +} diff --git a/src/test/run-pass/proc-macro/not-joint.rs b/src/test/run-pass/proc-macro/not-joint.rs new file mode 100644 index 00000000000..7a53348f963 --- /dev/null +++ b/src/test/run-pass/proc-macro/not-joint.rs @@ -0,0 +1,33 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:not-joint.rs + +extern crate not_joint as bar; +use bar::{tokens, nothing}; + +tokens![< -]; + +#[nothing] +a![< -]; + +#[nothing] +b!{< -} + +#[nothing] +c!(< -); + +#[nothing] +fn foo() { + //! dox + let x = 2 < - 3; +} + +fn main() {} diff --git a/src/test/run-pass/proc-macro/smoke.rs b/src/test/run-pass/proc-macro/smoke.rs new file mode 100644 index 00000000000..ba0cd3b398d --- /dev/null +++ b/src/test/run-pass/proc-macro/smoke.rs @@ -0,0 +1,28 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(unused_must_use)] +#![allow(path_statements)] +// aux-build:derive-a.rs + +#[macro_use] +extern crate derive_a; + +#[derive(Debug, PartialEq, A, Eq, Copy, Clone)] +struct A; + +fn main() { + A; + assert_eq!(A, A); + A.clone(); + let a = A; + let _c = a; + let _d = a; +} diff --git a/src/test/run-pass/proc-macro/span-api-tests.rs b/src/test/run-pass/proc-macro/span-api-tests.rs new file mode 100644 index 00000000000..415cada265e --- /dev/null +++ b/src/test/run-pass/proc-macro/span-api-tests.rs @@ -0,0 +1,41 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:span-api-tests.rs +// aux-build:span-test-macros.rs + +// ignore-pretty + +#[macro_use] +extern crate span_test_macros; + +extern crate span_api_tests; + +use span_api_tests::{reemit, assert_fake_source_file, assert_source_file}; + +macro_rules! say_hello { + ($macname:ident) => ( $macname! { "Hello, world!" }) +} + +assert_source_file! { "Hello, world!" } + +say_hello! { assert_source_file } + +reemit_legacy! { + assert_source_file! { "Hello, world!" } +} + +say_hello_extern! { assert_fake_source_file } + +reemit! { + assert_source_file! { "Hello, world!" } +} + +fn main() {} diff --git a/src/test/run-pass/proc-macro/struct-field-macro.rs b/src/test/run-pass/proc-macro/struct-field-macro.rs new file mode 100644 index 00000000000..b1ac8038fa2 --- /dev/null +++ b/src/test/run-pass/proc-macro/struct-field-macro.rs @@ -0,0 +1,26 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![allow(dead_code)] +// aux-build:derive-nothing.rs + +#[macro_use] +extern crate derive_nothing; + +macro_rules! int { + () => { i32 } +} + +#[derive(Nothing)] +struct S { + x: int!(), +} + +fn main() {} diff --git a/src/test/run-pass/proc_macro.rs b/src/test/run-pass/proc_macro.rs new file mode 100644 index 00000000000..e14ceca8e42 --- /dev/null +++ b/src/test/run-pass/proc_macro.rs @@ -0,0 +1,48 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:proc_macro_def.rs +// ignore-cross-compile + +#![feature(proc_macro_hygiene)] + +extern crate proc_macro_def; + +use proc_macro_def::{attr_tru, attr_identity, identity, ret_tru, tru}; + +#[attr_tru] +fn f1() -> bool { + return false; +} + +#[attr_identity] +fn f2() -> bool { + return identity!(true); +} + +fn f3() -> identity!(bool) { + ret_tru!(); +} + +fn f4(x: bool) -> bool { + match x { + identity!(true) => false, + identity!(false) => true, + } +} + +fn main() { + assert!(f1()); + assert!(f2()); + assert!(tru!()); + assert!(f3()); + assert!(identity!(5 == 5)); + assert!(f4(false)); +} diff --git a/src/test/ui-fulldeps/attribute-order-restricted.rs b/src/test/ui-fulldeps/attribute-order-restricted.rs deleted file mode 100644 index 7b1eecd1558..00000000000 --- a/src/test/ui-fulldeps/attribute-order-restricted.rs +++ /dev/null @@ -1,14 +0,0 @@ -// aux-build:attr_proc_macro.rs - -extern crate attr_proc_macro; -use attr_proc_macro::*; - -#[attr_proc_macro] // OK -#[derive(Clone)] -struct Before; - -#[derive(Clone)] -#[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]` -struct After; - -fn main() {} diff --git a/src/test/ui-fulldeps/attribute-order-restricted.stderr b/src/test/ui-fulldeps/attribute-order-restricted.stderr deleted file mode 100644 index a4f165cd1b5..00000000000 --- a/src/test/ui-fulldeps/attribute-order-restricted.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: macro attributes must be placed before `#[derive]` - --> $DIR/attribute-order-restricted.rs:11:1 - | -LL | #[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]` - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs b/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs deleted file mode 100644 index 679cb772868..00000000000 --- a/src/test/ui-fulldeps/auxiliary/attr_proc_macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs b/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs deleted file mode 100644 index 6484725814a..00000000000 --- a/src/test/ui-fulldeps/auxiliary/bang_proc_macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro] -pub fn bang_proc_macro(input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/ui-fulldeps/auxiliary/derive-clona.rs b/src/test/ui-fulldeps/auxiliary/derive-clona.rs deleted file mode 100644 index 719fbdb15ef..00000000000 --- a/src/test/ui-fulldeps/auxiliary/derive-clona.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Clona)] -pub fn derive_clonea(input: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/ui-fulldeps/auxiliary/derive-foo.rs b/src/test/ui-fulldeps/auxiliary/derive-foo.rs deleted file mode 100644 index 64dcf72ba20..00000000000 --- a/src/test/ui-fulldeps/auxiliary/derive-foo.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(FooWithLongName)] -pub fn derive_foo(input: TokenStream) -> TokenStream { - "".parse().unwrap() -} diff --git a/src/test/ui-fulldeps/auxiliary/invalid-punct-ident.rs b/src/test/ui-fulldeps/auxiliary/invalid-punct-ident.rs deleted file mode 100644 index cc899fa610d..00000000000 --- a/src/test/ui-fulldeps/auxiliary/invalid-punct-ident.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_raw_ident)] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro] -pub fn invalid_punct(_: TokenStream) -> TokenStream { - TokenTree::from(Punct::new('`', Spacing::Alone)).into() -} - -#[proc_macro] -pub fn invalid_ident(_: TokenStream) -> TokenStream { - TokenTree::from(Ident::new("*", Span::call_site())).into() -} - -#[proc_macro] -pub fn invalid_raw_ident(_: TokenStream) -> TokenStream { - TokenTree::from(Ident::new_raw("self", Span::call_site())).into() -} - -#[proc_macro] -pub fn lexer_failure(_: TokenStream) -> TokenStream { - "a b ) c".parse().expect("parsing failed without panic") -} diff --git a/src/test/ui-fulldeps/auxiliary/lifetimes.rs b/src/test/ui-fulldeps/auxiliary/lifetimes.rs deleted file mode 100644 index fc59a622bfa..00000000000 --- a/src/test/ui-fulldeps/auxiliary/lifetimes.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro] -pub fn single_quote_alone(_: TokenStream) -> TokenStream { - // `&'a u8`, but the `'` token is not joint - let trees: Vec = vec![ - Punct::new('&', Spacing::Alone).into(), - Punct::new('\'', Spacing::Alone).into(), - Ident::new("a", Span::call_site()).into(), - Ident::new("u8", Span::call_site()).into(), - ]; - trees.into_iter().collect() -} diff --git a/src/test/ui-fulldeps/auxiliary/subspan.rs b/src/test/ui-fulldeps/auxiliary/subspan.rs deleted file mode 100644 index 134b04d7333..00000000000 --- a/src/test/ui-fulldeps/auxiliary/subspan.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_diagnostic, proc_macro_span)] - -extern crate proc_macro; - -use proc_macro::{TokenStream, TokenTree, Span, Diagnostic}; - -fn parse(input: TokenStream) -> Result<(), Diagnostic> { - if let Some(TokenTree::Literal(lit)) = input.into_iter().next() { - let mut spans = vec![]; - let string = lit.to_string(); - for hi in string.matches("hi") { - let index = hi.as_ptr() as usize - string.as_ptr() as usize; - let subspan = lit.subspan(index..(index + hi.len())).unwrap(); - spans.push(subspan); - } - - if !spans.is_empty() { - Err(Span::call_site().error("found 'hi's").span_note(spans, "here")) - } else { - Ok(()) - } - } else { - Err(Span::call_site().error("invalid input: expected string literal")) - } -} - -#[proc_macro] -pub fn subspan(input: TokenStream) -> TokenStream { - if let Err(diag) = parse(input) { - diag.emit(); - } - - TokenStream::new() -} diff --git a/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs b/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs deleted file mode 100644 index 124bc05b7a3..00000000000 --- a/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Foo)] -pub fn derive_foo(input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_derive(Bar)] -pub fn derive_bar(input: TokenStream) -> TokenStream { - panic!("lolnope"); -} - -#[proc_macro_derive(WithHelper, attributes(helper))] -pub fn with_helper(input: TokenStream) -> TokenStream { - TokenStream::new() -} - -#[proc_macro_attribute] -pub fn helper(_: TokenStream, input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/ui-fulldeps/custom-derive/derive-in-mod.rs b/src/test/ui-fulldeps/custom-derive/derive-in-mod.rs deleted file mode 100644 index 8478ff1a6ae..00000000000 --- a/src/test/ui-fulldeps/custom-derive/derive-in-mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -// compile-pass -// aux-build:plugin.rs - -extern crate plugin; - -mod inner { - use plugin::WithHelper; - - #[derive(WithHelper)] - struct S; -} - -fn main() {} diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs deleted file mode 100644 index ba072ba3568..00000000000 --- a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs +++ /dev/null @@ -1,12 +0,0 @@ -// aux-build:plugin.rs - -#[macro_use(WithHelper)] -extern crate plugin; - -use plugin::helper; - -#[derive(WithHelper)] -#[helper] //~ ERROR `helper` is ambiguous -struct S; - -fn main() {} diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr deleted file mode 100644 index 2c9d226cc9e..00000000000 --- a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0659]: `helper` is ambiguous (derive helper attribute vs any other name) - --> $DIR/helper-attr-blocked-by-import-ambig.rs:9:3 - | -LL | #[helper] //~ ERROR `helper` is ambiguous - | ^^^^^^ ambiguous name - | -note: `helper` could refer to the derive helper attribute defined here - --> $DIR/helper-attr-blocked-by-import-ambig.rs:8:10 - | -LL | #[derive(WithHelper)] - | ^^^^^^^^^^ -note: `helper` could also refer to the attribute macro imported here - --> $DIR/helper-attr-blocked-by-import-ambig.rs:6:5 - | -LL | use plugin::helper; - | ^^^^^^^^^^^^^^ - = help: use `crate::helper` to refer to this attribute macro unambiguously - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs deleted file mode 100644 index abbf014f553..00000000000 --- a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs +++ /dev/null @@ -1,28 +0,0 @@ -// compile-pass -// aux-build:plugin.rs - -#[macro_use(WithHelper)] -extern crate plugin; - -use self::one::*; -use self::two::*; - -mod helper {} - -mod one { - use helper; - - #[derive(WithHelper)] - #[helper] - struct One; -} - -mod two { - use helper; - - #[derive(WithHelper)] - #[helper] - struct Two; -} - -fn main() {} diff --git a/src/test/ui-fulldeps/custom-derive/issue-36935.rs b/src/test/ui-fulldeps/custom-derive/issue-36935.rs deleted file mode 100644 index 92c47eba9ad..00000000000 --- a/src/test/ui-fulldeps/custom-derive/issue-36935.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:plugin.rs - - -#[macro_use] extern crate plugin; - -#[derive(Foo, Bar)] //~ ERROR proc-macro derive panicked -struct Baz { - a: i32, - b: i32, -} - -fn main() {} diff --git a/src/test/ui-fulldeps/custom-derive/issue-36935.stderr b/src/test/ui-fulldeps/custom-derive/issue-36935.stderr deleted file mode 100644 index ecbe0a9a0c0..00000000000 --- a/src/test/ui-fulldeps/custom-derive/issue-36935.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: proc-macro derive panicked - --> $DIR/issue-36935.rs:16:15 - | -LL | #[derive(Foo, Bar)] //~ ERROR proc-macro derive panicked - | ^^^ - | - = help: message: lolnope - -error: aborting due to previous error - diff --git a/src/test/ui-fulldeps/invalid-punct-ident-1.rs b/src/test/ui-fulldeps/invalid-punct-ident-1.rs deleted file mode 100644 index 576c156c105..00000000000 --- a/src/test/ui-fulldeps/invalid-punct-ident-1.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:invalid-punct-ident.rs - -#[macro_use] -extern crate invalid_punct_ident; - -invalid_punct!(); //~ ERROR proc macro panicked diff --git a/src/test/ui-fulldeps/invalid-punct-ident-1.stderr b/src/test/ui-fulldeps/invalid-punct-ident-1.stderr deleted file mode 100644 index 3b3619e2637..00000000000 --- a/src/test/ui-fulldeps/invalid-punct-ident-1.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: proc macro panicked - --> $DIR/invalid-punct-ident-1.rs:16:1 - | -LL | invalid_punct!(); //~ ERROR proc macro panicked - | ^^^^^^^^^^^^^^^^^ - | - = help: message: unsupported character `'`'` - -error: aborting due to previous error - diff --git a/src/test/ui-fulldeps/invalid-punct-ident-2.rs b/src/test/ui-fulldeps/invalid-punct-ident-2.rs deleted file mode 100644 index 874a7d169d1..00000000000 --- a/src/test/ui-fulldeps/invalid-punct-ident-2.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:invalid-punct-ident.rs - -#[macro_use] -extern crate invalid_punct_ident; - -invalid_ident!(); //~ ERROR proc macro panicked diff --git a/src/test/ui-fulldeps/invalid-punct-ident-2.stderr b/src/test/ui-fulldeps/invalid-punct-ident-2.stderr deleted file mode 100644 index 869c0908bb5..00000000000 --- a/src/test/ui-fulldeps/invalid-punct-ident-2.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: proc macro panicked - --> $DIR/invalid-punct-ident-2.rs:16:1 - | -LL | invalid_ident!(); //~ ERROR proc macro panicked - | ^^^^^^^^^^^^^^^^^ - | - = help: message: `"*"` is not a valid identifier - -error: aborting due to previous error - diff --git a/src/test/ui-fulldeps/invalid-punct-ident-3.rs b/src/test/ui-fulldeps/invalid-punct-ident-3.rs deleted file mode 100644 index f73bf500545..00000000000 --- a/src/test/ui-fulldeps/invalid-punct-ident-3.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:invalid-punct-ident.rs - -#[macro_use] -extern crate invalid_punct_ident; - -invalid_raw_ident!(); //~ ERROR proc macro panicked diff --git a/src/test/ui-fulldeps/invalid-punct-ident-3.stderr b/src/test/ui-fulldeps/invalid-punct-ident-3.stderr deleted file mode 100644 index 716f6ffa098..00000000000 --- a/src/test/ui-fulldeps/invalid-punct-ident-3.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: proc macro panicked - --> $DIR/invalid-punct-ident-3.rs:16:1 - | -LL | invalid_raw_ident!(); //~ ERROR proc macro panicked - | ^^^^^^^^^^^^^^^^^^^^^ - | - = help: message: `"self"` is not a valid raw identifier - -error: aborting due to previous error - diff --git a/src/test/ui-fulldeps/invalid-punct-ident-4.rs b/src/test/ui-fulldeps/invalid-punct-ident-4.rs deleted file mode 100644 index 1e93c69c650..00000000000 --- a/src/test/ui-fulldeps/invalid-punct-ident-4.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:invalid-punct-ident.rs - -#[macro_use] -extern crate invalid_punct_ident; - -lexer_failure!(); //~ ERROR proc macro panicked - //~| ERROR unexpected close delimiter: `)` diff --git a/src/test/ui-fulldeps/invalid-punct-ident-4.stderr b/src/test/ui-fulldeps/invalid-punct-ident-4.stderr deleted file mode 100644 index 669a1eb5839..00000000000 --- a/src/test/ui-fulldeps/invalid-punct-ident-4.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unexpected close delimiter: `)` - --> $DIR/invalid-punct-ident-4.rs:16:1 - | -LL | lexer_failure!(); //~ ERROR proc macro panicked - | ^^^^^^^^^^^^^^^^^ unexpected close delimiter - -error: proc macro panicked - --> $DIR/invalid-punct-ident-4.rs:16:1 - | -LL | lexer_failure!(); //~ ERROR proc macro panicked - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui-fulldeps/lifetimes.rs b/src/test/ui-fulldeps/lifetimes.rs deleted file mode 100644 index ff6464a7a3a..00000000000 --- a/src/test/ui-fulldeps/lifetimes.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:lifetimes.rs - -#![feature(proc_macro_hygiene)] - -extern crate lifetimes; - -use lifetimes::*; - -type A = single_quote_alone!(); //~ ERROR expected type, found `'` diff --git a/src/test/ui-fulldeps/lifetimes.stderr b/src/test/ui-fulldeps/lifetimes.stderr deleted file mode 100644 index 6baf2b16998..00000000000 --- a/src/test/ui-fulldeps/lifetimes.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected type, found `'` - --> $DIR/lifetimes.rs:19:10 - | -LL | type A = single_quote_alone!(); //~ ERROR expected type, found `'` - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.rs b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.rs deleted file mode 100644 index 6a47e50f62d..00000000000 --- a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.rs +++ /dev/null @@ -1,20 +0,0 @@ -// aux-build:builtin-attrs.rs -// compile-flags:--test - -#![feature(decl_macro, test)] - -extern crate test; -extern crate builtin_attrs; -use builtin_attrs::{test, bench}; - -#[test] // OK, shadowed -fn test() {} - -#[bench] // OK, shadowed -fn bench(b: &mut test::Bencher) {} - -fn not_main() { - Test; - Bench; - NonExistent; //~ ERROR cannot find value `NonExistent` in this scope -} diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.stderr b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.stderr deleted file mode 100644 index db07055b6a1..00000000000 --- a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs-test.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0425]: cannot find value `NonExistent` in this scope - --> $DIR/ambiguous-builtin-attrs-test.rs:19:5 - | -LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope - | ^^^^^^^^^^^ not found in this scope - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs deleted file mode 100644 index 9f4f0abf324..00000000000 --- a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.rs +++ /dev/null @@ -1,31 +0,0 @@ -// aux-build:builtin-attrs.rs - -#![feature(decl_macro)] //~ ERROR `feature` is ambiguous - -extern crate builtin_attrs; -use builtin_attrs::{test, bench}; -use builtin_attrs::*; - -#[repr(C)] //~ ERROR `repr` is ambiguous -struct S; -#[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous -struct SCond; - -#[test] // OK, shadowed -fn test() {} - -#[bench] // OK, shadowed -fn bench() {} - -fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous - match 0u8 { - #[repr(C)] //~ ERROR `repr` is ambiguous - _ => {} - } -} - -fn main() { - Test; - Bench; - NonExistent; //~ ERROR cannot find value `NonExistent` in this scope -} diff --git a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr b/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr deleted file mode 100644 index 79dc922b9db..00000000000 --- a/src/test/ui-fulldeps/proc-macro/ambiguous-builtin-attrs.stderr +++ /dev/null @@ -1,80 +0,0 @@ -error[E0425]: cannot find value `NonExistent` in this scope - --> $DIR/ambiguous-builtin-attrs.rs:30:5 - | -LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope - | ^^^^^^^^^^^ not found in this scope - -error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) - --> $DIR/ambiguous-builtin-attrs.rs:9:3 - | -LL | #[repr(C)] //~ ERROR `repr` is ambiguous - | ^^^^ ambiguous name - | - = note: `repr` could refer to a built-in attribute -note: `repr` could also refer to the attribute macro imported here - --> $DIR/ambiguous-builtin-attrs.rs:7:5 - | -LL | use builtin_attrs::*; - | ^^^^^^^^^^^^^^^^ - = help: use `crate::repr` to refer to this attribute macro unambiguously - -error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) - --> $DIR/ambiguous-builtin-attrs.rs:11:19 - | -LL | #[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous - | ^^^^ ambiguous name - | - = note: `repr` could refer to a built-in attribute -note: `repr` could also refer to the attribute macro imported here - --> $DIR/ambiguous-builtin-attrs.rs:7:5 - | -LL | use builtin_attrs::*; - | ^^^^^^^^^^^^^^^^ - = help: use `crate::repr` to refer to this attribute macro unambiguously - -error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) - --> $DIR/ambiguous-builtin-attrs.rs:20:34 - | -LL | fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous - | ^^^^ ambiguous name - | - = note: `repr` could refer to a built-in attribute -note: `repr` could also refer to the attribute macro imported here - --> $DIR/ambiguous-builtin-attrs.rs:7:5 - | -LL | use builtin_attrs::*; - | ^^^^^^^^^^^^^^^^ - = help: use `crate::repr` to refer to this attribute macro unambiguously - -error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) - --> $DIR/ambiguous-builtin-attrs.rs:22:11 - | -LL | #[repr(C)] //~ ERROR `repr` is ambiguous - | ^^^^ ambiguous name - | - = note: `repr` could refer to a built-in attribute -note: `repr` could also refer to the attribute macro imported here - --> $DIR/ambiguous-builtin-attrs.rs:7:5 - | -LL | use builtin_attrs::*; - | ^^^^^^^^^^^^^^^^ - = help: use `crate::repr` to refer to this attribute macro unambiguously - -error[E0659]: `feature` is ambiguous (built-in attribute vs any other name) - --> $DIR/ambiguous-builtin-attrs.rs:3:4 - | -LL | #![feature(decl_macro)] //~ ERROR `feature` is ambiguous - | ^^^^^^^ ambiguous name - | - = note: `feature` could refer to a built-in attribute -note: `feature` could also refer to the attribute macro imported here - --> $DIR/ambiguous-builtin-attrs.rs:7:5 - | -LL | use builtin_attrs::*; - | ^^^^^^^^^^^^^^^^ - = help: use `crate::feature` to refer to this attribute macro unambiguously - -error: aborting due to 6 previous errors - -Some errors occurred: E0425, E0659. -For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.rs b/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.rs deleted file mode 100644 index af47dad9e0b..00000000000 --- a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:attribute-spans-preserved.rs - -extern crate attribute_spans_preserved as foo; - -use foo::foo; - -#[ foo ( let y: u32 = "z"; ) ] //~ ERROR: mismatched types -#[ bar { let x: u32 = "y"; } ] //~ ERROR: mismatched types -fn main() { -} diff --git a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stderr b/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stderr deleted file mode 100644 index 329e5bea61c..00000000000 --- a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/attribute-spans-preserved.rs:17:23 - | -LL | #[ foo ( let y: u32 = "z"; ) ] //~ ERROR: mismatched types - | ^^^ expected u32, found reference - | - = note: expected type `u32` - found type `&'static str` - -error[E0308]: mismatched types - --> $DIR/attribute-spans-preserved.rs:18:23 - | -LL | #[ bar { let x: u32 = "y"; } ] //~ ERROR: mismatched types - | ^^^ expected u32, found reference - | - = note: expected type `u32` - found type `&'static str` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stdout b/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stdout deleted file mode 100644 index b1487fcd5ed..00000000000 --- a/src/test/ui-fulldeps/proc-macro/attribute-spans-preserved.stdout +++ /dev/null @@ -1 +0,0 @@ -fn main ( ) { let y : u32 = "z" ; { let x : u32 = "y" ; } } diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs deleted file mode 100644 index 679cb772868..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/attr_proc_macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/attribute-spans-preserved.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/attribute-spans-preserved.rs deleted file mode 100644 index e725cc7afb8..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/attribute-spans-preserved.rs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro_attribute] -pub fn foo(attr: TokenStream, f: TokenStream) -> TokenStream { - let mut tokens = f.into_iter(); - assert_eq!(tokens.next().unwrap().to_string(), "#"); - let next_attr = match tokens.next().unwrap() { - TokenTree::Group(g) => g, - _ => panic!(), - }; - - let fn_tok = tokens.next().unwrap(); - let ident_tok = tokens.next().unwrap(); - let args_tok = tokens.next().unwrap(); - let body = tokens.next().unwrap(); - - let new_body = attr.into_iter() - .chain(next_attr.stream().into_iter().skip(1)); - - let tokens = vec![ - fn_tok, - ident_tok, - args_tok, - Group::new(Delimiter::Brace, new_body.collect()).into(), - ].into_iter().collect::(); - println!("{}", tokens); - return tokens -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/bang_proc_macro.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/bang_proc_macro.rs deleted file mode 100644 index 6484725814a..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/bang_proc_macro.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// force-host -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro] -pub fn bang_proc_macro(input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs deleted file mode 100644 index e18ca57aab1..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/builtin-attrs.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro_attribute] -pub fn feature(_: TokenStream, input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] -pub fn repr(_: TokenStream, input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] -pub fn test(_: TokenStream, input: TokenStream) -> TokenStream { - "struct Test;".parse().unwrap() -} - -#[proc_macro_attribute] -pub fn bench(_: TokenStream, input: TokenStream) -> TokenStream { - "struct Bench;".parse().unwrap() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed-2.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed-2.rs deleted file mode 100644 index 9912a89dafb..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed-2.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[macro_export] -macro_rules! my_attr { () => () } diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed.rs deleted file mode 100644 index 4e701710f42..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowed.rs +++ /dev/null @@ -1,11 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro_derive(MyTrait, attributes(my_attr))] -pub fn foo(_: TokenStream) -> TokenStream { - TokenStream::new() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowing.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowing.rs deleted file mode 100644 index 0fd8aa5638a..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-helper-shadowing.rs +++ /dev/null @@ -1,16 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro_attribute] -pub fn my_attr(_: TokenStream, input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_derive(MyTrait, attributes(my_attr))] -pub fn derive(input: TokenStream) -> TokenStream { - TokenStream::new() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-panic.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/derive-panic.rs deleted file mode 100644 index 3274f0324e1..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/derive-panic.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic -// force-host - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(A)] -pub fn derive_a(_input: TokenStream) -> TokenStream { - panic!("nope!"); -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/generate-mod.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/generate-mod.rs deleted file mode 100644 index 1ed8ef52027..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/generate-mod.rs +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// run-pass -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro] -pub fn check(_: TokenStream) -> TokenStream { - " - type Alias = FromOutside; // OK - struct Outer; - mod inner { - type Alias = FromOutside; // `FromOutside` shouldn't be available from here - type Inner = Outer; // `Outer` shouldn't be available from here - } - ".parse().unwrap() -} - -#[proc_macro_attribute] -pub fn check_attr(_: TokenStream, _: TokenStream) -> TokenStream { - " - type AliasAttr = FromOutside; // OK - struct OuterAttr; - mod inner_attr { - type Alias = FromOutside; // `FromOutside` shouldn't be available from here - type Inner = OuterAttr; // `OuterAttr` shouldn't be available from here - } - ".parse().unwrap() -} - -#[proc_macro_derive(CheckDerive)] -pub fn check_derive(_: TokenStream) -> TokenStream { - " - type AliasDerive = FromOutside; // OK - struct OuterDerive; - mod inner_derive { - type Alias = FromOutside; // `FromOutside` shouldn't be available from here - type Inner = OuterDerive; // `OuterDerive` shouldn't be available from here - } - ".parse().unwrap() -} - -#[proc_macro_derive(CheckDeriveLint)] -pub fn check_derive_lint(_: TokenStream) -> TokenStream { - " - type AliasDeriveLint = FromOutside; // OK - struct OuterDeriveLint; - #[allow(proc_macro_derive_resolution_fallback)] - mod inner_derive_lint { - type Alias = FromOutside; // `FromOutside` shouldn't be available from here - type Inner = OuterDeriveLint; // `OuterDeriveLint` shouldn't be available from here - } - ".parse().unwrap() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/issue-53481.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/issue-53481.rs deleted file mode 100644 index 9554cdde490..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/issue-53481.rs +++ /dev/null @@ -1,12 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro_derive(MyTrait, attributes(my_attr))] -pub fn foo(_: TokenStream) -> TokenStream { - TokenStream::new() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs deleted file mode 100644 index be1777f3ebd..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/macro-brackets.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro_attribute] -pub fn doit(_: TokenStream, input: TokenStream) -> TokenStream { - input.into_iter().collect() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs deleted file mode 100644 index 383016f990e..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/multispan.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)] - -extern crate proc_macro; - -use proc_macro::{TokenStream, TokenTree, Span, Diagnostic}; - -fn parse(input: TokenStream) -> Result<(), Diagnostic> { - let mut hi_spans = vec![]; - for tree in input { - if let TokenTree::Ident(ref ident) = tree { - if ident.to_string() == "hi" { - hi_spans.push(ident.span()); - } - } - } - - if !hi_spans.is_empty() { - return Err(Span::def_site() - .error("hello to you, too!") - .span_note(hi_spans, "found these 'hi's")); - } - - Ok(()) -} - -#[proc_macro] -pub fn hello(input: TokenStream) -> TokenStream { - if let Err(diag) = parse(input) { - diag.emit(); - } - - TokenStream::new() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/nested-item-spans.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/nested-item-spans.rs deleted file mode 100644 index 6b893150b45..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/nested-item-spans.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro_attribute] -pub fn foo(_: TokenStream, item: TokenStream) -> TokenStream { - item.into_iter().collect() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs deleted file mode 100644 index f5590405e61..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/parent-source-spans.rs +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![feature(proc_macro_diagnostic, proc_macro_span)] -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::{TokenStream, TokenTree, Span}; - -fn lit_span(tt: TokenTree) -> (Span, String) { - match tt { - TokenTree::Literal(..) | - TokenTree::Group(..) => (tt.span(), tt.to_string().trim().into()), - _ => panic!("expected a literal in token tree, got: {:?}", tt) - } -} - -#[proc_macro] -pub fn parent_source_spans(input: TokenStream) -> TokenStream { - let mut tokens = input.into_iter(); - let (sp1, str1) = lit_span(tokens.next().expect("first string")); - let _ = tokens.next(); - let (sp2, str2) = lit_span(tokens.next().expect("second string")); - - sp1.error(format!("first final: {}", str1)).emit(); - sp2.error(format!("second final: {}", str2)).emit(); - - if let (Some(p1), Some(p2)) = (sp1.parent(), sp2.parent()) { - p1.error(format!("first parent: {}", str1)).emit(); - p2.error(format!("second parent: {}", str2)).emit(); - - if let (Some(gp1), Some(gp2)) = (p1.parent(), p2.parent()) { - gp1.error(format!("first grandparent: {}", str1)).emit(); - gp2.error(format!("second grandparent: {}", str2)).emit(); - } - } - - sp1.source().error(format!("first source: {}", str1)).emit(); - sp2.source().error(format!("second source: {}", str2)).emit(); - - "ok".parse().unwrap() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/span-preservation.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/span-preservation.rs deleted file mode 100644 index 65ed9cf7372..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/span-preservation.rs +++ /dev/null @@ -1,12 +0,0 @@ -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_attribute] -pub fn foo(_: TokenStream, input: TokenStream) -> TokenStream { - input.into_iter().collect() -} diff --git a/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs b/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs deleted file mode 100644 index 569a458f55a..00000000000 --- a/src/test/ui-fulldeps/proc-macro/auxiliary/three-equals.rs +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] -#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)] - -extern crate proc_macro; - -use proc_macro::{TokenStream, TokenTree, Span, Diagnostic}; - -fn parse(input: TokenStream) -> Result<(), Diagnostic> { - let mut count = 0; - let mut last_span = Span::def_site(); - for tree in input { - let span = tree.span(); - if count >= 3 { - return Err(span.error(format!("expected EOF, found `{}`.", tree)) - .span_note(last_span, "last good input was here") - .help("input must be: `===`")) - } - - if let TokenTree::Punct(ref tt) = tree { - if tt.as_char() == '=' { - count += 1; - last_span = span; - continue - } - } - return Err(span.error(format!("expected `=`, found `{}`.", tree))); - } - - if count < 3 { - return Err(Span::def_site() - .error(format!("found {} equal signs, need exactly 3", count)) - .help("input must be: `===`")) - } - - Ok(()) -} - -#[proc_macro] -pub fn three_equals(input: TokenStream) -> TokenStream { - if let Err(diag) = parse(input) { - diag.emit(); - return TokenStream::new(); - } - - "3".parse().unwrap() -} diff --git a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowed.rs b/src/test/ui-fulldeps/proc-macro/derive-helper-shadowed.rs deleted file mode 100644 index 792b54b3b94..00000000000 --- a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowed.rs +++ /dev/null @@ -1,16 +0,0 @@ -// compile-pass -// aux-build:derive-helper-shadowed.rs -// aux-build:derive-helper-shadowed-2.rs - -#[macro_use] -extern crate derive_helper_shadowed; -#[macro_use(my_attr)] -extern crate derive_helper_shadowed_2; - -macro_rules! my_attr { () => () } - -#[derive(MyTrait)] -#[my_attr] // OK -struct S; - -fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.rs b/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.rs deleted file mode 100644 index aa9eae0ba31..00000000000 --- a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.rs +++ /dev/null @@ -1,10 +0,0 @@ -// aux-build:derive-helper-shadowing.rs - -extern crate derive_helper_shadowing; -use derive_helper_shadowing::*; - -#[my_attr] //~ ERROR `my_attr` is ambiguous -#[derive(MyTrait)] -struct S; - -fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr b/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr deleted file mode 100644 index cc50fefc464..00000000000 --- a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0659]: `my_attr` is ambiguous (derive helper attribute vs any other name) - --> $DIR/derive-helper-shadowing.rs:6:3 - | -LL | #[my_attr] //~ ERROR `my_attr` is ambiguous - | ^^^^^^^ ambiguous name - | -note: `my_attr` could refer to the derive helper attribute defined here - --> $DIR/derive-helper-shadowing.rs:7:10 - | -LL | #[derive(MyTrait)] - | ^^^^^^^ -note: `my_attr` could also refer to the attribute macro imported here - --> $DIR/derive-helper-shadowing.rs:4:5 - | -LL | use derive_helper_shadowing::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - = help: use `crate::my_attr` to refer to this attribute macro unambiguously - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs b/src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs deleted file mode 100644 index 25a2a376147..00000000000 --- a/src/test/ui-fulldeps/proc-macro/extern-prelude-extern-crate-proc-macro.rs +++ /dev/null @@ -1,7 +0,0 @@ -// compile-pass -// edition:2018 - -extern crate proc_macro; -use proc_macro::TokenStream; // OK - -fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/generate-mod.rs b/src/test/ui-fulldeps/proc-macro/generate-mod.rs deleted file mode 100644 index 977faf7decd..00000000000 --- a/src/test/ui-fulldeps/proc-macro/generate-mod.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Modules generated by transparent proc macros still acts as barriers for names (issue #50504). - -// aux-build:generate-mod.rs - -extern crate generate_mod; - -struct FromOutside; - -generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `Outer` in this scope - -#[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope - //~| ERROR cannot find type `OuterAttr` in this scope -struct S; - -#[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope - //~| WARN cannot find type `OuterDerive` in this scope - //~| WARN this was previously accepted - //~| WARN this was previously accepted -struct Z; - -fn inner_block() { - #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope - //~| WARN cannot find type `OuterDerive` in this scope - //~| WARN this was previously accepted - //~| WARN this was previously accepted - struct InnerZ; -} - -#[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed -struct W; - -fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/generate-mod.stderr b/src/test/ui-fulldeps/proc-macro/generate-mod.stderr deleted file mode 100644 index a981b1bc8b8..00000000000 --- a/src/test/ui-fulldeps/proc-macro/generate-mod.stderr +++ /dev/null @@ -1,64 +0,0 @@ -error[E0412]: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:19:1 - | -LL | generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope - -error[E0412]: cannot find type `Outer` in this scope - --> $DIR/generate-mod.rs:19:1 - | -LL | generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope - -error[E0412]: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:22:1 - | -LL | #[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope - -error[E0412]: cannot find type `OuterAttr` in this scope - --> $DIR/generate-mod.rs:22:1 - | -LL | #[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope - -warning: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:26:10 - | -LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = note: #[warn(proc_macro_derive_resolution_fallback)] on by default - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #50504 - -warning: cannot find type `OuterDerive` in this scope - --> $DIR/generate-mod.rs:26:10 - | -LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #50504 - -warning: cannot find type `FromOutside` in this scope - --> $DIR/generate-mod.rs:33:14 - | -LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #50504 - -warning: cannot find type `OuterDerive` in this scope - --> $DIR/generate-mod.rs:33:14 - | -LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope - | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #50504 - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui-fulldeps/proc-macro/invalid-attributes.rs b/src/test/ui-fulldeps/proc-macro/invalid-attributes.rs deleted file mode 100644 index 8b940a0f405..00000000000 --- a/src/test/ui-fulldeps/proc-macro/invalid-attributes.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro = "test"] //~ ERROR: does not take any arguments -pub fn a(a: TokenStream) -> TokenStream { a } - -#[proc_macro()] //~ ERROR: does not take any arguments -pub fn c(a: TokenStream) -> TokenStream { a } - -#[proc_macro(x)] //~ ERROR: does not take any arguments -pub fn d(a: TokenStream) -> TokenStream { a } - -#[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments -pub fn e(_: TokenStream, a: TokenStream) -> TokenStream { a } - -#[proc_macro_attribute()] //~ ERROR: does not take any arguments -pub fn g(_: TokenStream, a: TokenStream) -> TokenStream { a } - -#[proc_macro_attribute(x)] //~ ERROR: does not take any arguments -pub fn h(_: TokenStream, a: TokenStream) -> TokenStream { a } diff --git a/src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr b/src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr deleted file mode 100644 index 5fd87362db2..00000000000 --- a/src/test/ui-fulldeps/proc-macro/invalid-attributes.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error: `#[proc_macro]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:19:1 - | -LL | #[proc_macro = "test"] //~ ERROR: does not take any arguments - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: `#[proc_macro]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:22:1 - | -LL | #[proc_macro()] //~ ERROR: does not take any arguments - | ^^^^^^^^^^^^^^^ - -error: `#[proc_macro]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:25:1 - | -LL | #[proc_macro(x)] //~ ERROR: does not take any arguments - | ^^^^^^^^^^^^^^^^ - -error: `#[proc_macro_attribute]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:28:1 - | -LL | #[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `#[proc_macro_attribute]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:31:1 - | -LL | #[proc_macro_attribute()] //~ ERROR: does not take any arguments - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `#[proc_macro_attribute]` attribute does not take any arguments - --> $DIR/invalid-attributes.rs:34:1 - | -LL | #[proc_macro_attribute(x)] //~ ERROR: does not take any arguments - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 6 previous errors - diff --git a/src/test/ui-fulldeps/proc-macro/issue-53481.rs b/src/test/ui-fulldeps/proc-macro/issue-53481.rs deleted file mode 100644 index 479fd1db630..00000000000 --- a/src/test/ui-fulldeps/proc-macro/issue-53481.rs +++ /dev/null @@ -1,22 +0,0 @@ -// compile-pass -// aux-build:issue-53481.rs - -#[macro_use] -extern crate issue_53481; - -mod m1 { - use m2::MyTrait; - - #[derive(MyTrait)] - struct A {} -} - -mod m2 { - pub type MyTrait = u8; - - #[derive(MyTrait)] - #[my_attr] - struct B {} -} - -fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/load-panic.rs b/src/test/ui-fulldeps/proc-macro/load-panic.rs deleted file mode 100644 index 462eaf03417..00000000000 --- a/src/test/ui-fulldeps/proc-macro/load-panic.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-panic.rs -// compile-flags:--error-format human - -#[macro_use] -extern crate derive_panic; - -#[derive(A)] -//~^ ERROR: proc-macro derive panicked -struct Foo; - -fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/load-panic.stderr b/src/test/ui-fulldeps/proc-macro/load-panic.stderr deleted file mode 100644 index 30ad53f9041..00000000000 --- a/src/test/ui-fulldeps/proc-macro/load-panic.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: proc-macro derive panicked - --> $DIR/load-panic.rs:17:10 - | -LL | #[derive(A)] - | ^ - | - = help: message: nope! - -error: aborting due to previous error - diff --git a/src/test/ui-fulldeps/proc-macro/macro-brackets.rs b/src/test/ui-fulldeps/proc-macro/macro-brackets.rs deleted file mode 100644 index b29f2775201..00000000000 --- a/src/test/ui-fulldeps/proc-macro/macro-brackets.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:macro-brackets.rs - -extern crate macro_brackets as bar; -use bar::doit; - -macro_rules! id { - ($($t:tt)*) => ($($t)*) -} - -#[doit] -id![static X: u32 = 'a';]; //~ ERROR: mismatched types - - -fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/macro-brackets.stderr b/src/test/ui-fulldeps/proc-macro/macro-brackets.stderr deleted file mode 100644 index 7c263d38df9..00000000000 --- a/src/test/ui-fulldeps/proc-macro/macro-brackets.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/macro-brackets.rs:21:21 - | -LL | id![static X: u32 = 'a';]; //~ ERROR: mismatched types - | ^^^ expected u32, found char - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.rs b/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.rs deleted file mode 100644 index fa05ad2fc60..00000000000 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.rs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro] -pub fn my_macro(input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] -pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream { - input -} - -#[proc_macro_derive(MyTrait)] -pub fn my_macro_derive(input: TokenStream) -> TokenStream { - input -} - -fn check_bang1() { - my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it -} -fn check_bang2() { - my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines it -} -fn check_bang3() { - MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it -} - -#[my_macro] //~ ERROR can't use a procedural macro from the same crate that defines it -fn check_attr1() {} -#[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it -fn check_attr2() {} -#[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it -fn check_attr3() {} - -#[derive(my_macro)] //~ ERROR can't use a procedural macro from the same crate that defines it -struct CheckDerive1; -#[derive(my_macro_attr)] //~ ERROR can't use a procedural macro from the same crate that defines it -struct CheckDerive2; -#[derive(MyTrait)] //~ ERROR can't use a procedural macro from the same crate that defines it -struct CheckDerive3; diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr b/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr deleted file mode 100644 index 9def03e9450..00000000000 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved-2.stderr +++ /dev/null @@ -1,56 +0,0 @@ -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:34:5 - | -LL | my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^ - -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:37:5 - | -LL | my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^^^^ - -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:40:5 - | -LL | MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^ - -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:43:3 - | -LL | #[my_macro] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^ - -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:45:3 - | -LL | #[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^^^^ - -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:47:3 - | -LL | #[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^ - -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:50:10 - | -LL | #[derive(my_macro)] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^ - -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:52:10 - | -LL | #[derive(my_macro_attr)] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^^^^^^^ - -error: can't use a procedural macro from the same crate that defines it - --> $DIR/macro-namespace-reserved-2.rs:54:10 - | -LL | #[derive(MyTrait)] //~ ERROR can't use a procedural macro from the same crate that defines it - | ^^^^^^^ - -error: aborting due to 9 previous errors - diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.rs b/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.rs deleted file mode 100644 index e7bb05de88c..00000000000 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![feature(decl_macro)] -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro] -pub fn my_macro(input: TokenStream) -> TokenStream { - input -} - -#[proc_macro_attribute] -pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream { - input -} - -#[proc_macro_derive(MyTrait)] -pub fn my_macro_derive(input: TokenStream) -> TokenStream { - input -} - -macro my_macro() {} //~ ERROR the name `my_macro` is defined multiple times -macro my_macro_attr() {} //~ ERROR the name `my_macro_attr` is defined multiple times -macro MyTrait() {} //~ ERROR the name `MyTrait` is defined multiple times - -#[proc_macro_derive(SameName)] -pub fn foo(input: TokenStream) -> TokenStream { - input -} - -#[proc_macro] -pub fn SameName(input: TokenStream) -> TokenStream { -//~^ ERROR the name `SameName` is defined multiple times - input -} diff --git a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.stderr b/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.stderr deleted file mode 100644 index 44b51edcc0b..00000000000 --- a/src/test/ui-fulldeps/proc-macro/macro-namespace-reserved.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error[E0428]: the name `my_macro` is defined multiple times - --> $DIR/macro-namespace-reserved.rs:34:1 - | -LL | pub fn my_macro(input: TokenStream) -> TokenStream { - | -------------------------------------------------- previous definition of the macro `my_macro` here -... -LL | macro my_macro() {} //~ ERROR the name `my_macro` is defined multiple times - | ^^^^^^^^^^^^^^^^ `my_macro` redefined here - | - = note: `my_macro` must be defined only once in the macro namespace of this module - -error[E0428]: the name `my_macro_attr` is defined multiple times - --> $DIR/macro-namespace-reserved.rs:35:1 - | -LL | pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream { - | ----------------------------------------------------------------------- previous definition of the macro `my_macro_attr` here -... -LL | macro my_macro_attr() {} //~ ERROR the name `my_macro_attr` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^^^ `my_macro_attr` redefined here - | - = note: `my_macro_attr` must be defined only once in the macro namespace of this module - -error[E0428]: the name `MyTrait` is defined multiple times - --> $DIR/macro-namespace-reserved.rs:36:1 - | -LL | #[proc_macro_derive(MyTrait)] - | ------- previous definition of the macro `MyTrait` here -... -LL | macro MyTrait() {} //~ ERROR the name `MyTrait` is defined multiple times - | ^^^^^^^^^^^^^^^ `MyTrait` redefined here - | - = note: `MyTrait` must be defined only once in the macro namespace of this module - -error[E0428]: the name `SameName` is defined multiple times - --> $DIR/macro-namespace-reserved.rs:44:1 - | -LL | #[proc_macro_derive(SameName)] - | -------- previous definition of the macro `SameName` here -... -LL | pub fn SameName(input: TokenStream) -> TokenStream { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SameName` redefined here - | - = note: `SameName` must be defined only once in the macro namespace of this module - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui-fulldeps/proc-macro/macro-use-attr.rs b/src/test/ui-fulldeps/proc-macro/macro-use-attr.rs deleted file mode 100644 index 904562e903d..00000000000 --- a/src/test/ui-fulldeps/proc-macro/macro-use-attr.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass -// aux-build:attr_proc_macro.rs - -#[macro_use] extern crate attr_proc_macro; - -#[attr_proc_macro] -struct Foo; - -fn main() { - let _ = Foo; -} diff --git a/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs b/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs deleted file mode 100644 index d7713f48e70..00000000000 --- a/src/test/ui-fulldeps/proc-macro/macro-use-bang.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass -// aux-build:bang_proc_macro.rs - -#![feature(proc_macro_hygiene)] - -#[macro_use] -extern crate bang_proc_macro; - -fn main() { - bang_proc_macro!(println!("Hello, world!")); -} diff --git a/src/test/ui-fulldeps/proc-macro/multispan.rs b/src/test/ui-fulldeps/proc-macro/multispan.rs deleted file mode 100644 index 03067868a81..00000000000 --- a/src/test/ui-fulldeps/proc-macro/multispan.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:multispan.rs - -#![feature(proc_macro_hygiene)] - -extern crate multispan; - -use multispan::hello; - -fn main() { - // This one emits no error. - hello!(); - - // Exactly one 'hi'. - hello!(hi); //~ ERROR hello to you, too! - - // Now two, back to back. - hello!(hi hi); //~ ERROR hello to you, too! - - // Now three, back to back. - hello!(hi hi hi); //~ ERROR hello to you, too! - - // Now several, with spacing. - hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! - hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! - hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! - hello!(hi good hi and good bye); //~ ERROR hello to you, too! -} diff --git a/src/test/ui-fulldeps/proc-macro/multispan.stderr b/src/test/ui-fulldeps/proc-macro/multispan.stderr deleted file mode 100644 index 39bdbb5e450..00000000000 --- a/src/test/ui-fulldeps/proc-macro/multispan.stderr +++ /dev/null @@ -1,86 +0,0 @@ -error: hello to you, too! - --> $DIR/multispan.rs:24:5 - | -LL | hello!(hi); //~ ERROR hello to you, too! - | ^^^^^^^^^^^ - | -note: found these 'hi's - --> $DIR/multispan.rs:24:12 - | -LL | hello!(hi); //~ ERROR hello to you, too! - | ^^ - -error: hello to you, too! - --> $DIR/multispan.rs:27:5 - | -LL | hello!(hi hi); //~ ERROR hello to you, too! - | ^^^^^^^^^^^^^^ - | -note: found these 'hi's - --> $DIR/multispan.rs:27:12 - | -LL | hello!(hi hi); //~ ERROR hello to you, too! - | ^^ ^^ - -error: hello to you, too! - --> $DIR/multispan.rs:30:5 - | -LL | hello!(hi hi hi); //~ ERROR hello to you, too! - | ^^^^^^^^^^^^^^^^^ - | -note: found these 'hi's - --> $DIR/multispan.rs:30:12 - | -LL | hello!(hi hi hi); //~ ERROR hello to you, too! - | ^^ ^^ ^^ - -error: hello to you, too! - --> $DIR/multispan.rs:33:5 - | -LL | hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: found these 'hi's - --> $DIR/multispan.rs:33:12 - | -LL | hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! - | ^^ ^^ ^^ ^^ ^^ - -error: hello to you, too! - --> $DIR/multispan.rs:34:5 - | -LL | hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: found these 'hi's - --> $DIR/multispan.rs:34:12 - | -LL | hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! - | ^^ ^^ ^^ ^^ - -error: hello to you, too! - --> $DIR/multispan.rs:35:5 - | -LL | hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: found these 'hi's - --> $DIR/multispan.rs:35:19 - | -LL | hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! - | ^^ ^^ - -error: hello to you, too! - --> $DIR/multispan.rs:36:5 - | -LL | hello!(hi good hi and good bye); //~ ERROR hello to you, too! - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: found these 'hi's - --> $DIR/multispan.rs:36:12 - | -LL | hello!(hi good hi and good bye); //~ ERROR hello to you, too! - | ^^ ^^ - -error: aborting due to 7 previous errors - diff --git a/src/test/ui-fulldeps/proc-macro/nested-item-spans.rs b/src/test/ui-fulldeps/proc-macro/nested-item-spans.rs deleted file mode 100644 index 8f059d6344d..00000000000 --- a/src/test/ui-fulldeps/proc-macro/nested-item-spans.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:nested-item-spans.rs - -extern crate nested_item_spans; - -use nested_item_spans::foo; - -#[foo] -fn another() { - fn bar() { - let x: u32 = "x"; //~ ERROR: mismatched types - } - - bar(); -} - -fn main() { - #[foo] - fn bar() { - let x: u32 = "x"; //~ ERROR: mismatched types - } - - bar(); - another(); -} diff --git a/src/test/ui-fulldeps/proc-macro/nested-item-spans.stderr b/src/test/ui-fulldeps/proc-macro/nested-item-spans.stderr deleted file mode 100644 index 75140747e8c..00000000000 --- a/src/test/ui-fulldeps/proc-macro/nested-item-spans.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/nested-item-spans.rs:20:22 - | -LL | let x: u32 = "x"; //~ ERROR: mismatched types - | ^^^ expected u32, found reference - | - = note: expected type `u32` - found type `&'static str` - -error[E0308]: mismatched types - --> $DIR/nested-item-spans.rs:29:22 - | -LL | let x: u32 = "x"; //~ ERROR: mismatched types - | ^^^ expected u32, found reference - | - = note: expected type `u32` - found type `&'static str` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui-fulldeps/proc-macro/non-root.rs b/src/test/ui-fulldeps/proc-macro/non-root.rs deleted file mode 100644 index 24404885788..00000000000 --- a/src/test/ui-fulldeps/proc-macro/non-root.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -fn foo(arg: TokenStream) -> TokenStream { - #[proc_macro] - pub fn foo(arg: TokenStream) -> TokenStream { arg } - //~^ ERROR functions tagged with `#[proc_macro]` must currently reside in the root of the crate - - arg -} diff --git a/src/test/ui-fulldeps/proc-macro/non-root.stderr b/src/test/ui-fulldeps/proc-macro/non-root.stderr deleted file mode 100644 index 23222a2b851..00000000000 --- a/src/test/ui-fulldeps/proc-macro/non-root.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: functions tagged with `#[proc_macro]` must currently reside in the root of the crate - --> $DIR/non-root.rs:20:5 - | -LL | pub fn foo(arg: TokenStream) -> TokenStream { arg } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs b/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs deleted file mode 100644 index 8f8e22ba1c3..00000000000 --- a/src/test/ui-fulldeps/proc-macro/parent-source-spans.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:parent-source-spans.rs - - -#![feature(decl_macro, proc_macro_hygiene)] - -extern crate parent_source_spans; - -use parent_source_spans::parent_source_spans; - -macro one($a:expr, $b:expr) { - two!($a, $b); - //~^ ERROR first parent: "hello" - //~| ERROR second parent: "world" -} - -macro two($a:expr, $b:expr) { - three!($a, $b); - //~^ ERROR first final: "hello" - //~| ERROR second final: "world" - //~| ERROR first final: "yay" - //~| ERROR second final: "rust" -} - -// forwarding tokens directly doesn't create a new source chain -macro three($($tokens:tt)*) { - four!($($tokens)*); -} - -macro four($($tokens:tt)*) { - parent_source_spans!($($tokens)*); -} - -fn main() { - one!("hello", "world"); - //~^ ERROR first grandparent: "hello" - //~| ERROR second grandparent: "world" - //~| ERROR first source: "hello" - //~| ERROR second source: "world" - - two!("yay", "rust"); - //~^ ERROR first parent: "yay" - //~| ERROR second parent: "rust" - //~| ERROR first source: "yay" - //~| ERROR second source: "rust" - - three!("hip", "hop"); - //~^ ERROR first final: "hip" - //~| ERROR second final: "hop" - //~| ERROR first source: "hip" - //~| ERROR second source: "hop" -} diff --git a/src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr b/src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr deleted file mode 100644 index 0442c4f6ce7..00000000000 --- a/src/test/ui-fulldeps/proc-macro/parent-source-spans.stderr +++ /dev/null @@ -1,128 +0,0 @@ -error: first final: "hello" - --> $DIR/parent-source-spans.rs:27:12 - | -LL | three!($a, $b); - | ^^ -... -LL | one!("hello", "world"); - | ----------------------- in this macro invocation - -error: second final: "world" - --> $DIR/parent-source-spans.rs:27:16 - | -LL | three!($a, $b); - | ^^ -... -LL | one!("hello", "world"); - | ----------------------- in this macro invocation - -error: first parent: "hello" - --> $DIR/parent-source-spans.rs:21:5 - | -LL | two!($a, $b); - | ^^^^^^^^^^^^^ -... -LL | one!("hello", "world"); - | ----------------------- in this macro invocation - -error: second parent: "world" - --> $DIR/parent-source-spans.rs:21:5 - | -LL | two!($a, $b); - | ^^^^^^^^^^^^^ -... -LL | one!("hello", "world"); - | ----------------------- in this macro invocation - -error: first grandparent: "hello" - --> $DIR/parent-source-spans.rs:44:5 - | -LL | one!("hello", "world"); - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: second grandparent: "world" - --> $DIR/parent-source-spans.rs:44:5 - | -LL | one!("hello", "world"); - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: first source: "hello" - --> $DIR/parent-source-spans.rs:44:5 - | -LL | one!("hello", "world"); - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: second source: "world" - --> $DIR/parent-source-spans.rs:44:5 - | -LL | one!("hello", "world"); - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: first final: "yay" - --> $DIR/parent-source-spans.rs:27:12 - | -LL | three!($a, $b); - | ^^ -... -LL | two!("yay", "rust"); - | -------------------- in this macro invocation - -error: second final: "rust" - --> $DIR/parent-source-spans.rs:27:16 - | -LL | three!($a, $b); - | ^^ -... -LL | two!("yay", "rust"); - | -------------------- in this macro invocation - -error: first parent: "yay" - --> $DIR/parent-source-spans.rs:50:5 - | -LL | two!("yay", "rust"); - | ^^^^^^^^^^^^^^^^^^^^ - -error: second parent: "rust" - --> $DIR/parent-source-spans.rs:50:5 - | -LL | two!("yay", "rust"); - | ^^^^^^^^^^^^^^^^^^^^ - -error: first source: "yay" - --> $DIR/parent-source-spans.rs:50:5 - | -LL | two!("yay", "rust"); - | ^^^^^^^^^^^^^^^^^^^^ - -error: second source: "rust" - --> $DIR/parent-source-spans.rs:50:5 - | -LL | two!("yay", "rust"); - | ^^^^^^^^^^^^^^^^^^^^ - -error: first final: "hip" - --> $DIR/parent-source-spans.rs:56:12 - | -LL | three!("hip", "hop"); - | ^^^^^ - -error: second final: "hop" - --> $DIR/parent-source-spans.rs:56:19 - | -LL | three!("hip", "hop"); - | ^^^^^ - -error: first source: "hip" - --> $DIR/parent-source-spans.rs:56:12 - | -LL | three!("hip", "hop"); - | ^^^^^ - -error: second source: "hop" - --> $DIR/parent-source-spans.rs:56:19 - | -LL | three!("hip", "hop"); - | ^^^^^ - -error: aborting due to 18 previous errors - diff --git a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs b/src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs deleted file mode 100644 index ff5984aa67c..00000000000 --- a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.rs +++ /dev/null @@ -1,22 +0,0 @@ -#![crate_type = "proc-macro"] - -extern crate proc_macro; -use proc_macro::*; - -#[proc_macro_attribute] -pub fn cfg(_: TokenStream, input: TokenStream) -> TokenStream { - //~^ ERROR name `cfg` is reserved in macro namespace - input -} - -#[proc_macro_attribute] -pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { - //~^ ERROR name `cfg_attr` is reserved in macro namespace - input -} - -#[proc_macro_attribute] -pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { - //~^ ERROR name `derive` is reserved in macro namespace - input -} diff --git a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr b/src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr deleted file mode 100644 index be6e80c3878..00000000000 --- a/src/test/ui-fulldeps/proc-macro/reserved-macro-names.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: name `cfg` is reserved in macro namespace - --> $DIR/reserved-macro-names.rs:7:8 - | -LL | pub fn cfg(_: TokenStream, input: TokenStream) -> TokenStream { - | ^^^ - -error: name `cfg_attr` is reserved in macro namespace - --> $DIR/reserved-macro-names.rs:13:8 - | -LL | pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { - | ^^^^^^^^ - -error: name `derive` is reserved in macro namespace - --> $DIR/reserved-macro-names.rs:19:8 - | -LL | pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { - | ^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/src/test/ui-fulldeps/proc-macro/signature.rs b/src/test/ui-fulldeps/proc-macro/signature.rs deleted file mode 100644 index f2ea6f778cd..00000000000 --- a/src/test/ui-fulldeps/proc-macro/signature.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "proc-macro"] -#![allow(warnings)] - -extern crate proc_macro; - -#[proc_macro_derive(A)] -pub unsafe extern fn foo(a: i32, b: u32) -> u32 { - //~^ ERROR: mismatched types - loop {} -} diff --git a/src/test/ui-fulldeps/proc-macro/signature.stderr b/src/test/ui-fulldeps/proc-macro/signature.stderr deleted file mode 100644 index fdd10c3c5b9..00000000000 --- a/src/test/ui-fulldeps/proc-macro/signature.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/signature.rs:17:1 - | -LL | / pub unsafe extern fn foo(a: i32, b: u32) -> u32 { -LL | | //~^ ERROR: mismatched types -LL | | loop {} -LL | | } - | |_^ expected normal fn, found unsafe fn - | - = note: expected type `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` - found type `unsafe extern "C" fn(i32, u32) -> u32 {foo}` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui-fulldeps/proc-macro/span-preservation.rs b/src/test/ui-fulldeps/proc-macro/span-preservation.rs deleted file mode 100644 index adcb42ab2d1..00000000000 --- a/src/test/ui-fulldeps/proc-macro/span-preservation.rs +++ /dev/null @@ -1,51 +0,0 @@ -// aux-build:span-preservation.rs - -// For each of these, we should get the appropriate type mismatch error message, -// and the function should be echoed. - -extern crate span_preservation as foo; - -use foo::foo; - -#[foo] -fn a() { - let x: usize = "hello";;;;; -} - -#[foo] -fn b(x: Option) -> usize { - match x { - Some(x) => { return x }, - None => 10 - } -} - -#[foo] -fn c() { - struct Foo { - a: usize - } - - struct Bar { - a: usize, - b: usize - } - - let x = Foo { a: 10isize }; - let y = Foo { a: 10, b: 10isize }; -} - -// FIXME: This doesn't work at the moment. See the one below. The pretty-printer -// injects a "C" between `extern` and `fn` which causes a "probably_eq" -// `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST. -#[foo] -extern fn bar() { - 0 -} - -#[foo] -extern "C" fn baz() { - 0 -} - -fn main() {} diff --git a/src/test/ui-fulldeps/proc-macro/span-preservation.stderr b/src/test/ui-fulldeps/proc-macro/span-preservation.stderr deleted file mode 100644 index f33245aec37..00000000000 --- a/src/test/ui-fulldeps/proc-macro/span-preservation.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0308]: mismatched types - | - = note: expected type `()` - found type `{integer}` - -error[E0308]: mismatched types - --> $DIR/span-preservation.rs:12:20 - | -LL | let x: usize = "hello";;;;; - | ^^^^^^^ expected usize, found reference - | - = note: expected type `usize` - found type `&'static str` - -error[E0308]: mismatched types - --> $DIR/span-preservation.rs:18:29 - | -LL | Some(x) => { return x }, - | ^ expected usize, found isize - -error[E0308]: mismatched types - --> $DIR/span-preservation.rs:34:22 - | -LL | let x = Foo { a: 10isize }; - | ^^^^^^^ expected usize, found isize - -error[E0560]: struct `c::Foo` has no field named `b` - --> $DIR/span-preservation.rs:35:26 - | -LL | let y = Foo { a: 10, b: 10isize }; - | ^ `c::Foo` does not have this field - | - = note: available fields are: `a` - -error[E0308]: mismatched types - --> $DIR/span-preservation.rs:48:5 - | -LL | extern "C" fn baz() { - | - possibly return type missing here? -LL | 0 - | ^ expected (), found integral variable - | - = note: expected type `()` - found type `{integer}` - -error: aborting due to 6 previous errors - -Some errors occurred: E0308, E0560. -For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui-fulldeps/proc-macro/three-equals.rs b/src/test/ui-fulldeps/proc-macro/three-equals.rs deleted file mode 100644 index e3285d3e821..00000000000 --- a/src/test/ui-fulldeps/proc-macro/three-equals.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:three-equals.rs - - -#![feature(proc_macro_hygiene)] - -extern crate three_equals; - -use three_equals::three_equals; - -fn main() { - // This one is okay. - three_equals!(===); - - // Need exactly three equals. - three_equals!(==); //~ ERROR found 2 equal signs, need exactly 3 - - // Need exactly three equals. - three_equals!(=====); //~ ERROR expected EOF - - // Only equals accepted. - three_equals!(abc); //~ ERROR expected `=` - - // Only equals accepted. - three_equals!(!!); //~ ERROR expected `=` - - // Only three characters expected. - three_equals!(===a); //~ ERROR expected EOF -} diff --git a/src/test/ui-fulldeps/proc-macro/three-equals.stderr b/src/test/ui-fulldeps/proc-macro/three-equals.stderr deleted file mode 100644 index 1a0337f93f9..00000000000 --- a/src/test/ui-fulldeps/proc-macro/three-equals.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error: found 2 equal signs, need exactly 3 - --> $DIR/three-equals.rs:25:5 - | -LL | three_equals!(==); //~ ERROR found 2 equal signs, need exactly 3 - | ^^^^^^^^^^^^^^^^^^ - | - = help: input must be: `===` - -error: expected EOF, found `=`. - --> $DIR/three-equals.rs:28:21 - | -LL | three_equals!(=====); //~ ERROR expected EOF - | ^^ - | -note: last good input was here - --> $DIR/three-equals.rs:28:21 - | -LL | three_equals!(=====); //~ ERROR expected EOF - | ^^ - = help: input must be: `===` - -error: expected `=`, found `abc`. - --> $DIR/three-equals.rs:31:19 - | -LL | three_equals!(abc); //~ ERROR expected `=` - | ^^^ - -error: expected `=`, found `!`. - --> $DIR/three-equals.rs:34:19 - | -LL | three_equals!(!!); //~ ERROR expected `=` - | ^ - -error: expected EOF, found `a`. - --> $DIR/three-equals.rs:37:22 - | -LL | three_equals!(===a); //~ ERROR expected EOF - | ^ - | -note: last good input was here - --> $DIR/three-equals.rs:37:21 - | -LL | three_equals!(===a); //~ ERROR expected EOF - | ^ - = help: input must be: `===` - -error: aborting due to 5 previous errors - diff --git a/src/test/ui-fulldeps/resolve-error.rs b/src/test/ui-fulldeps/resolve-error.rs deleted file mode 100644 index 1940151357c..00000000000 --- a/src/test/ui-fulldeps/resolve-error.rs +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:derive-foo.rs -// aux-build:derive-clona.rs -// aux-build:attr_proc_macro.rs -// aux-build:bang_proc_macro.rs - -#![feature(custom_attribute)] - -#[macro_use] -extern crate derive_foo; -#[macro_use] -extern crate derive_clona; -extern crate attr_proc_macro; -extern crate bang_proc_macro; - -use attr_proc_macro::attr_proc_macro; -use bang_proc_macro::bang_proc_macro; - -macro_rules! FooWithLongNam { - () => {} -} - -macro_rules! attr_proc_mac { - () => {} -} - -#[derive(FooWithLongNan)] -//~^ ERROR cannot find -struct Foo; - -#[attr_proc_macra] // OK, interpreted as a custom attribute -struct Bar; - -#[FooWithLongNan] // OK, interpreted as a custom attribute -struct Asdf; - -#[derive(Dlone)] -//~^ ERROR cannot find -struct A; - -#[derive(Dlona)] -//~^ ERROR cannot find -struct B; - -#[derive(attr_proc_macra)] -//~^ ERROR cannot find -struct C; - -fn main() { - FooWithLongNama!(); - //~^ ERROR cannot find - - attr_proc_macra!(); - //~^ ERROR cannot find - - Dlona!(); - //~^ ERROR cannot find - - bang_proc_macrp!(); - //~^ ERROR cannot find -} diff --git a/src/test/ui-fulldeps/resolve-error.stderr b/src/test/ui-fulldeps/resolve-error.stderr deleted file mode 100644 index 59ca668d485..00000000000 --- a/src/test/ui-fulldeps/resolve-error.stderr +++ /dev/null @@ -1,50 +0,0 @@ -error: cannot find derive macro `FooWithLongNan` in this scope - --> $DIR/resolve-error.rs:36:10 - | -LL | #[derive(FooWithLongNan)] - | ^^^^^^^^^^^^^^ help: try: `FooWithLongName` - -error: cannot find derive macro `Dlone` in this scope - --> $DIR/resolve-error.rs:46:10 - | -LL | #[derive(Dlone)] - | ^^^^^ help: try: `Clone` - -error: cannot find derive macro `Dlona` in this scope - --> $DIR/resolve-error.rs:50:10 - | -LL | #[derive(Dlona)] - | ^^^^^ help: try: `Clona` - -error: cannot find derive macro `attr_proc_macra` in this scope - --> $DIR/resolve-error.rs:54:10 - | -LL | #[derive(attr_proc_macra)] - | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro` - -error: cannot find macro `FooWithLongNama!` in this scope - --> $DIR/resolve-error.rs:59:5 - | -LL | FooWithLongNama!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam` - -error: cannot find macro `attr_proc_macra!` in this scope - --> $DIR/resolve-error.rs:62:5 - | -LL | attr_proc_macra!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac` - -error: cannot find macro `Dlona!` in this scope - --> $DIR/resolve-error.rs:65:5 - | -LL | Dlona!(); - | ^^^^^ - -error: cannot find macro `bang_proc_macrp!` in this scope - --> $DIR/resolve-error.rs:68:5 - | -LL | bang_proc_macrp!(); - | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro` - -error: aborting due to 8 previous errors - diff --git a/src/test/ui-fulldeps/rust-2018/auxiliary/suggestions-not-always-applicable.rs b/src/test/ui-fulldeps/rust-2018/auxiliary/suggestions-not-always-applicable.rs deleted file mode 100644 index 7ae4731fde1..00000000000 --- a/src/test/ui-fulldeps/rust-2018/auxiliary/suggestions-not-always-applicable.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// no-prefer-dynamic - -#![crate_type = "proc-macro"] - -extern crate proc_macro; - -use proc_macro::*; - -#[proc_macro_attribute] -pub fn foo(_attr: TokenStream, _f: TokenStream) -> TokenStream { - "pub fn foo() -> ::Foo { ::Foo }".parse().unwrap() -} diff --git a/src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs b/src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs deleted file mode 100644 index 1068c058745..00000000000 --- a/src/test/ui-fulldeps/rust-2018/proc-macro-crate-in-paths.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-pass - -#![crate_type = "proc-macro"] -#![deny(rust_2018_compatibility)] -#![feature(rust_2018_preview)] - -extern crate proc_macro; - -use proc_macro::TokenStream; - -#[proc_macro_derive(Template, attributes(template))] -pub fn derive_template(input: TokenStream) -> TokenStream { - input -} diff --git a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.fixed b/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.fixed deleted file mode 100644 index b64ebed0305..00000000000 --- a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.fixed +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:suggestions-not-always-applicable.rs -// edition:2015 -// run-rustfix -// rustfix-only-machine-applicable -// compile-pass - -#![feature(rust_2018_preview)] -#![warn(rust_2018_compatibility)] - -extern crate suggestions_not_always_applicable as foo; - -pub struct Foo; - -mod test { - use crate::foo::foo; - - #[foo] //~ WARN: absolute paths must start with - //~| WARN: previously accepted - //~| WARN: absolute paths - //~| WARN: previously accepted - fn main() { - } -} - -fn main() { - test::foo(); -} diff --git a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.rs b/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.rs deleted file mode 100644 index b64ebed0305..00000000000 --- a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:suggestions-not-always-applicable.rs -// edition:2015 -// run-rustfix -// rustfix-only-machine-applicable -// compile-pass - -#![feature(rust_2018_preview)] -#![warn(rust_2018_compatibility)] - -extern crate suggestions_not_always_applicable as foo; - -pub struct Foo; - -mod test { - use crate::foo::foo; - - #[foo] //~ WARN: absolute paths must start with - //~| WARN: previously accepted - //~| WARN: absolute paths - //~| WARN: previously accepted - fn main() { - } -} - -fn main() { - test::foo(); -} diff --git a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr b/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr deleted file mode 100644 index 415733a346f..00000000000 --- a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr +++ /dev/null @@ -1,24 +0,0 @@ -warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/suggestions-not-always-applicable.rs:27:5 - | -LL | #[foo] //~ WARN: absolute paths must start with - | ^^^^^^ - | -note: lint level defined here - --> $DIR/suggestions-not-always-applicable.rs:18:9 - | -LL | #![warn(rust_2018_compatibility)] - | ^^^^^^^^^^^^^^^^^^^^^^^ - = note: #[warn(absolute_paths_not_starting_with_crate)] implied by #[warn(rust_2018_compatibility)] - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue #53130 - -warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/suggestions-not-always-applicable.rs:27:5 - | -LL | #[foo] //~ WARN: absolute paths must start with - | ^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue #53130 - diff --git a/src/test/ui-fulldeps/subspan.rs b/src/test/ui-fulldeps/subspan.rs deleted file mode 100644 index dccf6e20448..00000000000 --- a/src/test/ui-fulldeps/subspan.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:subspan.rs - -extern crate subspan; - -use subspan::subspan; - -// This one emits no error. -subspan!(""); - -// Exactly one 'hi'. -subspan!("hi"); //~ ERROR found 'hi's - -// Now two, back to back. -subspan!("hihi"); //~ ERROR found 'hi's - -// Now three, back to back. -subspan!("hihihi"); //~ ERROR found 'hi's - -// Now several, with spacing. -subspan!("why I hide? hi!"); //~ ERROR found 'hi's -subspan!("hey, hi, hidy, hidy, hi hi"); //~ ERROR found 'hi's -subspan!("this is a hi, and this is another hi"); //~ ERROR found 'hi's -subspan!("how are you this evening"); //~ ERROR found 'hi's -subspan!("this is highly eradic"); //~ ERROR found 'hi's - -fn main() { } diff --git a/src/test/ui-fulldeps/subspan.stderr b/src/test/ui-fulldeps/subspan.stderr deleted file mode 100644 index d9339bdaf76..00000000000 --- a/src/test/ui-fulldeps/subspan.stderr +++ /dev/null @@ -1,98 +0,0 @@ -error: found 'hi's - --> $DIR/subspan.rs:21:1 - | -LL | subspan!("hi"); //~ ERROR found 'hi's - | ^^^^^^^^^^^^^^^ - | -note: here - --> $DIR/subspan.rs:21:11 - | -LL | subspan!("hi"); //~ ERROR found 'hi's - | ^^ - -error: found 'hi's - --> $DIR/subspan.rs:24:1 - | -LL | subspan!("hihi"); //~ ERROR found 'hi's - | ^^^^^^^^^^^^^^^^^ - | -note: here - --> $DIR/subspan.rs:24:11 - | -LL | subspan!("hihi"); //~ ERROR found 'hi's - | ^^^^ - -error: found 'hi's - --> $DIR/subspan.rs:27:1 - | -LL | subspan!("hihihi"); //~ ERROR found 'hi's - | ^^^^^^^^^^^^^^^^^^^ - | -note: here - --> $DIR/subspan.rs:27:11 - | -LL | subspan!("hihihi"); //~ ERROR found 'hi's - | ^^^^^^ - -error: found 'hi's - --> $DIR/subspan.rs:30:1 - | -LL | subspan!("why I hide? hi!"); //~ ERROR found 'hi's - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: here - --> $DIR/subspan.rs:30:17 - | -LL | subspan!("why I hide? hi!"); //~ ERROR found 'hi's - | ^^ ^^ - -error: found 'hi's - --> $DIR/subspan.rs:31:1 - | -LL | subspan!("hey, hi, hidy, hidy, hi hi"); //~ ERROR found 'hi's - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: here - --> $DIR/subspan.rs:31:16 - | -LL | subspan!("hey, hi, hidy, hidy, hi hi"); //~ ERROR found 'hi's - | ^^ ^^ ^^ ^^ ^^ - -error: found 'hi's - --> $DIR/subspan.rs:32:1 - | -LL | subspan!("this is a hi, and this is another hi"); //~ ERROR found 'hi's - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: here - --> $DIR/subspan.rs:32:12 - | -LL | subspan!("this is a hi, and this is another hi"); //~ ERROR found 'hi's - | ^^ ^^ ^^ ^^ - -error: found 'hi's - --> $DIR/subspan.rs:33:1 - | -LL | subspan!("how are you this evening"); //~ ERROR found 'hi's - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: here - --> $DIR/subspan.rs:33:24 - | -LL | subspan!("how are you this evening"); //~ ERROR found 'hi's - | ^^ - -error: found 'hi's - --> $DIR/subspan.rs:34:1 - | -LL | subspan!("this is highly eradic"); //~ ERROR found 'hi's - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: here - --> $DIR/subspan.rs:34:12 - | -LL | subspan!("this is highly eradic"); //~ ERROR found 'hi's - | ^^ ^^ - -error: aborting due to 8 previous errors - diff --git a/src/test/ui-fulldeps/unnecessary-extern-crate.rs b/src/test/ui-fulldeps/unnecessary-extern-crate.rs deleted file mode 100644 index 1cdc9229d07..00000000000 --- a/src/test/ui-fulldeps/unnecessary-extern-crate.rs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// edition:2018 - -#![deny(unused_extern_crates)] -#![feature(alloc, test, libc, crate_visibility_modifier)] - -extern crate alloc; -//~^ ERROR unused extern crate -//~| HELP remove -extern crate alloc as x; -//~^ ERROR unused extern crate -//~| HELP remove - -extern crate proc_macro; - -#[macro_use] -extern crate test; - -pub extern crate test as y; - -pub extern crate libc; - -pub(crate) extern crate libc as a; - -crate extern crate libc as b; - -mod foo { - pub(in crate::foo) extern crate libc as c; - - pub(super) extern crate libc as d; - - extern crate alloc; - //~^ ERROR unused extern crate - //~| HELP remove - - extern crate alloc as x; - //~^ ERROR unused extern crate - //~| HELP remove - - pub extern crate test; - - pub extern crate test as y; - - mod bar { - extern crate alloc; - //~^ ERROR unused extern crate - //~| HELP remove - - extern crate alloc as x; - //~^ ERROR unused extern crate - //~| HELP remove - - pub(in crate::foo::bar) extern crate libc as e; - - fn dummy() { - unsafe { - e::getpid(); - } - } - } - - fn dummy() { - unsafe { - c::getpid(); - d::getpid(); - } - } -} - - -fn main() { - unsafe { a::getpid(); } - unsafe { b::getpid(); } - - proc_macro::TokenStream::new(); -} diff --git a/src/test/ui-fulldeps/unnecessary-extern-crate.stderr b/src/test/ui-fulldeps/unnecessary-extern-crate.stderr deleted file mode 100644 index 58ec5901585..00000000000 --- a/src/test/ui-fulldeps/unnecessary-extern-crate.stderr +++ /dev/null @@ -1,44 +0,0 @@ -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:16:1 - | -LL | extern crate alloc; - | ^^^^^^^^^^^^^^^^^^^ help: remove it - | -note: lint level defined here - --> $DIR/unnecessary-extern-crate.rs:13:9 - | -LL | #![deny(unused_extern_crates)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:19:1 - | -LL | extern crate alloc as x; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:41:5 - | -LL | extern crate alloc; - | ^^^^^^^^^^^^^^^^^^^ help: remove it - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:45:5 - | -LL | extern crate alloc as x; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:54:9 - | -LL | extern crate alloc; - | ^^^^^^^^^^^^^^^^^^^ help: remove it - -error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:58:9 - | -LL | extern crate alloc as x; - | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it - -error: aborting due to 6 previous errors - diff --git a/src/test/ui/custom-derive/auxiliary/plugin.rs b/src/test/ui/custom-derive/auxiliary/plugin.rs new file mode 100644 index 00000000000..124bc05b7a3 --- /dev/null +++ b/src/test/ui/custom-derive/auxiliary/plugin.rs @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Foo)] +pub fn derive_foo(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_derive(Bar)] +pub fn derive_bar(input: TokenStream) -> TokenStream { + panic!("lolnope"); +} + +#[proc_macro_derive(WithHelper, attributes(helper))] +pub fn with_helper(input: TokenStream) -> TokenStream { + TokenStream::new() +} + +#[proc_macro_attribute] +pub fn helper(_: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui/custom-derive/derive-in-mod.rs b/src/test/ui/custom-derive/derive-in-mod.rs new file mode 100644 index 00000000000..8478ff1a6ae --- /dev/null +++ b/src/test/ui/custom-derive/derive-in-mod.rs @@ -0,0 +1,13 @@ +// compile-pass +// aux-build:plugin.rs + +extern crate plugin; + +mod inner { + use plugin::WithHelper; + + #[derive(WithHelper)] + struct S; +} + +fn main() {} diff --git a/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.rs b/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.rs new file mode 100644 index 00000000000..ba072ba3568 --- /dev/null +++ b/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.rs @@ -0,0 +1,12 @@ +// aux-build:plugin.rs + +#[macro_use(WithHelper)] +extern crate plugin; + +use plugin::helper; + +#[derive(WithHelper)] +#[helper] //~ ERROR `helper` is ambiguous +struct S; + +fn main() {} diff --git a/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.stderr b/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.stderr new file mode 100644 index 00000000000..2c9d226cc9e --- /dev/null +++ b/src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.stderr @@ -0,0 +1,21 @@ +error[E0659]: `helper` is ambiguous (derive helper attribute vs any other name) + --> $DIR/helper-attr-blocked-by-import-ambig.rs:9:3 + | +LL | #[helper] //~ ERROR `helper` is ambiguous + | ^^^^^^ ambiguous name + | +note: `helper` could refer to the derive helper attribute defined here + --> $DIR/helper-attr-blocked-by-import-ambig.rs:8:10 + | +LL | #[derive(WithHelper)] + | ^^^^^^^^^^ +note: `helper` could also refer to the attribute macro imported here + --> $DIR/helper-attr-blocked-by-import-ambig.rs:6:5 + | +LL | use plugin::helper; + | ^^^^^^^^^^^^^^ + = help: use `crate::helper` to refer to this attribute macro unambiguously + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/custom-derive/helper-attr-blocked-by-import.rs b/src/test/ui/custom-derive/helper-attr-blocked-by-import.rs new file mode 100644 index 00000000000..abbf014f553 --- /dev/null +++ b/src/test/ui/custom-derive/helper-attr-blocked-by-import.rs @@ -0,0 +1,28 @@ +// compile-pass +// aux-build:plugin.rs + +#[macro_use(WithHelper)] +extern crate plugin; + +use self::one::*; +use self::two::*; + +mod helper {} + +mod one { + use helper; + + #[derive(WithHelper)] + #[helper] + struct One; +} + +mod two { + use helper; + + #[derive(WithHelper)] + #[helper] + struct Two; +} + +fn main() {} diff --git a/src/test/ui/custom-derive/issue-36935.rs b/src/test/ui/custom-derive/issue-36935.rs new file mode 100644 index 00000000000..92c47eba9ad --- /dev/null +++ b/src/test/ui/custom-derive/issue-36935.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:plugin.rs + + +#[macro_use] extern crate plugin; + +#[derive(Foo, Bar)] //~ ERROR proc-macro derive panicked +struct Baz { + a: i32, + b: i32, +} + +fn main() {} diff --git a/src/test/ui/custom-derive/issue-36935.stderr b/src/test/ui/custom-derive/issue-36935.stderr new file mode 100644 index 00000000000..ecbe0a9a0c0 --- /dev/null +++ b/src/test/ui/custom-derive/issue-36935.stderr @@ -0,0 +1,10 @@ +error: proc-macro derive panicked + --> $DIR/issue-36935.rs:16:15 + | +LL | #[derive(Foo, Bar)] //~ ERROR proc-macro derive panicked + | ^^^ + | + = help: message: lolnope + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/ambiguous-builtin-attrs-test.rs b/src/test/ui/proc-macro/ambiguous-builtin-attrs-test.rs new file mode 100644 index 00000000000..6a47e50f62d --- /dev/null +++ b/src/test/ui/proc-macro/ambiguous-builtin-attrs-test.rs @@ -0,0 +1,20 @@ +// aux-build:builtin-attrs.rs +// compile-flags:--test + +#![feature(decl_macro, test)] + +extern crate test; +extern crate builtin_attrs; +use builtin_attrs::{test, bench}; + +#[test] // OK, shadowed +fn test() {} + +#[bench] // OK, shadowed +fn bench(b: &mut test::Bencher) {} + +fn not_main() { + Test; + Bench; + NonExistent; //~ ERROR cannot find value `NonExistent` in this scope +} diff --git a/src/test/ui/proc-macro/ambiguous-builtin-attrs-test.stderr b/src/test/ui/proc-macro/ambiguous-builtin-attrs-test.stderr new file mode 100644 index 00000000000..db07055b6a1 --- /dev/null +++ b/src/test/ui/proc-macro/ambiguous-builtin-attrs-test.stderr @@ -0,0 +1,9 @@ +error[E0425]: cannot find value `NonExistent` in this scope + --> $DIR/ambiguous-builtin-attrs-test.rs:19:5 + | +LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope + | ^^^^^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0425`. diff --git a/src/test/ui/proc-macro/ambiguous-builtin-attrs.rs b/src/test/ui/proc-macro/ambiguous-builtin-attrs.rs new file mode 100644 index 00000000000..9f4f0abf324 --- /dev/null +++ b/src/test/ui/proc-macro/ambiguous-builtin-attrs.rs @@ -0,0 +1,31 @@ +// aux-build:builtin-attrs.rs + +#![feature(decl_macro)] //~ ERROR `feature` is ambiguous + +extern crate builtin_attrs; +use builtin_attrs::{test, bench}; +use builtin_attrs::*; + +#[repr(C)] //~ ERROR `repr` is ambiguous +struct S; +#[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous +struct SCond; + +#[test] // OK, shadowed +fn test() {} + +#[bench] // OK, shadowed +fn bench() {} + +fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous + match 0u8 { + #[repr(C)] //~ ERROR `repr` is ambiguous + _ => {} + } +} + +fn main() { + Test; + Bench; + NonExistent; //~ ERROR cannot find value `NonExistent` in this scope +} diff --git a/src/test/ui/proc-macro/ambiguous-builtin-attrs.stderr b/src/test/ui/proc-macro/ambiguous-builtin-attrs.stderr new file mode 100644 index 00000000000..79dc922b9db --- /dev/null +++ b/src/test/ui/proc-macro/ambiguous-builtin-attrs.stderr @@ -0,0 +1,80 @@ +error[E0425]: cannot find value `NonExistent` in this scope + --> $DIR/ambiguous-builtin-attrs.rs:30:5 + | +LL | NonExistent; //~ ERROR cannot find value `NonExistent` in this scope + | ^^^^^^^^^^^ not found in this scope + +error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) + --> $DIR/ambiguous-builtin-attrs.rs:9:3 + | +LL | #[repr(C)] //~ ERROR `repr` is ambiguous + | ^^^^ ambiguous name + | + = note: `repr` could refer to a built-in attribute +note: `repr` could also refer to the attribute macro imported here + --> $DIR/ambiguous-builtin-attrs.rs:7:5 + | +LL | use builtin_attrs::*; + | ^^^^^^^^^^^^^^^^ + = help: use `crate::repr` to refer to this attribute macro unambiguously + +error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) + --> $DIR/ambiguous-builtin-attrs.rs:11:19 + | +LL | #[cfg_attr(all(), repr(C))] //~ ERROR `repr` is ambiguous + | ^^^^ ambiguous name + | + = note: `repr` could refer to a built-in attribute +note: `repr` could also refer to the attribute macro imported here + --> $DIR/ambiguous-builtin-attrs.rs:7:5 + | +LL | use builtin_attrs::*; + | ^^^^^^^^^^^^^^^^ + = help: use `crate::repr` to refer to this attribute macro unambiguously + +error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) + --> $DIR/ambiguous-builtin-attrs.rs:20:34 + | +LL | fn non_macro_expanded_location<#[repr(C)] T>() { //~ ERROR `repr` is ambiguous + | ^^^^ ambiguous name + | + = note: `repr` could refer to a built-in attribute +note: `repr` could also refer to the attribute macro imported here + --> $DIR/ambiguous-builtin-attrs.rs:7:5 + | +LL | use builtin_attrs::*; + | ^^^^^^^^^^^^^^^^ + = help: use `crate::repr` to refer to this attribute macro unambiguously + +error[E0659]: `repr` is ambiguous (built-in attribute vs any other name) + --> $DIR/ambiguous-builtin-attrs.rs:22:11 + | +LL | #[repr(C)] //~ ERROR `repr` is ambiguous + | ^^^^ ambiguous name + | + = note: `repr` could refer to a built-in attribute +note: `repr` could also refer to the attribute macro imported here + --> $DIR/ambiguous-builtin-attrs.rs:7:5 + | +LL | use builtin_attrs::*; + | ^^^^^^^^^^^^^^^^ + = help: use `crate::repr` to refer to this attribute macro unambiguously + +error[E0659]: `feature` is ambiguous (built-in attribute vs any other name) + --> $DIR/ambiguous-builtin-attrs.rs:3:4 + | +LL | #![feature(decl_macro)] //~ ERROR `feature` is ambiguous + | ^^^^^^^ ambiguous name + | + = note: `feature` could refer to a built-in attribute +note: `feature` could also refer to the attribute macro imported here + --> $DIR/ambiguous-builtin-attrs.rs:7:5 + | +LL | use builtin_attrs::*; + | ^^^^^^^^^^^^^^^^ + = help: use `crate::feature` to refer to this attribute macro unambiguously + +error: aborting due to 6 previous errors + +Some errors occurred: E0425, E0659. +For more information about an error, try `rustc --explain E0425`. diff --git a/src/test/ui/proc-macro/attribute-order-restricted.rs b/src/test/ui/proc-macro/attribute-order-restricted.rs new file mode 100644 index 00000000000..7b1eecd1558 --- /dev/null +++ b/src/test/ui/proc-macro/attribute-order-restricted.rs @@ -0,0 +1,14 @@ +// aux-build:attr_proc_macro.rs + +extern crate attr_proc_macro; +use attr_proc_macro::*; + +#[attr_proc_macro] // OK +#[derive(Clone)] +struct Before; + +#[derive(Clone)] +#[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]` +struct After; + +fn main() {} diff --git a/src/test/ui/proc-macro/attribute-order-restricted.stderr b/src/test/ui/proc-macro/attribute-order-restricted.stderr new file mode 100644 index 00000000000..a4f165cd1b5 --- /dev/null +++ b/src/test/ui/proc-macro/attribute-order-restricted.stderr @@ -0,0 +1,8 @@ +error: macro attributes must be placed before `#[derive]` + --> $DIR/attribute-order-restricted.rs:11:1 + | +LL | #[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]` + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/attribute-spans-preserved.rs b/src/test/ui/proc-macro/attribute-spans-preserved.rs new file mode 100644 index 00000000000..af47dad9e0b --- /dev/null +++ b/src/test/ui/proc-macro/attribute-spans-preserved.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:attribute-spans-preserved.rs + +extern crate attribute_spans_preserved as foo; + +use foo::foo; + +#[ foo ( let y: u32 = "z"; ) ] //~ ERROR: mismatched types +#[ bar { let x: u32 = "y"; } ] //~ ERROR: mismatched types +fn main() { +} diff --git a/src/test/ui/proc-macro/attribute-spans-preserved.stderr b/src/test/ui/proc-macro/attribute-spans-preserved.stderr new file mode 100644 index 00000000000..329e5bea61c --- /dev/null +++ b/src/test/ui/proc-macro/attribute-spans-preserved.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/attribute-spans-preserved.rs:17:23 + | +LL | #[ foo ( let y: u32 = "z"; ) ] //~ ERROR: mismatched types + | ^^^ expected u32, found reference + | + = note: expected type `u32` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/attribute-spans-preserved.rs:18:23 + | +LL | #[ bar { let x: u32 = "y"; } ] //~ ERROR: mismatched types + | ^^^ expected u32, found reference + | + = note: expected type `u32` + found type `&'static str` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/proc-macro/attribute-spans-preserved.stdout b/src/test/ui/proc-macro/attribute-spans-preserved.stdout new file mode 100644 index 00000000000..b1487fcd5ed --- /dev/null +++ b/src/test/ui/proc-macro/attribute-spans-preserved.stdout @@ -0,0 +1 @@ +fn main ( ) { let y : u32 = "z" ; { let x : u32 = "y" ; } } diff --git a/src/test/ui/proc-macro/auxiliary/attr_proc_macro.rs b/src/test/ui/proc-macro/auxiliary/attr_proc_macro.rs new file mode 100644 index 00000000000..679cb772868 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/attr_proc_macro.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn attr_proc_macro(_: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui/proc-macro/auxiliary/attribute-spans-preserved.rs b/src/test/ui/proc-macro/auxiliary/attribute-spans-preserved.rs new file mode 100644 index 00000000000..e725cc7afb8 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/attribute-spans-preserved.rs @@ -0,0 +1,44 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_attribute] +pub fn foo(attr: TokenStream, f: TokenStream) -> TokenStream { + let mut tokens = f.into_iter(); + assert_eq!(tokens.next().unwrap().to_string(), "#"); + let next_attr = match tokens.next().unwrap() { + TokenTree::Group(g) => g, + _ => panic!(), + }; + + let fn_tok = tokens.next().unwrap(); + let ident_tok = tokens.next().unwrap(); + let args_tok = tokens.next().unwrap(); + let body = tokens.next().unwrap(); + + let new_body = attr.into_iter() + .chain(next_attr.stream().into_iter().skip(1)); + + let tokens = vec![ + fn_tok, + ident_tok, + args_tok, + Group::new(Delimiter::Brace, new_body.collect()).into(), + ].into_iter().collect::(); + println!("{}", tokens); + return tokens +} diff --git a/src/test/ui/proc-macro/auxiliary/bang_proc_macro.rs b/src/test/ui/proc-macro/auxiliary/bang_proc_macro.rs new file mode 100644 index 00000000000..6484725814a --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/bang_proc_macro.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn bang_proc_macro(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui/proc-macro/auxiliary/builtin-attrs.rs b/src/test/ui/proc-macro/auxiliary/builtin-attrs.rs new file mode 100644 index 00000000000..e18ca57aab1 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/builtin-attrs.rs @@ -0,0 +1,36 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro_attribute] +pub fn feature(_: TokenStream, input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_attribute] +pub fn repr(_: TokenStream, input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_attribute] +pub fn test(_: TokenStream, input: TokenStream) -> TokenStream { + "struct Test;".parse().unwrap() +} + +#[proc_macro_attribute] +pub fn bench(_: TokenStream, input: TokenStream) -> TokenStream { + "struct Bench;".parse().unwrap() +} diff --git a/src/test/ui/proc-macro/auxiliary/derive-clona.rs b/src/test/ui/proc-macro/auxiliary/derive-clona.rs new file mode 100644 index 00000000000..719fbdb15ef --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/derive-clona.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Clona)] +pub fn derive_clonea(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/ui/proc-macro/auxiliary/derive-foo.rs b/src/test/ui/proc-macro/auxiliary/derive-foo.rs new file mode 100644 index 00000000000..64dcf72ba20 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/derive-foo.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(FooWithLongName)] +pub fn derive_foo(input: TokenStream) -> TokenStream { + "".parse().unwrap() +} diff --git a/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed-2.rs b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed-2.rs new file mode 100644 index 00000000000..9912a89dafb --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed-2.rs @@ -0,0 +1,2 @@ +#[macro_export] +macro_rules! my_attr { () => () } diff --git a/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed.rs b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed.rs new file mode 100644 index 00000000000..4e701710f42 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowed.rs @@ -0,0 +1,11 @@ +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro_derive(MyTrait, attributes(my_attr))] +pub fn foo(_: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/src/test/ui/proc-macro/auxiliary/derive-helper-shadowing.rs b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowing.rs new file mode 100644 index 00000000000..0fd8aa5638a --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/derive-helper-shadowing.rs @@ -0,0 +1,16 @@ +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro_attribute] +pub fn my_attr(_: TokenStream, input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_derive(MyTrait, attributes(my_attr))] +pub fn derive(input: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/src/test/ui/proc-macro/auxiliary/derive-panic.rs b/src/test/ui/proc-macro/auxiliary/derive-panic.rs new file mode 100644 index 00000000000..3274f0324e1 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/derive-panic.rs @@ -0,0 +1,23 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic +// force-host + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(A)] +pub fn derive_a(_input: TokenStream) -> TokenStream { + panic!("nope!"); +} diff --git a/src/test/ui/proc-macro/auxiliary/generate-mod.rs b/src/test/ui/proc-macro/auxiliary/generate-mod.rs new file mode 100644 index 00000000000..1ed8ef52027 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/generate-mod.rs @@ -0,0 +1,66 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// run-pass +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro] +pub fn check(_: TokenStream) -> TokenStream { + " + type Alias = FromOutside; // OK + struct Outer; + mod inner { + type Alias = FromOutside; // `FromOutside` shouldn't be available from here + type Inner = Outer; // `Outer` shouldn't be available from here + } + ".parse().unwrap() +} + +#[proc_macro_attribute] +pub fn check_attr(_: TokenStream, _: TokenStream) -> TokenStream { + " + type AliasAttr = FromOutside; // OK + struct OuterAttr; + mod inner_attr { + type Alias = FromOutside; // `FromOutside` shouldn't be available from here + type Inner = OuterAttr; // `OuterAttr` shouldn't be available from here + } + ".parse().unwrap() +} + +#[proc_macro_derive(CheckDerive)] +pub fn check_derive(_: TokenStream) -> TokenStream { + " + type AliasDerive = FromOutside; // OK + struct OuterDerive; + mod inner_derive { + type Alias = FromOutside; // `FromOutside` shouldn't be available from here + type Inner = OuterDerive; // `OuterDerive` shouldn't be available from here + } + ".parse().unwrap() +} + +#[proc_macro_derive(CheckDeriveLint)] +pub fn check_derive_lint(_: TokenStream) -> TokenStream { + " + type AliasDeriveLint = FromOutside; // OK + struct OuterDeriveLint; + #[allow(proc_macro_derive_resolution_fallback)] + mod inner_derive_lint { + type Alias = FromOutside; // `FromOutside` shouldn't be available from here + type Inner = OuterDeriveLint; // `OuterDeriveLint` shouldn't be available from here + } + ".parse().unwrap() +} diff --git a/src/test/ui/proc-macro/auxiliary/invalid-punct-ident.rs b/src/test/ui/proc-macro/auxiliary/invalid-punct-ident.rs new file mode 100644 index 00000000000..cc899fa610d --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/invalid-punct-ident.rs @@ -0,0 +1,38 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_raw_ident)] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro] +pub fn invalid_punct(_: TokenStream) -> TokenStream { + TokenTree::from(Punct::new('`', Spacing::Alone)).into() +} + +#[proc_macro] +pub fn invalid_ident(_: TokenStream) -> TokenStream { + TokenTree::from(Ident::new("*", Span::call_site())).into() +} + +#[proc_macro] +pub fn invalid_raw_ident(_: TokenStream) -> TokenStream { + TokenTree::from(Ident::new_raw("self", Span::call_site())).into() +} + +#[proc_macro] +pub fn lexer_failure(_: TokenStream) -> TokenStream { + "a b ) c".parse().expect("parsing failed without panic") +} diff --git a/src/test/ui/proc-macro/auxiliary/issue-53481.rs b/src/test/ui/proc-macro/auxiliary/issue-53481.rs new file mode 100644 index 00000000000..9554cdde490 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/issue-53481.rs @@ -0,0 +1,12 @@ +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_derive(MyTrait, attributes(my_attr))] +pub fn foo(_: TokenStream) -> TokenStream { + TokenStream::new() +} diff --git a/src/test/ui/proc-macro/auxiliary/lifetimes.rs b/src/test/ui/proc-macro/auxiliary/lifetimes.rs new file mode 100644 index 00000000000..fc59a622bfa --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/lifetimes.rs @@ -0,0 +1,29 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro] +pub fn single_quote_alone(_: TokenStream) -> TokenStream { + // `&'a u8`, but the `'` token is not joint + let trees: Vec = vec![ + Punct::new('&', Spacing::Alone).into(), + Punct::new('\'', Spacing::Alone).into(), + Ident::new("a", Span::call_site()).into(), + Ident::new("u8", Span::call_site()).into(), + ]; + trees.into_iter().collect() +} diff --git a/src/test/ui/proc-macro/auxiliary/macro-brackets.rs b/src/test/ui/proc-macro/auxiliary/macro-brackets.rs new file mode 100644 index 00000000000..be1777f3ebd --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/macro-brackets.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro_attribute] +pub fn doit(_: TokenStream, input: TokenStream) -> TokenStream { + input.into_iter().collect() +} diff --git a/src/test/ui/proc-macro/auxiliary/multispan.rs b/src/test/ui/proc-macro/auxiliary/multispan.rs new file mode 100644 index 00000000000..383016f990e --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/multispan.rs @@ -0,0 +1,46 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)] + +extern crate proc_macro; + +use proc_macro::{TokenStream, TokenTree, Span, Diagnostic}; + +fn parse(input: TokenStream) -> Result<(), Diagnostic> { + let mut hi_spans = vec![]; + for tree in input { + if let TokenTree::Ident(ref ident) = tree { + if ident.to_string() == "hi" { + hi_spans.push(ident.span()); + } + } + } + + if !hi_spans.is_empty() { + return Err(Span::def_site() + .error("hello to you, too!") + .span_note(hi_spans, "found these 'hi's")); + } + + Ok(()) +} + +#[proc_macro] +pub fn hello(input: TokenStream) -> TokenStream { + if let Err(diag) = parse(input) { + diag.emit(); + } + + TokenStream::new() +} diff --git a/src/test/ui/proc-macro/auxiliary/nested-item-spans.rs b/src/test/ui/proc-macro/auxiliary/nested-item-spans.rs new file mode 100644 index 00000000000..6b893150b45 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/nested-item-spans.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_attribute] +pub fn foo(_: TokenStream, item: TokenStream) -> TokenStream { + item.into_iter().collect() +} diff --git a/src/test/ui/proc-macro/auxiliary/parent-source-spans.rs b/src/test/ui/proc-macro/auxiliary/parent-source-spans.rs new file mode 100644 index 00000000000..f5590405e61 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/parent-source-spans.rs @@ -0,0 +1,52 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![feature(proc_macro_diagnostic, proc_macro_span)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::{TokenStream, TokenTree, Span}; + +fn lit_span(tt: TokenTree) -> (Span, String) { + match tt { + TokenTree::Literal(..) | + TokenTree::Group(..) => (tt.span(), tt.to_string().trim().into()), + _ => panic!("expected a literal in token tree, got: {:?}", tt) + } +} + +#[proc_macro] +pub fn parent_source_spans(input: TokenStream) -> TokenStream { + let mut tokens = input.into_iter(); + let (sp1, str1) = lit_span(tokens.next().expect("first string")); + let _ = tokens.next(); + let (sp2, str2) = lit_span(tokens.next().expect("second string")); + + sp1.error(format!("first final: {}", str1)).emit(); + sp2.error(format!("second final: {}", str2)).emit(); + + if let (Some(p1), Some(p2)) = (sp1.parent(), sp2.parent()) { + p1.error(format!("first parent: {}", str1)).emit(); + p2.error(format!("second parent: {}", str2)).emit(); + + if let (Some(gp1), Some(gp2)) = (p1.parent(), p2.parent()) { + gp1.error(format!("first grandparent: {}", str1)).emit(); + gp2.error(format!("second grandparent: {}", str2)).emit(); + } + } + + sp1.source().error(format!("first source: {}", str1)).emit(); + sp2.source().error(format!("second source: {}", str2)).emit(); + + "ok".parse().unwrap() +} diff --git a/src/test/ui/proc-macro/auxiliary/span-preservation.rs b/src/test/ui/proc-macro/auxiliary/span-preservation.rs new file mode 100644 index 00000000000..65ed9cf7372 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/span-preservation.rs @@ -0,0 +1,12 @@ +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_attribute] +pub fn foo(_: TokenStream, input: TokenStream) -> TokenStream { + input.into_iter().collect() +} diff --git a/src/test/ui/proc-macro/auxiliary/subspan.rs b/src/test/ui/proc-macro/auxiliary/subspan.rs new file mode 100644 index 00000000000..134b04d7333 --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/subspan.rs @@ -0,0 +1,47 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_diagnostic, proc_macro_span)] + +extern crate proc_macro; + +use proc_macro::{TokenStream, TokenTree, Span, Diagnostic}; + +fn parse(input: TokenStream) -> Result<(), Diagnostic> { + if let Some(TokenTree::Literal(lit)) = input.into_iter().next() { + let mut spans = vec![]; + let string = lit.to_string(); + for hi in string.matches("hi") { + let index = hi.as_ptr() as usize - string.as_ptr() as usize; + let subspan = lit.subspan(index..(index + hi.len())).unwrap(); + spans.push(subspan); + } + + if !spans.is_empty() { + Err(Span::call_site().error("found 'hi's").span_note(spans, "here")) + } else { + Ok(()) + } + } else { + Err(Span::call_site().error("invalid input: expected string literal")) + } +} + +#[proc_macro] +pub fn subspan(input: TokenStream) -> TokenStream { + if let Err(diag) = parse(input) { + diag.emit(); + } + + TokenStream::new() +} diff --git a/src/test/ui/proc-macro/auxiliary/three-equals.rs b/src/test/ui/proc-macro/auxiliary/three-equals.rs new file mode 100644 index 00000000000..569a458f55a --- /dev/null +++ b/src/test/ui/proc-macro/auxiliary/three-equals.rs @@ -0,0 +1,58 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![feature(proc_macro_diagnostic, proc_macro_span, proc_macro_def_site)] + +extern crate proc_macro; + +use proc_macro::{TokenStream, TokenTree, Span, Diagnostic}; + +fn parse(input: TokenStream) -> Result<(), Diagnostic> { + let mut count = 0; + let mut last_span = Span::def_site(); + for tree in input { + let span = tree.span(); + if count >= 3 { + return Err(span.error(format!("expected EOF, found `{}`.", tree)) + .span_note(last_span, "last good input was here") + .help("input must be: `===`")) + } + + if let TokenTree::Punct(ref tt) = tree { + if tt.as_char() == '=' { + count += 1; + last_span = span; + continue + } + } + return Err(span.error(format!("expected `=`, found `{}`.", tree))); + } + + if count < 3 { + return Err(Span::def_site() + .error(format!("found {} equal signs, need exactly 3", count)) + .help("input must be: `===`")) + } + + Ok(()) +} + +#[proc_macro] +pub fn three_equals(input: TokenStream) -> TokenStream { + if let Err(diag) = parse(input) { + diag.emit(); + return TokenStream::new(); + } + + "3".parse().unwrap() +} diff --git a/src/test/ui/proc-macro/derive-helper-shadowed.rs b/src/test/ui/proc-macro/derive-helper-shadowed.rs new file mode 100644 index 00000000000..792b54b3b94 --- /dev/null +++ b/src/test/ui/proc-macro/derive-helper-shadowed.rs @@ -0,0 +1,16 @@ +// compile-pass +// aux-build:derive-helper-shadowed.rs +// aux-build:derive-helper-shadowed-2.rs + +#[macro_use] +extern crate derive_helper_shadowed; +#[macro_use(my_attr)] +extern crate derive_helper_shadowed_2; + +macro_rules! my_attr { () => () } + +#[derive(MyTrait)] +#[my_attr] // OK +struct S; + +fn main() {} diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.rs b/src/test/ui/proc-macro/derive-helper-shadowing.rs new file mode 100644 index 00000000000..aa9eae0ba31 --- /dev/null +++ b/src/test/ui/proc-macro/derive-helper-shadowing.rs @@ -0,0 +1,10 @@ +// aux-build:derive-helper-shadowing.rs + +extern crate derive_helper_shadowing; +use derive_helper_shadowing::*; + +#[my_attr] //~ ERROR `my_attr` is ambiguous +#[derive(MyTrait)] +struct S; + +fn main() {} diff --git a/src/test/ui/proc-macro/derive-helper-shadowing.stderr b/src/test/ui/proc-macro/derive-helper-shadowing.stderr new file mode 100644 index 00000000000..cc50fefc464 --- /dev/null +++ b/src/test/ui/proc-macro/derive-helper-shadowing.stderr @@ -0,0 +1,21 @@ +error[E0659]: `my_attr` is ambiguous (derive helper attribute vs any other name) + --> $DIR/derive-helper-shadowing.rs:6:3 + | +LL | #[my_attr] //~ ERROR `my_attr` is ambiguous + | ^^^^^^^ ambiguous name + | +note: `my_attr` could refer to the derive helper attribute defined here + --> $DIR/derive-helper-shadowing.rs:7:10 + | +LL | #[derive(MyTrait)] + | ^^^^^^^ +note: `my_attr` could also refer to the attribute macro imported here + --> $DIR/derive-helper-shadowing.rs:4:5 + | +LL | use derive_helper_shadowing::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = help: use `crate::my_attr` to refer to this attribute macro unambiguously + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs b/src/test/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs new file mode 100644 index 00000000000..25a2a376147 --- /dev/null +++ b/src/test/ui/proc-macro/extern-prelude-extern-crate-proc-macro.rs @@ -0,0 +1,7 @@ +// compile-pass +// edition:2018 + +extern crate proc_macro; +use proc_macro::TokenStream; // OK + +fn main() {} diff --git a/src/test/ui/proc-macro/generate-mod.rs b/src/test/ui/proc-macro/generate-mod.rs new file mode 100644 index 00000000000..977faf7decd --- /dev/null +++ b/src/test/ui/proc-macro/generate-mod.rs @@ -0,0 +1,43 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Modules generated by transparent proc macros still acts as barriers for names (issue #50504). + +// aux-build:generate-mod.rs + +extern crate generate_mod; + +struct FromOutside; + +generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope + //~| ERROR cannot find type `Outer` in this scope + +#[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope + //~| ERROR cannot find type `OuterAttr` in this scope +struct S; + +#[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope + //~| WARN cannot find type `OuterDerive` in this scope + //~| WARN this was previously accepted + //~| WARN this was previously accepted +struct Z; + +fn inner_block() { + #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope + //~| WARN cannot find type `OuterDerive` in this scope + //~| WARN this was previously accepted + //~| WARN this was previously accepted + struct InnerZ; +} + +#[derive(generate_mod::CheckDeriveLint)] // OK, lint is suppressed +struct W; + +fn main() {} diff --git a/src/test/ui/proc-macro/generate-mod.stderr b/src/test/ui/proc-macro/generate-mod.stderr new file mode 100644 index 00000000000..a981b1bc8b8 --- /dev/null +++ b/src/test/ui/proc-macro/generate-mod.stderr @@ -0,0 +1,64 @@ +error[E0412]: cannot find type `FromOutside` in this scope + --> $DIR/generate-mod.rs:19:1 + | +LL | generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `Outer` in this scope + --> $DIR/generate-mod.rs:19:1 + | +LL | generate_mod::check!(); //~ ERROR cannot find type `FromOutside` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `FromOutside` in this scope + --> $DIR/generate-mod.rs:22:1 + | +LL | #[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +error[E0412]: cannot find type `OuterAttr` in this scope + --> $DIR/generate-mod.rs:22:1 + | +LL | #[generate_mod::check_attr] //~ ERROR cannot find type `FromOutside` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope + +warning: cannot find type `FromOutside` in this scope + --> $DIR/generate-mod.rs:26:10 + | +LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import + | + = note: #[warn(proc_macro_derive_resolution_fallback)] on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #50504 + +warning: cannot find type `OuterDerive` in this scope + --> $DIR/generate-mod.rs:26:10 + | +LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #50504 + +warning: cannot find type `FromOutside` in this scope + --> $DIR/generate-mod.rs:33:14 + | +LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #50504 + +warning: cannot find type `OuterDerive` in this scope + --> $DIR/generate-mod.rs:33:14 + | +LL | #[derive(generate_mod::CheckDerive)] //~ WARN cannot find type `FromOutside` in this scope + | ^^^^^^^^^^^^^^^^^^^^^^^^^ names from parent modules are not accessible without an explicit import + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #50504 + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0412`. diff --git a/src/test/ui/proc-macro/invalid-attributes.rs b/src/test/ui/proc-macro/invalid-attributes.rs new file mode 100644 index 00000000000..8b940a0f405 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-attributes.rs @@ -0,0 +1,35 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro = "test"] //~ ERROR: does not take any arguments +pub fn a(a: TokenStream) -> TokenStream { a } + +#[proc_macro()] //~ ERROR: does not take any arguments +pub fn c(a: TokenStream) -> TokenStream { a } + +#[proc_macro(x)] //~ ERROR: does not take any arguments +pub fn d(a: TokenStream) -> TokenStream { a } + +#[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments +pub fn e(_: TokenStream, a: TokenStream) -> TokenStream { a } + +#[proc_macro_attribute()] //~ ERROR: does not take any arguments +pub fn g(_: TokenStream, a: TokenStream) -> TokenStream { a } + +#[proc_macro_attribute(x)] //~ ERROR: does not take any arguments +pub fn h(_: TokenStream, a: TokenStream) -> TokenStream { a } diff --git a/src/test/ui/proc-macro/invalid-attributes.stderr b/src/test/ui/proc-macro/invalid-attributes.stderr new file mode 100644 index 00000000000..5fd87362db2 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-attributes.stderr @@ -0,0 +1,38 @@ +error: `#[proc_macro]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:19:1 + | +LL | #[proc_macro = "test"] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[proc_macro]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:22:1 + | +LL | #[proc_macro()] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^ + +error: `#[proc_macro]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:25:1 + | +LL | #[proc_macro(x)] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^ + +error: `#[proc_macro_attribute]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:28:1 + | +LL | #[proc_macro_attribute = "test"] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[proc_macro_attribute]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:31:1 + | +LL | #[proc_macro_attribute()] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[proc_macro_attribute]` attribute does not take any arguments + --> $DIR/invalid-attributes.rs:34:1 + | +LL | #[proc_macro_attribute(x)] //~ ERROR: does not take any arguments + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/ui/proc-macro/invalid-punct-ident-1.rs b/src/test/ui/proc-macro/invalid-punct-ident-1.rs new file mode 100644 index 00000000000..576c156c105 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-punct-ident-1.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:invalid-punct-ident.rs + +#[macro_use] +extern crate invalid_punct_ident; + +invalid_punct!(); //~ ERROR proc macro panicked diff --git a/src/test/ui/proc-macro/invalid-punct-ident-1.stderr b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr new file mode 100644 index 00000000000..3b3619e2637 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-punct-ident-1.stderr @@ -0,0 +1,10 @@ +error: proc macro panicked + --> $DIR/invalid-punct-ident-1.rs:16:1 + | +LL | invalid_punct!(); //~ ERROR proc macro panicked + | ^^^^^^^^^^^^^^^^^ + | + = help: message: unsupported character `'`'` + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/invalid-punct-ident-2.rs b/src/test/ui/proc-macro/invalid-punct-ident-2.rs new file mode 100644 index 00000000000..874a7d169d1 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-punct-ident-2.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:invalid-punct-ident.rs + +#[macro_use] +extern crate invalid_punct_ident; + +invalid_ident!(); //~ ERROR proc macro panicked diff --git a/src/test/ui/proc-macro/invalid-punct-ident-2.stderr b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr new file mode 100644 index 00000000000..869c0908bb5 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-punct-ident-2.stderr @@ -0,0 +1,10 @@ +error: proc macro panicked + --> $DIR/invalid-punct-ident-2.rs:16:1 + | +LL | invalid_ident!(); //~ ERROR proc macro panicked + | ^^^^^^^^^^^^^^^^^ + | + = help: message: `"*"` is not a valid identifier + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/invalid-punct-ident-3.rs b/src/test/ui/proc-macro/invalid-punct-ident-3.rs new file mode 100644 index 00000000000..f73bf500545 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-punct-ident-3.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:invalid-punct-ident.rs + +#[macro_use] +extern crate invalid_punct_ident; + +invalid_raw_ident!(); //~ ERROR proc macro panicked diff --git a/src/test/ui/proc-macro/invalid-punct-ident-3.stderr b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr new file mode 100644 index 00000000000..716f6ffa098 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-punct-ident-3.stderr @@ -0,0 +1,10 @@ +error: proc macro panicked + --> $DIR/invalid-punct-ident-3.rs:16:1 + | +LL | invalid_raw_ident!(); //~ ERROR proc macro panicked + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: message: `"self"` is not a valid raw identifier + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/invalid-punct-ident-4.rs b/src/test/ui/proc-macro/invalid-punct-ident-4.rs new file mode 100644 index 00000000000..1e93c69c650 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-punct-ident-4.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:invalid-punct-ident.rs + +#[macro_use] +extern crate invalid_punct_ident; + +lexer_failure!(); //~ ERROR proc macro panicked + //~| ERROR unexpected close delimiter: `)` diff --git a/src/test/ui/proc-macro/invalid-punct-ident-4.stderr b/src/test/ui/proc-macro/invalid-punct-ident-4.stderr new file mode 100644 index 00000000000..669a1eb5839 --- /dev/null +++ b/src/test/ui/proc-macro/invalid-punct-ident-4.stderr @@ -0,0 +1,14 @@ +error: unexpected close delimiter: `)` + --> $DIR/invalid-punct-ident-4.rs:16:1 + | +LL | lexer_failure!(); //~ ERROR proc macro panicked + | ^^^^^^^^^^^^^^^^^ unexpected close delimiter + +error: proc macro panicked + --> $DIR/invalid-punct-ident-4.rs:16:1 + | +LL | lexer_failure!(); //~ ERROR proc macro panicked + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/proc-macro/issue-53481.rs b/src/test/ui/proc-macro/issue-53481.rs new file mode 100644 index 00000000000..479fd1db630 --- /dev/null +++ b/src/test/ui/proc-macro/issue-53481.rs @@ -0,0 +1,22 @@ +// compile-pass +// aux-build:issue-53481.rs + +#[macro_use] +extern crate issue_53481; + +mod m1 { + use m2::MyTrait; + + #[derive(MyTrait)] + struct A {} +} + +mod m2 { + pub type MyTrait = u8; + + #[derive(MyTrait)] + #[my_attr] + struct B {} +} + +fn main() {} diff --git a/src/test/ui/proc-macro/lifetimes.rs b/src/test/ui/proc-macro/lifetimes.rs new file mode 100644 index 00000000000..ff6464a7a3a --- /dev/null +++ b/src/test/ui/proc-macro/lifetimes.rs @@ -0,0 +1,19 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:lifetimes.rs + +#![feature(proc_macro_hygiene)] + +extern crate lifetimes; + +use lifetimes::*; + +type A = single_quote_alone!(); //~ ERROR expected type, found `'` diff --git a/src/test/ui/proc-macro/lifetimes.stderr b/src/test/ui/proc-macro/lifetimes.stderr new file mode 100644 index 00000000000..6baf2b16998 --- /dev/null +++ b/src/test/ui/proc-macro/lifetimes.stderr @@ -0,0 +1,8 @@ +error: expected type, found `'` + --> $DIR/lifetimes.rs:19:10 + | +LL | type A = single_quote_alone!(); //~ ERROR expected type, found `'` + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/load-panic.rs b/src/test/ui/proc-macro/load-panic.rs new file mode 100644 index 00000000000..462eaf03417 --- /dev/null +++ b/src/test/ui/proc-macro/load-panic.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-panic.rs +// compile-flags:--error-format human + +#[macro_use] +extern crate derive_panic; + +#[derive(A)] +//~^ ERROR: proc-macro derive panicked +struct Foo; + +fn main() {} diff --git a/src/test/ui/proc-macro/load-panic.stderr b/src/test/ui/proc-macro/load-panic.stderr new file mode 100644 index 00000000000..30ad53f9041 --- /dev/null +++ b/src/test/ui/proc-macro/load-panic.stderr @@ -0,0 +1,10 @@ +error: proc-macro derive panicked + --> $DIR/load-panic.rs:17:10 + | +LL | #[derive(A)] + | ^ + | + = help: message: nope! + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/macro-brackets.rs b/src/test/ui/proc-macro/macro-brackets.rs new file mode 100644 index 00000000000..b29f2775201 --- /dev/null +++ b/src/test/ui/proc-macro/macro-brackets.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:macro-brackets.rs + +extern crate macro_brackets as bar; +use bar::doit; + +macro_rules! id { + ($($t:tt)*) => ($($t)*) +} + +#[doit] +id![static X: u32 = 'a';]; //~ ERROR: mismatched types + + +fn main() {} diff --git a/src/test/ui/proc-macro/macro-brackets.stderr b/src/test/ui/proc-macro/macro-brackets.stderr new file mode 100644 index 00000000000..7c263d38df9 --- /dev/null +++ b/src/test/ui/proc-macro/macro-brackets.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/macro-brackets.rs:21:21 + | +LL | id![static X: u32 = 'a';]; //~ ERROR: mismatched types + | ^^^ expected u32, found char + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/proc-macro/macro-namespace-reserved-2.rs b/src/test/ui/proc-macro/macro-namespace-reserved-2.rs new file mode 100644 index 00000000000..fa05ad2fc60 --- /dev/null +++ b/src/test/ui/proc-macro/macro-namespace-reserved-2.rs @@ -0,0 +1,55 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro] +pub fn my_macro(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_attribute] +pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream { + input +} + +#[proc_macro_derive(MyTrait)] +pub fn my_macro_derive(input: TokenStream) -> TokenStream { + input +} + +fn check_bang1() { + my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it +} +fn check_bang2() { + my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines it +} +fn check_bang3() { + MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it +} + +#[my_macro] //~ ERROR can't use a procedural macro from the same crate that defines it +fn check_attr1() {} +#[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it +fn check_attr2() {} +#[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it +fn check_attr3() {} + +#[derive(my_macro)] //~ ERROR can't use a procedural macro from the same crate that defines it +struct CheckDerive1; +#[derive(my_macro_attr)] //~ ERROR can't use a procedural macro from the same crate that defines it +struct CheckDerive2; +#[derive(MyTrait)] //~ ERROR can't use a procedural macro from the same crate that defines it +struct CheckDerive3; diff --git a/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr new file mode 100644 index 00000000000..9def03e9450 --- /dev/null +++ b/src/test/ui/proc-macro/macro-namespace-reserved-2.stderr @@ -0,0 +1,56 @@ +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:34:5 + | +LL | my_macro!(); //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^^ + +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:37:5 + | +LL | my_macro_attr!(); //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^^^^^^^ + +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:40:5 + | +LL | MyTrait!(); //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^ + +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:43:3 + | +LL | #[my_macro] //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^^ + +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:45:3 + | +LL | #[my_macro_attr] //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^^^^^^^ + +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:47:3 + | +LL | #[MyTrait] //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^ + +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:50:10 + | +LL | #[derive(my_macro)] //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^^ + +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:52:10 + | +LL | #[derive(my_macro_attr)] //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^^^^^^^ + +error: can't use a procedural macro from the same crate that defines it + --> $DIR/macro-namespace-reserved-2.rs:54:10 + | +LL | #[derive(MyTrait)] //~ ERROR can't use a procedural macro from the same crate that defines it + | ^^^^^^^ + +error: aborting due to 9 previous errors + diff --git a/src/test/ui/proc-macro/macro-namespace-reserved.rs b/src/test/ui/proc-macro/macro-namespace-reserved.rs new file mode 100644 index 00000000000..e7bb05de88c --- /dev/null +++ b/src/test/ui/proc-macro/macro-namespace-reserved.rs @@ -0,0 +1,47 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![feature(decl_macro)] +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro] +pub fn my_macro(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro_attribute] +pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream { + input +} + +#[proc_macro_derive(MyTrait)] +pub fn my_macro_derive(input: TokenStream) -> TokenStream { + input +} + +macro my_macro() {} //~ ERROR the name `my_macro` is defined multiple times +macro my_macro_attr() {} //~ ERROR the name `my_macro_attr` is defined multiple times +macro MyTrait() {} //~ ERROR the name `MyTrait` is defined multiple times + +#[proc_macro_derive(SameName)] +pub fn foo(input: TokenStream) -> TokenStream { + input +} + +#[proc_macro] +pub fn SameName(input: TokenStream) -> TokenStream { +//~^ ERROR the name `SameName` is defined multiple times + input +} diff --git a/src/test/ui/proc-macro/macro-namespace-reserved.stderr b/src/test/ui/proc-macro/macro-namespace-reserved.stderr new file mode 100644 index 00000000000..44b51edcc0b --- /dev/null +++ b/src/test/ui/proc-macro/macro-namespace-reserved.stderr @@ -0,0 +1,47 @@ +error[E0428]: the name `my_macro` is defined multiple times + --> $DIR/macro-namespace-reserved.rs:34:1 + | +LL | pub fn my_macro(input: TokenStream) -> TokenStream { + | -------------------------------------------------- previous definition of the macro `my_macro` here +... +LL | macro my_macro() {} //~ ERROR the name `my_macro` is defined multiple times + | ^^^^^^^^^^^^^^^^ `my_macro` redefined here + | + = note: `my_macro` must be defined only once in the macro namespace of this module + +error[E0428]: the name `my_macro_attr` is defined multiple times + --> $DIR/macro-namespace-reserved.rs:35:1 + | +LL | pub fn my_macro_attr(input: TokenStream, _: TokenStream) -> TokenStream { + | ----------------------------------------------------------------------- previous definition of the macro `my_macro_attr` here +... +LL | macro my_macro_attr() {} //~ ERROR the name `my_macro_attr` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^ `my_macro_attr` redefined here + | + = note: `my_macro_attr` must be defined only once in the macro namespace of this module + +error[E0428]: the name `MyTrait` is defined multiple times + --> $DIR/macro-namespace-reserved.rs:36:1 + | +LL | #[proc_macro_derive(MyTrait)] + | ------- previous definition of the macro `MyTrait` here +... +LL | macro MyTrait() {} //~ ERROR the name `MyTrait` is defined multiple times + | ^^^^^^^^^^^^^^^ `MyTrait` redefined here + | + = note: `MyTrait` must be defined only once in the macro namespace of this module + +error[E0428]: the name `SameName` is defined multiple times + --> $DIR/macro-namespace-reserved.rs:44:1 + | +LL | #[proc_macro_derive(SameName)] + | -------- previous definition of the macro `SameName` here +... +LL | pub fn SameName(input: TokenStream) -> TokenStream { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `SameName` redefined here + | + = note: `SameName` must be defined only once in the macro namespace of this module + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0428`. diff --git a/src/test/ui/proc-macro/macro-use-attr.rs b/src/test/ui/proc-macro/macro-use-attr.rs new file mode 100644 index 00000000000..904562e903d --- /dev/null +++ b/src/test/ui/proc-macro/macro-use-attr.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// aux-build:attr_proc_macro.rs + +#[macro_use] extern crate attr_proc_macro; + +#[attr_proc_macro] +struct Foo; + +fn main() { + let _ = Foo; +} diff --git a/src/test/ui/proc-macro/macro-use-bang.rs b/src/test/ui/proc-macro/macro-use-bang.rs new file mode 100644 index 00000000000..d7713f48e70 --- /dev/null +++ b/src/test/ui/proc-macro/macro-use-bang.rs @@ -0,0 +1,21 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass +// aux-build:bang_proc_macro.rs + +#![feature(proc_macro_hygiene)] + +#[macro_use] +extern crate bang_proc_macro; + +fn main() { + bang_proc_macro!(println!("Hello, world!")); +} diff --git a/src/test/ui/proc-macro/multispan.rs b/src/test/ui/proc-macro/multispan.rs new file mode 100644 index 00000000000..03067868a81 --- /dev/null +++ b/src/test/ui/proc-macro/multispan.rs @@ -0,0 +1,37 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:multispan.rs + +#![feature(proc_macro_hygiene)] + +extern crate multispan; + +use multispan::hello; + +fn main() { + // This one emits no error. + hello!(); + + // Exactly one 'hi'. + hello!(hi); //~ ERROR hello to you, too! + + // Now two, back to back. + hello!(hi hi); //~ ERROR hello to you, too! + + // Now three, back to back. + hello!(hi hi hi); //~ ERROR hello to you, too! + + // Now several, with spacing. + hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! + hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! + hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! + hello!(hi good hi and good bye); //~ ERROR hello to you, too! +} diff --git a/src/test/ui/proc-macro/multispan.stderr b/src/test/ui/proc-macro/multispan.stderr new file mode 100644 index 00000000000..39bdbb5e450 --- /dev/null +++ b/src/test/ui/proc-macro/multispan.stderr @@ -0,0 +1,86 @@ +error: hello to you, too! + --> $DIR/multispan.rs:24:5 + | +LL | hello!(hi); //~ ERROR hello to you, too! + | ^^^^^^^^^^^ + | +note: found these 'hi's + --> $DIR/multispan.rs:24:12 + | +LL | hello!(hi); //~ ERROR hello to you, too! + | ^^ + +error: hello to you, too! + --> $DIR/multispan.rs:27:5 + | +LL | hello!(hi hi); //~ ERROR hello to you, too! + | ^^^^^^^^^^^^^^ + | +note: found these 'hi's + --> $DIR/multispan.rs:27:12 + | +LL | hello!(hi hi); //~ ERROR hello to you, too! + | ^^ ^^ + +error: hello to you, too! + --> $DIR/multispan.rs:30:5 + | +LL | hello!(hi hi hi); //~ ERROR hello to you, too! + | ^^^^^^^^^^^^^^^^^ + | +note: found these 'hi's + --> $DIR/multispan.rs:30:12 + | +LL | hello!(hi hi hi); //~ ERROR hello to you, too! + | ^^ ^^ ^^ + +error: hello to you, too! + --> $DIR/multispan.rs:33:5 + | +LL | hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: found these 'hi's + --> $DIR/multispan.rs:33:12 + | +LL | hello!(hi hey hi yo hi beep beep hi hi); //~ ERROR hello to you, too! + | ^^ ^^ ^^ ^^ ^^ + +error: hello to you, too! + --> $DIR/multispan.rs:34:5 + | +LL | hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: found these 'hi's + --> $DIR/multispan.rs:34:12 + | +LL | hello!(hi there, hi how are you? hi... hi.); //~ ERROR hello to you, too! + | ^^ ^^ ^^ ^^ + +error: hello to you, too! + --> $DIR/multispan.rs:35:5 + | +LL | hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: found these 'hi's + --> $DIR/multispan.rs:35:19 + | +LL | hello!(whoah. hi di hi di ho); //~ ERROR hello to you, too! + | ^^ ^^ + +error: hello to you, too! + --> $DIR/multispan.rs:36:5 + | +LL | hello!(hi good hi and good bye); //~ ERROR hello to you, too! + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: found these 'hi's + --> $DIR/multispan.rs:36:12 + | +LL | hello!(hi good hi and good bye); //~ ERROR hello to you, too! + | ^^ ^^ + +error: aborting due to 7 previous errors + diff --git a/src/test/ui/proc-macro/nested-item-spans.rs b/src/test/ui/proc-macro/nested-item-spans.rs new file mode 100644 index 00000000000..8f059d6344d --- /dev/null +++ b/src/test/ui/proc-macro/nested-item-spans.rs @@ -0,0 +1,34 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:nested-item-spans.rs + +extern crate nested_item_spans; + +use nested_item_spans::foo; + +#[foo] +fn another() { + fn bar() { + let x: u32 = "x"; //~ ERROR: mismatched types + } + + bar(); +} + +fn main() { + #[foo] + fn bar() { + let x: u32 = "x"; //~ ERROR: mismatched types + } + + bar(); + another(); +} diff --git a/src/test/ui/proc-macro/nested-item-spans.stderr b/src/test/ui/proc-macro/nested-item-spans.stderr new file mode 100644 index 00000000000..75140747e8c --- /dev/null +++ b/src/test/ui/proc-macro/nested-item-spans.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/nested-item-spans.rs:20:22 + | +LL | let x: u32 = "x"; //~ ERROR: mismatched types + | ^^^ expected u32, found reference + | + = note: expected type `u32` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/nested-item-spans.rs:29:22 + | +LL | let x: u32 = "x"; //~ ERROR: mismatched types + | ^^^ expected u32, found reference + | + = note: expected type `u32` + found type `&'static str` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/proc-macro/non-root.rs b/src/test/ui/proc-macro/non-root.rs new file mode 100644 index 00000000000..24404885788 --- /dev/null +++ b/src/test/ui/proc-macro/non-root.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +fn foo(arg: TokenStream) -> TokenStream { + #[proc_macro] + pub fn foo(arg: TokenStream) -> TokenStream { arg } + //~^ ERROR functions tagged with `#[proc_macro]` must currently reside in the root of the crate + + arg +} diff --git a/src/test/ui/proc-macro/non-root.stderr b/src/test/ui/proc-macro/non-root.stderr new file mode 100644 index 00000000000..23222a2b851 --- /dev/null +++ b/src/test/ui/proc-macro/non-root.stderr @@ -0,0 +1,8 @@ +error: functions tagged with `#[proc_macro]` must currently reside in the root of the crate + --> $DIR/non-root.rs:20:5 + | +LL | pub fn foo(arg: TokenStream) -> TokenStream { arg } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/proc-macro/parent-source-spans.rs b/src/test/ui/proc-macro/parent-source-spans.rs new file mode 100644 index 00000000000..8f8e22ba1c3 --- /dev/null +++ b/src/test/ui/proc-macro/parent-source-spans.rs @@ -0,0 +1,61 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:parent-source-spans.rs + + +#![feature(decl_macro, proc_macro_hygiene)] + +extern crate parent_source_spans; + +use parent_source_spans::parent_source_spans; + +macro one($a:expr, $b:expr) { + two!($a, $b); + //~^ ERROR first parent: "hello" + //~| ERROR second parent: "world" +} + +macro two($a:expr, $b:expr) { + three!($a, $b); + //~^ ERROR first final: "hello" + //~| ERROR second final: "world" + //~| ERROR first final: "yay" + //~| ERROR second final: "rust" +} + +// forwarding tokens directly doesn't create a new source chain +macro three($($tokens:tt)*) { + four!($($tokens)*); +} + +macro four($($tokens:tt)*) { + parent_source_spans!($($tokens)*); +} + +fn main() { + one!("hello", "world"); + //~^ ERROR first grandparent: "hello" + //~| ERROR second grandparent: "world" + //~| ERROR first source: "hello" + //~| ERROR second source: "world" + + two!("yay", "rust"); + //~^ ERROR first parent: "yay" + //~| ERROR second parent: "rust" + //~| ERROR first source: "yay" + //~| ERROR second source: "rust" + + three!("hip", "hop"); + //~^ ERROR first final: "hip" + //~| ERROR second final: "hop" + //~| ERROR first source: "hip" + //~| ERROR second source: "hop" +} diff --git a/src/test/ui/proc-macro/parent-source-spans.stderr b/src/test/ui/proc-macro/parent-source-spans.stderr new file mode 100644 index 00000000000..0442c4f6ce7 --- /dev/null +++ b/src/test/ui/proc-macro/parent-source-spans.stderr @@ -0,0 +1,128 @@ +error: first final: "hello" + --> $DIR/parent-source-spans.rs:27:12 + | +LL | three!($a, $b); + | ^^ +... +LL | one!("hello", "world"); + | ----------------------- in this macro invocation + +error: second final: "world" + --> $DIR/parent-source-spans.rs:27:16 + | +LL | three!($a, $b); + | ^^ +... +LL | one!("hello", "world"); + | ----------------------- in this macro invocation + +error: first parent: "hello" + --> $DIR/parent-source-spans.rs:21:5 + | +LL | two!($a, $b); + | ^^^^^^^^^^^^^ +... +LL | one!("hello", "world"); + | ----------------------- in this macro invocation + +error: second parent: "world" + --> $DIR/parent-source-spans.rs:21:5 + | +LL | two!($a, $b); + | ^^^^^^^^^^^^^ +... +LL | one!("hello", "world"); + | ----------------------- in this macro invocation + +error: first grandparent: "hello" + --> $DIR/parent-source-spans.rs:44:5 + | +LL | one!("hello", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: second grandparent: "world" + --> $DIR/parent-source-spans.rs:44:5 + | +LL | one!("hello", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: first source: "hello" + --> $DIR/parent-source-spans.rs:44:5 + | +LL | one!("hello", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: second source: "world" + --> $DIR/parent-source-spans.rs:44:5 + | +LL | one!("hello", "world"); + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: first final: "yay" + --> $DIR/parent-source-spans.rs:27:12 + | +LL | three!($a, $b); + | ^^ +... +LL | two!("yay", "rust"); + | -------------------- in this macro invocation + +error: second final: "rust" + --> $DIR/parent-source-spans.rs:27:16 + | +LL | three!($a, $b); + | ^^ +... +LL | two!("yay", "rust"); + | -------------------- in this macro invocation + +error: first parent: "yay" + --> $DIR/parent-source-spans.rs:50:5 + | +LL | two!("yay", "rust"); + | ^^^^^^^^^^^^^^^^^^^^ + +error: second parent: "rust" + --> $DIR/parent-source-spans.rs:50:5 + | +LL | two!("yay", "rust"); + | ^^^^^^^^^^^^^^^^^^^^ + +error: first source: "yay" + --> $DIR/parent-source-spans.rs:50:5 + | +LL | two!("yay", "rust"); + | ^^^^^^^^^^^^^^^^^^^^ + +error: second source: "rust" + --> $DIR/parent-source-spans.rs:50:5 + | +LL | two!("yay", "rust"); + | ^^^^^^^^^^^^^^^^^^^^ + +error: first final: "hip" + --> $DIR/parent-source-spans.rs:56:12 + | +LL | three!("hip", "hop"); + | ^^^^^ + +error: second final: "hop" + --> $DIR/parent-source-spans.rs:56:19 + | +LL | three!("hip", "hop"); + | ^^^^^ + +error: first source: "hip" + --> $DIR/parent-source-spans.rs:56:12 + | +LL | three!("hip", "hop"); + | ^^^^^ + +error: second source: "hop" + --> $DIR/parent-source-spans.rs:56:19 + | +LL | three!("hip", "hop"); + | ^^^^^ + +error: aborting due to 18 previous errors + diff --git a/src/test/ui/proc-macro/reserved-macro-names.rs b/src/test/ui/proc-macro/reserved-macro-names.rs new file mode 100644 index 00000000000..ff5984aa67c --- /dev/null +++ b/src/test/ui/proc-macro/reserved-macro-names.rs @@ -0,0 +1,22 @@ +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +#[proc_macro_attribute] +pub fn cfg(_: TokenStream, input: TokenStream) -> TokenStream { + //~^ ERROR name `cfg` is reserved in macro namespace + input +} + +#[proc_macro_attribute] +pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { + //~^ ERROR name `cfg_attr` is reserved in macro namespace + input +} + +#[proc_macro_attribute] +pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { + //~^ ERROR name `derive` is reserved in macro namespace + input +} diff --git a/src/test/ui/proc-macro/reserved-macro-names.stderr b/src/test/ui/proc-macro/reserved-macro-names.stderr new file mode 100644 index 00000000000..be6e80c3878 --- /dev/null +++ b/src/test/ui/proc-macro/reserved-macro-names.stderr @@ -0,0 +1,20 @@ +error: name `cfg` is reserved in macro namespace + --> $DIR/reserved-macro-names.rs:7:8 + | +LL | pub fn cfg(_: TokenStream, input: TokenStream) -> TokenStream { + | ^^^ + +error: name `cfg_attr` is reserved in macro namespace + --> $DIR/reserved-macro-names.rs:13:8 + | +LL | pub fn cfg_attr(_: TokenStream, input: TokenStream) -> TokenStream { + | ^^^^^^^^ + +error: name `derive` is reserved in macro namespace + --> $DIR/reserved-macro-names.rs:19:8 + | +LL | pub fn derive(_: TokenStream, input: TokenStream) -> TokenStream { + | ^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/proc-macro/resolve-error.rs b/src/test/ui/proc-macro/resolve-error.rs new file mode 100644 index 00000000000..1940151357c --- /dev/null +++ b/src/test/ui/proc-macro/resolve-error.rs @@ -0,0 +1,70 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:derive-foo.rs +// aux-build:derive-clona.rs +// aux-build:attr_proc_macro.rs +// aux-build:bang_proc_macro.rs + +#![feature(custom_attribute)] + +#[macro_use] +extern crate derive_foo; +#[macro_use] +extern crate derive_clona; +extern crate attr_proc_macro; +extern crate bang_proc_macro; + +use attr_proc_macro::attr_proc_macro; +use bang_proc_macro::bang_proc_macro; + +macro_rules! FooWithLongNam { + () => {} +} + +macro_rules! attr_proc_mac { + () => {} +} + +#[derive(FooWithLongNan)] +//~^ ERROR cannot find +struct Foo; + +#[attr_proc_macra] // OK, interpreted as a custom attribute +struct Bar; + +#[FooWithLongNan] // OK, interpreted as a custom attribute +struct Asdf; + +#[derive(Dlone)] +//~^ ERROR cannot find +struct A; + +#[derive(Dlona)] +//~^ ERROR cannot find +struct B; + +#[derive(attr_proc_macra)] +//~^ ERROR cannot find +struct C; + +fn main() { + FooWithLongNama!(); + //~^ ERROR cannot find + + attr_proc_macra!(); + //~^ ERROR cannot find + + Dlona!(); + //~^ ERROR cannot find + + bang_proc_macrp!(); + //~^ ERROR cannot find +} diff --git a/src/test/ui/proc-macro/resolve-error.stderr b/src/test/ui/proc-macro/resolve-error.stderr new file mode 100644 index 00000000000..59ca668d485 --- /dev/null +++ b/src/test/ui/proc-macro/resolve-error.stderr @@ -0,0 +1,50 @@ +error: cannot find derive macro `FooWithLongNan` in this scope + --> $DIR/resolve-error.rs:36:10 + | +LL | #[derive(FooWithLongNan)] + | ^^^^^^^^^^^^^^ help: try: `FooWithLongName` + +error: cannot find derive macro `Dlone` in this scope + --> $DIR/resolve-error.rs:46:10 + | +LL | #[derive(Dlone)] + | ^^^^^ help: try: `Clone` + +error: cannot find derive macro `Dlona` in this scope + --> $DIR/resolve-error.rs:50:10 + | +LL | #[derive(Dlona)] + | ^^^^^ help: try: `Clona` + +error: cannot find derive macro `attr_proc_macra` in this scope + --> $DIR/resolve-error.rs:54:10 + | +LL | #[derive(attr_proc_macra)] + | ^^^^^^^^^^^^^^^ help: try: `attr_proc_macro` + +error: cannot find macro `FooWithLongNama!` in this scope + --> $DIR/resolve-error.rs:59:5 + | +LL | FooWithLongNama!(); + | ^^^^^^^^^^^^^^^ help: you could try the macro: `FooWithLongNam` + +error: cannot find macro `attr_proc_macra!` in this scope + --> $DIR/resolve-error.rs:62:5 + | +LL | attr_proc_macra!(); + | ^^^^^^^^^^^^^^^ help: you could try the macro: `attr_proc_mac` + +error: cannot find macro `Dlona!` in this scope + --> $DIR/resolve-error.rs:65:5 + | +LL | Dlona!(); + | ^^^^^ + +error: cannot find macro `bang_proc_macrp!` in this scope + --> $DIR/resolve-error.rs:68:5 + | +LL | bang_proc_macrp!(); + | ^^^^^^^^^^^^^^^ help: you could try the macro: `bang_proc_macro` + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/proc-macro/signature.rs b/src/test/ui/proc-macro/signature.rs new file mode 100644 index 00000000000..f2ea6f778cd --- /dev/null +++ b/src/test/ui/proc-macro/signature.rs @@ -0,0 +1,20 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] +#![allow(warnings)] + +extern crate proc_macro; + +#[proc_macro_derive(A)] +pub unsafe extern fn foo(a: i32, b: u32) -> u32 { + //~^ ERROR: mismatched types + loop {} +} diff --git a/src/test/ui/proc-macro/signature.stderr b/src/test/ui/proc-macro/signature.stderr new file mode 100644 index 00000000000..fdd10c3c5b9 --- /dev/null +++ b/src/test/ui/proc-macro/signature.stderr @@ -0,0 +1,15 @@ +error[E0308]: mismatched types + --> $DIR/signature.rs:17:1 + | +LL | / pub unsafe extern fn foo(a: i32, b: u32) -> u32 { +LL | | //~^ ERROR: mismatched types +LL | | loop {} +LL | | } + | |_^ expected normal fn, found unsafe fn + | + = note: expected type `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found type `unsafe extern "C" fn(i32, u32) -> u32 {foo}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/proc-macro/span-preservation.rs b/src/test/ui/proc-macro/span-preservation.rs new file mode 100644 index 00000000000..adcb42ab2d1 --- /dev/null +++ b/src/test/ui/proc-macro/span-preservation.rs @@ -0,0 +1,51 @@ +// aux-build:span-preservation.rs + +// For each of these, we should get the appropriate type mismatch error message, +// and the function should be echoed. + +extern crate span_preservation as foo; + +use foo::foo; + +#[foo] +fn a() { + let x: usize = "hello";;;;; +} + +#[foo] +fn b(x: Option) -> usize { + match x { + Some(x) => { return x }, + None => 10 + } +} + +#[foo] +fn c() { + struct Foo { + a: usize + } + + struct Bar { + a: usize, + b: usize + } + + let x = Foo { a: 10isize }; + let y = Foo { a: 10, b: 10isize }; +} + +// FIXME: This doesn't work at the moment. See the one below. The pretty-printer +// injects a "C" between `extern` and `fn` which causes a "probably_eq" +// `TokenStream` mismatch. The lack of `"C"` should be preserved in the AST. +#[foo] +extern fn bar() { + 0 +} + +#[foo] +extern "C" fn baz() { + 0 +} + +fn main() {} diff --git a/src/test/ui/proc-macro/span-preservation.stderr b/src/test/ui/proc-macro/span-preservation.stderr new file mode 100644 index 00000000000..f33245aec37 --- /dev/null +++ b/src/test/ui/proc-macro/span-preservation.stderr @@ -0,0 +1,49 @@ +error[E0308]: mismatched types + | + = note: expected type `()` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/span-preservation.rs:12:20 + | +LL | let x: usize = "hello";;;;; + | ^^^^^^^ expected usize, found reference + | + = note: expected type `usize` + found type `&'static str` + +error[E0308]: mismatched types + --> $DIR/span-preservation.rs:18:29 + | +LL | Some(x) => { return x }, + | ^ expected usize, found isize + +error[E0308]: mismatched types + --> $DIR/span-preservation.rs:34:22 + | +LL | let x = Foo { a: 10isize }; + | ^^^^^^^ expected usize, found isize + +error[E0560]: struct `c::Foo` has no field named `b` + --> $DIR/span-preservation.rs:35:26 + | +LL | let y = Foo { a: 10, b: 10isize }; + | ^ `c::Foo` does not have this field + | + = note: available fields are: `a` + +error[E0308]: mismatched types + --> $DIR/span-preservation.rs:48:5 + | +LL | extern "C" fn baz() { + | - possibly return type missing here? +LL | 0 + | ^ expected (), found integral variable + | + = note: expected type `()` + found type `{integer}` + +error: aborting due to 6 previous errors + +Some errors occurred: E0308, E0560. +For more information about an error, try `rustc --explain E0308`. diff --git a/src/test/ui/proc-macro/subspan.rs b/src/test/ui/proc-macro/subspan.rs new file mode 100644 index 00000000000..dccf6e20448 --- /dev/null +++ b/src/test/ui/proc-macro/subspan.rs @@ -0,0 +1,36 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:subspan.rs + +extern crate subspan; + +use subspan::subspan; + +// This one emits no error. +subspan!(""); + +// Exactly one 'hi'. +subspan!("hi"); //~ ERROR found 'hi's + +// Now two, back to back. +subspan!("hihi"); //~ ERROR found 'hi's + +// Now three, back to back. +subspan!("hihihi"); //~ ERROR found 'hi's + +// Now several, with spacing. +subspan!("why I hide? hi!"); //~ ERROR found 'hi's +subspan!("hey, hi, hidy, hidy, hi hi"); //~ ERROR found 'hi's +subspan!("this is a hi, and this is another hi"); //~ ERROR found 'hi's +subspan!("how are you this evening"); //~ ERROR found 'hi's +subspan!("this is highly eradic"); //~ ERROR found 'hi's + +fn main() { } diff --git a/src/test/ui/proc-macro/subspan.stderr b/src/test/ui/proc-macro/subspan.stderr new file mode 100644 index 00000000000..d9339bdaf76 --- /dev/null +++ b/src/test/ui/proc-macro/subspan.stderr @@ -0,0 +1,98 @@ +error: found 'hi's + --> $DIR/subspan.rs:21:1 + | +LL | subspan!("hi"); //~ ERROR found 'hi's + | ^^^^^^^^^^^^^^^ + | +note: here + --> $DIR/subspan.rs:21:11 + | +LL | subspan!("hi"); //~ ERROR found 'hi's + | ^^ + +error: found 'hi's + --> $DIR/subspan.rs:24:1 + | +LL | subspan!("hihi"); //~ ERROR found 'hi's + | ^^^^^^^^^^^^^^^^^ + | +note: here + --> $DIR/subspan.rs:24:11 + | +LL | subspan!("hihi"); //~ ERROR found 'hi's + | ^^^^ + +error: found 'hi's + --> $DIR/subspan.rs:27:1 + | +LL | subspan!("hihihi"); //~ ERROR found 'hi's + | ^^^^^^^^^^^^^^^^^^^ + | +note: here + --> $DIR/subspan.rs:27:11 + | +LL | subspan!("hihihi"); //~ ERROR found 'hi's + | ^^^^^^ + +error: found 'hi's + --> $DIR/subspan.rs:30:1 + | +LL | subspan!("why I hide? hi!"); //~ ERROR found 'hi's + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: here + --> $DIR/subspan.rs:30:17 + | +LL | subspan!("why I hide? hi!"); //~ ERROR found 'hi's + | ^^ ^^ + +error: found 'hi's + --> $DIR/subspan.rs:31:1 + | +LL | subspan!("hey, hi, hidy, hidy, hi hi"); //~ ERROR found 'hi's + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: here + --> $DIR/subspan.rs:31:16 + | +LL | subspan!("hey, hi, hidy, hidy, hi hi"); //~ ERROR found 'hi's + | ^^ ^^ ^^ ^^ ^^ + +error: found 'hi's + --> $DIR/subspan.rs:32:1 + | +LL | subspan!("this is a hi, and this is another hi"); //~ ERROR found 'hi's + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: here + --> $DIR/subspan.rs:32:12 + | +LL | subspan!("this is a hi, and this is another hi"); //~ ERROR found 'hi's + | ^^ ^^ ^^ ^^ + +error: found 'hi's + --> $DIR/subspan.rs:33:1 + | +LL | subspan!("how are you this evening"); //~ ERROR found 'hi's + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: here + --> $DIR/subspan.rs:33:24 + | +LL | subspan!("how are you this evening"); //~ ERROR found 'hi's + | ^^ + +error: found 'hi's + --> $DIR/subspan.rs:34:1 + | +LL | subspan!("this is highly eradic"); //~ ERROR found 'hi's + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: here + --> $DIR/subspan.rs:34:12 + | +LL | subspan!("this is highly eradic"); //~ ERROR found 'hi's + | ^^ ^^ + +error: aborting due to 8 previous errors + diff --git a/src/test/ui/proc-macro/three-equals.rs b/src/test/ui/proc-macro/three-equals.rs new file mode 100644 index 00000000000..e3285d3e821 --- /dev/null +++ b/src/test/ui/proc-macro/three-equals.rs @@ -0,0 +1,38 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:three-equals.rs + + +#![feature(proc_macro_hygiene)] + +extern crate three_equals; + +use three_equals::three_equals; + +fn main() { + // This one is okay. + three_equals!(===); + + // Need exactly three equals. + three_equals!(==); //~ ERROR found 2 equal signs, need exactly 3 + + // Need exactly three equals. + three_equals!(=====); //~ ERROR expected EOF + + // Only equals accepted. + three_equals!(abc); //~ ERROR expected `=` + + // Only equals accepted. + three_equals!(!!); //~ ERROR expected `=` + + // Only three characters expected. + three_equals!(===a); //~ ERROR expected EOF +} diff --git a/src/test/ui/proc-macro/three-equals.stderr b/src/test/ui/proc-macro/three-equals.stderr new file mode 100644 index 00000000000..1a0337f93f9 --- /dev/null +++ b/src/test/ui/proc-macro/three-equals.stderr @@ -0,0 +1,48 @@ +error: found 2 equal signs, need exactly 3 + --> $DIR/three-equals.rs:25:5 + | +LL | three_equals!(==); //~ ERROR found 2 equal signs, need exactly 3 + | ^^^^^^^^^^^^^^^^^^ + | + = help: input must be: `===` + +error: expected EOF, found `=`. + --> $DIR/three-equals.rs:28:21 + | +LL | three_equals!(=====); //~ ERROR expected EOF + | ^^ + | +note: last good input was here + --> $DIR/three-equals.rs:28:21 + | +LL | three_equals!(=====); //~ ERROR expected EOF + | ^^ + = help: input must be: `===` + +error: expected `=`, found `abc`. + --> $DIR/three-equals.rs:31:19 + | +LL | three_equals!(abc); //~ ERROR expected `=` + | ^^^ + +error: expected `=`, found `!`. + --> $DIR/three-equals.rs:34:19 + | +LL | three_equals!(!!); //~ ERROR expected `=` + | ^ + +error: expected EOF, found `a`. + --> $DIR/three-equals.rs:37:22 + | +LL | three_equals!(===a); //~ ERROR expected EOF + | ^ + | +note: last good input was here + --> $DIR/three-equals.rs:37:21 + | +LL | three_equals!(===a); //~ ERROR expected EOF + | ^ + = help: input must be: `===` + +error: aborting due to 5 previous errors + diff --git a/src/test/ui/rust-2018/auxiliary/suggestions-not-always-applicable.rs b/src/test/ui/rust-2018/auxiliary/suggestions-not-always-applicable.rs new file mode 100644 index 00000000000..7ae4731fde1 --- /dev/null +++ b/src/test/ui/rust-2018/auxiliary/suggestions-not-always-applicable.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// no-prefer-dynamic + +#![crate_type = "proc-macro"] + +extern crate proc_macro; + +use proc_macro::*; + +#[proc_macro_attribute] +pub fn foo(_attr: TokenStream, _f: TokenStream) -> TokenStream { + "pub fn foo() -> ::Foo { ::Foo }".parse().unwrap() +} diff --git a/src/test/ui/rust-2018/proc-macro-crate-in-paths.rs b/src/test/ui/rust-2018/proc-macro-crate-in-paths.rs new file mode 100644 index 00000000000..1068c058745 --- /dev/null +++ b/src/test/ui/rust-2018/proc-macro-crate-in-paths.rs @@ -0,0 +1,24 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-pass + +#![crate_type = "proc-macro"] +#![deny(rust_2018_compatibility)] +#![feature(rust_2018_preview)] + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro_derive(Template, attributes(template))] +pub fn derive_template(input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui/rust-2018/suggestions-not-always-applicable.fixed b/src/test/ui/rust-2018/suggestions-not-always-applicable.fixed new file mode 100644 index 00000000000..b64ebed0305 --- /dev/null +++ b/src/test/ui/rust-2018/suggestions-not-always-applicable.fixed @@ -0,0 +1,37 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:suggestions-not-always-applicable.rs +// edition:2015 +// run-rustfix +// rustfix-only-machine-applicable +// compile-pass + +#![feature(rust_2018_preview)] +#![warn(rust_2018_compatibility)] + +extern crate suggestions_not_always_applicable as foo; + +pub struct Foo; + +mod test { + use crate::foo::foo; + + #[foo] //~ WARN: absolute paths must start with + //~| WARN: previously accepted + //~| WARN: absolute paths + //~| WARN: previously accepted + fn main() { + } +} + +fn main() { + test::foo(); +} diff --git a/src/test/ui/rust-2018/suggestions-not-always-applicable.rs b/src/test/ui/rust-2018/suggestions-not-always-applicable.rs new file mode 100644 index 00000000000..b64ebed0305 --- /dev/null +++ b/src/test/ui/rust-2018/suggestions-not-always-applicable.rs @@ -0,0 +1,37 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:suggestions-not-always-applicable.rs +// edition:2015 +// run-rustfix +// rustfix-only-machine-applicable +// compile-pass + +#![feature(rust_2018_preview)] +#![warn(rust_2018_compatibility)] + +extern crate suggestions_not_always_applicable as foo; + +pub struct Foo; + +mod test { + use crate::foo::foo; + + #[foo] //~ WARN: absolute paths must start with + //~| WARN: previously accepted + //~| WARN: absolute paths + //~| WARN: previously accepted + fn main() { + } +} + +fn main() { + test::foo(); +} diff --git a/src/test/ui/rust-2018/suggestions-not-always-applicable.stderr b/src/test/ui/rust-2018/suggestions-not-always-applicable.stderr new file mode 100644 index 00000000000..415733a346f --- /dev/null +++ b/src/test/ui/rust-2018/suggestions-not-always-applicable.stderr @@ -0,0 +1,24 @@ +warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/suggestions-not-always-applicable.rs:27:5 + | +LL | #[foo] //~ WARN: absolute paths must start with + | ^^^^^^ + | +note: lint level defined here + --> $DIR/suggestions-not-always-applicable.rs:18:9 + | +LL | #![warn(rust_2018_compatibility)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + = note: #[warn(absolute_paths_not_starting_with_crate)] implied by #[warn(rust_2018_compatibility)] + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #53130 + +warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/suggestions-not-always-applicable.rs:27:5 + | +LL | #[foo] //~ WARN: absolute paths must start with + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! + = note: for more information, see issue #53130 + diff --git a/src/test/ui/unnecessary-extern-crate.rs b/src/test/ui/unnecessary-extern-crate.rs new file mode 100644 index 00000000000..1cdc9229d07 --- /dev/null +++ b/src/test/ui/unnecessary-extern-crate.rs @@ -0,0 +1,85 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// edition:2018 + +#![deny(unused_extern_crates)] +#![feature(alloc, test, libc, crate_visibility_modifier)] + +extern crate alloc; +//~^ ERROR unused extern crate +//~| HELP remove +extern crate alloc as x; +//~^ ERROR unused extern crate +//~| HELP remove + +extern crate proc_macro; + +#[macro_use] +extern crate test; + +pub extern crate test as y; + +pub extern crate libc; + +pub(crate) extern crate libc as a; + +crate extern crate libc as b; + +mod foo { + pub(in crate::foo) extern crate libc as c; + + pub(super) extern crate libc as d; + + extern crate alloc; + //~^ ERROR unused extern crate + //~| HELP remove + + extern crate alloc as x; + //~^ ERROR unused extern crate + //~| HELP remove + + pub extern crate test; + + pub extern crate test as y; + + mod bar { + extern crate alloc; + //~^ ERROR unused extern crate + //~| HELP remove + + extern crate alloc as x; + //~^ ERROR unused extern crate + //~| HELP remove + + pub(in crate::foo::bar) extern crate libc as e; + + fn dummy() { + unsafe { + e::getpid(); + } + } + } + + fn dummy() { + unsafe { + c::getpid(); + d::getpid(); + } + } +} + + +fn main() { + unsafe { a::getpid(); } + unsafe { b::getpid(); } + + proc_macro::TokenStream::new(); +} diff --git a/src/test/ui/unnecessary-extern-crate.stderr b/src/test/ui/unnecessary-extern-crate.stderr new file mode 100644 index 00000000000..58ec5901585 --- /dev/null +++ b/src/test/ui/unnecessary-extern-crate.stderr @@ -0,0 +1,44 @@ +error: unused extern crate + --> $DIR/unnecessary-extern-crate.rs:16:1 + | +LL | extern crate alloc; + | ^^^^^^^^^^^^^^^^^^^ help: remove it + | +note: lint level defined here + --> $DIR/unnecessary-extern-crate.rs:13:9 + | +LL | #![deny(unused_extern_crates)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unused extern crate + --> $DIR/unnecessary-extern-crate.rs:19:1 + | +LL | extern crate alloc as x; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + +error: unused extern crate + --> $DIR/unnecessary-extern-crate.rs:41:5 + | +LL | extern crate alloc; + | ^^^^^^^^^^^^^^^^^^^ help: remove it + +error: unused extern crate + --> $DIR/unnecessary-extern-crate.rs:45:5 + | +LL | extern crate alloc as x; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + +error: unused extern crate + --> $DIR/unnecessary-extern-crate.rs:54:9 + | +LL | extern crate alloc; + | ^^^^^^^^^^^^^^^^^^^ help: remove it + +error: unused extern crate + --> $DIR/unnecessary-extern-crate.rs:58:9 + | +LL | extern crate alloc as x; + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it + +error: aborting due to 6 previous errors + -- cgit 1.4.1-3-g733a5