Skip to content

Commit 505b3c6

Browse files
authored
Require lint reasons in pulley-interpreter (#10173)
* Require lint reasons in `pulley-interpreter` Continuing work originally started in #9696 * Add more pulley #[cfg]
1 parent ed7eb50 commit 505b3c6

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

pulley/src/decode.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -715,11 +715,6 @@ for_each_extended_op!(define_extended_decoder);
715715
pub fn unwrap_uninhabited<T>(res: Result<T, Uninhabited>) -> T {
716716
match res {
717717
Ok(ok) => ok,
718-
719-
// Nightly rust warns that this pattern is unreachable, but stable rust
720-
// doesn't.
721-
#[allow(unreachable_patterns)]
722-
Err(err) => match err {},
723718
}
724719
}
725720

@@ -741,8 +736,8 @@ pub mod operands {
741736
)*
742737
) => {
743738
$(
744-
#[allow(unused_variables)]
745-
#[allow(missing_docs)]
739+
#[allow(unused_variables, reason = "macro-generated")]
740+
#[allow(missing_docs, reason = "macro-generated")]
746741
pub fn $snake_name<T: BytecodeStream>(pc: &mut T) -> Result<($($($field_ty,)*)?), T::Error> {
747742
Ok((($($((<$field_ty>::decode(pc))?,)*)?)))
748743
}
@@ -752,7 +747,8 @@ pub mod operands {
752747

753748
for_each_op!(define_operands_decoder);
754749

755-
#[allow(missing_docs)]
750+
/// Decode an extended opcode from `pc` to match the payload of the
751+
/// "extended" opcode.
756752
pub fn extended<T: BytecodeStream>(pc: &mut T) -> Result<(ExtendedOpcode,), T::Error> {
757753
Ok((ExtendedOpcode::decode(pc)?,))
758754
}

pulley/src/interp.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ impl Default for XRegVal {
418418
}
419419
}
420420

421-
#[allow(missing_docs)]
421+
#[allow(missing_docs, reason = "self-describing methods")]
422422
impl XRegVal {
423423
pub fn new_i32(x: i32) -> Self {
424424
let mut val = XRegVal::default();
@@ -537,7 +537,7 @@ impl Default for FRegVal {
537537
}
538538
}
539539

540-
#[allow(missing_docs)]
540+
#[allow(missing_docs, reason = "self-describing methods")]
541541
impl FRegVal {
542542
pub fn new_f32(f: f32) -> Self {
543543
let mut val = Self::default();
@@ -620,7 +620,7 @@ impl Default for VRegVal {
620620
}
621621
}
622622

623-
#[allow(missing_docs)]
623+
#[allow(missing_docs, reason = "self-describing methods")]
624624
impl VRegVal {
625625
pub fn new_u128(i: u128) -> Self {
626626
let mut val = Self::default();

pulley/src/lib.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
#![cfg_attr(pulley_tail_calls, allow(incomplete_features, unstable_features))]
66
#![deny(missing_docs)]
77
#![no_std]
8-
#![expect(clippy::allow_attributes_without_reason, reason = "crate not migrated")]
98

109
#[cfg(feature = "std")]
1110
#[macro_use]
1211
extern crate std;
1312

14-
#[allow(unused_extern_crates)] // Some cfg's don't use this.
13+
#[cfg(feature = "decode")]
1514
extern crate alloc;
1615

1716
/// Calls the given macro with each opcode.
@@ -1408,12 +1407,12 @@ pub use op::*;
14081407
pub mod opcode;
14091408
pub use opcode::*;
14101409

1411-
#[allow(dead_code)] // Unused in some `cfg`s.
1410+
#[cfg(any(feature = "encode", feature = "decode"))]
14121411
pub(crate) unsafe fn unreachable_unchecked<T>() -> T {
14131412
#[cfg(debug_assertions)]
14141413
unreachable!();
14151414

1416-
#[cfg_attr(debug_assertions, allow(unreachable_code))]
1415+
#[cfg(not(debug_assertions))]
14171416
unsafe {
14181417
core::hint::unreachable_unchecked()
14191418
}

pulley/src/op.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ macro_rules! define_op {
3636
$(
3737
// TODO: add doc comments to all fields and update all
3838
// the macros to match them.
39-
#[allow(missing_docs)]
39+
#[allow(missing_docs, reason = "macro-generated code")]
4040
pub $field : $field_ty,
4141
)*
4242
)? }
@@ -86,7 +86,7 @@ macro_rules! define_extended_op {
8686
$(
8787
// TODO: add doc comments to all fields and update all
8888
// the macros to match them.
89-
#[allow(missing_docs)]
89+
#[allow(missing_docs, reason = "macro-generated code")]
9090
pub $field : $field_ty,
9191
)*
9292
)? }

pulley/src/regs.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ macro_rules! impl_reg {
6565
#[repr(u8)]
6666
#[derive(Debug,Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6767
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
68-
#[allow(non_camel_case_types, missing_docs)]
68+
#[allow(missing_docs, reason = "self-describing variants")]
69+
#[expect(non_camel_case_types, reason = "matching in-asm register names")]
6970
#[rustfmt::skip]
7071
pub enum XReg {
7172
x0, x1, x2, x3, x4, x5, x6, x7, x8, x9,
@@ -107,7 +108,8 @@ fn assert_special_start_is_right() {
107108
#[repr(u8)]
108109
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
109110
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
110-
#[allow(non_camel_case_types, missing_docs)]
111+
#[allow(missing_docs, reason = "self-describing variants")]
112+
#[expect(non_camel_case_types, reason = "matching in-asm register names")]
111113
#[rustfmt::skip]
112114
pub enum FReg {
113115
f0, f1, f2, f3, f4, f5, f6, f7, f8, f9,
@@ -120,7 +122,8 @@ pub enum FReg {
120122
#[repr(u8)]
121123
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
122124
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
123-
#[allow(non_camel_case_types, missing_docs)]
125+
#[allow(missing_docs, reason = "self-describing variants")]
126+
#[expect(non_camel_case_types, reason = "matching in-asm register names")]
124127
#[rustfmt::skip]
125128
pub enum VReg {
126129
v0, v1, v2, v3, v4, v5, v6, v7, v8, v9,
@@ -137,7 +140,7 @@ impl_reg!(VReg, V, 0..32);
137140
///
138141
/// Never appears inside an instruction -- instructions always name a particular
139142
/// class of register -- but this is useful for testing and things like that.
140-
#[allow(missing_docs)]
143+
#[allow(missing_docs, reason = "self-describing variants")]
141144
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
142145
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
143146
pub enum AnyReg {

0 commit comments

Comments
 (0)