@@ -4,8 +4,8 @@ use rustc_ast::token;
44use rustc_ast:: tokenstream:: { DelimSpacing , DelimSpan , Spacing , TokenStream , TokenTree } ;
55use rustc_errors:: ErrorGuaranteed ;
66use rustc_expand:: base:: { AttrProcMacro , ExtCtxt } ;
7- use rustc_span:: Span ;
87use rustc_span:: symbol:: { Ident , Symbol , kw, sym} ;
8+ use rustc_span:: { DesugaringKind , Span } ;
99
1010pub ( crate ) struct ExpandRequires ;
1111
@@ -121,23 +121,19 @@ fn expand_contract_clause(
121121 }
122122 }
123123
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-
129124 Ok ( new_tts)
130125}
131126
132127fn expand_requires_tts (
133- _ecx : & mut ExtCtxt < ' _ > ,
128+ ecx : & mut ExtCtxt < ' _ > ,
134129 attr_span : Span ,
135130 annotation : TokenStream ,
136131 annotated : TokenStream ,
137132) -> 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| {
139135 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 ) ) ,
141137 Spacing :: Joint ,
142138 ) ) ;
143139 new_tts. push_tree ( TokenTree :: Token (
@@ -155,14 +151,15 @@ fn expand_requires_tts(
155151}
156152
157153fn expand_ensures_tts (
158- _ecx : & mut ExtCtxt < ' _ > ,
154+ ecx : & mut ExtCtxt < ' _ > ,
159155 attr_span : Span ,
160156 annotation : TokenStream ,
161157 annotated : TokenStream ,
162158) -> 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| {
164161 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 ) ) ,
166163 Spacing :: Joint ,
167164 ) ) ;
168165 new_tts. push_tree ( TokenTree :: Delimited (
0 commit comments