Skip to content

Commit bde2985

Browse files
Pasta-coderP-E-P
authored andcommitted
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 <0001jayant@gmail.com>
1 parent cfc5ac9 commit bde2985

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![crate_type = "lib"]
2+
#![feature(no_core)]
3+
#![feature(lang_items)]
4+
#![no_core]
5+
// { dg-options "-w" }
6+
7+
#[lang = "sized"]
8+
pub trait Sized {}
9+
10+
#[lang = "clone"]
11+
pub trait Clone: Sized {
12+
fn clone(&self) -> Self;
13+
}
14+
15+
#[lang = "copy"]
16+
pub trait Copy: Clone {}
17+
18+
#[derive(Clone)] // { dg-error "derive may only be applied to structs, enums and unions" }
19+
fn foo() {}
20+
21+
#[derive(Clone)] // { dg-error "derive may only be applied to structs, enums and unions" }
22+
trait Bar {}
23+
24+
// Valid test: Derive Copy and Clone on a unit struct
25+
#[derive(Copy, Clone)]
26+
struct TupleStruct;
27+
28+
// { dg-prune-output "could not resolve" }

0 commit comments

Comments
 (0)