-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multiple tests for non root proc macro
Add multiple tests to prevent regressions on procedural macros errors when one is declared outside of the crate's top level. gcc/testsuite/ChangeLog: * rust/compile/proc_macro_attribute_non_root_function.rs: New test. * rust/compile/proc_macro_attribute_non_root_method.rs: New test. * rust/compile/proc_macro_attribute_non_root_module.rs: New test. * rust/compile/proc_macro_derive_non_root_function.rs: New test. * rust/compile/proc_macro_derive_non_root_method.rs: New test. * rust/compile/proc_macro_derive_non_root_module.rs: New test. * rust/compile/proc_macro_non_root_function.rs: New test. * rust/compile/proc_macro_non_root_method.rs: New test. * rust/compile/proc_macro_non_root_module.rs: New test. Signed-off-by: Pierre-Emmanuel Patry <[email protected]>
- Loading branch information
Showing
9 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
gcc/testsuite/rust/compile/proc_macro_attribute_non_root_function.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
fn outer_function() { | ||
#[proc_macro_attribute] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_attribute.. must currently reside in the root of the crate" } | ||
} |
10 changes: 10 additions & 0 deletions
10
gcc/testsuite/rust/compile/proc_macro_attribute_non_root_method.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
struct DummyStruct; | ||
|
||
impl DummyStruct { | ||
pub fn method(self) { | ||
#[proc_macro_attribute] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_attribute.. must currently reside in the root of the crate" } | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
gcc/testsuite/rust/compile/proc_macro_attribute_non_root_module.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
mod test_module { | ||
#[proc_macro_attribute] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_attribute.. must currently reside in the root of the crate" } | ||
} |
6 changes: 6 additions & 0 deletions
6
gcc/testsuite/rust/compile/proc_macro_derive_non_root_function.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
fn outer_function() { | ||
#[proc_macro_derive(SomeTrait)] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_derive.. must currently reside in the root of the crate" } | ||
} |
12 changes: 12 additions & 0 deletions
12
gcc/testsuite/rust/compile/proc_macro_derive_non_root_method.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
trait SomeTrait {} | ||
|
||
struct DummyStruct; | ||
|
||
impl DummyStruct { | ||
pub fn method(self) { | ||
#[proc_macro_derive(SomeTrait)] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_derive.. must currently reside in the root of the crate" } | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
gcc/testsuite/rust/compile/proc_macro_derive_non_root_module.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
mod test_module { | ||
#[proc_macro_derive(SomeTrait)] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro_derive.. must currently reside in the root of the crate" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
fn outer_function() { | ||
#[proc_macro] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro.. must currently reside in the root of the crate" } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
struct DummyStruct; | ||
|
||
impl DummyStruct { | ||
pub fn method(self) { | ||
#[proc_macro] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro.. must currently reside in the root of the crate" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// { dg-additional-options "-frust-crate-type=proc-macro" } | ||
|
||
mod test_module { | ||
#[proc_macro] | ||
pub fn non_root_function() {} // { dg-error "functions tagged with .#.proc_macro.. must currently reside in the root of the crate" } | ||
} |