diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:20:29 +0000 |
commit | 631cd5845e8de329d0e227aaa707d7ea228b8f8f (patch) | |
tree | a1b87c8f8cad01cf18f7c5f57a08f102771ed303 /compiler/rustc_builtin_macros/src/cfg_accessible.rs | |
parent | Adding debian version 1.69.0+dfsg1-1. (diff) | |
download | rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.tar.xz rustc-631cd5845e8de329d0e227aaa707d7ea228b8f8f.zip |
Merging upstream version 1.70.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_builtin_macros/src/cfg_accessible.rs')
-rw-r--r-- | compiler/rustc_builtin_macros/src/cfg_accessible.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/compiler/rustc_builtin_macros/src/cfg_accessible.rs b/compiler/rustc_builtin_macros/src/cfg_accessible.rs index 4e4cafc71..37ac09ccd 100644 --- a/compiler/rustc_builtin_macros/src/cfg_accessible.rs +++ b/compiler/rustc_builtin_macros/src/cfg_accessible.rs @@ -1,5 +1,6 @@ //! Implementation of the `#[cfg_accessible(path)]` attribute macro. +use crate::errors; use rustc_ast as ast; use rustc_expand::base::{Annotatable, ExpandResult, ExtCtxt, Indeterminate, MultiItemModifier}; use rustc_feature::AttributeTemplate; @@ -10,15 +11,22 @@ use rustc_span::Span; pub(crate) struct Expander; fn validate_input<'a>(ecx: &mut ExtCtxt<'_>, mi: &'a ast::MetaItem) -> Option<&'a ast::Path> { + use errors::CfgAccessibleInvalid::*; match mi.meta_item_list() { None => {} - Some([]) => ecx.span_err(mi.span, "`cfg_accessible` path is not specified"), - Some([_, .., l]) => ecx.span_err(l.span(), "multiple `cfg_accessible` paths are specified"), + Some([]) => { + ecx.emit_err(UnspecifiedPath(mi.span)); + } + Some([_, .., l]) => { + ecx.emit_err(MultiplePaths(l.span())); + } Some([nmi]) => match nmi.meta_item() { - None => ecx.span_err(nmi.span(), "`cfg_accessible` path cannot be a literal"), + None => { + ecx.emit_err(LiteralPath(nmi.span())); + } Some(mi) => { if !mi.is_word() { - ecx.span_err(mi.span, "`cfg_accessible` path cannot accept arguments"); + ecx.emit_err(HasArguments(mi.span)); } return Some(&mi.path); } @@ -53,7 +61,7 @@ impl MultiItemModifier for Expander { Ok(true) => ExpandResult::Ready(vec![item]), Ok(false) => ExpandResult::Ready(Vec::new()), Err(Indeterminate) if ecx.force_mode => { - ecx.span_err(span, "cannot determine whether the path is accessible or not"); + ecx.emit_err(errors::CfgAccessibleIndeterminate { span }); ExpandResult::Ready(vec![item]) } Err(Indeterminate) => ExpandResult::Retry(item), |