Skip to content

Commit fc6a3d8

Browse files
committed
EII tests
1 parent a78f9aa commit fc6a3d8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+958
-0
lines changed

tests/ui/eii/auxiliary/codegen1.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ no-prefer-dynamic
2+
#![crate_type = "rlib"]
3+
#![feature(eii)]
4+
5+
#[eii(eii1)]
6+
fn decl1(x: u64);
7+
8+
mod private {
9+
#[eii(eii2)]
10+
pub fn decl2(x: u64);
11+
}
12+
13+
pub use private::eii2 as eii3;
14+
pub use private::decl2 as decl3;
15+
16+
pub fn local_call_decl1(x: u64) {
17+
decl1(x)
18+
}

tests/ui/eii/auxiliary/codegen2.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ no-prefer-dynamic
2+
#![crate_type = "rlib"]
3+
#![feature(eii)]
4+
5+
#[eii(eii1)]
6+
pub fn decl1(x: u64);

tests/ui/eii/auxiliary/codegen3.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ no-prefer-dynamic
2+
#![crate_type = "rlib"]
3+
#![feature(eii)]
4+
5+
// does have an impl but can't be called
6+
#[eii(eii1)]
7+
fn decl1(x: u64);
8+
9+
#[eii(eii2)]
10+
pub fn decl2(x: u64);
11+
12+
mod private {
13+
#[eii(eii3)]
14+
pub fn decl3(x: u64);
15+
}
16+
17+
pub use private::eii3 as eii4;
18+
pub use private::decl3 as decl4;
19+
20+
pub fn local_call_decl1(x: u64) {
21+
decl1(x)
22+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ no-prefer-dynamic
2+
#![crate_type = "rlib"]
3+
#![feature(eii)]
4+
#![feature(decl_macro)]
5+
#![feature(rustc_attrs)]
6+
#![feature(eii_internals)]
7+
8+
#[eii_macro_for(bar)]
9+
#[rustc_builtin_macro(eii_macro)]
10+
pub macro foo() {
11+
12+
}
13+
14+
unsafe extern "Rust" {
15+
pub safe fn bar(x: u64) -> u64;
16+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ run-pass
2+
//@ check-run-results
3+
//@ aux-build: codegen2.rs
4+
//@ compile-flags: -O
5+
#![feature(eii)]
6+
7+
extern crate codegen2 as codegen;
8+
9+
#[codegen::eii1]
10+
fn eii1_impl(x: u64) {
11+
println!("{x:?}")
12+
}
13+
14+
// what you would write:
15+
fn main() {
16+
// directly
17+
eii1_impl(21);
18+
// through the alias
19+
codegen::decl1(42);
20+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
21
2+
42
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ run-pass
2+
//@ check-run-results
3+
#![feature(eii)]
4+
5+
#[eii]
6+
fn hello(x: u64);
7+
8+
#[hello]
9+
fn hello_impl(x: u64) {
10+
println!("{x:?}")
11+
}
12+
13+
// what you would write:
14+
fn main() {
15+
// directly
16+
hello_impl(21);
17+
// through the alias
18+
hello(42);
19+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
21
2+
42

tests/ui/eii/cross_crate.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ compile-flags: --crate-type rlib
2+
//@ check-pass
3+
//@ aux-build: cross_crate_eii_declaration.rs
4+
#![feature(eii)]
5+
#![feature(decl_macro)]
6+
#![feature(rustc_attrs)]
7+
#![feature(eii_internals)]
8+
9+
extern crate cross_crate_eii_declaration;
10+
11+
#[unsafe(cross_crate_eii_declaration::foo)]
12+
fn other(x: u64) -> u64 {
13+
x
14+
}
15+
16+
fn main() {
17+
cross_crate_eii_declaration::bar(0);
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ compile-flags: --crate-type rlib
2+
//@ aux-build: cross_crate_eii_declaration.rs
3+
#![feature(eii)]
4+
#![feature(decl_macro)]
5+
#![feature(rustc_attrs)]
6+
#![feature(eii_internals)]
7+
8+
extern crate cross_crate_eii_declaration;
9+
10+
#[unsafe(cross_crate_eii_declaration::foo)]
11+
fn other() -> u64 {
12+
//~^ ERROR `other` has 0 parameters but #[foo] requires it to have 1
13+
0
14+
}
15+
16+
fn main() {
17+
cross_crate_eii_declaration::bar(0);
18+
}

0 commit comments

Comments
 (0)