|
| 1 | +// ignore-tidy-filelength |
1 | 2 | //! "Collection" is the process of determining the type and other external
|
2 | 3 | //! details of each item in Rust. Collection is specifically concerned
|
3 | 4 | //! with *inter-procedural* things -- for example, for a function
|
@@ -2856,7 +2857,42 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, id: DefId) -> CodegenFnAttrs {
|
2856 | 2857 | } else if attr.has_name(sym::rustc_std_internal_symbol) {
|
2857 | 2858 | codegen_fn_attrs.flags |= CodegenFnAttrFlags::RUSTC_STD_INTERNAL_SYMBOL;
|
2858 | 2859 | } else if attr.has_name(sym::used) {
|
2859 |
| - codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED; |
| 2860 | + let inner = attr.meta_item_list(); |
| 2861 | + match inner.as_deref() { |
| 2862 | + Some([item]) if item.has_name(sym::linker) => { |
| 2863 | + if !tcx.features().used_with_arg { |
| 2864 | + feature_err( |
| 2865 | + &tcx.sess.parse_sess, |
| 2866 | + sym::used_with_arg, |
| 2867 | + attr.span, |
| 2868 | + "`#[used(linker)]` is currently unstable", |
| 2869 | + ) |
| 2870 | + .emit(); |
| 2871 | + } |
| 2872 | + codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED_LINKER; |
| 2873 | + } |
| 2874 | + Some([item]) if item.has_name(sym::compiler) => { |
| 2875 | + if !tcx.features().used_with_arg { |
| 2876 | + feature_err( |
| 2877 | + &tcx.sess.parse_sess, |
| 2878 | + sym::used_with_arg, |
| 2879 | + attr.span, |
| 2880 | + "`#[used(compiler)]` is currently unstable", |
| 2881 | + ) |
| 2882 | + .emit(); |
| 2883 | + } |
| 2884 | + codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED; |
| 2885 | + } |
| 2886 | + Some(_) => { |
| 2887 | + tcx.sess |
| 2888 | + .struct_span_err( |
| 2889 | + attr.span, |
| 2890 | + "expected `used`, `used(compiler)` or `used(linker)`", |
| 2891 | + ) |
| 2892 | + .emit(); |
| 2893 | + } |
| 2894 | + None => codegen_fn_attrs.flags |= CodegenFnAttrFlags::USED, |
| 2895 | + } |
2860 | 2896 | } else if attr.has_name(sym::cmse_nonsecure_entry) {
|
2861 | 2897 | if !matches!(tcx.fn_sig(id).abi(), abi::Abi::C { .. }) {
|
2862 | 2898 | struct_span_err!(
|
|
0 commit comments