Skip to content

Commit 7b3a361

Browse files
Uitests for external statics
1 parent d2dd8e9 commit 7b3a361

29 files changed

Lines changed: 358 additions & 36 deletions

tests/ui/eii/attribute_targets.stderr

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,106 @@
1-
error: `#[foo]` is only valid on functions
1+
error: `#[foo]` is only valid on functions and statics
22
--> $DIR/attribute_targets.rs:7:1
33
|
44
LL | #[foo]
55
| ^^^^^^
66

7-
error: `#[eii]` is only valid on functions
7+
error: `#[eii]` is only valid on functions and statics
88
--> $DIR/attribute_targets.rs:9:1
99
|
1010
LL | #[eii]
1111
| ^^^^^^
1212

13-
error: `#[foo]` is only valid on functions
13+
error: `#[foo]` is only valid on functions and statics
1414
--> $DIR/attribute_targets.rs:13:1
1515
|
1616
LL | #[foo]
1717
| ^^^^^^
1818

19-
error: `#[eii]` is only valid on functions
19+
error: `#[eii]` is only valid on functions and statics
2020
--> $DIR/attribute_targets.rs:15:1
2121
|
2222
LL | #[eii]
2323
| ^^^^^^
2424

25-
error: `#[foo]` is only valid on functions
25+
error: `#[foo]` is only valid on functions and statics
2626
--> $DIR/attribute_targets.rs:21:1
2727
|
2828
LL | #[foo]
2929
| ^^^^^^
3030

31-
error: `#[eii]` is only valid on functions
31+
error: `#[eii]` is only valid on functions and statics
3232
--> $DIR/attribute_targets.rs:23:1
3333
|
3434
LL | #[eii]
3535
| ^^^^^^
3636

37-
error: `#[foo]` is only valid on functions
37+
error: `#[foo]` is only valid on functions and statics
3838
--> $DIR/attribute_targets.rs:27:1
3939
|
4040
LL | #[foo]
4141
| ^^^^^^
4242

43-
error: `#[eii]` is only valid on functions
43+
error: `#[eii]` is only valid on functions and statics
4444
--> $DIR/attribute_targets.rs:29:1
4545
|
4646
LL | #[eii]
4747
| ^^^^^^
4848

49-
error: `#[foo]` is only valid on functions
49+
error: `#[foo]` is only valid on functions and statics
5050
--> $DIR/attribute_targets.rs:32:5
5151
|
5252
LL | #[foo]
5353
| ^^^^^^
5454

55-
error: `#[eii]` is only valid on functions
55+
error: `#[eii]` is only valid on functions and statics
5656
--> $DIR/attribute_targets.rs:34:5
5757
|
5858
LL | #[eii]
5959
| ^^^^^^
6060

61-
error: `#[foo]` is only valid on functions
61+
error: `#[foo]` is only valid on functions and statics
6262
--> $DIR/attribute_targets.rs:39:1
6363
|
6464
LL | #[foo]
6565
| ^^^^^^
6666

67-
error: `#[eii]` is only valid on functions
67+
error: `#[eii]` is only valid on functions and statics
6868
--> $DIR/attribute_targets.rs:41:1
6969
|
7070
LL | #[eii]
7171
| ^^^^^^
7272

73-
error: `#[foo]` is only valid on functions
73+
error: `#[foo]` is only valid on functions and statics
7474
--> $DIR/attribute_targets.rs:44:5
7575
|
7676
LL | #[foo]
7777
| ^^^^^^
7878

79-
error: `#[eii]` is only valid on functions
79+
error: `#[eii]` is only valid on functions and statics
8080
--> $DIR/attribute_targets.rs:46:5
8181
|
8282
LL | #[eii]
8383
| ^^^^^^
8484

85-
error: `#[foo]` is only valid on functions
85+
error: `#[foo]` is only valid on functions and statics
8686
--> $DIR/attribute_targets.rs:51:1
8787
|
8888
LL | #[foo]
8989
| ^^^^^^
9090

91-
error: `#[eii]` is only valid on functions
91+
error: `#[eii]` is only valid on functions and statics
9292
--> $DIR/attribute_targets.rs:53:1
9393
|
9494
LL | #[eii]
9595
| ^^^^^^
9696

97-
error: `#[foo]` is only valid on functions
97+
error: `#[foo]` is only valid on functions and statics
9898
--> $DIR/attribute_targets.rs:56:5
9999
|
100100
LL | #[foo]
101101
| ^^^^^^
102102

103-
error: `#[eii]` is only valid on functions
103+
error: `#[eii]` is only valid on functions and statics
104104
--> $DIR/attribute_targets.rs:58:5
105105
|
106106
LL | #[eii]

tests/ui/eii/error_statement_position.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: `#[eii]` is only valid on functions
1+
error: `#[eii]` is only valid on functions and statics
22
--> $DIR/error_statement_position.rs:8:5
33
|
44
LL | #[eii]

tests/ui/eii/errors.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ unsafe extern "Rust" {
2525
safe fn bar(x: u64) -> u64;
2626
}
2727

28-
#[foo] //~ ERROR `#[foo]` is only valid on functions
29-
static X: u64 = 4;
30-
#[foo] //~ ERROR `#[foo]` is only valid on functions
28+
#[foo] //~ ERROR `#[foo]` is only valid on functions and statics
3129
const Y: u64 = 4;
32-
#[foo] //~ ERROR `#[foo]` is only valid on functions
30+
#[foo] //~ ERROR `#[foo]` is only valid on functions and statics
3331
macro bar() {}
3432

3533
#[foo()]

tests/ui/eii/errors.stderr

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,47 +52,41 @@ error: `#[eii_declaration(...)]` expects a list of one or two elements
5252
LL | #[eii_declaration = "unsafe"]
5353
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5454

55-
error: `#[foo]` is only valid on functions
55+
error: `#[foo]` is only valid on functions and statics
5656
--> $DIR/errors.rs:28:1
5757
|
5858
LL | #[foo]
5959
| ^^^^^^
6060

61-
error: `#[foo]` is only valid on functions
61+
error: `#[foo]` is only valid on functions and statics
6262
--> $DIR/errors.rs:30:1
6363
|
6464
LL | #[foo]
6565
| ^^^^^^
6666

67-
error: `#[foo]` is only valid on functions
68-
--> $DIR/errors.rs:32:1
69-
|
70-
LL | #[foo]
71-
| ^^^^^^
72-
7367
error: `#[foo]` expected no arguments or a single argument: `#[foo(default)]`
74-
--> $DIR/errors.rs:35:1
68+
--> $DIR/errors.rs:33:1
7569
|
7670
LL | #[foo()]
7771
| ^^^^^^^^
7872

7973
error: `#[foo]` expected no arguments or a single argument: `#[foo(default)]`
80-
--> $DIR/errors.rs:37:1
74+
--> $DIR/errors.rs:35:1
8175
|
8276
LL | #[foo(default, bar)]
8377
| ^^^^^^^^^^^^^^^^^^^^
8478

8579
error: `#[foo]` expected no arguments or a single argument: `#[foo(default)]`
86-
--> $DIR/errors.rs:39:1
80+
--> $DIR/errors.rs:37:1
8781
|
8882
LL | #[foo("default")]
8983
| ^^^^^^^^^^^^^^^^^
9084

9185
error: `#[foo]` expected no arguments or a single argument: `#[foo(default)]`
92-
--> $DIR/errors.rs:41:1
86+
--> $DIR/errors.rs:39:1
9387
|
9488
LL | #[foo = "default"]
9589
| ^^^^^^^^^^^^^^^^^^
9690

97-
error: aborting due to 15 previous errors
91+
error: aborting due to 14 previous errors
9892

tests/ui/eii/shadow_builtin.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ ignore-backends: gcc
2+
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
3+
//@ ignore-windows
4+
// Tests whether calling EIIs works with the declaration in the same crate.
5+
#![feature(extern_item_impls)]
6+
7+
#[eii(inline)]
8+
//~^ ERROR `#[inline]` required, but not found
9+
fn test(x: u64);
10+
11+
#[inline]
12+
//~^ ERROR `inline` is ambiguous
13+
fn test_impl(x: u64) {
14+
println!("{x:?}")
15+
}
16+
17+
fn main() { }

tests/ui/eii/shadow_builtin.stderr

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
error[E0659]: `inline` is ambiguous
2+
--> $DIR/shadow_builtin.rs:11:3
3+
|
4+
LL | #[inline]
5+
| ^^^^^^ ambiguous name
6+
|
7+
= note: ambiguous because of a name conflict with a builtin attribute
8+
= note: `inline` could refer to a built-in attribute
9+
note: `inline` could also refer to the attribute macro defined here
10+
--> $DIR/shadow_builtin.rs:7:1
11+
|
12+
LL | #[eii(inline)]
13+
| ^^^^^^^^^^^^^^
14+
= help: use `crate::inline` to refer to this attribute macro unambiguously
15+
16+
error: `#[inline]` required, but not found
17+
--> $DIR/shadow_builtin.rs:7:7
18+
|
19+
LL | #[eii(inline)]
20+
| ^^^^^^ expected because `#[inline]` was declared here in crate `shadow_builtin`
21+
|
22+
= help: expected at least one implementation in crate `shadow_builtin` or any of its dependencies
23+
24+
error: aborting due to 2 previous errors
25+
26+
For more information about this error, try `rustc --explain E0659`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ ignore-backends: gcc
2+
// FIXME: linking on windows (speciifcally mingw) not yet supported, see tracking issue #125418
3+
//@ ignore-windows
4+
// Tests whether EIIs work on statics
5+
#![feature(extern_item_impls)]
6+
7+
#[eii]
8+
//~^ ERROR `#[eii]` requires the name as an explicit argument when used on a static
9+
static HELLO: u64;
10+
11+
fn main() { }
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: `#[eii]` requires the name as an explicit argument when used on a static
2+
--> $DIR/argument_required.rs:7:1
3+
|
4+
LL | #[eii]
5+
| ^^^^^^
6+
7+
error: aborting due to 1 previous error
8+
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(extern_item_impls)]
4+
5+
#[eii(eii1)]
6+
pub static DECL1: u64;
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(extern_item_impls)]
4+
5+
#[eii(eii1)]
6+
pub static DECL1: u64;
7+
8+
#[eii1]
9+
pub static EII1_IMPL: u64 = 5;

0 commit comments

Comments
 (0)