Skip to content

unsafe attribute error with Rust edition 2024 #2073

@muse254

Description

@muse254

Describe the bug

Issue building with Rust edition 2024.

The error log:

error: unsafe attribute used without unsafe
  --> /redacted/flipper/lib.rs:6:5
   |
6  | /     /// Defines the storage of your contract.
7  | |     /// Add new fields to the below struct in order
8  | |     /// to add new static storage fields to your contract.
9  | |     #[ink(storage)]
...  |
12 | |         value: bool,
13 | |     }
   | |_____^ usage of unsafe attribute
   |
help: wrap the attribute in `unsafe(...)`
   |
6  ~     unsafe(/// Defines the storage of your contract.
7  |     /// Add new fields to the below struct in order
...
12 |         value: bool,
13 ~     })
   |

error: could not compile `flipper` (bin "flipper") due to 1 previous error
ERROR: 

To Reproduce
Steps to reproduce the behavior:

  1. Create the flipper contract example: cargo contract new flipper
  2. In the Cargo.toml change [package.edition] to "2024". The default here was "2021".
  3. Build: cargo contract build

Expected behavior

Having a more intuitive error from the cargo-contract tooling would help if the edition it's not yet supported.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: MacOS M1
  • cargo-contract version: 5.0.3-unknown-aarch64-apple-darwin
  • ink! version: 5.1.1

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions