debug · rust-lang/rust@59281e9 (original) (raw)
File tree
1 file changed
lines changed
- compiler/rustc_builtin_macros/src
1 file changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -2,8 +2,9 @@ use rustc_ast::token; | ||
2 | 2 | use rustc_ast::tokenstream::{DelimSpacing, DelimSpan, Spacing, TokenStream, TokenTree}; |
3 | 3 | use rustc_errors::ErrorGuaranteed; |
4 | 4 | use rustc_expand::base::{AttrProcMacro, ExtCtxt}; |
5 | -use rustc_span::Span; | |
5 | +use rustc_span:🪥:Transparency; | |
6 | 6 | use rustc_span::symbol::{Ident, Symbol, kw}; |
7 | +use rustc_span::{ExpnData, ExpnKind, LocalExpnId, MacroKind, Span, sym}; | |
7 | 8 | |
8 | 9 | pub(crate) struct ExpandRequires; |
9 | 10 | |
@@ -57,6 +58,18 @@ fn expand_contract_clause( | ||
57 | 58 | if let TokenTree::Token(token, _) = tt { token.is_ident_named(sym) } else { false } |
58 | 59 | }; |
59 | 60 | |
61 | +let expn_data = ExpnData { | |
62 | + ..ExpnData::default( | |
63 | +ExpnKind::Macro(MacroKind::Attr, sym::contract_checks), | |
64 | + attr_span, | |
65 | + attr_span.edition(), | |
66 | +None, | |
67 | +None, | |
68 | +) | |
69 | +}; | |
70 | +let expn_id = LocalExpnId::fresh(expn_data, attr_span.ctxt()); | |
71 | +let attr_span = attr_span.apply_mark(expn_id.to_expn_id(), Transparency::Transparent); | |
72 | + | |
60 | 73 | // Find the `fn` keyword to check if this is a function. |
61 | 74 | if cursor |
62 | 75 | .find(|tt |