Skip to content

Commit a2775a6

Browse files
committed
test codegen of eii
1 parent 2d3bf55 commit a2775a6

34 files changed

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

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)] //~ ERROR couldn't find an implementation for `#[eii2]`
10+
pub fn decl2(x: u64);
11+
12+
mod private {
13+
#[eii(eii3)] //~ ERROR couldn't find an implementation for `#[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+
}

tests/ui/eii/auxiliary/cross_crate_eii_declaration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ no-prefer-dynamic
2+
#![crate_type = "rlib"]
13
#![feature(eii)]
24
#![feature(decl_macro)]
35
#![feature(rustc_attrs)]

tests/ui/eii/codegen_cross_crate.rs

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

tests/ui/eii/codegen_single_crate.rs

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_wrong_ty.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[unsafe(cross_crate_eii_declaration::foo)]
66
LL | fn other() -> u64 {
77
| ^^^^^^^^^^^^^^^^^ expected 1 parameter, found 0
88
|
9-
::: $DIR/auxiliary/cross_crate_eii_declaration.rs:13:5
9+
::: $DIR/auxiliary/cross_crate_eii_declaration.rs:15:5
1010
|
1111
LL | pub safe fn bar(x: u64) -> u64;
1212
| ------------------------------- requires 1 parameter
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ no-prefer-dynamic
2+
#![crate_type = "rlib"]
3+
#![feature(eii)]
4+
5+
#[eii(eii1)]
6+
pub fn decl1(x: u64) {
7+
println!("default {x}");
8+
}
9+

0 commit comments

Comments
 (0)