Unverified Commit f5f48c6f authored by Robin Freyler's avatar Robin Freyler
Browse files

[pDSL] Make CI (rustfmt) happy again

parent 1e162395
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of pDSL.
//
// pDSL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// pDSL is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with pDSL. If not, see <http://www.gnu.org/licenses/>.
use crate::{
ast,
errors::Result,
hir,
ident_ext::IdentExt,
};
......@@ -8,10 +23,6 @@ use serde::{
Deserialize,
Serialize,
};
use serde_json::{
json,
Value as JsonValue,
};
/// Describes a message parameter or return type.
#[derive(Debug, PartialEq, Eq, Deserialize, Serialize)]
......@@ -220,11 +231,14 @@ impl From<&hir::Contract> for ContractDescription {
}
}
/// Writes a JSON API description into the `target/` folder.
pub fn generate_api_description(contract: &hir::Contract) {
let description = ContractDescription::from(contract);
let contents = serde_json::to_string(&description).unwrap();
let contents = serde_json::to_string(&description)
.expect("Failed at generating JSON API description as JSON");
let mut path_buf = String::from("target/");
path_buf.push_str(description.name());
path_buf.push_str(".json");
std::fs::write(path_buf, contents);
std::fs::write(path_buf, contents)
.expect("Failed at writing JSON API descrition to file");
}
......@@ -364,7 +364,12 @@ pub struct Message {
impl Message {
/// Returns `true` if the message potentially mutates its state.
pub fn is_mut(&self) -> bool {
let self_arg = self.sig.decl.inputs.iter().next()
let self_arg = self
.sig
.decl
.inputs
.iter()
.next()
.expect("messages must always have at least `&mut self` as parameter");
match self_arg {
ast::FnArg::SelfRef(syn::ArgSelfRef { mutability, .. }) => {
......
......@@ -62,7 +62,6 @@ pub(crate) fn contract_gen_impl2(
let ast_contract = parser::parse_contract(input.clone())?;
let hir_contract = hir::Contract::from_ast(&ast_contract)?;
api::generate_api_description(&hir_contract);
// gen::gir::generate(&hir_program)?;
let tokens = gen::codegen(&hir_contract);
Ok(tokens.into())
}
......@@ -56,10 +56,6 @@ mod contract;
mod exec_env;
mod msg_handler;
// #[cfg(all(test, features = "test-env"))]
#[cfg(test)]
mod tests;
pub use crate::{
contract::{
Contract,
......
......@@ -14,13 +14,13 @@
// You should have received a copy of the GNU General Public License
// along with pDSL. If not, see <http://www.gnu.org/licenses/>.
use crate::{
use pdsl_core::storage;
use pdsl_model::{
messages,
state,
ContractDecl,
TestableContract,
};
use pdsl_core::storage;
state! {
/// A simple contract having just one value that can be incremented and returned.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment