Rollup merge of #131057 - Urgau:cfg-erronous-unsafe, r=jieyouxu

Reject leading unsafe in `cfg!(...)` and `--check-cfg`

This PR reject leading unsafe in `cfg!(...)` and `--check-cfg`.

Fixes (after-backport) https://github.com/rust-lang/rust/issues/131055
r? `@jieyouxu`
This commit is contained in:
Matthias Krüger
2024-09-30 14:33:46 +02:00
committed by GitHub
6 changed files with 33 additions and 5 deletions

View File

@@ -174,7 +174,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch
}
};
let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::Yes) {
let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::No) {
Ok(meta_item) if parser.token == token::Eof => meta_item,
Ok(..) => expected_error(),
Err(err) => {