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_builtin_macros/src/derive.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_builtin_macros/src/derive.rs')
| -rw-r--r-- | compiler/rustc_builtin_macros/src/derive.rs | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/compiler/rustc_builtin_macros/src/derive.rs b/compiler/rustc_builtin_macros/src/derive.rs index c540ff4e1de..57bddf0ab60 100644 --- a/compiler/rustc_builtin_macros/src/derive.rs +++ b/compiler/rustc_builtin_macros/src/derive.rs @@ -1,5 +1,5 @@ use rustc_ast as ast; -use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, Safety, StmtKind}; +use rustc_ast::{GenericParamKind, ItemKind, MetaItemKind, NestedMetaItem, StmtKind}; use rustc_expand::base::{ Annotatable, DeriveResolution, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier, }; @@ -62,7 +62,6 @@ impl MultiItemModifier for Expander { // Reject `#[derive(Debug = "value", Debug(abc))]`, but recover the // paths. report_path_args(sess, meta); - report_unsafe_args(sess, meta); meta.path.clone() }) .map(|path| DeriveResolution { @@ -162,13 +161,3 @@ fn report_path_args(sess: &Session, meta: &ast::MetaItem) { } } } - -fn report_unsafe_args(sess: &Session, meta: &ast::MetaItem) { - match meta.unsafety { - Safety::Unsafe(span) => { - sess.dcx().emit_err(errors::DeriveUnsafePath { span }); - } - Safety::Default => {} - Safety::Safe(_) => unreachable!(), - } -} |
