forked from Rust-GCC/gccrs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rust-GCC#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>
- Loading branch information
1 parent
47c947c
commit a218b03
Showing
10 changed files
with
122 additions
and
37 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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,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() {} |
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,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() { | ||
|
||
} |