fix: satisfy clippy's demands

This commit is contained in:
microproofs 2024-01-11 14:53:02 -05:00
parent 8b62873ef5
commit 4a8fecb70a
7 changed files with 14 additions and 14 deletions

View File

@ -928,7 +928,7 @@ impl<'a> CodeGenerator<'a> {
let list_elem_types = tipo.get_inner_types(); let list_elem_types = tipo.get_inner_types();
let list_elem_type = list_elem_types let list_elem_type = list_elem_types
.get(0) .first()
.unwrap_or_else(|| unreachable!("No list element type?")); .unwrap_or_else(|| unreachable!("No list element type?"));
let mut elems = elements let mut elems = elements
@ -2172,7 +2172,7 @@ impl<'a> CodeGenerator<'a> {
let list_elem_types = subject_tipo.get_inner_types(); let list_elem_types = subject_tipo.get_inner_types();
let list_elem_type = list_elem_types let list_elem_type = list_elem_types
.get(0) .first()
.unwrap_or_else(|| unreachable!("No list element type?")); .unwrap_or_else(|| unreachable!("No list element type?"));
let defined_tails = defined_tails.clone(); let defined_tails = defined_tails.clone();
@ -3862,7 +3862,7 @@ impl<'a> CodeGenerator<'a> {
if constr_type.arguments.is_empty() { if constr_type.arguments.is_empty() {
term = Term::constr_data() term = Term::constr_data()
.apply(Term::integer(constr_index.try_into().unwrap())) .apply(Term::integer(constr_index.into()))
.apply(term); .apply(term);
let mut program: Program<Name> = Program { let mut program: Program<Name> = Program {

View File

@ -1256,11 +1256,11 @@ pub fn convert_constants_to_data(constants: Vec<Rc<UplcConstant>>) -> Vec<UplcCo
let constant = match constant.as_ref() { let constant = match constant.as_ref() {
UplcConstant::Integer(i) => UplcConstant::Data(PlutusData::BigInt(to_pallas_bigint(i))), UplcConstant::Integer(i) => UplcConstant::Data(PlutusData::BigInt(to_pallas_bigint(i))),
UplcConstant::ByteString(b) => { UplcConstant::ByteString(b) => {
UplcConstant::Data(PlutusData::BoundedBytes(b.clone().try_into().unwrap())) UplcConstant::Data(PlutusData::BoundedBytes(b.clone().into()))
}
UplcConstant::String(s) => {
UplcConstant::Data(PlutusData::BoundedBytes(s.as_bytes().to_vec().into()))
} }
UplcConstant::String(s) => UplcConstant::Data(PlutusData::BoundedBytes(
s.as_bytes().to_vec().try_into().unwrap(),
)),
UplcConstant::Bool(b) => UplcConstant::Data(PlutusData::Constr(Constr { UplcConstant::Bool(b) => UplcConstant::Data(PlutusData::Constr(Constr {
tag: convert_constr_to_tag((*b).into()).unwrap_or(ANY_TAG), tag: convert_constr_to_tag((*b).into()).unwrap_or(ANY_TAG),

View File

@ -1767,7 +1767,7 @@ fn get_compatible_record_fields<A>(
return compatible; return compatible;
} }
let first = match constructors.get(0) { let first = match constructors.first() {
Some(first) => first, Some(first) => first,
None => return compatible, None => return compatible,
}; };

View File

@ -207,7 +207,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> {
} => match tipo.get_app_args(true, "", "List", 1, self.environment) { } => match tipo.get_app_args(true, "", "List", 1, self.environment) {
Some(args) => { Some(args) => {
let tipo = args let tipo = args
.get(0) .first()
.expect("Failed to get type argument of List") .expect("Failed to get type argument of List")
.clone(); .clone();

View File

@ -263,7 +263,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
function(vec![self.argument_type.clone()], return_type.clone()), function(vec![self.argument_type.clone()], return_type.clone()),
func.location(), func.location(),
if let Type::Fn { args, .. } = func.tipo().deref() { if let Type::Fn { args, .. } = func.tipo().deref() {
if let Some(typ) = args.get(0) { if let Some(typ) = args.first() {
typ.is_data() typ.is_data()
} else { } else {
false false
@ -300,7 +300,7 @@ impl<'a, 'b, 'c> PipeTyper<'a, 'b, 'c> {
match types { match types {
(Type::Fn { args: a, .. }, Type::Fn { args: b, .. }) if a.len() == b.len() => { (Type::Fn { args: a, .. }, Type::Fn { args: b, .. }) if a.len() == b.len() => {
match (a.get(0), b.get(0)) { match (a.first(), b.first()) {
(Some(a), Some(b)) => self (Some(a), Some(b)) => self
.expr_typer .expr_typer
.environment .environment

View File

@ -250,7 +250,7 @@ impl Annotated<Schema> {
"Option" => { "Option" => {
let generic = Annotated::do_from_type( let generic = Annotated::do_from_type(
args.get(0) args.first()
.expect("Option types have always one generic argument"), .expect("Option types have always one generic argument"),
modules, modules,
type_parameters, type_parameters,
@ -283,7 +283,7 @@ impl Annotated<Schema> {
"List" => { "List" => {
let generic = Annotated::do_from_type( let generic = Annotated::do_from_type(
args.get(0) args.first()
.expect("List types have always one generic argument"), .expect("List types have always one generic argument"),
modules, modules,
type_parameters, type_parameters,

View File

@ -820,7 +820,7 @@ impl DefaultFunction {
DefaultFunction::BData => { DefaultFunction::BData => {
let b = args[0].unwrap_byte_string()?; let b = args[0].unwrap_byte_string()?;
let value = Value::data(PlutusData::BoundedBytes(b.clone().try_into().unwrap())); let value = Value::data(PlutusData::BoundedBytes(b.clone().into()));
Ok(value) Ok(value)
} }