forked from libre-chip/fayalite
		
	clean up some clippy warnings
This commit is contained in:
		
							parent
							
								
									f12322aa2a
								
							
						
					
					
						commit
						ed1aea41f3
					
				
					 12 changed files with 45 additions and 29 deletions
				
			
		| 
						 | 
				
			
			@ -58,8 +58,7 @@ impl ParsedBundle {
 | 
			
		|||
        }
 | 
			
		||||
        *mutability = FieldMutability::None;
 | 
			
		||||
        colon_token.get_or_insert(Token));
 | 
			
		||||
        let options = errors.unwrap_or_default(HdlAttr::parse_and_take_attr(attrs));
 | 
			
		||||
        options
 | 
			
		||||
        errors.unwrap_or_default(HdlAttr::parse_and_take_attr(attrs))
 | 
			
		||||
    }
 | 
			
		||||
    fn parse(item: ItemStruct) -> syn::Result<Self> {
 | 
			
		||||
        let ItemStruct {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -600,7 +600,7 @@ impl ToTokens for ParsedEnum {
 | 
			
		|||
                static_generics.split_for_impl();
 | 
			
		||||
            let static_type_body_variants =
 | 
			
		||||
                Vec::from_iter(variants.iter().map(|ParsedVariant { ident, field, .. }| {
 | 
			
		||||
                    if let Some(_) = field {
 | 
			
		||||
                    if field.is_some() {
 | 
			
		||||
                        quote_spanned! {span=>
 | 
			
		||||
                            #ident: ::fayalite::ty::StaticType::TYPE,
 | 
			
		||||
                        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1410,7 +1410,7 @@ impl ParseTypes<Path> for ParsedType {
 | 
			
		|||
        let mut args = None;
 | 
			
		||||
        let segments = Punctuated::from_iter(segments.pairs_mut().map_pair_value_mut(|segment| {
 | 
			
		||||
            let PathSegment { ident, arguments } = segment;
 | 
			
		||||
            if let Some(_) = args {
 | 
			
		||||
            if args.is_some() {
 | 
			
		||||
                parser
 | 
			
		||||
                    .errors()
 | 
			
		||||
                    .error(&ident, "associated types/consts are not yet implemented");
 | 
			
		||||
| 
						 | 
				
			
			@ -1594,7 +1594,7 @@ impl ParseTypes<Path> for ParsedConstGenericType {
 | 
			
		|||
        let mut args = None;
 | 
			
		||||
        let segments = Punctuated::from_iter(segments.pairs_mut().map_pair_value_mut(|segment| {
 | 
			
		||||
            let PathSegment { ident, arguments } = segment;
 | 
			
		||||
            if let Some(_) = args {
 | 
			
		||||
            if args.is_some() {
 | 
			
		||||
                parser
 | 
			
		||||
                    .errors()
 | 
			
		||||
                    .error(&ident, "associated types/consts are not yet implemented");
 | 
			
		||||
| 
						 | 
				
			
			@ -3554,7 +3554,7 @@ impl SplitForImpl for Generics {
 | 
			
		|||
        Self::TypeGenerics<'_>,
 | 
			
		||||
        Self::WhereClause<'_>,
 | 
			
		||||
    ) {
 | 
			
		||||
        Generics::split_for_impl(&self)
 | 
			
		||||
        Generics::split_for_impl(self)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -144,6 +144,12 @@ impl BundleTypePropertiesBuilder {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Default for BundleTypePropertiesBuilder {
 | 
			
		||||
    fn default() -> Self {
 | 
			
		||||
        Self::new()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Bundle {
 | 
			
		||||
    #[track_caller]
 | 
			
		||||
    pub fn new(fields: Interned<[BundleField]>) -> Self {
 | 
			
		||||
| 
						 | 
				
			
			@ -342,6 +348,7 @@ macro_rules! impl_tuples {
 | 
			
		|||
                std::iter::once(MatchVariantWithoutScope(($(Expr::field(this, stringify!($num)),)*)))
 | 
			
		||||
            }
 | 
			
		||||
            fn mask_type(&self) -> Self::MaskType {
 | 
			
		||||
                #![allow(clippy::unused_unit)]
 | 
			
		||||
                let ($($var,)*) = self;
 | 
			
		||||
                ($($var.mask_type(),)*)
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			@ -350,6 +357,7 @@ macro_rules! impl_tuples {
 | 
			
		|||
            }
 | 
			
		||||
            #[track_caller]
 | 
			
		||||
            fn from_canonical(canonical_type: CanonicalType) -> Self {
 | 
			
		||||
                #![allow(clippy::unused_unit)]
 | 
			
		||||
                let CanonicalType::Bundle(bundle) = canonical_type else {
 | 
			
		||||
                    panic!("expected bundle");
 | 
			
		||||
                };
 | 
			
		||||
| 
						 | 
				
			
			@ -358,7 +366,7 @@ macro_rules! impl_tuples {
 | 
			
		|||
                };
 | 
			
		||||
                $(let BundleField { name, flipped, ty } = $var;
 | 
			
		||||
                assert_eq!(&*name, stringify!($num));
 | 
			
		||||
                assert_eq!(flipped, false);
 | 
			
		||||
                assert!(!flipped);
 | 
			
		||||
                let $var = $T::from_canonical(ty);)*
 | 
			
		||||
                ($($var,)*)
 | 
			
		||||
            }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -169,6 +169,12 @@ impl EnumTypePropertiesBuilder {
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Default for EnumTypePropertiesBuilder {
 | 
			
		||||
    fn default() -> Self {
 | 
			
		||||
        Self::new()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl Enum {
 | 
			
		||||
    #[track_caller]
 | 
			
		||||
    pub fn new(variants: Interned<[EnumVariant]>) -> Self {
 | 
			
		||||
| 
						 | 
				
			
			@ -399,9 +405,8 @@ impl<T: Type> HdlOption<T> {
 | 
			
		|||
        else {
 | 
			
		||||
            unreachable!();
 | 
			
		||||
        };
 | 
			
		||||
        let value = f(value).map_err(|e| {
 | 
			
		||||
        let value = f(value).inspect_err(|_| {
 | 
			
		||||
            and_then_out.complete(()); // avoid error
 | 
			
		||||
            e
 | 
			
		||||
        })?;
 | 
			
		||||
        let and_then_out = and_then_out.complete(Expr::ty(value));
 | 
			
		||||
        connect(and_then_out, value);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -147,7 +147,7 @@ where
 | 
			
		|||
 | 
			
		||||
    fn try_from_usize(v: usize) -> Option<Self::SizeType> {
 | 
			
		||||
        if v == VALUE {
 | 
			
		||||
            Some(Self::SizeType::default())
 | 
			
		||||
            Some(ConstUsize)
 | 
			
		||||
        } else {
 | 
			
		||||
            None
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -560,7 +560,7 @@ pub trait BoolOrIntType: Type + sealed::BoolOrIntTypeSealed {
 | 
			
		|||
    }
 | 
			
		||||
    fn bits_to_expr(bits: Cow<'_, BitSlice>) -> Expr<Self>;
 | 
			
		||||
    fn le_bytes_to_expr_wrapping(bytes: &[u8], bit_width: usize) -> Expr<Self> {
 | 
			
		||||
        let bitslice = BitSlice::<u8, Lsb0>::from_slice(&bytes);
 | 
			
		||||
        let bitslice = BitSlice::<u8, Lsb0>::from_slice(bytes);
 | 
			
		||||
        let bitslice = &bitslice[..bit_width.min(bitslice.len())];
 | 
			
		||||
        let mut bits = BitVec::new();
 | 
			
		||||
        bits.extend_from_bitslice(bitslice);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -634,7 +634,7 @@ impl<Element: Type, Len: Size> Mem<Element, Len> {
 | 
			
		|||
        self.0.source_location
 | 
			
		||||
    }
 | 
			
		||||
    pub fn array_type(self) -> ArrayType<Element, Len> {
 | 
			
		||||
        self.0.array_type.clone()
 | 
			
		||||
        self.0.array_type
 | 
			
		||||
    }
 | 
			
		||||
    pub fn initial_value(self) -> Option<Interned<BitSlice>> {
 | 
			
		||||
        self.0.initial_value
 | 
			
		||||
| 
						 | 
				
			
			@ -987,7 +987,7 @@ impl<Element: Type, Len: Size> MemBuilder<Element, Len> {
 | 
			
		|||
    #[allow(clippy::result_unit_err)]
 | 
			
		||||
    pub fn get_array_type(&self) -> Result<ArrayType<Element, Len>, ()> {
 | 
			
		||||
        Ok(ArrayType::new(
 | 
			
		||||
            self.mem_element_type.clone(),
 | 
			
		||||
            self.mem_element_type,
 | 
			
		||||
            Len::from_usize(self.get_depth()?),
 | 
			
		||||
        ))
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -607,6 +607,10 @@ impl BlockStack {
 | 
			
		|||
pub struct Id(NonZeroU64);
 | 
			
		||||
 | 
			
		||||
impl Id {
 | 
			
		||||
    #[allow(
 | 
			
		||||
        clippy::new_without_default,
 | 
			
		||||
        reason = "returns a different value each time, so there isn't really a default value"
 | 
			
		||||
    )]
 | 
			
		||||
    pub fn new() -> Self {
 | 
			
		||||
        static NEXT_ID: AtomicU64 = AtomicU64::new(1);
 | 
			
		||||
        Self(
 | 
			
		||||
| 
						 | 
				
			
			@ -945,7 +949,7 @@ impl From<NormalModuleBody<ModuleBuilding>> for NormalModuleBody {
 | 
			
		|||
                    Stmt::Declaration(decl) => {
 | 
			
		||||
                        let annotations = annotations_map
 | 
			
		||||
                            .remove(&decl)
 | 
			
		||||
                            .map(|v| Intern::intern_owned(v))
 | 
			
		||||
                            .map(Intern::intern_owned)
 | 
			
		||||
                            .unwrap_or_default();
 | 
			
		||||
                        match decl {
 | 
			
		||||
                            StmtDeclaration::Wire(StmtWire {
 | 
			
		||||
| 
						 | 
				
			
			@ -1615,10 +1619,7 @@ impl AssertValidityState {
 | 
			
		|||
        let module = self.module;
 | 
			
		||||
        if block == 0 {
 | 
			
		||||
            for module_io in &*module.module_io {
 | 
			
		||||
                self.insert_new_base(
 | 
			
		||||
                    TargetBase::intern_sized(module_io.module_io.clone().into()),
 | 
			
		||||
                    block,
 | 
			
		||||
                );
 | 
			
		||||
                self.insert_new_base(TargetBase::intern_sized(module_io.module_io.into()), block);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        let Block { memories, stmts } = self.blocks[block];
 | 
			
		||||
| 
						 | 
				
			
			@ -1934,7 +1935,7 @@ impl ModuleBuilder {
 | 
			
		|||
        let module_io = module_io.canonical();
 | 
			
		||||
        let mut impl_ = self.impl_.borrow_mut();
 | 
			
		||||
        let impl_ = &mut *impl_;
 | 
			
		||||
        impl_.io_indexes.insert(module_io.clone(), impl_.io.len());
 | 
			
		||||
        impl_.io_indexes.insert(module_io, impl_.io.len());
 | 
			
		||||
        impl_.io.push(AnnotatedModuleIO {
 | 
			
		||||
            annotations: vec![],
 | 
			
		||||
            module_io,
 | 
			
		||||
| 
						 | 
				
			
			@ -2478,7 +2479,7 @@ pub fn memory_array_with_loc<Element: Type, Len: Size>(
 | 
			
		|||
    mem_array_type: ArrayType<Element, Len>,
 | 
			
		||||
    source_location: SourceLocation,
 | 
			
		||||
) -> MemBuilder<Element, Len> {
 | 
			
		||||
    let mut retval = memory_impl(name, mem_array_type.element().clone(), source_location);
 | 
			
		||||
    let mut retval = memory_impl(name, mem_array_type.element(), source_location);
 | 
			
		||||
    retval.depth(mem_array_type.len());
 | 
			
		||||
    retval
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -271,12 +271,12 @@ impl State {
 | 
			
		|||
            .into()),
 | 
			
		||||
            EnumTypeState::TagUIntAndBody(_) => {
 | 
			
		||||
                let int_tag_expr = Expr::<TagAndBody<UInt, UInt>>::from_canonical(folded_expr).tag;
 | 
			
		||||
                Ok(match_int_tag(int_tag_expr, source_location, &folded_blocks).into())
 | 
			
		||||
                Ok(match_int_tag(int_tag_expr, source_location, folded_blocks).into())
 | 
			
		||||
            }
 | 
			
		||||
            EnumTypeState::UInt(_) => {
 | 
			
		||||
                let int_tag_expr = Expr::<UInt>::from_canonical(folded_expr)
 | 
			
		||||
                    [..unfolded_enum_type.discriminant_bit_width()];
 | 
			
		||||
                Ok(match_int_tag(int_tag_expr, source_location, &folded_blocks).into())
 | 
			
		||||
                Ok(match_int_tag(int_tag_expr, source_location, folded_blocks).into())
 | 
			
		||||
            }
 | 
			
		||||
            EnumTypeState::Unchanged => Ok(StmtMatch {
 | 
			
		||||
                expr: Expr::from_canonical(folded_expr),
 | 
			
		||||
| 
						 | 
				
			
			@ -929,13 +929,10 @@ impl Folder for State {
 | 
			
		|||
        unreachable!()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn fold_enum_literal<T: EnumType>(
 | 
			
		||||
    fn fold_enum_literal<T: EnumType + Fold<Self>>(
 | 
			
		||||
        &mut self,
 | 
			
		||||
        _v: ops::EnumLiteral<T>,
 | 
			
		||||
    ) -> Result<ops::EnumLiteral<T>, Self::Error>
 | 
			
		||||
    where
 | 
			
		||||
        T: Fold<Self>,
 | 
			
		||||
    {
 | 
			
		||||
    ) -> Result<ops::EnumLiteral<T>, Self::Error> {
 | 
			
		||||
        unreachable!()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -766,7 +766,7 @@ impl ModuleState {
 | 
			
		|||
                    output_stmts.push(
 | 
			
		||||
                        StmtWire {
 | 
			
		||||
                            annotations: Default::default(),
 | 
			
		||||
                            wire: canonical_wire.clone(),
 | 
			
		||||
                            wire: canonical_wire,
 | 
			
		||||
                        }
 | 
			
		||||
                        .into(),
 | 
			
		||||
                    );
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -106,3 +106,9 @@ impl<T: ?Sized> ScopedRef<T> {
 | 
			
		|||
        self.0.with_opt(f)
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl<T: ?Sized> Default for ScopedRef<T> {
 | 
			
		||||
    fn default() -> Self {
 | 
			
		||||
        Self::new()
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2258,7 +2258,7 @@ pub fn check_memory_of_bundle() {
 | 
			
		|||
    let wmask: (Bool, Bool) = m.input();
 | 
			
		||||
    #[hdl]
 | 
			
		||||
    let clk: Clock = m.input();
 | 
			
		||||
    let mem_init = Vec::from_iter((0..0x10u8).map(|i| (i ^ 3, (i ^ i / 2).cast_to_static())));
 | 
			
		||||
    let mem_init = Vec::from_iter((0..0x10u8).map(|i| (i ^ 3, (i ^ (i / 2)).cast_to_static())));
 | 
			
		||||
    #[hdl]
 | 
			
		||||
    let mut mem = memory_with_init(mem_init);
 | 
			
		||||
    let read_port = mem.new_read_port();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue