Skip to content

Commit

Permalink
Rollup merge of rust-lang#61024 - petrochenkov:proctest, r=nikomatsakis
Browse files Browse the repository at this point in the history
tests: Centralize proc macros commonly used for testing

Many proc macros in `ui\proc-macro\auxiliary` were doing same things.
(I added a fair share of those myself.)

Now commonly used macros (empty, identity, etc) are collected in one place - `ui\proc-macro\auxiliary\test-macros.rs`.
  • Loading branch information
Centril authored May 28, 2019
2 parents 031ecf4 + fb52aea commit 3520ec3
Show file tree
Hide file tree
Showing 72 changed files with 475 additions and 649 deletions.
28 changes: 0 additions & 28 deletions src/test/ui/custom-derive/auxiliary/plugin.rs

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/custom-derive/derive-in-mod.rs

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/custom-derive/helper-attr-blocked-by-import-ambig.rs

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions src/test/ui/custom-derive/helper-attr-blocked-by-import.rs

This file was deleted.

12 changes: 0 additions & 12 deletions src/test/ui/custom-derive/issue-36935.rs

This file was deleted.

10 changes: 0 additions & 10 deletions src/test/ui/custom-derive/issue-36935.stderr

This file was deleted.

10 changes: 5 additions & 5 deletions src/test/ui/proc-macro/attribute-order-restricted.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// aux-build:attr_proc_macro.rs
// aux-build:test-macros.rs

extern crate attr_proc_macro;
use attr_proc_macro::*;
#[macro_use]
extern crate test_macros;

#[attr_proc_macro] // OK
#[identity_attr] // OK
#[derive(Clone)]
struct Before;

#[derive(Clone)]
#[attr_proc_macro] //~ ERROR macro attributes must be placed before `#[derive]`
#[identity_attr] //~ ERROR macro attributes must be placed before `#[derive]`
struct After;

fn main() {}
4 changes: 2 additions & 2 deletions src/test/ui/proc-macro/attribute-order-restricted.stderr
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
error: macro attributes must be placed before `#[derive]`
--> $DIR/attribute-order-restricted.rs:11:1
|
LL | #[attr_proc_macro]
| ^^^^^^^^^^^^^^^^^^
LL | #[identity_attr]
| ^^^^^^^^^^^^^^^^

error: aborting due to previous error

17 changes: 8 additions & 9 deletions src/test/ui/proc-macro/attribute-with-error.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// aux-build:attribute-with-error.rs
// aux-build:test-macros.rs

#![feature(custom_inner_attributes)]

extern crate attribute_with_error;
#[macro_use]
extern crate test_macros;

use attribute_with_error::foo;

#[foo]
#[recollect_attr]
fn test1() {
let a: i32 = "foo";
//~^ ERROR: mismatched types
Expand All @@ -15,13 +14,13 @@ fn test1() {
}

fn test2() {
#![foo]
#![recollect_attr]

// 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
// FIXME: should have a #[recollect_attr] attribute here and assert that it works
fn foo(&self) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
Expand All @@ -31,13 +30,13 @@ trait A {
struct B;

impl A for B {
#[foo]
#[recollect_attr]
fn foo(&self) {
let a: i32 = "foo";
//~^ ERROR: mismatched types
}
}

#[foo]
#[recollect_attr]
fn main() {
}
8 changes: 4 additions & 4 deletions src/test/ui/proc-macro/attribute-with-error.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:11:18
--> $DIR/attribute-with-error.rs:10:18
|
LL | let a: i32 = "foo";
| ^^^^^ expected i32, found reference
Expand All @@ -8,7 +8,7 @@ LL | let a: i32 = "foo";
found type `&'static str`

error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:13:18
--> $DIR/attribute-with-error.rs:12:18
|
LL | let b: i32 = "f'oo";
| ^^^^^^ expected i32, found reference
Expand All @@ -17,7 +17,7 @@ LL | let b: i32 = "f'oo";
found type `&'static str`

error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:26:22
--> $DIR/attribute-with-error.rs:25:22
|
LL | let a: i32 = "foo";
| ^^^^^ expected i32, found reference
Expand All @@ -26,7 +26,7 @@ LL | let a: i32 = "foo";
found type `&'static str`

error[E0308]: mismatched types
--> $DIR/attribute-with-error.rs:36:22
--> $DIR/attribute-with-error.rs:35:22
|
LL | let a: i32 = "foo";
| ^^^^^ expected i32, found reference
Expand Down
13 changes: 0 additions & 13 deletions src/test/ui/proc-macro/auxiliary/attr_proc_macro.rs

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/proc-macro/auxiliary/attribute-with-error.rs

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/proc-macro/auxiliary/bang_proc_macro.rs

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/ui/proc-macro/auxiliary/derive-a-b.rs

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/proc-macro/auxiliary/derive-a.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#[macro_export]
macro_rules! my_attr { () => () }
macro_rules! empty_helper { () => () }
12 changes: 0 additions & 12 deletions src/test/ui/proc-macro/auxiliary/derive-helper-shadowed.rs

This file was deleted.

17 changes: 0 additions & 17 deletions src/test/ui/proc-macro/auxiliary/derive-helper-shadowing.rs

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/ui/proc-macro/auxiliary/derive-panic.rs

This file was deleted.

6 changes: 3 additions & 3 deletions src/test/ui/proc-macro/auxiliary/dollar-crate-external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ pub type S = u8;
#[macro_export]
macro_rules! external {
() => {
dollar_crate::m! {
print_bang! {
struct M($crate::S);
}

#[dollar_crate::a]
#[print_attr]
struct A($crate::S);

#[derive(dollar_crate::d)]
#[derive(Print)]
struct D($crate::S);
};
}
Loading

0 comments on commit 3520ec3

Please sign in to comment.