-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Better sanitize attr diagnostic #145182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Better sanitize attr diagnostic #145182
Conversation
error: invalid setting for `address` | ||
--> $DIR/invalid-sanitize.rs:15:12 | ||
| | ||
LL | #[sanitize(address = "bogus")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like for this to only mark the "bogus" part. I couldn't figure out how to get the correct span for that.
e327696
to
2b7dbe6
Compare
☔ The latest upstream changes (presumably #145300) made this pull request unmergeable. Please resolve the merge conflicts. |
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 removes the #[no_sanitize] attribute, which was behind an unstable feature named no_sanitize. Instead, we introduce the sanitize attribute which is more powerful and allows to be extended in the future (instead of just focusing on turning sanitizers off). This also makes sanitize(kernel_address = ..) attribute work with -Zsanitize=address To do it the same as how clang disables address sanitizer, we now disable ASAN on sanitize(kernel_address = "off") and KASAN on sanitize(address = "off"). The same was added to clang in https://reviews.llvm.org/D44981.
2b7dbe6
to
cf64064
Compare
☔ The latest upstream changes (presumably #145085) made this pull request unmergeable. Please resolve the merge conflicts. |
Based on #142681
While working on a new sanitizer i noticed that the error messages here could be better.
This now differentiates between a wrong / nonexisting sanitizer and a wrong / nonexisting value for a valid sanitizer.
This is my first time doing a PR to rustc, so i could have missed something.