diff options
author | Liam Naddell <liam.naddell@mail.utoronto.ca> | 2024-07-06 20:34:28 -0400 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-19 15:32:01 +0100 |
commit | 3c5e87297bd56b7d95ecdf9f3ca9e9110cfc34c7 (patch) | |
tree | b3f868c7f067a3f6e2c62aeb4a7441e311966898 /gcc/testsuite/rust | |
parent | 1a921c844bf5b92a5389575e384c69e8103d2fad (diff) | |
download | gcc-3c5e87297bd56b7d95ecdf9f3ca9e9110cfc34c7.zip gcc-3c5e87297bd56b7d95ecdf9f3ca9e9110cfc34c7.tar.gz gcc-3c5e87297bd56b7d95ecdf9f3ca9e9110cfc34c7.tar.bz2 |
gccrs: [gccrs#3045] #[may_dangle] in safe impl
gcc/rust/ChangeLog:
* ast/rust-ast.cc:
Fix Attribute constructors to copy inner_attribute
* checks/errors/rust-unsafe-checker.cc:
Add pass for #[may_dangle] in safe impl's
* hir/rust-ast-lower-item.cc:
Add support for unsafe impl's
* hir/rust-ast-lower-type.cc:
Lower attributes in impl's from AST to HIR
* hir/rust-hir-dump.cc:
Change single attribute to AttrVec
* hir/tree/rust-hir-item.h:
Add unsafe support to Impl blocks in HIR
* hir/tree/rust-hir.cc:
Change single attribute to AttrVec
* hir/tree/rust-hir.h:
Add has/get_outer_attribute to GenericParam
gcc/testsuite/ChangeLog:
* rust/compile/issue-3045-1.rs:
Add test for #[may_dangle] Generic Type triggering error
* rust/compile/issue-3045-2.rs:
Add test for #[may_dangle] Lifetime triggering error
Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
Diffstat (limited to 'gcc/testsuite/rust')
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3045-1.rs | 21 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/issue-3045-2.rs | 20 |
2 files changed, 41 insertions, 0 deletions
diff --git a/gcc/testsuite/rust/compile/issue-3045-1.rs b/gcc/testsuite/rust/compile/issue-3045-1.rs new file mode 100644 index 0000000..a1328f2 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3045-1.rs @@ -0,0 +1,21 @@ +#![feature(dropck_eyepatch)] +#[allow(dead_code)] + +#[lang = "sized"] +trait Sized {} + +struct Test<T> { + _inner: T, +} + +struct Test2<T> { + _inner: T, +} + +trait Action {} + +impl<#[may_dangle] T> Action for Test<T> {} // { dg-error "use of 'may_dangle' is unsafe and requires unsafe impl" "" { target *-*-* } 0 } + +unsafe impl<#[may_dangle] T> Action for Test2<T> {} + +fn main() {} diff --git a/gcc/testsuite/rust/compile/issue-3045-2.rs b/gcc/testsuite/rust/compile/issue-3045-2.rs new file mode 100644 index 0000000..177707fb --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-3045-2.rs @@ -0,0 +1,20 @@ +#![feature(dropck_eyepatch)] +#[allow(dead_code)] + +#[lang = "sized"] +trait Sized {} + + +trait Action {} + +struct Inspector<'a>(&'a u8); +struct Inspector2<'a>(&'a u8); + +impl<#[may_dangle] 'a> Action for Inspector<'a> {} // { dg-error "use of 'may_dangle' is unsafe and requires unsafe impl" "" { target *-*-* } 0 } + +unsafe impl<#[may_dangle] 'a> Action for Inspector2<'a> {} + + +fn main() { + +} |