diff options
| author | bors <bors@rust-lang.org> | 2019-07-06 21:47:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-07-06 21:47:45 +0000 |
| commit | b0bd5f236d9bea38b8c9048f379fec179b09984c (patch) | |
| tree | 4361af5c2be0fc980a75611e33190057f582bde7 /src/libsyntax/ext | |
| parent | dfd52ba6ac2262c6b61c59ec86bfd23e4e53d3de (diff) | |
| parent | 7ef02dcf6735a1168caabb0493d7576f12c99baf (diff) | |
Auto merge of #62452 - Centril:rollup-5jww3h7, r=Centril
Rollup of 5 pull requests
Successful merges:
- #60081 (Refactor unicode.py script)
- #61862 (Make the Weak::{into,as}_raw methods)
- #62243 (Improve documentation for built-in macros)
- #62422 (Remove some uses of mem::uninitialized)
- #62436 (normalize use of backticks/lowercase in compiler messages for librustc_mir)
Failed merges:
r? @ghost
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/tt/macro_rules.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 1a448cb2a43..cf3c748cd82 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -2,7 +2,6 @@ use crate::edition::Edition; use crate::ext::base::{DummyResult, ExtCtxt, MacResult, TTMacroExpander}; use crate::ext::base::{SyntaxExtension, SyntaxExtensionKind}; use crate::ext::expand::{AstFragment, AstFragmentKind}; -use crate::ext::hygiene::Transparency; use crate::ext::tt::macro_parser::{parse, parse_failure_msg}; use crate::ext::tt::macro_parser::{Error, Failure, Success}; use crate::ext::tt::macro_parser::{MatchedNonterminal, MatchedSeq}; @@ -15,7 +14,7 @@ use crate::parse::token::{self, NtTT, Token}; use crate::parse::{Directory, ParseSess}; use crate::symbol::{kw, sym, Symbol}; use crate::tokenstream::{DelimSpan, TokenStream, TokenTree}; -use crate::{ast, attr}; +use crate::{ast, attr, attr::TransparencyError}; use errors::FatalError; use log::debug; @@ -380,13 +379,19 @@ pub fn compile( let expander: Box<_> = Box::new(MacroRulesMacroExpander { name: def.ident, lhses, rhses, valid }); - let default_transparency = if attr::contains_name(&def.attrs, sym::rustc_transparent_macro) { - Transparency::Transparent - } else if body.legacy { - Transparency::SemiTransparent - } else { - Transparency::Opaque - }; + let (default_transparency, transparency_error) = + attr::find_transparency(&def.attrs, body.legacy); + match transparency_error { + Some(TransparencyError::UnknownTransparency(value, span)) => + sess.span_diagnostic.span_err( + span, &format!("unknown macro transparency: `{}`", value) + ), + Some(TransparencyError::MultipleTransparencyAttrs(old_span, new_span)) => + sess.span_diagnostic.span_err( + vec![old_span, new_span], "multiple macro transparency attributes" + ), + None => {} + } let allow_internal_unstable = attr::find_by_name(&def.attrs, sym::allow_internal_unstable).map(|attr| { |
