forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#8450 - Jarcho:unsafe_blocks_8449, r=giraffate
Rework `undocumented_unsafe_blocks` fixes: rust-lang#8264 fixes: rust-lang#8449 One thing came up while working on this. Currently comments on the same line are supported like so: ```rust /* SAFETY: reason */ unsafe {} ``` Is this worth supporting at all? Anything other than a couple of words doesn't really fit well. edit: [zulip topic](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60undocumented_unsafe_blocks.60.20same.20line.20comment) changelog: Don't lint `undocumented_unsafe_blocks` when the unsafe block comes from a proc-macro. changelog: Don't lint `undocumented_unsafe_blocks` when the preceding line has a safety comment and the unsafe block is a sub-expression.
- Loading branch information
Showing
6 changed files
with
277 additions
and
262 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
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,18 @@ | ||
// compile-flags: --emit=link | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
|
||
use proc_macro::{Delimiter, Group, Ident, TokenStream, TokenTree}; | ||
|
||
#[proc_macro] | ||
pub fn unsafe_block(input: TokenStream) -> TokenStream { | ||
let span = input.into_iter().next().unwrap().span(); | ||
TokenStream::from_iter([TokenTree::Ident(Ident::new("unsafe", span)), { | ||
let mut group = Group::new(Delimiter::Brace, TokenStream::new()); | ||
group.set_span(span); | ||
TokenTree::Group(group) | ||
}]) | ||
} |
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
Oops, something went wrong.