Use #[expect(lint)] over #[allow(lint)] where possible (#17822)

This commit is contained in:
Micha Reiser 2025-05-03 21:20:31 +02:00 committed by GitHub
parent 8535af8516
commit fa628018b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
148 changed files with 221 additions and 268 deletions

View file

@ -248,7 +248,7 @@ mod tests {
use super::NotebookDocument;
enum TestCellContent {
#[allow(dead_code)]
#[expect(dead_code)]
Markup(String),
Code(String),
}

View file

@ -34,7 +34,7 @@ pub(crate) fn init_logging(log_level: LogLevel, log_file: Option<&std::path::Pat
.append(true)
.open(&path)
.map_err(|err| {
#[allow(clippy::print_stderr)]
#[expect(clippy::print_stderr)]
{
eprintln!(
"Failed to open file at {} for logging: {err}",

View file

@ -2,7 +2,7 @@
use std::num::NonZeroUsize;
// The new PanicInfoHook name requires MSRV >= 1.82
#[allow(deprecated)]
#[expect(deprecated)]
use std::panic::PanicInfo;
use lsp_server::Message;
@ -114,7 +114,7 @@ impl Server {
pub(crate) fn run(self) -> crate::Result<()> {
// The new PanicInfoHook name requires MSRV >= 1.82
#[allow(deprecated)]
#[expect(deprecated)]
type PanicHook = Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>;
struct RestorePanicHook {
hook: Option<PanicHook>,
@ -168,7 +168,6 @@ impl Server {
.join()
}
#[allow(clippy::needless_pass_by_value)] // this is because we aren't using `next_request_id` yet.
fn event_loop(
connection: &Connection,
_client_capabilities: &ClientCapabilities,

View file

@ -144,7 +144,7 @@ fn local_notification_task<'a, N: traits::SyncNotificationHandler>(
}))
}
#[allow(dead_code)]
#[expect(dead_code)]
fn background_notification_thread<'a, N: traits::BackgroundDocumentNotificationHandler>(
req: server::Notification,
schedule: BackgroundSchedule,

View file

@ -48,7 +48,7 @@ impl Client<'_> {
}
}
#[allow(dead_code)] // we'll need to use `Notifier` in the future
#[expect(dead_code)] // we'll need to use `Notifier` in the future
impl Notifier {
pub(crate) fn notify<N>(&self, params: N::Params) -> crate::Result<()>
where

View file

@ -106,7 +106,7 @@ impl Pool {
self.job_sender.send(job).unwrap();
}
#[allow(dead_code)]
#[expect(dead_code)]
pub(super) fn len(&self) -> usize {
self.extant_tasks.load(Ordering::SeqCst)
}

View file

@ -183,14 +183,14 @@ mod imp {
QoSClass::Background => libc::qos_class_t::QOS_CLASS_BACKGROUND,
};
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let code = unsafe { libc::pthread_set_qos_class_self_np(c, 0) };
if code == 0 {
return;
}
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let errno = unsafe { *libc::__error() };
match errno {
@ -223,10 +223,10 @@ mod imp {
}
pub(super) fn get_current_thread_qos_class() -> Option<QoSClass> {
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let current_thread = unsafe { libc::pthread_self() };
let mut qos_class_raw = libc::qos_class_t::QOS_CLASS_UNSPECIFIED;
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let code = unsafe {
libc::pthread_get_qos_class_np(current_thread, &mut qos_class_raw, std::ptr::null_mut())
};
@ -241,7 +241,7 @@ mod imp {
// ones which we cannot handle anyway
//
// 0: https://github.com/apple-oss-distributions/libpthread/blob/67e155c94093be9a204b69637d198eceff2c7c46/src/qos.c#L171-L177
#[allow(unsafe_code)]
#[expect(unsafe_code)]
let errno = unsafe { *libc::__error() };
unreachable!("`pthread_get_qos_class_np` failed unexpectedly (os error {errno})");
}

View file

@ -1,7 +1,7 @@
use lsp_types::{ClientCapabilities, MarkupKind};
#[derive(Debug, Clone, PartialEq, Eq, Default)]
#[allow(clippy::struct_excessive_bools)]
#[expect(clippy::struct_excessive_bools)]
pub(crate) struct ResolvedClientCapabilities {
pub(crate) code_action_deferred_edit_resolution: bool,
pub(crate) apply_edit: bool,

View file

@ -230,7 +230,6 @@ impl DocumentController {
}
}
#[allow(dead_code)]
pub(crate) fn as_text(&self) -> Option<&TextDocument> {
match self {
Self::Text(document) => Some(document),

View file

@ -258,6 +258,6 @@ fn virtual_path_not_found(path: impl Display) -> std::io::Error {
fn document_revision(document: &DocumentQuery) -> FileRevision {
// The file revision is just an opaque number which doesn't have any significant meaning other
// than that the file has changed if the revisions are different.
#[allow(clippy::cast_sign_loss)]
#[expect(clippy::cast_sign_loss)]
FileRevision::new(document.version() as u128)
}