Skip to content

Commit

Permalink
more lints, fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Dec 11, 2023
1 parent 8bd7e87 commit 912dc75
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 30 deletions.
46 changes: 29 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- rust: nightly
flags: --feature nightly
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
Expand All @@ -35,7 +35,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: taiki-e/install-action@cargo-hack
- uses: Swatinem/rust-cache@v2
Expand All @@ -48,7 +48,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@clippy
- uses: Swatinem/rust-cache@v2
with:
Expand All @@ -57,25 +57,37 @@ jobs:
env:
RUSTFLAGS: -Dwarnings

# TODO
# docs:
# runs-on: ubuntu-latest
# timeout-minutes: 30
# steps:
# - uses: actions/checkout@v3
# - uses: dtolnay/rust-toolchain@nightly
# - uses: Swatinem/rust-cache@v2
# with:
# cache-on-failure: true
# - run: cargo doc --workspace --all-features --no-deps --document-private-items
# env:
# RUSTDOCFLAGS: "--cfg docsrs -D warnings"
docs:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
pages: write
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
- run: cargo doc --workspace
env:
RUSTDOCFLAGS:
--cfg docsrs -D warnings --show-type-layout --generate-link-to-definition
--enable-index-page -Zunstable-options
- name: Deploy documentation
uses: peaceiris/actions-gh-pages@v3
# TODO
if: false && github.event_name == 'push' && github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: target/doc
force_orphan: true

fmt:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt
Expand Down
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ resolver = "2"

[workspace.package]
version = "0.0.0"
authors = ["DaniPopes <57450786+DaniPopes@users.noreply.github.com>"]
edition = "2021"
rust-version = "1.74"
authors = ["DaniPopes <57450786+DaniPopes@users.noreply.github.com>"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/danipopes/rsolc"
keywords = ["ethereum", "solidity", "solc", "crypto", "compiler"]
categories = ["compilers", "cryptography", "cryptography::cryptocurrencies"]

[workspace.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[workspace.dependencies]
rsolc-ast = { version = "0.0.0", path = "crates/ast" }
rsolc-data-structures = { version = "0.0.0", path = "crates/data-structures" }
Expand Down
Binary file added assets/favicon.ico
Binary file not shown.
Binary file added assets/logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions crates/ast/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
//! Solidity Abstract Syntax Tree (AST) definitions.
//!
//! `solidity/libsolidity/ast`

#![doc(
html_logo_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/logo.jpg",
html_favicon_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/favicon.ico"
)]
#![warn(unreachable_pub, rustdoc::all)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

// TODO
use rsolc_data_structures as _;
use rsolc_macros as _;

pub mod enums;
pub mod token;
13 changes: 13 additions & 0 deletions crates/data-structures/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
//! Common data datastructures.

#![doc(
html_logo_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/logo.jpg",
html_favicon_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/favicon.ico"
)]
#![warn(unreachable_pub, rustdoc::all)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

use smallvec as _;

pub mod fx;
8 changes: 8 additions & 0 deletions crates/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
//! Modified from [rustc_macros](https://github.com/rust-lang/rust/blob/661b33f5247debc4e0cd948caa388997e18e9cb8/compiler/rustc_macros/src/lib.rs)
//! and [`rustc_index_macros`](https://github.com/rust-lang/rust/blob/f1eee2843fd3e62c71d993f732082b28cb5b22a0/compiler/rustc_index_macros).

#![doc(
html_logo_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/logo.jpg",
html_favicon_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/favicon.ico"
)]
#![warn(rustdoc::all)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
#![cfg_attr(feature = "nightly", feature(allow_internal_unstable))]
#![cfg_attr(feature = "nightly", allow(internal_features))]

Expand Down
11 changes: 5 additions & 6 deletions crates/parser/src/lexer/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use rsolc_ast::token::{BinOpToken, CommentKind, Delimiter, Lit, LitKind, Token, TokenKind};
use rsolc_span::{sym, BytePos, Pos, Span, Symbol};

mod cursor;
pub mod cursor;
pub use cursor::{is_id_continue, is_id_start, is_ident, is_whitespace, Cursor};

mod unicode_chars;
use unicode_chars::UNICODE_ARRAY;

mod unescape;
use unescape::Mode;
pub mod unescape;

// use self::cursor::Base;

Expand Down Expand Up @@ -303,9 +302,9 @@ impl<'a> StringReader<'a> {
prefix_len: u32,
) -> (LitKind, Symbol) {
let mode = match kind {
LitKind::Str => Mode::Str,
LitKind::UnicodeStr => Mode::UnicodeStr,
LitKind::HexStr => Mode::HexStr,
LitKind::Str => unescape::Mode::Str,
LitKind::UnicodeStr => unescape::Mode::UnicodeStr,
LitKind::HexStr => unescape::Mode::HexStr,
_ => unreachable!(),
};
let content_start = start + BytePos(prefix_len);
Expand Down
6 changes: 4 additions & 2 deletions crates/parser/src/lexer/unescape.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//! Utilities for validating string and char literals and turning them into
//! values they represent.
//! Utilities for validating string and char literals and turning them into values they represent.

use std::{ops::Range, str::Chars};

Expand Down Expand Up @@ -73,8 +72,11 @@ pub enum EscapeError {
/// What kind of literal do we parse.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Mode {
/// Normal string literal (e.g. `"a"`).
Str,
/// Unicode string literal (e.g. `unicode"😀"`).
UnicodeStr,
/// Hex string literal (e.g. `hex"1234"`).
HexStr,
}

Expand Down
13 changes: 13 additions & 0 deletions crates/parser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
//! Solidity parser.

#![doc(
html_logo_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/logo.jpg",
html_favicon_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/favicon.ico"
)]
#![warn(unreachable_pub, rustdoc::all)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

// TODO
use unicode_ident as _;
use unicode_normalization as _;

pub mod errors;
pub mod lexer;

Expand Down
12 changes: 12 additions & 0 deletions crates/span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
//!
//! This API is completely unstable and subject to change.

#![doc(
html_logo_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/logo.jpg",
html_favicon_url = "https://raw.githubusercontent.com/danipopes/rsolc/main/assets/favicon.ico"
)]
#![warn(unreachable_pub, rustdoc::all)]
#![cfg_attr(not(test), warn(unused_crate_dependencies))]
#![deny(unused_must_use, rust_2018_idioms)]
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]

mod globals;
mod pos;
mod span;
Expand All @@ -20,3 +29,6 @@ pub use globals::*;
pub use pos::{BytePos, CharPos, Pos};
pub use span::Span;
pub use symbol::{kw, sym, Ident, Symbol};

/// TODO
pub struct SourceMap {}
4 changes: 2 additions & 2 deletions crates/span/src/pos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ impl_pos! {
/// A character offset.
///
/// Because of multibyte UTF-8 characters, a byte offset
/// is not equivalent to a character offset. The [`SourceMap`] will convert [`BytePos`]
/// values to `CharPos` values as necessary.
/// is not equivalent to a character offset. The [`SourceMap`](crate::SourceMap) will convert
/// [`BytePos`] values to `CharPos` values as necessary.
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]
pub struct CharPos(pub usize);
}

0 comments on commit 912dc75

Please sign in to comment.