Skip to content

Unsafe attributes not allowed #4244

@bjorn3

Description

@bjorn3

Summary

While all attributes made unsafe in the 2024 edition can be used without unsafe in prior editions, rustc still accepts the unsafe marking on older editions.

Reproducer

I tried this code:

#[unsafe(no_mangle)]
fn foo() {}

Does the code make use of any (1.49) nightly feature ?

  • Nightly

Godbolt link

No response

Actual behavior

An error is emitted.

Expected behavior

Compiles successfully on all editions.

GCC Version

gccrs (Compiler-Explorer-Build-gcc--binutils-2.44) 15.2.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions