@@ -4,8 +4,8 @@ use rustc_ast::token;
4
4
use rustc_ast:: tokenstream:: { DelimSpacing , DelimSpan , Spacing , TokenStream , TokenTree } ;
5
5
use rustc_errors:: ErrorGuaranteed ;
6
6
use rustc_expand:: base:: { AttrProcMacro , ExtCtxt } ;
7
- use rustc_span:: Span ;
8
7
use rustc_span:: symbol:: { Ident , Symbol , kw, sym} ;
8
+ use rustc_span:: { DesugaringKind , Span } ;
9
9
10
10
pub ( crate ) struct ExpandRequires ;
11
11
@@ -121,23 +121,19 @@ fn expand_contract_clause(
121
121
}
122
122
}
123
123
124
- // Record the span as a contract attribute expansion.
125
- // This is used later to stop users from using the extended syntax directly
126
- // which is gated via `contracts_internals`.
127
- ecx. psess ( ) . contract_attribute_spans . push ( attr_span) ;
128
-
129
124
Ok ( new_tts)
130
125
}
131
126
132
127
fn expand_requires_tts (
133
- _ecx : & mut ExtCtxt < ' _ > ,
128
+ ecx : & mut ExtCtxt < ' _ > ,
134
129
attr_span : Span ,
135
130
annotation : TokenStream ,
136
131
annotated : TokenStream ,
137
132
) -> Result < TokenStream , ErrorGuaranteed > {
138
- expand_contract_clause ( _ecx, attr_span, annotated, |new_tts| {
133
+ let feature_span = ecx. with_def_site_ctxt ( attr_span) ;
134
+ expand_contract_clause ( ecx, attr_span, annotated, |new_tts| {
139
135
new_tts. push_tree ( TokenTree :: Token (
140
- token:: Token :: from_ast_ident ( Ident :: new ( kw:: ContractRequires , attr_span ) ) ,
136
+ token:: Token :: from_ast_ident ( Ident :: new ( kw:: ContractRequires , feature_span ) ) ,
141
137
Spacing :: Joint ,
142
138
) ) ;
143
139
new_tts. push_tree ( TokenTree :: Token (
@@ -155,14 +151,15 @@ fn expand_requires_tts(
155
151
}
156
152
157
153
fn expand_ensures_tts (
158
- _ecx : & mut ExtCtxt < ' _ > ,
154
+ ecx : & mut ExtCtxt < ' _ > ,
159
155
attr_span : Span ,
160
156
annotation : TokenStream ,
161
157
annotated : TokenStream ,
162
158
) -> Result < TokenStream , ErrorGuaranteed > {
163
- expand_contract_clause ( _ecx, attr_span, annotated, |new_tts| {
159
+ let feature_span = ecx. with_def_site_ctxt ( attr_span) ;
160
+ expand_contract_clause ( ecx, attr_span, annotated, |new_tts| {
164
161
new_tts. push_tree ( TokenTree :: Token (
165
- token:: Token :: from_ast_ident ( Ident :: new ( kw:: ContractEnsures , attr_span ) ) ,
162
+ token:: Token :: from_ast_ident ( Ident :: new ( kw:: ContractEnsures , feature_span ) ) ,
166
163
Spacing :: Joint ,
167
164
) ) ;
168
165
new_tts. push_tree ( TokenTree :: Delimited (
0 commit comments