Skip to content

Commit 89429ad

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 89429ad

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(no_core)]
2+
#![feature(lang_items)]
3+
#![no_core]
4+
// { dg-options "-w" }
5+
6+
#[lang = "sized"]
7+
pub trait Sized {}
8+
9+
#[lang = "clone"]
10+
pub trait Clone: Sized {}
11+
12+
#[derive(Clone)] // { dg-error "derive may only be applied to structs, enums and unions" }
13+
fn foo() {}
14+
15+
#[derive(Clone)] // { dg-error "derive may only be applied to structs, enums and unions" }
16+
trait Bar {}
17+
18+
#[derive(Clone)]
19+
struct TupleStruct(i32); // This should NOT error
20+
21+
fn main() {}

0 commit comments

Comments
 (0)