diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-08-08 18:21:20 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-08-12 09:14:50 +0300 |
| commit | 8a4facc3c30d9dfbbfc1ddc6d413dfb0520699c6 (patch) | |
| tree | f17dec95c54f6880ef5a4705db742ecb648847ae /src/libsyntax_pos/lib.rs | |
| parent | 2fa5340318111d562af2ef4897c75916731d55a2 (diff) | |
| download | rust-8a4facc3c30d9dfbbfc1ddc6d413dfb0520699c6.tar.gz rust-8a4facc3c30d9dfbbfc1ddc6d413dfb0520699c6.zip | |
syntax: #[allow_internal_unsafe] bypasses the unsafe_code lint in macros.
Diffstat (limited to 'src/libsyntax_pos/lib.rs')
| -rw-r--r-- | src/libsyntax_pos/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 7006f45455e..e162bc26412 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -153,6 +153,16 @@ impl Span { } } + /// Check if a span is "internal" to a macro in which `unsafe` + /// can be used without triggering the `unsafe_code` lint + // (that is, a macro marked with `#[allow_internal_unsafe]`). + pub fn allows_unsafe(&self) -> bool { + match self.ctxt.outer().expn_info() { + Some(info) => info.callee.allow_internal_unsafe, + None => false, + } + } + pub fn macro_backtrace(mut self) -> Vec<MacroBacktrace> { let mut prev_span = DUMMY_SP; let mut result = vec![]; |
