@@ -609,10 +609,8 @@ Attributes on the anonymous crate module define important metadata that influenc
609
609
the behavior of the compiler.
610
610
611
611
~~~~
612
- // Linkage attributes
613
- #[ link(name = "projx",
614
- vers = "2.5",
615
- uuid = "9cccc5d5-aceb-4af5-8285-811211826b82") ];
612
+ // Package ID
613
+ #[ pkgid = "projx#2.5" ];
616
614
617
615
// Additional metadata attributes
618
616
#[ desc = "Project X" ];
@@ -775,36 +773,24 @@ An _`extern mod` declaration_ specifies a dependency on an external crate.
775
773
The external crate is then bound into the declaring scope
776
774
as the ` ident ` provided in the ` extern_mod_decl ` .
777
775
778
- The external crate is resolved to a specific ` soname ` at compile time,
779
- and a runtime linkage requirement to that ` soname ` is passed to the linker for
780
- loading at runtime.
781
- The ` soname ` is resolved at compile time by scanning the compiler's library path
782
- and matching the ` link_attrs ` provided in the ` use_decl ` against any ` #link ` attributes that
783
- were declared on the external crate when it was compiled.
784
- If no ` link_attrs ` are provided,
785
- a default ` name ` attribute is assumed,
786
- equal to the ` ident ` given in the ` use_decl ` .
787
-
788
- Optionally, an identifier in an ` extern mod ` declaration may be followed by an equals sign,
789
- then a string literal denoting a relative path on the filesystem.
790
- This path should exist in one of the directories in the Rust path,
791
- which by default contains the ` .rust ` subdirectory of the current directory and each of its parents,
792
- as well as any directories in the colon-separated (or semicolon-separated on Windows)
793
- list of paths that is the ` RUST_PATH ` environment variable.
794
- The meaning of ` extern mod a = "b/c/d"; ` , supposing that ` /a ` is in the RUST_PATH,
795
- is that the name ` a ` should be taken as a reference to the crate whose absolute location is
796
- ` /a/b/c/d ` .
776
+ The external crate is resolved to a specific ` soname ` at compile time, and a
777
+ runtime linkage requirement to that ` soname ` is passed to the linker for
778
+ loading at runtime. The ` soname ` is resolved at compile time by scanning the
779
+ compiler's library path and matching the optional ` pkgid ` provided as a string literal
780
+ against the ` pkgid ` attributes that were declared on the external crate when
781
+ it was compiled. If no ` pkgid ` is provided, a default ` name ` attribute is
782
+ assumed, equal to the ` ident ` given in the ` extern_mod_decl ` .
797
783
798
784
Four examples of ` extern mod ` declarations:
799
785
800
786
~~~~ {.xfail-test}
801
- extern mod pcre (uuid = "54aba0f8-a7b1-4beb-92f1-4cf625264841") ;
787
+ extern mod pcre;
802
788
803
- extern mod extra; // equivalent to: extern mod extra ( name = "extra" ) ;
789
+ extern mod extra; // equivalent to: extern mod extra = "extra";
804
790
805
- extern mod rustextra (name = "extra") ; // linking to 'extra' under another name
791
+ extern mod rustextra = "extra"; // linking to 'extra' under another name
806
792
807
- extern mod complicated_mod = "some-file/in/the-rust/path";
793
+ extern mod foo = "some/where/foo#1.0"; // a full package ID for rustpkg
808
794
~~~~
809
795
810
796
##### Use declarations
@@ -1742,7 +1728,8 @@ names are effectively reserved. Some significant attributes include:
1742
1728
* The ` doc ` attribute, for documenting code in-place.
1743
1729
* The ` cfg ` attribute, for conditional-compilation by build-configuration.
1744
1730
* The ` lang ` attribute, for custom definitions of traits and functions that are known to the Rust compiler (see [ Language items] ( #language-items ) ).
1745
- * The ` link ` attribute, for describing linkage metadata for a crate.
1731
+ * The ` link ` attribute, for describing linkage metadata for a extern blocks.
1732
+ * The ` pkgid ` attribute, for describing the package ID of a crate.
1746
1733
* The ` test ` attribute, for marking functions as unit tests.
1747
1734
* The ` allow ` , ` warn ` , ` forbid ` , and ` deny ` attributes, for
1748
1735
controlling lint checks (see [ Lint check attributes] ( #lint-check-attributes ) ).
@@ -3795,7 +3782,7 @@ specified then log level 4 is assumed. Debug messages can be omitted
3795
3782
by passing ` --cfg ndebug ` to ` rustc ` .
3796
3783
3797
3784
As an example, to see all the logs generated by the compiler, you would set
3798
- ` RUST_LOG ` to ` rustc ` , which is the crate name (as specified in its ` link `
3785
+ ` RUST_LOG ` to ` rustc ` , which is the crate name (as specified in its ` pkgid `
3799
3786
[ attribute] ( #attributes ) ). To narrow down the logs to just crate resolution,
3800
3787
you would set it to ` rustc::metadata::creader ` . To see just error logging
3801
3788
use ` rustc=0 ` .
0 commit comments