forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#105970 - Ezrashaw:add-docs+test-e0462, r=Gu…
…illaumeGomez docs/test: add UI test and long-form error docs for E0462 Another UI test/ docs combo. r? `@GuillaumeGomez`
- Loading branch information
Showing
6 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Found `staticlib` `..` instead of `rlib` or `dylib`. | ||
|
||
Consider the following two files: | ||
|
||
`a.rs` | ||
```ignore (cannot-link-with-other-tests) | ||
#![crate_type = "staticlib"] | ||
fn foo() {} | ||
``` | ||
|
||
`main.rs` | ||
```ignore (cannot-link-with-other-tests) | ||
extern crate a; | ||
fn main() { | ||
a::foo(); | ||
} | ||
``` | ||
|
||
Crate `a` is compiled as a `staticlib`. A `staticlib` is a system-dependant | ||
library only intended for linking with non-Rust applications (C programs). Note | ||
that `staticlib`s include all upstream dependencies (`core`, `std`, other user | ||
dependencies, etc) which makes them significantly larger than `dylib`s: | ||
prefer `staticlib` for linking with C programs. Learn more about different | ||
`crate_type`s in [this section of the Reference](../reference/linkage.html). | ||
|
||
This error can be fixed by: | ||
* Using [Cargo](../cargo/index.html), the Rust package manager, automatically | ||
fixing this issue. | ||
* Recompiling the crate as a `rlib` or `dylib`; formats suitable for Rust | ||
linking. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// aux-build:found-staticlib.rs | ||
|
||
// normalize-stderr-test: "\.nll/" -> "/" | ||
// normalize-stderr-test: "\\\?\\" -> "" | ||
// normalize-stderr-test: "(lib)?found_staticlib\.[a-z]+" -> "libfound_staticlib.somelib" | ||
|
||
extern crate found_staticlib; //~ ERROR E0462 | ||
|
||
fn main() { | ||
found_staticlib::foo(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0462]: found staticlib `found_staticlib` instead of rlib or dylib | ||
--> $DIR/E0462.rs:7:1 | ||
| | ||
LL | extern crate found_staticlib; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: the following crate versions were found: | ||
crate `found_staticlib`: $TEST_BUILD_DIR/error-codes/E0462/auxiliary/libfound_staticlib.somelib | ||
= help: please recompile that crate using --crate-type lib | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0462`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// no-prefer-dynamic | ||
#![crate_type = "staticlib"] | ||
|
||
pub fn foo() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters