-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
#[no_sanitize]
attribute
- Loading branch information
Showing
3 changed files
with
95 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#![feature(no_sanitize)] | ||
#![feature(stmt_expr_attributes)] | ||
#![deny(unused_attributes)] | ||
#![allow(dead_code)] | ||
|
||
fn invalid() { | ||
#[no_sanitize(memory)] //~ ERROR attribute should be applied to a function definition | ||
{ | ||
1 | ||
}; | ||
} | ||
|
||
#[no_sanitize(memory)] //~ ERROR attribute should be applied to a function definition | ||
type InvalidTy = (); | ||
|
||
#[no_sanitize(memory)] //~ ERROR attribute should be applied to a function definition | ||
mod invalid_module {} | ||
|
||
fn main() { | ||
let _ = #[no_sanitize(memory)] //~ ERROR attribute should be applied to a function definition | ||
(|| 1); | ||
} | ||
|
||
#[no_sanitize(memory)] //~ ERROR attribute should be applied to a function definition | ||
struct F; | ||
|
||
#[no_sanitize(memory)] //~ ERROR attribute should be applied to a function definition | ||
impl F { | ||
#[no_sanitize(memory)] | ||
fn valid(&self) {} | ||
} | ||
|
||
#[no_sanitize(memory)] | ||
fn valid() {} |
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 definition | ||
--> $DIR/no-sanitize.rs:7:5 | ||
| | ||
LL | #[no_sanitize(memory)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | / { | ||
LL | | 1 | ||
LL | | }; | ||
| |_____- not a function definition | ||
|
||
error: attribute should be applied to a function definition | ||
--> $DIR/no-sanitize.rs:13:1 | ||
| | ||
LL | #[no_sanitize(memory)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | type InvalidTy = (); | ||
| -------------------- not a function definition | ||
|
||
error: attribute should be applied to a function definition | ||
--> $DIR/no-sanitize.rs:16:1 | ||
| | ||
LL | #[no_sanitize(memory)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | mod invalid_module {} | ||
| --------------------- not a function definition | ||
|
||
error: attribute should be applied to a function definition | ||
--> $DIR/no-sanitize.rs:20:13 | ||
| | ||
LL | let _ = #[no_sanitize(memory)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | (|| 1); | ||
| ------ not a function definition | ||
|
||
error: attribute should be applied to a function definition | ||
--> $DIR/no-sanitize.rs:24:1 | ||
| | ||
LL | #[no_sanitize(memory)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | struct F; | ||
| --------- not a function definition | ||
|
||
error: attribute should be applied to a function definition | ||
--> $DIR/no-sanitize.rs:27:1 | ||
| | ||
LL | #[no_sanitize(memory)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | / impl F { | ||
LL | | #[no_sanitize(memory)] | ||
LL | | fn valid(&self) {} | ||
LL | | } | ||
| |_- not a function definition | ||
|
||
error: aborting due to 6 previous errors | ||
|