diff options
| author | Luca Casonato <hello@lcas.dev> | 2022-06-26 00:13:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-26 00:13:24 +0200 |
| commit | 8d82ba729937baf83011354242cabc3d50c13dc2 (patch) | |
| tree | 3e8c4d87986338639eeef4a76543e4335020262c /cli | |
| parent | 38505db39137f33bfdb942658ea892a617ac0980 (diff) | |
build: require safety comments on unsafe code (#13870)
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'cli')
| -rw-r--r-- | cli/bench/http.rs | 10 | ||||
| -rw-r--r-- | cli/deno_dir.rs | 8 | ||||
| -rw-r--r-- | cli/lsp/logging.rs | 6 | ||||
| -rw-r--r-- | cli/lsp/parent_process_checker.rs | 2 | ||||
| -rw-r--r-- | cli/unix_util.rs | 2 |
5 files changed, 22 insertions, 6 deletions
diff --git a/cli/bench/http.rs b/cli/bench/http.rs index 83f8eef8b..770642907 100644 --- a/cli/bench/http.rs +++ b/cli/bench/http.rs @@ -153,11 +153,13 @@ fn run( fn get_port() -> u16 { static mut NEXT_PORT: u16 = 4544; - let port = unsafe { NEXT_PORT }; - - unsafe { + // TODO(bartlomieju): + #[allow(clippy::undocumented_unsafe_blocks)] + let port = unsafe { + let p = NEXT_PORT; NEXT_PORT += 1; - } + p + }; port } diff --git a/cli/deno_dir.rs b/cli/deno_dir.rs index ea46474d0..c6a5eca29 100644 --- a/cli/deno_dir.rs +++ b/cli/deno_dir.rs @@ -76,7 +76,13 @@ mod dirs { pub fn home_dir() -> Option<PathBuf> { std::env::var_os("HOME") .and_then(|h| if h.is_empty() { None } else { Some(h) }) - .or_else(|| unsafe { fallback() }) + .or_else(|| { + // TODO(bartlomieju): + #[allow(clippy::undocumented_unsafe_blocks)] + unsafe { + fallback() + } + }) .map(PathBuf::from) } diff --git a/cli/lsp/logging.rs b/cli/lsp/logging.rs index b3fc06d89..88392dca2 100644 --- a/cli/lsp/logging.rs +++ b/cli/lsp/logging.rs @@ -21,7 +21,11 @@ pub fn set_lsp_log_level(level: log::Level) { pub fn lsp_log_level() -> log::Level { let level = LSP_LOG_LEVEL.load(Ordering::SeqCst); - unsafe { std::mem::transmute(level) } + // TODO(bartlomieju): + #[allow(clippy::undocumented_unsafe_blocks)] + unsafe { + std::mem::transmute(level) + } } /// Use this macro to do "info" logs in the lsp code. This allows diff --git a/cli/lsp/parent_process_checker.rs b/cli/lsp/parent_process_checker.rs index f4bf99d3e..e4a359bd9 100644 --- a/cli/lsp/parent_process_checker.rs +++ b/cli/lsp/parent_process_checker.rs @@ -20,6 +20,8 @@ pub fn start(parent_process_id: u32) { #[cfg(unix)] fn is_process_active(process_id: u32) -> bool { + // TODO(bartlomieju): + #[allow(clippy::undocumented_unsafe_blocks)] unsafe { // signal of 0 checks for the existence of the process id libc::kill(process_id as i32, 0) == 0 diff --git a/cli/unix_util.rs b/cli/unix_util.rs index 927b99d64..f282f6cfe 100644 --- a/cli/unix_util.rs +++ b/cli/unix_util.rs @@ -4,6 +4,8 @@ /// This is the difference between `ulimit -n` and `ulimit -n -H`. pub fn raise_fd_limit() { #[cfg(unix)] + // TODO(bartlomieju): + #[allow(clippy::undocumented_unsafe_blocks)] unsafe { let mut limits = libc::rlimit { rlim_cur: 0, |
