@@ -100,7 +100,7 @@ use rustc_middle::ty::query::Providers;
100
100
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
101
101
use rustc_middle:: util;
102
102
use rustc_session:: config:: EntryFnType ;
103
- use rustc_span:: { Span , DUMMY_SP } ;
103
+ use rustc_span:: { symbol :: sym , Span , DUMMY_SP } ;
104
104
use rustc_target:: spec:: abi:: Abi ;
105
105
use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt as _;
106
106
use rustc_trait_selection:: traits:: {
@@ -194,6 +194,23 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: LocalDefId) {
194
194
. emit ( ) ;
195
195
error = true ;
196
196
}
197
+
198
+ for attr in it. attrs {
199
+ if attr. check_name ( sym:: track_caller) {
200
+ tcx. sess
201
+ . struct_span_err (
202
+ attr. span ,
203
+ "`main` function is not allowed to be `#[track_caller]`" ,
204
+ )
205
+ . span_label (
206
+ main_span,
207
+ "`main` function is not allowed to be `#[track_caller]`" ,
208
+ )
209
+ . emit ( ) ;
210
+ error = true ;
211
+ }
212
+ }
213
+
197
214
if error {
198
215
return ;
199
216
}
@@ -268,12 +285,29 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: LocalDefId) {
268
285
tcx. sess,
269
286
span,
270
287
E0752 ,
271
- "start is not allowed to be `async`"
288
+ "` start` is not allowed to be `async`"
272
289
)
273
- . span_label ( span, "start is not allowed to be `async`" )
290
+ . span_label ( span, "` start` is not allowed to be `async`" )
274
291
. emit ( ) ;
275
292
error = true ;
276
293
}
294
+
295
+ for attr in it. attrs {
296
+ if attr. check_name ( sym:: track_caller) {
297
+ tcx. sess
298
+ . struct_span_err (
299
+ attr. span ,
300
+ "`start` is not allowed to be `#[track_caller]`" ,
301
+ )
302
+ . span_label (
303
+ start_span,
304
+ "`start` is not allowed to be `#[track_caller]`" ,
305
+ )
306
+ . emit ( ) ;
307
+ error = true ;
308
+ }
309
+ }
310
+
277
311
if error {
278
312
return ;
279
313
}
0 commit comments