Skip to content

Commit f4ee91d

Browse files
committed
expand: Added a more complete test .
This patch adds a regression test ensuring that deriving on invalid items (such as functions or traits) triggers a diagnostic error instead of an Internal Compiler Error (ICE). It also verifies that Tuple Structs are accepted as valid targets for derivation. Fixes #3875 gcc/testsuite/ChangeLog: * rust/compile/issue-3875.rs: New test. Signed-off-by: Jayant Chauhan <[email protected]>
1 parent c35ffdb commit f4ee91d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

gcc/rust/expand/rust-derive.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ DeriveVisitor::setup_impl_generics (
160160
}
161161

162162
} // namespace AST
163-
} // namespace Rust
163+
} // namespace Rust
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// { dg-options "-w" }
2+
3+
#[derive(Clone)] // { dg-error "derive may only be applied to structs, enums and unions" }
4+
fn foo() {} // { dg-excess-errors "" }
5+
6+
#[derive(Debug)] // { dg-error "derive may only be applied to structs, enums and unions" }
7+
trait Bar {} // { dg-excess-errors "" }
8+
9+
#[derive(Copy, Clone)]
10+
struct TupleStruct(i32); // This should NOT error
11+
12+
fn main() {}

0 commit comments

Comments
 (0)