@@ -13,6 +13,7 @@ use rustc_hir::{self as hir, LangItem, lang_items};
13
13
use rustc_middle:: middle:: codegen_fn_attrs:: {
14
14
CodegenFnAttrFlags , CodegenFnAttrs , PatchableFunctionEntry ,
15
15
} ;
16
+ use rustc_middle:: middle:: exported_symbols:: SymbolExportLevel ;
16
17
use rustc_middle:: mir:: mono:: Linkage ;
17
18
use rustc_middle:: query:: Providers ;
18
19
use rustc_middle:: span_bug;
@@ -113,6 +114,18 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
113
114
AttributeKind :: ExportName { name, .. } => {
114
115
codegen_fn_attrs. export_name = Some ( * name) ;
115
116
}
117
+ AttributeKind :: RustSymbolExportLevel ( span) => {
118
+ if !tcx. features ( ) . rust_symbol_export_level ( ) {
119
+ feature_err (
120
+ & tcx. sess ,
121
+ sym:: rust_symbol_export_level,
122
+ * span,
123
+ "`#[rust_symbol_export_level]` is currently unstable" ,
124
+ )
125
+ . emit ( ) ;
126
+ }
127
+ codegen_fn_attrs. export_level = Some ( SymbolExportLevel :: Rust ) ;
128
+ }
116
129
AttributeKind :: Naked ( _) => codegen_fn_attrs. flags |= CodegenFnAttrFlags :: NAKED ,
117
130
AttributeKind :: Align { align, .. } => codegen_fn_attrs. alignment = Some ( * align) ,
118
131
AttributeKind :: LinkName { name, .. } => codegen_fn_attrs. link_name = Some ( * name) ,
@@ -509,6 +522,17 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
509
522
err. emit ( ) ;
510
523
}
511
524
525
+ if codegen_fn_attrs. export_level . is_some ( ) && !codegen_fn_attrs. contains_extern_indicator ( ) {
526
+ let rust_symbol_export_level_span =
527
+ find_attr ! ( attrs, AttributeKind :: RustSymbolExportLevel ( span) => * span)
528
+ . unwrap_or_default ( ) ;
529
+ tcx. dcx ( ) . span_err (
530
+ rust_symbol_export_level_span,
531
+ "`#[rust_symbol_export_level]` will be ignored \
532
+ without `export_name`, `no_mangle`, or similar attribute",
533
+ ) ;
534
+ }
535
+
512
536
if let Some ( features) = check_tied_features (
513
537
tcx. sess ,
514
538
& codegen_fn_attrs
0 commit comments