Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent #[may_dangle] attribute from being used in safe impl #3045

Closed
P-E-P opened this issue Jun 11, 2024 · 0 comments · Fixed by #3078
Closed

Prevent #[may_dangle] attribute from being used in safe impl #3045

P-E-P opened this issue Jun 11, 2024 · 0 comments · Fixed by #3078

Comments

@P-E-P
Copy link
Member

P-E-P commented Jun 11, 2024

#[may_dangle] attributes should not be used from safe impl.

https://godbolt.org/z/6eKe5sKdo

@P-E-P P-E-P added this to the GCC 15.1 release milestone Jun 11, 2024
@CohenArthur CohenArthur removed this from the GCC 15.1 milestone Jul 1, 2024
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 7, 2024
gcc/rust/ChangeLog:
	* gcc/rust/checks/errors/rust-unsafe-checker.cc:
        Add pass for unsafe attr's in safe impl's
	* gcc/rust/hir/rust-ast-lower-type.cc:
        Add unsafe support to Impl blocks
	* gcc/rust/hir/tree/rust-hir-item.h:
        Add unsafe support to Impl blocks in HIR
	* gcc/rust/hir/tree/rust-hir.h:
        Add has/get_outer_attribute to GenericParam
	* gcc/rust/util/rust-hir-map.cc:
        Add unsafe support to Impl blocks
	* gcc/testsuite/rust/compile/issue-3045.rs:
        Add test for #[may_dangle] triggering error

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 7, 2024
gcc/rust/ChangeLog:
	* gcc/rust/checks/errors/rust-unsafe-checker.cc:
        Add pass for unsafe attr's in safe impl's
	* gcc/rust/hir/rust-ast-lower-type.cc:
        Add unsafe support to Impl blocks
	* gcc/rust/hir/tree/rust-hir-item.h:
        Add unsafe support to Impl blocks in HIR
	* gcc/rust/hir/tree/rust-hir.h:
        Add has/get_outer_attribute to GenericParam
	* gcc/rust/util/rust-hir-map.cc:
        Add unsafe support to Impl blocks
	* gcc/testsuite/rust/compile/issue-3045.rs:
        Add test for #[may_dangle] triggering error

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 7, 2024
gcc/rust/ChangeLog:
	* gcc/rust/checks/errors/rust-unsafe-checker.cc:
        Add pass for #[may_dangle] in safe impl's
	* gcc/rust/hir/rust-ast-lower-type.cc:
        Lower attributes in impl's from AST to HIR
	* gcc/rust/hir/tree/rust-hir-item.h:
        Add unsafe support to Impl blocks in HIR
	* gcc/rust/hir/tree/rust-hir.h:
        Add has/get_outer_attribute to GenericParam
	* gcc/rust/util/rust-hir-map.cc:
        Add unsafe support to Impl blocks
	* gcc/testsuite/rust/compile/issue-3045.rs:
        Add test for #[may_dangle] triggering error

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 7, 2024
gcc/rust/ChangeLog:
	* gcc/rust/ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* gcc/rust/checks/errors/rust-unsafe-checker.cc:
        Add pass for #[may_dangle] in safe impl's
	* gcc/rust/hir/rust-ast-lower-type.cc:
        Lower attributes in impl's from AST to HIR
	* gcc/rust/hir/tree/rust-hir-item.h:
        Add unsafe support to Impl blocks in HIR
	* gcc/rust/hir/tree/rust-hir.h:
        Add has/get_outer_attribute to GenericParam
	* gcc/rust/util/rust-hir-map.cc:
        Add unsafe support to Impl blocks
	* gcc/testsuite/rust/compile/issue-3045.rs:
        Add test for #[may_dangle] triggering error

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 7, 2024
gcc/rust/ChangeLog:
	* gcc/rust/ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* gcc/rust/checks/errors/rust-unsafe-checker.cc:
        Add pass for #[may_dangle] in safe impl's
	* gcc/rust/hir/rust-ast-lower-item.cc:
	Add support for unsafe impl's
	* gcc/rust/hir/rust-ast-lower-type.cc:
        Lower attributes in impl's from AST to HIR
	* gcc/rust/hir/tree/rust-hir-item.h:
        Add unsafe support to Impl blocks in HIR
	* gcc/rust/hir/tree/rust-hir.h:
        Add has/get_outer_attribute to GenericParam
	* gcc/rust/util/rust-hir-map.cc:
        Add unsafe support to Impl blocks
	* gcc/testsuite/rust/compile/issue-3045-1.rs:
        Add test for #[may_dangle] Generic Type triggering error
	* gcc/testsuite/rust/compile/issue-3045-1.rs:
        Add test for #[may_dangle] Lifetime triggering error

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 8, 2024
gcc/rust/ChangeLog:
	* gcc/rust/ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* gcc/rust/checks/errors/rust-unsafe-checker.cc:
	Add pass for #[may_dangle] in safe impl's
	* gcc/rust/hir/rust-ast-lower-item.cc:
	Add support for unsafe impl's
	* gcc/rust/hir/rust-ast-lower-type.cc:
	Lower attributes in impl's from AST to HIR
	* gcc/rust/hir/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* gcc/rust/hir/tree/rust-hir.h:
	Add has/get_outer_attribute to GenericParam
	* gcc/rust/util/rust-hir-map.cc:
	Add unsafe support to Impl blocks
	* gcc/testsuite/rust/compile/issue-3045-1.rs:
	Add test for #[may_dangle] Generic Type triggering error
	* gcc/testsuite/rust/compile/issue-3045-1.rs:
	Add test for #[may_dangle] Lifetime triggering error

Signed-off-by: Liam Naddell <liam.naddell@mail.utoronto.ca>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 8, 2024
gcc/rust/ChangeLog:
	* ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* hir/tree/rust-hir.h:
	Add has/get_outer_attribute to GenericParam
	* util/rust-hir-map.cc:
	Add unsafe support to Impl blocks

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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 11, 2024
gcc/rust/ChangeLog:
	* ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 11, 2024
gcc/rust/ChangeLog:
	* ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 11, 2024
gcc/rust/ChangeLog:
	* ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 15, 2024
gcc/rust/ChangeLog:
	* ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 15, 2024
gcc/rust/ChangeLog:
	* ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 15, 2024
gcc/rust/ChangeLog:
	* ast/rust-ast.h:
	Fix inner_attribute undefined behavior
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 16, 2024
gcc/rust/ChangeLog:
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 16, 2024
gcc/rust/ChangeLog:
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 18, 2024
gcc/rust/ChangeLog:
	* 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/tree/rust-hir-item.h:
	Add unsafe support to Impl blocks in HIR
	* 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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 19, 2024
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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 19, 2024
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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 24, 2024
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>
liamnaddell added a commit to liamnaddell/gccrs that referenced this issue Jul 24, 2024
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>
github-merge-queue bot pushed a commit that referenced this issue Jul 25, 2024
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants