This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +66
-1
lines changed
compiler/rustc_metadata/src
src/test/ui/rfc-2627-raw-dylib Expand file tree Collapse file tree 3 files changed +66
-1
lines changed Original file line number Diff line number Diff line change @@ -328,7 +328,31 @@ impl<'tcx> Collector<'tcx> {
328328 . map ( |child_item| self . build_dll_import ( abi, child_item) )
329329 . collect ( )
330330 }
331- _ => Vec :: new ( ) ,
331+ _ => {
332+ for child_item in foreign_mod_items {
333+ if self . tcx . def_kind ( child_item. id . def_id ) . has_codegen_attrs ( )
334+ && self
335+ . tcx
336+ . codegen_fn_attrs ( child_item. id . def_id )
337+ . link_ordinal
338+ . is_some ( )
339+ {
340+ let link_ordinal_attr = self
341+ . tcx
342+ . hir ( )
343+ . attrs ( self . tcx . hir ( ) . local_def_id_to_hir_id ( child_item. id . def_id ) )
344+ . iter ( )
345+ . find ( |a| a. has_name ( sym:: link_ordinal) )
346+ . unwrap ( ) ;
347+ sess. span_err (
348+ link_ordinal_attr. span ,
349+ "`#[link_ordinal]` is only supported if link kind is `raw-dylib`" ,
350+ ) ;
351+ }
352+ }
353+
354+ Vec :: new ( )
355+ }
332356 } ;
333357 self . libs . push ( NativeLib {
334358 name : name. map ( |( name, _) | name) ,
Original file line number Diff line number Diff line change 1+ #![ feature( raw_dylib) ]
2+ //~^ WARN the feature `raw_dylib` is incomplete
3+
4+ #[ link( name = "foo" ) ]
5+ extern "C" {
6+ #[ link_ordinal( 3 ) ]
7+ //~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib`
8+ fn foo ( ) ;
9+ }
10+
11+ #[ link( name = "bar" , kind = "static" ) ]
12+ extern "C" {
13+ #[ link_ordinal( 3 ) ]
14+ //~^ ERROR `#[link_ordinal]` is only supported if link kind is `raw-dylib`
15+ fn bar ( ) ;
16+ }
17+
18+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ warning: the feature `raw_dylib` is incomplete and may not be safe to use and/or cause compiler crashes
2+ --> $DIR/link-ordinal-unsupported-link-kind.rs:1:12
3+ |
4+ LL | #![feature(raw_dylib)]
5+ | ^^^^^^^^^
6+ |
7+ = note: `#[warn(incomplete_features)]` on by default
8+ = note: see issue #58713 <https://github.com/rust-lang/rust/issues/58713> for more information
9+
10+ error: `#[link_ordinal]` is only supported if link kind is `raw-dylib`
11+ --> $DIR/link-ordinal-unsupported-link-kind.rs:6:5
12+ |
13+ LL | #[link_ordinal(3)]
14+ | ^^^^^^^^^^^^^^^^^^
15+
16+ error: `#[link_ordinal]` is only supported if link kind is `raw-dylib`
17+ --> $DIR/link-ordinal-unsupported-link-kind.rs:13:5
18+ |
19+ LL | #[link_ordinal(3)]
20+ | ^^^^^^^^^^^^^^^^^^
21+
22+ error: aborting due to 2 previous errors; 1 warning emitted
23+
You can’t perform that action at this time.
0 commit comments