Skip to content

Unsafe in extern causes bad diagnostic #123306

Closed
@xTachyon

Description

@xTachyon

Code

extern {
    unsafe fn f();
}

Current output

error: functions in `extern` blocks cannot have qualifiers
 --> src\main.rs:2:15
  |
1 | extern {
  | ------ in this `extern` block
2 |     unsafe fn f();
  |               ^
  |
help: remove the qualifiers
  |
2 |     fn f();
  |     ~~

Desired output

error: functions in `extern` blocks cannot have qualifiers
 --> src\main.rs:2:15
  |
1 | extern {
  | ------ in this `extern` block
2 |     unsafe fn f();
  |               ^
  |
help: remove the qualifiers
  |
2 |     unsafe fn f();
  |     ~~~~~~

Rationale and extra context

Fn is not a qualifier.

Other cases

No response

Rust Version

rustc 1.77.1 (7cf61ebde 2024-03-27)
binary: rustc
commit-hash: 7cf61ebde7b22796c69757901dd346d0fe70bd97
commit-date: 2024-03-27
host: x86_64-pc-windows-msvc
release: 1.77.1
LLVM version: 17.0.6

Anything else?

No response

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions