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.
Emit an error for invalid use of the linkage attribute
- Loading branch information
Showing
5 changed files
with
124 additions
and
1 deletion.
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
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,42 @@ | ||
#![feature(linkage)] | ||
#![feature(stmt_expr_attributes)] | ||
#![deny(unused_attributes)] | ||
#![allow(dead_code)] | ||
|
||
#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static | ||
type InvalidTy = (); | ||
|
||
#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static | ||
mod invalid_module {} | ||
|
||
#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static | ||
struct F; | ||
|
||
#[linkage = "weak"] //~ ERROR attribute should be applied to a function or static | ||
impl F { | ||
#[linkage = "weak"] | ||
fn valid(&self) {} | ||
} | ||
|
||
#[linkage = "weak"] | ||
fn f() { | ||
#[linkage = "weak"] | ||
{ | ||
1 | ||
}; | ||
//~^^^^ ERROR attribute should be applied to a function or static | ||
} | ||
|
||
extern "C" { | ||
#[linkage = "weak"] | ||
static A: *const (); | ||
|
||
#[linkage = "weak"] | ||
fn bar(); | ||
} | ||
|
||
fn main() { | ||
let _ = #[linkage = "weak"] | ||
(|| 1); | ||
//~^^ ERROR attribute should be applied to a function or static | ||
} |
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,55 @@ | ||
error: attribute should be applied to a function or static | ||
--> $DIR/linkage.rs:6:1 | ||
| | ||
LL | #[linkage = "weak"] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | type InvalidTy = (); | ||
| -------------------- not a function definition or static | ||
|
||
error: attribute should be applied to a function or static | ||
--> $DIR/linkage.rs:9:1 | ||
| | ||
LL | #[linkage = "weak"] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | mod invalid_module {} | ||
| --------------------- not a function definition or static | ||
|
||
error: attribute should be applied to a function or static | ||
--> $DIR/linkage.rs:12:1 | ||
| | ||
LL | #[linkage = "weak"] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | struct F; | ||
| --------- not a function definition or static | ||
|
||
error: attribute should be applied to a function or static | ||
--> $DIR/linkage.rs:15:1 | ||
| | ||
LL | #[linkage = "weak"] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | / impl F { | ||
LL | | #[linkage = "weak"] | ||
LL | | fn valid(&self) {} | ||
LL | | } | ||
| |_- not a function definition or static | ||
|
||
error: attribute should be applied to a function or static | ||
--> $DIR/linkage.rs:23:5 | ||
| | ||
LL | #[linkage = "weak"] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | / { | ||
LL | | 1 | ||
LL | | }; | ||
| |_____- not a function definition or static | ||
|
||
error: attribute should be applied to a function or static | ||
--> $DIR/linkage.rs:39:13 | ||
| | ||
LL | let _ = #[linkage = "weak"] | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
LL | (|| 1); | ||
| ------ not a function definition or static | ||
|
||
error: aborting due to 6 previous errors | ||
|