mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Uitests for external statics
This commit is contained in:
@@ -1,106 +1,106 @@
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:7:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:9:1
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:13:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:15:1
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:21:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:23:1
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:27:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:29:1
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:32:5
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:34:5
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:39:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:41:1
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:44:5
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:46:5
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:51:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:53:1
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:56:5
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/attribute_targets.rs:58:5
|
||||
|
|
||||
LL | #[eii]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests EIIs with default implementations.
|
||||
// When there's no explicit declaration, the default should be called from the declaring crate.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
//@ needs-unwind
|
||||
//@ exec-env:RUST_BACKTRACE=1
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// A small test to make sure that unwinding works properly.
|
||||
//
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests EIIs with default implementations.
|
||||
// When an explicit implementation is given in one dependency, and the declaration is in another,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests EIIs with default implementations.
|
||||
// In the same crate, when there's no explicit declaration, the default should be called.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests EIIs with default implementations.
|
||||
// In the same crate, the explicit implementation should get priority.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//@ aux-build: impl1.rs
|
||||
//@ aux-build: impl2.rs
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// tests that EIIs error properly, even if the conflicting implementations live in another crate.
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//@ aux-build: impl2.rs
|
||||
//@ aux-build: impl3.rs
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests the error message when there are multiple implementations of an EII in many crates.
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//@ aux-build: impl3.rs
|
||||
//@ aux-build: impl4.rs
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests the error message when there are multiple implementations of an EII in many crates.
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether one function could implement two EIIs.
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
error: `#[eii]` is only valid on functions
|
||||
error: `#[eii]` is only valid on functions and statics
|
||||
--> $DIR/error_statement_position.rs:8:5
|
||||
|
|
||||
LL | #[eii]
|
||||
|
||||
@@ -25,11 +25,9 @@ fn hello() {
|
||||
safe fn bar(x: u64) -> u64;
|
||||
}
|
||||
|
||||
#[foo] //~ ERROR `#[foo]` is only valid on functions
|
||||
static X: u64 = 4;
|
||||
#[foo] //~ ERROR `#[foo]` is only valid on functions
|
||||
#[foo] //~ ERROR `#[foo]` is only valid on functions and statics
|
||||
const Y: u64 = 4;
|
||||
#[foo] //~ ERROR `#[foo]` is only valid on functions
|
||||
#[foo] //~ ERROR `#[foo]` is only valid on functions and statics
|
||||
macro bar() {}
|
||||
|
||||
#[foo()]
|
||||
|
||||
@@ -52,47 +52,41 @@ error: `#[eii_declaration(...)]` expects a list of one or two elements
|
||||
LL | #[eii_declaration = "unsafe"]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/errors.rs:28:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
error: `#[foo]` is only valid on functions and statics
|
||||
--> $DIR/errors.rs:30:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` is only valid on functions
|
||||
--> $DIR/errors.rs:32:1
|
||||
|
|
||||
LL | #[foo]
|
||||
| ^^^^^^
|
||||
|
||||
error: `#[foo]` expected no arguments or a single argument: `#[foo(default)]`
|
||||
--> $DIR/errors.rs:35:1
|
||||
--> $DIR/errors.rs:33:1
|
||||
|
|
||||
LL | #[foo()]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: `#[foo]` expected no arguments or a single argument: `#[foo(default)]`
|
||||
--> $DIR/errors.rs:37:1
|
||||
--> $DIR/errors.rs:35:1
|
||||
|
|
||||
LL | #[foo(default, bar)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[foo]` expected no arguments or a single argument: `#[foo(default)]`
|
||||
--> $DIR/errors.rs:39:1
|
||||
--> $DIR/errors.rs:37:1
|
||||
|
|
||||
LL | #[foo("default")]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: `#[foo]` expected no arguments or a single argument: `#[foo(default)]`
|
||||
--> $DIR/errors.rs:41:1
|
||||
--> $DIR/errors.rs:39:1
|
||||
|
|
||||
LL | #[foo = "default"]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 15 previous errors
|
||||
error: aborting due to 14 previous errors
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
//@ aux-build: codegen_cross_crate_other_crate.rs
|
||||
//@ compile-flags: -O
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether calling EIIs works with the declaration in another crate.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether calling EIIs works with the declaration in the same crate.
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether calling EIIs works with the declaration in the same crate.
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(inline)]
|
||||
//~^ ERROR `#[inline]` required, but not found
|
||||
fn test(x: u64);
|
||||
|
||||
#[inline]
|
||||
//~^ ERROR `inline` is ambiguous
|
||||
fn test_impl(x: u64) {
|
||||
println!("{x:?}")
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
@@ -0,0 +1,26 @@
|
||||
error[E0659]: `inline` is ambiguous
|
||||
--> $DIR/shadow_builtin.rs:11:3
|
||||
|
|
||||
LL | #[inline]
|
||||
| ^^^^^^ ambiguous name
|
||||
|
|
||||
= note: ambiguous because of a name conflict with a builtin attribute
|
||||
= note: `inline` could refer to a built-in attribute
|
||||
note: `inline` could also refer to the attribute macro defined here
|
||||
--> $DIR/shadow_builtin.rs:7:1
|
||||
|
|
||||
LL | #[eii(inline)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
= help: use `crate::inline` to refer to this attribute macro unambiguously
|
||||
|
||||
error: `#[inline]` required, but not found
|
||||
--> $DIR/shadow_builtin.rs:7:7
|
||||
|
|
||||
LL | #[eii(inline)]
|
||||
| ^^^^^^ expected because `#[inline]` was declared here in crate `shadow_builtin`
|
||||
|
|
||||
= help: expected at least one implementation in crate `shadow_builtin` or any of its dependencies
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0659`.
|
||||
@@ -0,0 +1,11 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs work on statics
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii]
|
||||
//~^ ERROR `#[eii]` requires the name as an explicit argument when used on a static
|
||||
static HELLO: u64;
|
||||
|
||||
fn main() { }
|
||||
@@ -0,0 +1,8 @@
|
||||
error: `#[eii]` requires the name as an explicit argument when used on a static
|
||||
--> $DIR/argument_required.rs:7:1
|
||||
|
|
||||
LL | #[eii]
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
//@ no-prefer-dynamic
|
||||
#![crate_type = "rlib"]
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(eii1)]
|
||||
pub static DECL1: u64;
|
||||
@@ -0,0 +1,9 @@
|
||||
//@ no-prefer-dynamic
|
||||
#![crate_type = "rlib"]
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(eii1)]
|
||||
pub static DECL1: u64;
|
||||
|
||||
#[eii1]
|
||||
pub static EII1_IMPL: u64 = 5;
|
||||
@@ -0,0 +1,21 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ aux-build: cross_crate_decl.rs
|
||||
//@ compile-flags: -O
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether calling EIIs works with the declaration in another crate.
|
||||
|
||||
extern crate cross_crate_decl as codegen;
|
||||
|
||||
#[codegen::eii1]
|
||||
static EII1_IMPL: u64 = 5;
|
||||
|
||||
// what you would write:
|
||||
fn main() {
|
||||
// directly
|
||||
println!("{}", EII1_IMPL);
|
||||
// through the alias
|
||||
println!("{}", codegen::DECL1);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
5
|
||||
5
|
||||
@@ -0,0 +1,18 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ aux-build: cross_crate_def.rs
|
||||
//@ compile-flags: -O
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether calling EIIs works with the declaration and definition in another crate.
|
||||
|
||||
extern crate cross_crate_def as codegen;
|
||||
|
||||
// what you would write:
|
||||
fn main() {
|
||||
// directly
|
||||
println!("{}", codegen::EII1_IMPL);
|
||||
// through the alias
|
||||
println!("{}", codegen::DECL1);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
5
|
||||
5
|
||||
@@ -0,0 +1,25 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs work on statics
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(hello)]
|
||||
static HELLO: u64;
|
||||
|
||||
#[hello]
|
||||
static HELLO_IMPL1: u64 = 5;
|
||||
//~^ ERROR multiple implementations of `#[hello]`
|
||||
|
||||
#[hello]
|
||||
static HELLO_IMPL2: u64 = 6;
|
||||
|
||||
// what you would write:
|
||||
fn main() {
|
||||
// directly
|
||||
println!("{HELLO_IMPL1}");
|
||||
println!("{HELLO_IMPL2}");
|
||||
|
||||
// through the alias
|
||||
println!("{HELLO}");
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
error: multiple implementations of `#[hello]`
|
||||
--> $DIR/duplicate.rs:11:1
|
||||
|
|
||||
LL | static HELLO_IMPL1: u64 = 5;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^ first implemented here in crate `duplicate`
|
||||
...
|
||||
LL | static HELLO_IMPL2: u64 = 6;
|
||||
| ----------------------- also implemented here in crate `duplicate`
|
||||
|
|
||||
= help: an "externally implementable item" can only have a single implementation in the final artifact. When multiple implementations are found, also in different crates, they conflict
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs work on statics
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(hello)]
|
||||
fn hello() -> u64;
|
||||
|
||||
#[hello]
|
||||
//~^ ERROR `#[hello]` must be used on a function
|
||||
static HELLO_IMPL: u64 = 5;
|
||||
|
||||
fn main() { }
|
||||
@@ -0,0 +1,8 @@
|
||||
error: `#[hello]` must be used on a function
|
||||
--> $DIR/mismatch_fn_static.rs:10:1
|
||||
|
|
||||
LL | #[hello]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs work on statics
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(hello)]
|
||||
static mut HELLO: u64;
|
||||
|
||||
#[hello]
|
||||
//~^ ERROR mutability does not match with the definition of`#[hello]`
|
||||
static HELLO_IMPL: u64 = 5;
|
||||
|
||||
// what you would write:
|
||||
fn main() {
|
||||
// directly
|
||||
println!("{HELLO_IMPL}");
|
||||
|
||||
// through the alias
|
||||
println!("{}", unsafe { HELLO });
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
error: mutability does not match with the definition of`#[hello]`
|
||||
--> $DIR/mismatch_mut.rs:10:1
|
||||
|
|
||||
LL | #[hello]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs work on statics
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(hello)]
|
||||
unsafe static mut HELLO: u64;
|
||||
|
||||
#[hello]
|
||||
//~^ ERROR safety does not match with the definition of`#[hello]`
|
||||
static HELLO_IMPL: u64 = 5;
|
||||
|
||||
// what you would write:
|
||||
fn main() {
|
||||
// directly
|
||||
println!("{HELLO_IMPL}");
|
||||
|
||||
// through the alias
|
||||
println!("{}", unsafe { HELLO });
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
error: safety does not match with the definition of`#[hello]`
|
||||
--> $DIR/mismatch_safety.rs:10:1
|
||||
|
|
||||
LL | #[hello]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs work on statics
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(hello)]
|
||||
static HELLO: u64;
|
||||
|
||||
#[hello]
|
||||
//~^ ERROR `#[hello]` must be used on a static
|
||||
fn hello_impl() -> u64 {
|
||||
5
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
@@ -0,0 +1,8 @@
|
||||
error: `#[hello]` must be used on a static
|
||||
--> $DIR/mismatch_static_fn.rs:10:1
|
||||
|
|
||||
LL | #[hello]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether one function could implement two EIIs.
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(a)]
|
||||
static A: u64;
|
||||
|
||||
#[eii(b)]
|
||||
static B: u64;
|
||||
|
||||
#[a]
|
||||
#[b]
|
||||
static IMPL: u64 = 5;
|
||||
|
||||
fn main() {
|
||||
println!("{A} {B} {IMPL}")
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
5 5 5
|
||||
@@ -0,0 +1,22 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs work on statics
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(hello)]
|
||||
static mut HELLO: u64;
|
||||
|
||||
#[hello]
|
||||
static mut HELLO_IMPL: u64 = 5;
|
||||
|
||||
// what you would write:
|
||||
fn main() {
|
||||
// directly
|
||||
println!("{}", unsafe { HELLO_IMPL });
|
||||
|
||||
// through the alias
|
||||
println!("{}", unsafe { HELLO });
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
5
|
||||
5
|
||||
@@ -0,0 +1,21 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs and their declarations share the same address
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(hello)]
|
||||
static HELLO: u64;
|
||||
|
||||
#[hello]
|
||||
static HELLO_IMPL: u64 = 5;
|
||||
|
||||
// what you would write:
|
||||
fn main() {
|
||||
assert_eq!(
|
||||
&HELLO as *const u64 as usize,
|
||||
&HELLO_IMPL as *const u64 as usize,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
//@ run-pass
|
||||
//@ check-run-results
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests whether EIIs work on statics
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
#[eii(hello)]
|
||||
static HELLO: u64;
|
||||
|
||||
#[hello]
|
||||
static HELLO_IMPL: u64 = 5;
|
||||
|
||||
// what you would write:
|
||||
fn main() {
|
||||
// directly
|
||||
println!("{HELLO_IMPL}");
|
||||
|
||||
// through the alias
|
||||
println!("{HELLO}");
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
5
|
||||
5
|
||||
@@ -0,0 +1,18 @@
|
||||
//@ check-pass
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests that mismatching types of the declaration and definition are rejected
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
use std::ptr;
|
||||
|
||||
#[eii(hello)]
|
||||
static HELLO: for<'a> fn(&'a u8) -> &'a u8;
|
||||
|
||||
#[hello]
|
||||
static HELLO_IMPL: for<'a> fn(&'a u8) -> &'static u8 = |_| todo!();
|
||||
|
||||
fn main() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests that mismatching types of the declaration and definition are rejected
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
use std::ptr;
|
||||
|
||||
#[eii(hello)]
|
||||
static HELLO: for<'a> fn(&'a u8) -> &'static u8;
|
||||
|
||||
#[hello]
|
||||
static HELLO_IMPL: for<'a> fn(&'a u8) -> &'a u8 = |_| todo!();
|
||||
//~^ ERROR mismatched types
|
||||
|
||||
fn main() {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/subtype_wrong.rs:13:1
|
||||
|
|
||||
LL | static HELLO_IMPL: for<'a> fn(&'a u8) -> &'a u8 = |_| todo!();
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ one type is more general than the other
|
||||
|
|
||||
= note: expected fn pointer `for<'a> fn(&'a _) -> &'static _`
|
||||
found fn pointer `for<'a> fn(&'a _) -> &'a _`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
||||
@@ -0,0 +1,18 @@
|
||||
//@ ignore-backends: gcc
|
||||
// FIXME: linking on windows (specifically mingw) not yet supported, see tracking issue #125418
|
||||
//@ ignore-windows
|
||||
// Tests that mismatching types of the declaration and definition are rejected
|
||||
#![feature(extern_item_impls)]
|
||||
|
||||
use std::ptr;
|
||||
|
||||
#[eii(hello)]
|
||||
static HELLO: u64;
|
||||
|
||||
#[hello]
|
||||
static HELLO_IMPL: bool = true;
|
||||
//~^ ERROR static `HELLO_IMPL` has a type that is incompatible with the declaration of `#[hello]` [E0806]
|
||||
|
||||
fn main() {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
error[E0806]: static `HELLO_IMPL` has a type that is incompatible with the declaration of `#[hello]`
|
||||
--> $DIR/wrong_ty.rs:13:1
|
||||
|
|
||||
LL | static HELLO_IMPL: bool = true;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: expected this because of this attribute
|
||||
--> $DIR/wrong_ty.rs:12:1
|
||||
|
|
||||
LL | #[hello]
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0806`.
|
||||
Reference in New Issue
Block a user