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#61231 - pnkfelix:issue-59548-linkage-diagno…
…stic, r=petrochenkov Fix linkage diagnostic so it doesn't ICE for external crates Fix linkage diagnostic so it doesn't ICE for external crates (As a drive-by improvement, improved the diagnostic to indicate *why* `*const T` or `*mut T` is required.) Fix rust-lang#59548 Fix rust-lang#61232
- Loading branch information
Showing
15 changed files
with
99 additions
and
18 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,7 @@ | ||
#![feature(linkage)] | ||
#![crate_type = "lib"] | ||
|
||
extern { | ||
#[linkage="external"] | ||
pub static collision: *const i32; | ||
} |
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,5 @@ | ||
#![feature(linkage)] | ||
#![crate_type = "lib"] | ||
|
||
#[linkage="external"] | ||
pub static EXTERN: u32 = 0; |
21 changes: 21 additions & 0 deletions
21
src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs
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,21 @@ | ||
// rust-lang/rust#61232: We used to ICE when trying to detect a | ||
// collision on the symbol generated for the external linkage item in | ||
// an extern crate. | ||
|
||
// aux-build:def_colliding_external.rs | ||
|
||
extern crate def_colliding_external as dep1; | ||
|
||
#[no_mangle] | ||
pub static _rust_extern_with_linkage_collision: i32 = 0; | ||
|
||
mod dep2 { | ||
#[no_mangle] | ||
pub static collision: usize = 0; | ||
} | ||
|
||
fn main() { | ||
unsafe { | ||
println!("{:p}", &dep1::collision); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/ui/linkage-attr/linkage-detect-extern-generated-name-collision.stderr
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,8 @@ | ||
error: symbol `collision` is already defined | ||
--> $DIR/auxiliary/def_colliding_external.rs:6:5 | ||
| | ||
LL | pub static collision: *const i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
23 changes: 23 additions & 0 deletions
23
src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.rs
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,23 @@ | ||
#![feature(linkage)] | ||
|
||
mod dep1 { | ||
extern { | ||
#[linkage="external"] | ||
#[no_mangle] | ||
pub static collision: *const i32; //~ ERROR symbol `collision` is already defined | ||
} | ||
} | ||
|
||
#[no_mangle] | ||
pub static _rust_extern_with_linkage_collision: i32 = 0; | ||
|
||
mod dep2 { | ||
#[no_mangle] | ||
pub static collision: usize = 0; | ||
} | ||
|
||
fn main() { | ||
unsafe { | ||
println!("{:p}", &dep1::collision); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/test/ui/linkage-attr/linkage-detect-local-generated-name-collision.stderr
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,8 @@ | ||
error: symbol `collision` is already defined | ||
--> $DIR/linkage-detect-local-generated-name-collision.rs:7:9 | ||
| | ||
LL | pub static collision: *const i32; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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,10 @@ | ||
// rust-lang/rust#59548: We used to ICE when trying to use a static | ||
// with a type that violated its own `#[linkage]`. | ||
|
||
// aux-build:def_illtyped_external.rs | ||
|
||
extern crate def_illtyped_external as dep; | ||
|
||
fn main() { | ||
println!("{:p}", &dep::EXTERN); | ||
} |
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,8 @@ | ||
error: must have type `*const T` or `*mut T` due to `#[linkage]` attribute | ||
--> $DIR/auxiliary/def_illtyped_external.rs:5:1 | ||
| | ||
LL | pub static EXTERN: u32 = 0; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
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
2 changes: 1 addition & 1 deletion
2
src/test/ui/linkage2.stderr → src/test/ui/linkage-attr/linkage2.stderr
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.