diff options
| author | carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> | 2024-07-09 19:06:49 -0500 |
|---|---|---|
| committer | carbotaniuman <41451839+carbotaniuman@users.noreply.github.com> | 2024-07-30 18:28:43 -0500 |
| commit | 49db8a5a999f0908b5bf74b88a2d72a4f4dddf48 (patch) | |
| tree | a080b5f39b3e923e2a2057102cf88362757f316c /compiler/rustc_interface/src/interface.rs | |
| parent | d8bc8761a5bb8456c0b7940434b3b3b4f0ed035c (diff) | |
| download | rust-49db8a5a999f0908b5bf74b88a2d72a4f4dddf48.tar.gz rust-49db8a5a999f0908b5bf74b88a2d72a4f4dddf48.zip | |
Add toggle for `parse_meta_item` unsafe parsing
This makes it possible for the `unsafe(...)` syntax to only be valid at the top level, and the `NestedMetaItem`s will automatically reject `unsafe(...)`.
Diffstat (limited to 'compiler/rustc_interface/src/interface.rs')
| -rw-r--r-- | compiler/rustc_interface/src/interface.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/rustc_interface/src/interface.rs b/compiler/rustc_interface/src/interface.rs index 886b043af24..04e2b7d45dc 100644 --- a/compiler/rustc_interface/src/interface.rs +++ b/compiler/rustc_interface/src/interface.rs @@ -15,6 +15,7 @@ use rustc_middle::ty; use rustc_middle::ty::CurrentGcx; use rustc_middle::util::Providers; use rustc_parse::new_parser_from_source_str; +use rustc_parse::parser::attr::AllowLeadingUnsafe; use rustc_query_impl::QueryCtxt; use rustc_query_system::query::print_query_stack; use rustc_session::config::{self, Cfg, CheckCfg, ExpectedValues, Input, OutFileName}; @@ -67,7 +68,7 @@ pub(crate) fn parse_cfg(dcx: DiagCtxtHandle<'_>, cfgs: Vec<String>) -> Cfg { } match new_parser_from_source_str(&psess, filename, s.to_string()) { - Ok(mut parser) => match parser.parse_meta_item() { + Ok(mut parser) => match parser.parse_meta_item(AllowLeadingUnsafe::No) { Ok(meta_item) if parser.token == token::Eof => { if meta_item.path.segments.len() != 1 { error!("argument key must be an identifier"); @@ -173,7 +174,7 @@ pub(crate) fn parse_check_cfg(dcx: DiagCtxtHandle<'_>, specs: Vec<String>) -> Ch } }; - let meta_item = match parser.parse_meta_item() { + let meta_item = match parser.parse_meta_item(AllowLeadingUnsafe::Yes) { Ok(meta_item) if parser.token == token::Eof => meta_item, Ok(..) => expected_error(), Err(err) => { |
