Implement the #[sanitize(..)] attribute
This change implements the #[sanitize(..)] attribute, which opts to
replace the currently unstable #[no_sanitize]. Essentially the new
attribute works similar as #[no_sanitize], just with more flexible
options regarding where it is applied. E.g. it is possible to turn
a certain sanitizer either on or off:
`#[sanitize(address = "on|off")]`
This attribute now also applies to more places, e.g. it is possible
to turn off a sanitizer for an entire module or impl block:
```rust
\#[sanitize(address = "off")]
mod foo {
fn unsanitized(..) {}
#[sanitize(address = "on")]
fn sanitized(..) {}
}
\#[sanitize(thread = "off")]
impl MyTrait for () {
...
}
```
This attribute is enabled behind the unstable `sanitize` feature.
This commit is contained in:
@@ -1499,6 +1499,23 @@ pub(crate) struct NoSanitize<'a> {
|
||||
pub attr_str: &'a str,
|
||||
}
|
||||
|
||||
/// "sanitize attribute not allowed here"
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_sanitize_attribute_not_allowed)]
|
||||
pub(crate) struct SanitizeAttributeNotAllowed {
|
||||
#[primary_span]
|
||||
pub attr_span: Span,
|
||||
/// "not a function, impl block, or module"
|
||||
#[label(passes_not_fn_impl_mod)]
|
||||
pub not_fn_impl_mod: Option<Span>,
|
||||
/// "function has no body"
|
||||
#[label(passes_no_body)]
|
||||
pub no_body: Option<Span>,
|
||||
/// "sanitize attribute can be applied to a function (with body), impl block, or module"
|
||||
#[help]
|
||||
pub help: (),
|
||||
}
|
||||
|
||||
// FIXME(jdonszelmann): move back to rustc_attr
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(passes_rustc_const_stable_indirect_pairing)]
|
||||
|
||||
Reference in New Issue
Block a user