Skip to content

cfg!(unsafe(foo)) and --check-cfg=unsafe(cfg(foo)) are erroneously accepted on beta #131055

Closed
@Urgau

Description

@Urgau

cfg!(unsafe(foo)) and --check-cfg=unsafe(cfg(foo)) both are erroneously accepted on beta.

They should not be accepted, neither of them is in any way "unsafe".

Code

I tried this code:

fn main() {
    let _a = cfg!(unsafe(foo));
}

I expected to see this happen: an error saying that unsafe cannot be put here like for #[cfg]&#[cfg_attr].

Instead, this happened: the unsafe is silently accepted.

Version it worked on

It most recently worked on: 1.81

Version with regression

rustc --version --verbose:

rustc 1.82.0-beta.5 (6a3b69c6b 2024-09-27)
binary: rustc
commit-hash: 6a3b69c6b0529151da5fb4568961519a80adccf9
commit-date: 2024-09-27
host: x86_64-unknown-linux-gnu
release: 1.82.0-beta.5
LLVM version: 19.1.0

@rustbot modify labels: +regression-from-stable-to-beta -regression-untriaged

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions