@@ -100,7 +100,7 @@ use rustc_middle::ty::query::Providers;
100100use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
101101use rustc_middle:: util;
102102use rustc_session:: config:: EntryFnType ;
103- use rustc_span:: { Span , DUMMY_SP } ;
103+ use rustc_span:: { symbol :: sym , Span , DUMMY_SP } ;
104104use rustc_target:: spec:: abi:: Abi ;
105105use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt as _;
106106use rustc_trait_selection:: traits:: {
@@ -194,6 +194,23 @@ fn check_main_fn_ty(tcx: TyCtxt<'_>, main_def_id: LocalDefId) {
194194 . emit ( ) ;
195195 error = true ;
196196 }
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+
197214 if error {
198215 return ;
199216 }
@@ -268,12 +285,29 @@ fn check_start_fn_ty(tcx: TyCtxt<'_>, start_def_id: LocalDefId) {
268285 tcx. sess,
269286 span,
270287 E0752 ,
271- "start is not allowed to be `async`"
288+ "` start` is not allowed to be `async`"
272289 )
273- . span_label ( span, "start is not allowed to be `async`" )
290+ . span_label ( span, "` start` is not allowed to be `async`" )
274291 . emit ( ) ;
275292 error = true ;
276293 }
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+
277311 if error {
278312 return ;
279313 }
0 commit comments